From 94e7ab7164029ca36f480b014a3fb1abaf12e0ff Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 16:44:48 +0200 Subject: [PATCH 01/40] Implement IsModuleOfficial --- Managers/PresetMan.cpp | 16 +++++++++++++++- Managers/PresetMan.h | 9 +++++++++ System/DataModule.cpp | 5 +++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 6f5a42b1c..b7b76f5f0 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,6 +29,8 @@ #include "LoadingScreen.h" #include "SettingsMan.h" +static const std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; + namespace RTE { ////////////////////////////////////////////////////////////////////////////////////////// @@ -164,7 +166,6 @@ bool PresetMan::LoadAllDataModules() { FindAndExtractZippedModules(); // Load all the official modules first! - std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; for (const std::string &officialModule : officialModules) { if (!LoadDataModule(officialModule, true, &LoadingScreen::LoadingSplashProgressReport)) { return false; @@ -310,6 +311,19 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) } +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetModuleIDFromPath +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Returns wether or not the module is vanilla. +// Arguments: The ID of the module to check. +// Return value: True if vanilla, false otherwise. + +bool PresetMan::IsModuleOfficial(int whichModule) +{ + return std::find(officialModules.begin(), officialModules.end(), GetDataModuleName(whichModule)) != officialModules.end(); +} + + ////////////////////////////////////////////////////////////////////////////////////////// // Method: AddEntityPreset ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 3aa34d4be..2c0820d04 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -173,6 +173,15 @@ class PresetMan : public Singleton { int GetModuleIDFromPath(std::string dataPath); + ////////////////////////////////////////////////////////////////////////////////////////// + // Method: GetModuleIDFromPath + ////////////////////////////////////////////////////////////////////////////////////////// + // Description: Returns wether or not the module is vanilla. + // Arguments: The ID of the module to check. + // Return value: True if vanilla, false otherwise. + + bool IsModuleOfficial(int whichModule = 0);; + ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetTotalModuleCount diff --git a/System/DataModule.cpp b/System/DataModule.cpp index d21daedb1..413f1540a 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -40,9 +40,10 @@ namespace RTE { // Report that we're starting to read a new DataModule if (progressCallback) { progressCallback(m_FileName + " " + static_cast(-43) + " loading:", true); } + const std::string moduleFolder = g_PresetMan.IsModuleOfficial(m_ModuleID) ? "Data/" : "Mods/"; Reader reader; - std::string indexPath(m_FileName + "/Index.ini"); - std::string mergedIndexPath(m_FileName + "/MergedIndex.ini"); + std::string indexPath(moduleFolder + m_FileName + "/Index.ini"); + std::string mergedIndexPath(moduleFolder + m_FileName + "/MergedIndex.ini"); // NOTE: This looks for the MergedIndex.ini generated by the index merger tool. The tool is mostly superseded by disabling loading visuals, but still provides some benefit. if (std::filesystem::exists(mergedIndexPath)) { indexPath = mergedIndexPath; } From 739bce7b2cd76c9398712e41f3593ccaaf91bb68 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 16:47:54 +0200 Subject: [PATCH 02/40] Change hardcoded path from Base.rte/ to Data/Base.rte --- Activities/AreaEditor.cpp | 4 +- Activities/AssemblyEditor.cpp | 2 +- Activities/EditorActivity.cpp | 4 +- Activities/GATutorial.cpp | 16 ++--- Activities/GameActivity.cpp | 44 +++++++------- Activities/GibEditor.cpp | 4 +- Activities/MultiplayerGame.cpp | 4 +- Activities/MultiplayerServerLobby.cpp | 8 +-- Activities/SceneEditor.cpp | 4 +- Entities/Actor.cpp | 28 ++++----- Entities/Deployment.cpp | 8 +-- Entities/Icon.cpp | 2 +- Entities/Scene.cpp | 2 +- GUI/GUISound.cpp | 78 ++++++++++++------------- Main.cpp | 2 +- Managers/ActivityMan.cpp | 4 +- Managers/ConsoleMan.cpp | 6 +- Managers/FrameMan.cpp | 8 +-- Managers/PostProcessMan.cpp | 6 +- Managers/SettingsMan.cpp | 2 +- Menus/AreaPickerGUI.cpp | 8 +-- Menus/AssemblyEditorGUI.cpp | 4 +- Menus/BuyMenuGUI.cpp | 14 ++--- Menus/InventoryMenuGUI.cpp | 6 +- Menus/LoadingScreen.cpp | 6 +- Menus/MainMenuGUI.cpp | 8 +-- Menus/MetagameGUI.cpp | 18 +++--- Menus/ModManagerGUI.cpp | 4 +- Menus/ObjectPickerGUI.cpp | 6 +- Menus/PieMenuGUI.cpp | 2 +- Menus/ScenarioGUI.cpp | 8 +-- Menus/SceneEditorGUI.cpp | 4 +- Menus/SettingsGUI.cpp | 4 +- Menus/SettingsInputMappingWizardGUI.cpp | 6 +- Menus/TitleScreen.cpp | 53 +++++++++-------- 35 files changed, 193 insertions(+), 194 deletions(-) diff --git a/Activities/AreaEditor.cpp b/Activities/AreaEditor.cpp index 466238fa0..9ab18b100 100644 --- a/Activities/AreaEditor.cpp +++ b/Activities/AreaEditor.cpp @@ -166,7 +166,7 @@ int AreaEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Base.rte/GUIs/AreaEditorGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/AreaEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -202,7 +202,7 @@ int AreaEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Activities/AssemblyEditor.cpp b/Activities/AssemblyEditor.cpp index 59006c0e5..c9a064995 100644 --- a/Activities/AssemblyEditor.cpp +++ b/Activities/AssemblyEditor.cpp @@ -167,7 +167,7 @@ int AssemblyEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Base.rte/GUIs/AssemblyEditorGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/AssemblyEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); diff --git a/Activities/EditorActivity.cpp b/Activities/EditorActivity.cpp index bf3895774..4b14c12b3 100644 --- a/Activities/EditorActivity.cpp +++ b/Activities/EditorActivity.cpp @@ -212,7 +212,7 @@ int EditorActivity::Start() // Play editing music g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); // Force the split screen config to just be one big screen for editing g_FrameMan.ResetSplitScreens(false, false); @@ -226,7 +226,7 @@ int EditorActivity::Start() m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } diff --git a/Activities/GATutorial.cpp b/Activities/GATutorial.cpp index c4e6b2891..b46c7b242 100644 --- a/Activities/GATutorial.cpp +++ b/Activities/GATutorial.cpp @@ -385,13 +385,13 @@ int GATutorial::Start() /* // Start special tutorial playlist g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); */ return error; } @@ -443,14 +443,14 @@ void GATutorial::End() if (playerWon) { g_AudioMan.ClearMusicQueue(); // Loop it twice, nice tune! - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); } else { g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); } } } diff --git a/Activities/GameActivity.cpp b/Activities/GameActivity.cpp index 65a3a255a..e0be1d5d6 100644 --- a/Activities/GameActivity.cpp +++ b/Activities/GameActivity.cpp @@ -984,14 +984,14 @@ int GameActivity::Start() m_pBannerRed[player]->Destroy(); else m_pBannerRed[player] = new GUIBanner; - m_pBannerRed[player]->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 8); + m_pBannerRed[player]->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 8); // Allocate and (re)create the banners if (m_pBannerYellow[player]) m_pBannerYellow[player]->Destroy(); else m_pBannerYellow[player] = new GUIBanner; - m_pBannerYellow[player]->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 8); + m_pBannerYellow[player]->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 8); // Resetting the banner repeat counter m_BannerRepeats[player] = 0; @@ -1024,35 +1024,35 @@ int GameActivity::Start() if (m_aLZCursor[0].empty()) { - ContentFile cursorFile("Base.rte/GUIs/Indicators/LZArrowRedL.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Indicators/LZArrowRedL.png"); cursorFile.GetAsAnimation(m_aLZCursor[0], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowGreenL.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowGreenL.png"); cursorFile.GetAsAnimation(m_aLZCursor[1], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowBlueL.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowBlueL.png"); cursorFile.GetAsAnimation(m_aLZCursor[2], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowYellowL.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowYellowL.png"); cursorFile.GetAsAnimation(m_aLZCursor[3], LZCURSORFRAMECOUNT); } if (m_aObjCursor[0].empty()) { - ContentFile cursorFile("Base.rte/GUIs/Indicators/ObjArrowRed.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Indicators/ObjArrowRed.png"); cursorFile.GetAsAnimation(m_aObjCursor[0], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowGreen.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowGreen.png"); cursorFile.GetAsAnimation(m_aObjCursor[1], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowBlue.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowBlue.png"); cursorFile.GetAsAnimation(m_aObjCursor[2], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowYellow.png"); + cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowYellow.png"); cursorFile.GetAsAnimation(m_aObjCursor[3], OBJARROWFRAMECOUNT); } // Start the in-game music g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/cc2g.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/cc2g.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); return error; } @@ -1111,20 +1111,20 @@ void GameActivity::End() if (playerWon) { // Didn't work well, has gap between intro and loop tracks -// g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinintro.ogg", 0); -// g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/uwinloop.ogg"); +// g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinintro.ogg", 0); +// g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/uwinloop.ogg"); g_AudioMan.ClearMusicQueue(); // Loop it twice, nice tune! - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); } else { g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); } */ @@ -1275,11 +1275,11 @@ void GameActivity::UpdateEditing() g_SceneMan.GetScene()->ResetPathFinding(); // Start the in-game track g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/cc2g.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/cc2g.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); } } } diff --git a/Activities/GibEditor.cpp b/Activities/GibEditor.cpp index 4ee588654..467fe16ff 100644 --- a/Activities/GibEditor.cpp +++ b/Activities/GibEditor.cpp @@ -172,7 +172,7 @@ int GibEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Base.rte/GUIs/GibEditorGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/GibEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -207,7 +207,7 @@ int GibEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Activities/MultiplayerGame.cpp b/Activities/MultiplayerGame.cpp index 6a6af4fca..7c047dbdd 100644 --- a/Activities/MultiplayerGame.cpp +++ b/Activities/MultiplayerGame.cpp @@ -173,11 +173,11 @@ namespace RTE { m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/MultiplayerGameGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/MultiplayerGameGUI.ini"); m_pGUIController->EnableMouse(true); // Resize the invisible root container so it matches the screen rez diff --git a/Activities/MultiplayerServerLobby.cpp b/Activities/MultiplayerServerLobby.cpp index ece99b263..13f7296b8 100644 --- a/Activities/MultiplayerServerLobby.cpp +++ b/Activities/MultiplayerServerLobby.cpp @@ -225,11 +225,11 @@ namespace RTE { m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/MultiplayerServerLobbyGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/MultiplayerServerLobbyGUI.ini"); m_pGUIController->EnableMouse(true); // Resize the invisible root container so it matches the screen rez @@ -326,7 +326,7 @@ namespace RTE { m_pScenePreviewBitmap = create_bitmap_ex(8, 140, 55); //m_pScenePreviewBitmap = create_bitmap_ex(8, c_ScenePreviewWidth, c_ScenePreviewHeight); - ContentFile defaultPreview("Base.rte/GUIs/DefaultPreview000.png"); + ContentFile defaultPreview("Data/Base.rte/GUIs/DefaultPreview000.png"); m_pDefaultPreviewBitmap = defaultPreview.GetAsBitmap(COLORCONV_NONE, false); clear_to_color(m_pScenePreviewBitmap, g_MaskColor); @@ -343,7 +343,7 @@ namespace RTE { if (!m_pCursor) { - ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); m_pCursor = cursorFile.GetAsBitmap(); } diff --git a/Activities/SceneEditor.cpp b/Activities/SceneEditor.cpp index bcaf1b603..d45e98f65 100644 --- a/Activities/SceneEditor.cpp +++ b/Activities/SceneEditor.cpp @@ -170,7 +170,7 @@ int SceneEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Base.rte/GUIs/SceneEditorGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/SceneEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -215,7 +215,7 @@ int SceneEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Entities/Actor.cpp b/Entities/Actor.cpp index 7dc2e1aa9..c04d873e7 100644 --- a/Entities/Actor.cpp +++ b/Entities/Actor.cpp @@ -239,34 +239,34 @@ int Actor::Create(const Actor &reference) // Only load the static AI mode icons once if (!m_sIconsLoaded) { - ContentFile("Base.rte/GUIs/TeamIcons/NoTeam.png").GetAsAnimation(m_apNoTeamIcon, 2); + ContentFile("Data/Base.rte/GUIs/TeamIcons/NoTeam.png").GetAsAnimation(m_apNoTeamIcon, 2); - ContentFile iconFile("Base.rte/GUIs/PieIcons/Blank000.png"); + ContentFile iconFile("Data/Base.rte/GUIs/PieIcons/Blank000.png"); m_apAIIcons[AIMODE_NONE] = iconFile.GetAsBitmap(); m_apAIIcons[AIMODE_BOMB] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Eye000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Eye000.png"); m_apAIIcons[AIMODE_SENTRY] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Cycle000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Cycle000.png"); m_apAIIcons[AIMODE_PATROL] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/GoTo000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/GoTo000.png"); m_apAIIcons[AIMODE_GOTO] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Brain000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Brain000.png"); m_apAIIcons[AIMODE_BRAINHUNT] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Dig000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Dig000.png"); m_apAIIcons[AIMODE_GOLDDIG] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Return000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Return000.png"); m_apAIIcons[AIMODE_RETURN] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Land000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Land000.png"); m_apAIIcons[AIMODE_STAY] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Launch000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Launch000.png"); m_apAIIcons[AIMODE_DELIVER] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Death000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Death000.png"); m_apAIIcons[AIMODE_SCUTTLE] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Follow000.png"); + iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Follow000.png"); m_apAIIcons[AIMODE_SQUAD] = iconFile.GetAsBitmap(); - ContentFile("Base.rte/GUIs/Indicators/SelectArrow.png").GetAsAnimation(m_apSelectArrow, 4); - ContentFile("Base.rte/GUIs/Indicators/AlarmExclamation.png").GetAsAnimation(m_apAlarmExclamation, 2); + ContentFile("Data/Base.rte/GUIs/Indicators/SelectArrow.png").GetAsAnimation(m_apSelectArrow, 4); + ContentFile("Data/Base.rte/GUIs/Indicators/AlarmExclamation.png").GetAsAnimation(m_apAlarmExclamation, 2); m_sIconsLoaded = true; } diff --git a/Entities/Deployment.cpp b/Entities/Deployment.cpp index 1e3b089d7..55ee865cf 100644 --- a/Entities/Deployment.cpp +++ b/Entities/Deployment.cpp @@ -60,11 +60,11 @@ int Deployment::Create() if (m_apArrowLeftBitmap.empty()) { - ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); + ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); } if (m_apArrowRightBitmap.empty()) { - ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); + ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); } return 0; @@ -87,11 +87,11 @@ int Deployment::Create(string loadoutName, const Icon &icon, float spawnRadius) if (m_apArrowLeftBitmap.empty()) { - ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); + ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); } if (m_apArrowRightBitmap.empty()) { - ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); + ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); } return 0; diff --git a/Entities/Icon.cpp b/Entities/Icon.cpp index cddfeb66a..9fa0d7840 100644 --- a/Entities/Icon.cpp +++ b/Entities/Icon.cpp @@ -17,7 +17,7 @@ namespace RTE { int Icon::Create() { if (m_BitmapsIndexed.empty() || m_BitmapsTrueColor.empty()) { - if (m_BitmapFile.GetDataPath().empty()) { m_BitmapFile.SetDataPath("Base.rte/GUIs/DefaultIcon.png"); } + if (m_BitmapFile.GetDataPath().empty()) { m_BitmapFile.SetDataPath("Data/Base.rte/GUIs/DefaultIcon.png"); } m_BitmapFile.GetAsAnimation(m_BitmapsIndexed, m_FrameCount, COLORCONV_REDUCE_TO_256); m_BitmapFile.GetAsAnimation(m_BitmapsTrueColor, m_FrameCount, COLORCONV_8_TO_32); diff --git a/Entities/Scene.cpp b/Entities/Scene.cpp index 1e5cb2a0b..3d72e04dc 100644 --- a/Entities/Scene.cpp +++ b/Entities/Scene.cpp @@ -1066,7 +1066,7 @@ int Scene::SavePreview(const std::string &bitmapPath) { } if (!m_pPreviewBitmap) { m_pPreviewBitmap = create_bitmap_ex(8, c_ScenePreviewWidth, c_ScenePreviewHeight); } - ContentFile scenePreviewGradient("Base.rte/GUIs/PreviewSkyGradient.png"); + ContentFile scenePreviewGradient("Data/Base.rte/GUIs/PreviewSkyGradient.png"); draw_sprite(m_pPreviewBitmap, scenePreviewGradient.GetAsBitmap(COLORCONV_NONE, true), 0, 0); int sceneWidth = m_pTerrain->GetBitmap()->w; diff --git a/GUI/GUISound.cpp b/GUI/GUISound.cpp index 79ac23da5..059caa05d 100644 --- a/GUI/GUISound.cpp +++ b/GUI/GUISound.cpp @@ -39,76 +39,76 @@ namespace RTE { void GUISound::Initialize() { // Interface sounds should not be pitched to reinforce the appearance of time decoupling between simulation and UI. - m_SplashSound.Create("Base.rte/Sounds/GUIs/MetaStart.flac", true, false); + m_SplashSound.Create("Data/Base.rte/Sounds/GUIs/MetaStart.flac", true, false); - m_EnterMenuSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + m_EnterMenuSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); - m_ExitMenuSound.Create("Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); - m_ExitMenuSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/MenuExit2.flac", true); + m_ExitMenuSound.Create("Data/Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); + m_ExitMenuSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/MenuExit2.flac", true); - m_FocusChangeSound.Create("Base.rte/Sounds/GUIs/FocusChange.flac", true, false); + m_FocusChangeSound.Create("Data/Base.rte/Sounds/GUIs/FocusChange.flac", true, false); - m_SelectionChangeSound.Create("Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); + m_SelectionChangeSound.Create("Data/Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); - m_ItemChangeSound.Create("Base.rte/Sounds/GUIs/ItemChange.flac", true, false); + m_ItemChangeSound.Create("Data/Base.rte/Sounds/GUIs/ItemChange.flac", true, false); - m_ButtonPressSound.Create("Base.rte/Sounds/GUIs/ButtonPress.flac", true, false); + m_ButtonPressSound.Create("Data/Base.rte/Sounds/GUIs/ButtonPress.flac", true, false); - m_BackButtonPressSound.Create("Base.rte/Sounds/GUIs/BackButtonPress.flac", true, false); + m_BackButtonPressSound.Create("Data/Base.rte/Sounds/GUIs/BackButtonPress.flac", true, false); - m_ConfirmSound.Create("Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); + m_ConfirmSound.Create("Data/Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); - m_UserErrorSound.Create("Base.rte/Sounds/GUIs/UserError.flac", true, false); + m_UserErrorSound.Create("Data/Base.rte/Sounds/GUIs/UserError.flac", true, false); - m_TestSound.Create("Base.rte/Sounds/GUIs/Test.flac", true, false); + m_TestSound.Create("Data/Base.rte/Sounds/GUIs/Test.flac", true, false); - m_PieMenuEnterSound.Create("Base.rte/Sounds/GUIs/PieMenuEnter.flac", true, false); + m_PieMenuEnterSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuEnter.flac", true, false); - m_PieMenuExitSound.Create("Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); + m_PieMenuExitSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); - // m_HoverChangeSound.Create("Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); + // m_HoverChangeSound.Create("Data/Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); m_HoverChangeSound = m_SelectionChangeSound; - m_HoverDisabledSound.Create("Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); + m_HoverDisabledSound.Create("Data/Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); - m_SlicePickedSound.Create("Base.rte/Sounds/GUIs/SlicePicked.flac", true, false); + m_SlicePickedSound.Create("Data/Base.rte/Sounds/GUIs/SlicePicked.flac", true, false); - // m_DisabledPickedSound.Create("Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); + // m_DisabledPickedSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); m_DisabledPickedSound = m_PieMenuExitSound; - m_FundsChangedSound.Create("Base.rte/Sounds/GUIs/FundsChanged1.flac", true, false); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged2.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged3.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged4.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged5.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged6.flac", true); + m_FundsChangedSound.Create("Data/Base.rte/Sounds/GUIs/FundsChanged1.flac", true, false); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged2.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged3.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged4.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged5.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged6.flac", true); m_FundsChangedSound.SetSoundOverlapMode(SoundContainer::SoundOverlapMode::RESTART); - m_ActorSwitchSound.Create("Base.rte/Sounds/GUIs/ActorSwitch.flac", true, false); + m_ActorSwitchSound.Create("Data/Base.rte/Sounds/GUIs/ActorSwitch.flac", true, false); - m_BrainSwitchSound.Create("Base.rte/Sounds/GUIs/BrainSwitch.flac", true, false); + m_BrainSwitchSound.Create("Data/Base.rte/Sounds/GUIs/BrainSwitch.flac", true, false); - m_CameraTravelSound.Create("Base.rte/Sounds/GUIs/CameraTravel1.flac", true, false); - m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/CameraTravel2.flac", true); - m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/CameraTravel3.flac", true); + m_CameraTravelSound.Create("Data/Base.rte/Sounds/GUIs/CameraTravel1.flac", true, false); + m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/CameraTravel2.flac", true); + m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/CameraTravel3.flac", true); - // m_AreaPickedSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_AreaPickedSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_AreaPickedSound = m_ConfirmSound; - // m_ObjectPickedSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_ObjectPickedSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_ObjectPickedSound = m_ConfirmSound; - // m_PurchaseMadeSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_PurchaseMadeSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_PurchaseMadeSound = m_ConfirmSound; - m_PlacementBlip.Create("Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); + m_PlacementBlip.Create("Data/Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); - m_PlacementThud.Create("Base.rte/Sounds/GUIs/PlacementThud1.flac", true, false); - m_PlacementThud.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementThud2.flac", true); + m_PlacementThud.Create("Data/Base.rte/Sounds/GUIs/PlacementThud1.flac", true, false); + m_PlacementThud.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementThud2.flac", true); - m_PlacementGravel.Create("Base.rte/Sounds/GUIs/PlacementGravel1.flac", true, false); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel2.flac", true); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel3.flac", true); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel4.flac", true); + m_PlacementGravel.Create("Data/Base.rte/Sounds/GUIs/PlacementGravel1.flac", true, false); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel2.flac", true); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel3.flac", true); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel4.flac", true); } } diff --git a/Main.cpp b/Main.cpp index 0ff6d48fe..74a0c5a8b 100644 --- a/Main.cpp +++ b/Main.cpp @@ -279,7 +279,7 @@ namespace RTE { /// Implementation of the main function. /// int main(int argc, char **argv) { - set_config_file("Base.rte/AllegroConfig.txt"); + set_config_file("Data/Base.rte/AllegroConfig.txt"); allegro_init(); loadpng_init(); set_close_button_callback(System::WindowCloseButtonHandler); diff --git a/Managers/ActivityMan.cpp b/Managers/ActivityMan.cpp index 0640c100d..2f91894b3 100644 --- a/Managers/ActivityMan.cpp +++ b/Managers/ActivityMan.cpp @@ -233,9 +233,9 @@ namespace RTE { g_AudioMan.PlayMusic(m_LastMusicPath.c_str()); g_AudioMan.SetMusicPosition(m_LastMusicPos); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); } } diff --git a/Managers/ConsoleMan.cpp b/Managers/ConsoleMan.cpp index adfd778ef..1e3419d4d 100644 --- a/Managers/ConsoleMan.cpp +++ b/Managers/ConsoleMan.cpp @@ -43,11 +43,11 @@ namespace RTE { if (!m_GUIInput) { m_GUIInput = new AllegroInput(-1); } if (!m_GUIControlManager) { m_GUIControlManager = new GUIControlManager(); } - if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { + if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Data/Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/ConsoleSkin.ini"); } - m_GUIControlManager->Load("Base.rte/GUIs/ConsoleGUI.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ConsoleGUI.ini"); m_GUIControlManager->EnableMouse(false); // Stretch the invisible root box to fill the screen @@ -134,7 +134,7 @@ namespace RTE { void ConsoleMan::SetConsoleUseMonospaceFont(bool useFont) { m_ConsoleUseMonospaceFont = useFont; - if (m_GUIControlManager) { m_GUIControlManager->ChangeSkin("Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini"); } + if (m_GUIControlManager) { m_GUIControlManager->ChangeSkin("Data/Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini"); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/FrameMan.cpp b/Managers/FrameMan.cpp index 748d67e65..beb4f2c05 100644 --- a/Managers/FrameMan.cpp +++ b/Managers/FrameMan.cpp @@ -79,7 +79,7 @@ namespace RTE { m_StoreNetworkBackBuffer = false; m_NetworkFrameCurrent = 0; m_NetworkFrameReady = 1; - m_PaletteFile = ContentFile("Base.rte/palette.bmp"); + m_PaletteFile = ContentFile("Data/Base.rte/palette.bmp"); m_BlackColor = 245; m_AlmostBlackColor = 245; m_GUIScreen = nullptr; @@ -301,7 +301,7 @@ namespace RTE { CreateBackBuffers(); - ContentFile scenePreviewGradientFile("Base.rte/GUIs/PreviewSkyGradient.png"); + ContentFile scenePreviewGradientFile("Data/Base.rte/GUIs/PreviewSkyGradient.png"); m_ScenePreviewDumpGradient = scenePreviewGradientFile.GetAsBitmap(COLORCONV_8_TO_32, false); return 0; @@ -922,13 +922,13 @@ namespace RTE { if (isSmall) { if (!m_SmallFont) { m_SmallFont = new GUIFont("SmallFont"); - m_SmallFont->Load(m_GUIScreen, "Base.rte/GUIs/Skins/FontSmall.png"); + m_SmallFont->Load(m_GUIScreen, "Data/Base.rte/GUIs/Skins/FontSmall.png"); } return m_SmallFont; } if (!m_LargeFont) { m_LargeFont = new GUIFont("FatFont"); - m_LargeFont->Load(m_GUIScreen, "Base.rte/GUIs/Skins/FontLarge.png"); + m_LargeFont->Load(m_GUIScreen, "Data/Base.rte/GUIs/Skins/FontLarge.png"); } return m_LargeFont; } diff --git a/Managers/PostProcessMan.cpp b/Managers/PostProcessMan.cpp index d95b18444..7641ad6ad 100644 --- a/Managers/PostProcessMan.cpp +++ b/Managers/PostProcessMan.cpp @@ -27,13 +27,13 @@ namespace RTE { int PostProcessMan::Initialize() { // TODO: Make more robust and load more glows! - ContentFile glowFile("Base.rte/Effects/Glows/YellowTiny.png"); + ContentFile glowFile("Data/Base.rte/Effects/Glows/YellowTiny.png"); m_YellowGlow = glowFile.GetAsBitmap(); m_YellowGlowHash = glowFile.GetHash(); - glowFile.SetDataPath("Base.rte/Effects/Glows/RedTiny.png"); + glowFile.SetDataPath("Data/Base.rte/Effects/Glows/RedTiny.png"); m_RedGlow = glowFile.GetAsBitmap(); m_RedGlowHash = glowFile.GetHash(); - glowFile.SetDataPath("Base.rte/Effects/Glows/BlueTiny.png"); + glowFile.SetDataPath("Data/Base.rte/Effects/Glows/BlueTiny.png"); m_BlueGlow = glowFile.GetAsBitmap(); m_BlueGlowHash = glowFile.GetHash(); diff --git a/Managers/SettingsMan.cpp b/Managers/SettingsMan.cpp index 4daad43c1..7f232b226 100644 --- a/Managers/SettingsMan.cpp +++ b/Managers/SettingsMan.cpp @@ -16,7 +16,7 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SettingsMan::Clear() { - m_SettingsPath = "Base.rte/Settings.ini"; + m_SettingsPath = "Data/Base.rte/Settings.ini"; m_SettingsNeedOverwrite = false; m_FlashOnBrainDamage = true; diff --git a/Menus/AreaPickerGUI.cpp b/Menus/AreaPickerGUI.cpp index 22a35be80..b59fca8b0 100644 --- a/Menus/AreaPickerGUI.cpp +++ b/Menus/AreaPickerGUI.cpp @@ -80,15 +80,15 @@ int AreaPickerGUI::Create(Controller *pController, string onlyOfType) m_pGUIInput = new AllegroInput(pController->GetPlayer()); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/AreaPickerGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/AreaPickerGUI.ini"); m_pGUIController->EnableMouse(pController->IsMouseControlled()); if (!s_pCursor) { - ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); s_pCursor = cursorFile.GetAsBitmap(); } @@ -101,7 +101,7 @@ int AreaPickerGUI::Create(Controller *pController, string onlyOfType) m_pParentBox = dynamic_cast(m_pGUIController->GetControl("PickerGUIBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); // m_pParentBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pParentBox->SetDrawBackground(true); // m_pParentBox->SetDrawType(GUICollectionBox::Image); diff --git a/Menus/AssemblyEditorGUI.cpp b/Menus/AssemblyEditorGUI.cpp index 02be26a2d..393c88954 100644 --- a/Menus/AssemblyEditorGUI.cpp +++ b/Menus/AssemblyEditorGUI.cpp @@ -153,9 +153,9 @@ int AssemblyEditorGUI::Create(Controller *pController, FeatureSets featureSet, i // Only load the static dot bitmaps once if (!s_pValidPathDot) { - ContentFile dotFile("Base.rte/GUIs/Indicators/PathDotValid.png"); + ContentFile dotFile("Data/Base.rte/GUIs/Indicators/PathDotValid.png"); s_pValidPathDot = dotFile.GetAsBitmap(); - dotFile.SetDataPath("Base.rte/GUIs/Indicators/PathDotInvalid.png"); + dotFile.SetDataPath("Data/Base.rte/GUIs/Indicators/PathDotInvalid.png"); s_pInvalidPathDot = dotFile.GetAsBitmap(); } diff --git a/Menus/BuyMenuGUI.cpp b/Menus/BuyMenuGUI.cpp index f37617d3d..e4a736b5f 100644 --- a/Menus/BuyMenuGUI.cpp +++ b/Menus/BuyMenuGUI.cpp @@ -142,15 +142,15 @@ int BuyMenuGUI::Create(Controller *pController) m_pGUIInput = new AllegroInput(pController->GetPlayer()); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/BuyMenuGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/BuyMenuGUI.ini"); m_pGUIController->EnableMouse(pController->IsMouseControlled()); if (!s_pCursor) { - ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); s_pCursor = cursorFile.GetAsBitmap(); } @@ -176,8 +176,8 @@ int BuyMenuGUI::Create(Controller *pController) // Set the images for the logo and header decorations GUICollectionBox *pHeader = dynamic_cast(m_pGUIController->GetControl("CatalogHeader")); m_pLogo = dynamic_cast(m_pGUIController->GetControl("CatalogLogo")); - ContentFile headerFile("Base.rte/GUIs/Skins/BuyMenu/BuyMenuHeader.png"); - ContentFile logoFile("Base.rte/GUIs/Skins/BuyMenu/BuyMenuLogo.png"); + ContentFile headerFile("Data/Base.rte/GUIs/Skins/BuyMenu/BuyMenuHeader.png"); + ContentFile logoFile("Data/Base.rte/GUIs/Skins/BuyMenu/BuyMenuLogo.png"); pHeader->SetDrawImage(new AllegroBitmap(headerFile.GetAsBitmap())); m_pLogo->SetDrawImage(new AllegroBitmap(logoFile.GetAsBitmap())); pHeader->SetDrawType(GUICollectionBox::Image); @@ -380,7 +380,7 @@ bool BuyMenuGUI::LoadAllLoadoutsFromFile() // Not a metagame player, just a regular scenario player else { - std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); + std::snprintf(loadoutPath, sizeof(loadoutPath), "Data/Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); } @@ -487,7 +487,7 @@ bool BuyMenuGUI::SaveAllLoadoutsToFile() std::snprintf(loadoutPath, sizeof(loadoutPath), "Metagames.rte/%s - LoadoutsMP%d.ini", g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1); } else - std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); + std::snprintf(loadoutPath, sizeof(loadoutPath), "Data/Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); // Open the file Writer loadoutFile(loadoutPath, false); diff --git a/Menus/InventoryMenuGUI.cpp b/Menus/InventoryMenuGUI.cpp index 8c15edf97..42da527e6 100644 --- a/Menus/InventoryMenuGUI.cpp +++ b/Menus/InventoryMenuGUI.cpp @@ -192,16 +192,16 @@ namespace RTE { if (!m_GUIControlManager) { m_GUIControlManager = std::make_unique(); } if (!m_GUIScreen) { m_GUIScreen = std::make_unique(g_FrameMan.GetBackBuffer8()); } if (!m_GUIInput) { m_GUIInput = std::make_unique(m_MenuController->GetPlayer()); } - RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Base.rte/GUIs/Skins", "InventoryMenuSkin.ini"), "Failed to create InventoryMenuGUI GUIControlManager and load it from Base.rte/GUIs/Skins/Menus/InventoryMenuSkin.ini"); + RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Data/Base.rte/GUIs/Skins", "InventoryMenuSkin.ini"), "Failed to create InventoryMenuGUI GUIControlManager and load it from Base.rte/GUIs/Skins/Menus/InventoryMenuSkin.ini"); //TODO When this is split into 2 classes, full mode should use the fonts from its gui control manager while transfer mode, will need to get its fonts from FrameMan. May be good for the ingame menu base class to have these font pointers, even if some subclasses set em up in different ways. //if (!m_SmallFont) { m_SmallFont = m_GUIControlManager->GetSkin()->GetFont("FontSmall.png"); } //if (!m_LargeFont) { m_LargeFont = m_GUIControlManager->GetSkin()->GetFont("FontLarge.png"); } - m_GUIControlManager->Load("Base.rte/GUIs/InventoryMenuGUI.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/InventoryMenuGUI.ini"); m_GUIControlManager->EnableMouse(m_MenuController->IsMouseControlled()); if (!s_CursorBitmap) { - ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); s_CursorBitmap = cursorFile.GetAsBitmap(); } diff --git a/Menus/LoadingScreen.cpp b/Menus/LoadingScreen.cpp index 4d801ac88..c3a4eeb13 100644 --- a/Menus/LoadingScreen.cpp +++ b/Menus/LoadingScreen.cpp @@ -25,8 +25,8 @@ namespace RTE { void LoadingScreen::Create(AllegroScreen *guiScreen, AllegroInput *guiInput, bool progressReportDisabled) { GUIControlManager loadingScreenManager; - RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); - loadingScreenManager.Load("Base.rte/GUIs/LoadingGUI.ini"); + RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); + loadingScreenManager.Load("Data/Base.rte/GUIs/LoadingGUI.ini"); int loadingSplashOffset = 0; if (!progressReportDisabled) { @@ -34,7 +34,7 @@ namespace RTE { loadingSplashOffset = m_ProgressListboxPosX / 4; } SceneLayer loadingSplash; - loadingSplash.Create(ContentFile("Base.rte/GUIs/Title/LoadingSplash.png").GetAsBitmap(COLORCONV_NONE, false), false, Vector(), true, false, Vector(1.0F, 0)); + loadingSplash.Create(ContentFile("Data/Base.rte/GUIs/Title/LoadingSplash.png").GetAsBitmap(COLORCONV_NONE, false), false, Vector(), true, false, Vector(1.0F, 0)); loadingSplash.SetOffset(Vector(static_cast(((loadingSplash.GetBitmap()->w - g_FrameMan.GetResX()) / 2) + loadingSplashOffset), 0)); Box loadingSplashTargetBox(Vector(0, static_cast((g_FrameMan.GetResY() - loadingSplash.GetBitmap()->h) / 2)), static_cast(g_FrameMan.GetResX()), static_cast(loadingSplash.GetBitmap()->h)); diff --git a/Menus/MainMenuGUI.cpp b/Menus/MainMenuGUI.cpp index 3f4455c76..832226611 100644 --- a/Menus/MainMenuGUI.cpp +++ b/Menus/MainMenuGUI.cpp @@ -50,12 +50,12 @@ namespace RTE { void MainMenuGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_MainMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); - m_MainMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuGUI.ini"); + RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); + m_MainMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuGUI.ini"); m_SubMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_SubMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuSubMenuGUI.ini"); + RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_SubMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuSubMenuGUI.ini"); GUICollectionBox *mainScreenRootBox = dynamic_cast(m_MainMenuScreenGUIControlManager->GetControl("root")); mainScreenRootBox->Resize(g_FrameMan.GetResX(), mainScreenRootBox->GetHeight()); diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index 73b29276f..5612cc5d3 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -370,10 +370,10 @@ int MetagameGUI::Create(Controller *pController) m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/MetagameGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/MetagameGUI.ini"); // Make sure we have convenient points to the containing GUI colleciton boxes that we will manipulate the positions of GUICollectionBox *pRootBox = m_apScreenBox[ROOTBOX] = dynamic_cast(m_pGUIController->GetControl("root")); @@ -386,10 +386,10 @@ int MetagameGUI::Create(Controller *pController) m_pBannerRedBottom = new GUIBanner(); m_pBannerYellowTop = new GUIBanner(); m_pBannerYellowBottom = new GUIBanner(); - m_pBannerRedTop->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); - m_pBannerRedBottom->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); - m_pBannerYellowTop->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); - m_pBannerYellowBottom->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); + m_pBannerRedTop->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); + m_pBannerRedBottom->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); + m_pBannerYellowTop->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); + m_pBannerYellowBottom->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); // General game message label m_pGameMessageLabel = dynamic_cast(m_pGUIController->GetControl("GameMessageLabel")); @@ -2483,7 +2483,7 @@ void MetagameGUI::UpdateInput() g_MetaMan.m_Players[metaPlayer].m_Funds -= SCANCOST; // Set up and start the scripted activity for scanning the site for this' team GAScripted *pScanActivity = new GAScripted; - pScanActivity->Create("Base.rte/Activities/SiteScan.lua", "SiteScan"); + pScanActivity->Create("Data/Base.rte/Activities/SiteScan.lua", "SiteScan"); char str[64]; std::snprintf(str, sizeof(str), "R%dScan", g_MetaMan.m_CurrentRound + 1); pScanActivity->SetPresetName(g_MetaMan.GetGameName() + str); @@ -2980,7 +2980,7 @@ void MetagameGUI::CompletedActivity() UpdateScenesBox(true); // Play some nice ambient music - g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1, 0.4); + g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1, 0.4); } } } @@ -4238,7 +4238,7 @@ void MetagameGUI::SetupOffensives() { // Set up the MetaFight activity GAScripted *pOffensive = new GAScripted; - pOffensive->Create("Base.rte/Activities/MetaFight.lua", "MetaFight"); + pOffensive->Create("Data/Base.rte/Activities/MetaFight.lua", "MetaFight"); char str[64]; std::snprintf(str, sizeof(str), "R%dA%d", g_MetaMan.m_CurrentRound + 1, offensiveCount); pOffensive->SetPresetName(g_MetaMan.GetGameName() + str); diff --git a/Menus/ModManagerGUI.cpp b/Menus/ModManagerGUI.cpp index c269ea97e..9dc667484 100644 --- a/Menus/ModManagerGUI.cpp +++ b/Menus/ModManagerGUI.cpp @@ -19,8 +19,8 @@ namespace RTE { ModManagerGUI::ModManagerGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/ModManagerGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ModManagerGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/ObjectPickerGUI.cpp b/Menus/ObjectPickerGUI.cpp index 1bd31847b..90ae3ba4b 100644 --- a/Menus/ObjectPickerGUI.cpp +++ b/Menus/ObjectPickerGUI.cpp @@ -66,13 +66,13 @@ namespace RTE { if (!m_GUIScreen) { m_GUIScreen = std::make_unique(g_FrameMan.GetBackBuffer8()); } if (!m_GUIInput) { m_GUIInput = std::make_unique(controller->GetPlayer()); } if (!m_GUIControlManager) { m_GUIControlManager = std::make_unique(); } - RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Base.rte/GUIs/Skins", "DefaultSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); + RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/ObjectPickerGUI.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ObjectPickerGUI.ini"); m_GUIControlManager->EnableMouse(controller->IsMouseControlled()); if (!s_Cursor) { - ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); s_Cursor = cursorFile.GetAsBitmap(); } diff --git a/Menus/PieMenuGUI.cpp b/Menus/PieMenuGUI.cpp index 9de92ae73..279303be3 100644 --- a/Menus/PieMenuGUI.cpp +++ b/Menus/PieMenuGUI.cpp @@ -51,7 +51,7 @@ namespace RTE { int PieMenuGUI::Create(Controller *controller, MovableObject *affectedObject) { RTEAssert(controller, "No controller sent to PieMenuGUI on creation!"); - if (!s_CursorBitmap) { s_CursorBitmap = ContentFile("Base.rte/GUIs/Skins/PieCursor.png").GetAsBitmap(); } + if (!s_CursorBitmap) { s_CursorBitmap = ContentFile("Data/Base.rte/GUIs/Skins/PieCursor.png").GetAsBitmap(); } if (!m_LargeFont) { m_LargeFont = g_FrameMan.GetLargeFont(); } diff --git a/Menus/ScenarioGUI.cpp b/Menus/ScenarioGUI.cpp index ef62bfd65..ab4594c39 100644 --- a/Menus/ScenarioGUI.cpp +++ b/Menus/ScenarioGUI.cpp @@ -52,8 +52,8 @@ namespace RTE { void ScenarioGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/ScenarioGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ScenarioGUI.ini"); m_RootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); m_RootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); @@ -95,8 +95,8 @@ namespace RTE { m_ScenePreviewImageBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxScenePreview")); m_StartActivityConfigButton = dynamic_cast(m_GUIControlManager->GetControl("ButtonStartActivityConfig")); - m_DefaultScenePreview.Create(ContentFile("Base.rte/GUIs/DefaultPreview.png"), 5); - m_DefaultScenePreview.SetSpriteAnimMode(SpriteAnimMode::ALWAYSLOOP); + m_DefaultScenePreview.Create(ContentFile("Data/Base.rte/GUIs/DefaultPreview.png"), 5); + m_DefaultScenePreview.SetSpriteAnimMode(MOSprite::SpriteAnimMode::ALWAYSLOOP); m_DefaultScenePreview.SetSpriteAnimDuration(200); m_DefaultScenePreview.SetPos(Vector(static_cast(m_ScenePreviewImageBox->GetXPos() + (m_ScenePreviewImageBox->GetWidth() / 2)), static_cast(m_ScenePreviewImageBox->GetYPos() + (m_ScenePreviewImageBox->GetHeight() / 2)))); diff --git a/Menus/SceneEditorGUI.cpp b/Menus/SceneEditorGUI.cpp index 119b0397b..7a0a505b5 100644 --- a/Menus/SceneEditorGUI.cpp +++ b/Menus/SceneEditorGUI.cpp @@ -152,9 +152,9 @@ int SceneEditorGUI::Create(Controller *pController, FeatureSets featureSet, int // Only load the static dot bitmaps once if (!s_pValidPathDot) { - ContentFile dotFile("Base.rte/GUIs/Indicators/PathDotValid.png"); + ContentFile dotFile("Data/Base.rte/GUIs/Indicators/PathDotValid.png"); s_pValidPathDot = dotFile.GetAsBitmap(); - dotFile.SetDataPath("Base.rte/GUIs/Indicators/PathDotInvalid.png"); + dotFile.SetDataPath("Data/Base.rte/GUIs/Indicators/PathDotInvalid.png"); s_pInvalidPathDot = dotFile.GetAsBitmap(); } diff --git a/Menus/SettingsGUI.cpp b/Menus/SettingsGUI.cpp index 36347be91..ad6b55da2 100644 --- a/Menus/SettingsGUI.cpp +++ b/Menus/SettingsGUI.cpp @@ -14,8 +14,8 @@ namespace RTE { SettingsGUI::SettingsGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/SettingsGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/SettingsGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/SettingsInputMappingWizardGUI.cpp b/Menus/SettingsInputMappingWizardGUI.cpp index 4b2d055e2..5b2774bb7 100644 --- a/Menus/SettingsInputMappingWizardGUI.cpp +++ b/Menus/SettingsInputMappingWizardGUI.cpp @@ -44,11 +44,11 @@ namespace RTE { m_InputWizardTitleLabel = dynamic_cast(m_GUIControlManager->GetControl("LabelPlayerInputMappingWizardTitle")); int dpadDiagramBitampCount = 13; - ContentFile("Base.rte/GUIs/Controllers/D-Pad.png").GetAsAnimation(m_DPadDiagramBitmaps, dpadDiagramBitampCount, COLORCONV_8_TO_32); + ContentFile("Data/Base.rte/GUIs/Controllers/D-Pad.png").GetAsAnimation(m_DPadDiagramBitmaps, dpadDiagramBitampCount, COLORCONV_8_TO_32); int analogDiagramBitmapCount = 21; - ContentFile("Base.rte/GUIs/Controllers/DualAnalogDS.png").GetAsAnimation(m_DualAnalogDSDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); - ContentFile("Base.rte/GUIs/Controllers/DualAnalogXB.png").GetAsAnimation(m_DualAnalogXBDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); + ContentFile("Data/Base.rte/GUIs/Controllers/DualAnalogDS.png").GetAsAnimation(m_DualAnalogDSDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); + ContentFile("Data/Base.rte/GUIs/Controllers/DualAnalogXB.png").GetAsAnimation(m_DualAnalogXBDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); CreateManualConfigScreen(); CreatePresetSelectionScreen(); diff --git a/Menus/TitleScreen.cpp b/Menus/TitleScreen.cpp index da9fbe8b0..e248dac6b 100644 --- a/Menus/TitleScreen.cpp +++ b/Menus/TitleScreen.cpp @@ -77,7 +77,7 @@ namespace RTE { if (!g_FrameMan.ResolutionChanged()) { if (!g_SettingsMan.SkipIntro() && !g_ActivityMan.IsSetToLaunchIntoActivity()) { m_IntroTextFont = std::make_unique("FontLarge"); - m_IntroTextFont->Load(guiScreen, "Base.rte/GUIs/Skins/Menus/FontLarge.png"); + m_IntroTextFont->Load(guiScreen, "Data/Base.rte/GUIs/Skins/Menus/FontLarge.png"); CreateIntroSequenceSlides(); } else { m_IntroSequenceState = IntroSequence::MainMenuAppear; @@ -91,33 +91,32 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void TitleScreen::CreateTitleElements() { - m_DataRealmsLogo = ContentFile("Base.rte/GUIs/Title/Intro/DRLogo5x.png").GetAsBitmap(); - m_FmodLogo = ContentFile("Base.rte/GUIs/Title/Intro/FMODLogo.png").GetAsBitmap(); - - m_PreGameLogoText.Create(ContentFile("Base.rte/GUIs/Title/Intro/PreTitle.png")); - m_PreGameLogoTextGlow.Create(ContentFile("Base.rte/GUIs/Title/Intro/PreTitleGlow.png")); - m_GameLogo.Create(ContentFile("Base.rte/GUIs/Title/Title.png")); - m_GameLogoGlow.Create(ContentFile("Base.rte/GUIs/Title/TitleGlow.png")); - m_Planet.Create(ContentFile("Base.rte/GUIs/Title/Planet.png")); - m_Moon.Create(ContentFile("Base.rte/GUIs/Title/Moon.png")); - m_Station.Create(ContentFile("Base.rte/GUIs/Title/Station.png")); - m_Nebula.Create(ContentFile("Base.rte/GUIs/Title/Nebula.png"), false, Vector(), false, false, Vector(0, -1.0F)); - m_Nebula.SetScrollRatio(Vector(-1.0F, 1.0F / 3.0F)); + m_DataRealmsLogo = ContentFile("Data/Base.rte/GUIs/Title/Intro/DRLogo5x.png").GetAsBitmap(); + m_FmodLogo = ContentFile("Data/Base.rte/GUIs/Title/Intro/FMODLogo.png").GetAsBitmap(); + + m_PreGameLogoText.Create(ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitle.png")); + m_PreGameLogoTextGlow.Create(ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitleGlow.png")); + m_GameLogo.Create(ContentFile("Data/Base.rte/GUIs/Title/Title.png")); + m_GameLogoGlow.Create(ContentFile("Data/Base.rte/GUIs/Title/TitleGlow.png")); + m_Planet.Create(ContentFile("Data/Base.rte/GUIs/Title/Planet.png")); + m_Moon.Create(ContentFile("Data/Base.rte/GUIs/Title/Moon.png")); + m_Station.Create(ContentFile("Data/Base.rte/GUIs/Title/Station.png")); + m_Nebula.Create(ContentFile("Data/Base.rte/GUIs/Title/Nebula.png"), false, Vector(), false, false, Vector(0, -1.0F)); set_write_alpha_blender(); - draw_trans_sprite(m_PreGameLogoText.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/Intro/PreTitleAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_GameLogo.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/TitleAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_Planet.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/PlanetAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_Moon.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/MoonAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_PreGameLogoText.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitleAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_GameLogo.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/TitleAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_Planet.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/PlanetAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_Moon.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/MoonAlpha.png").GetAsBitmap(), 0, 0); int starSmallBitmapCount = 4; - std::vector starSmallBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarSmall.png").GetAsAnimation(starSmallBitmapCount); + std::vector starSmallBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarSmall.png").GetAsAnimation(starSmallBitmapCount); int starLargeBitmapCount = 1; - std::vector starLargeBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarLarge.png").GetAsAnimation(starLargeBitmapCount); + std::vector starLargeBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarLarge.png").GetAsAnimation(starLargeBitmapCount); int starHugeBitmapCount = 2; - std::vector starHugeBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarHuge.png").GetAsAnimation(starHugeBitmapCount); + std::vector starHugeBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarHuge.png").GetAsAnimation(starHugeBitmapCount); int starCount = (g_FrameMan.GetResX() * m_Nebula.GetBitmap()->h) / 1000; for (int i = 0; i < starCount; ++i) { @@ -146,7 +145,7 @@ namespace RTE { void TitleScreen::CreateIntroSequenceSlides() { std::string highRes = (g_FrameMan.GetResY() >= 680) ? "HD" : ""; for (int slideNum = 0; slideNum < m_IntroSlides.size(); ++slideNum) { - m_IntroSlides[slideNum] = ContentFile(("Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); + m_IntroSlides.at(slideNum) = ContentFile(("Data/Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); } } @@ -250,7 +249,7 @@ namespace RTE { m_IntroScrollDuration = 66.6F - m_IntroScrollStartTime; m_ScrollOffset.SetY(m_IntroScrollStartOffsetY); - g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccintro.ogg", 0); + g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccintro.ogg", 0); g_AudioMan.SetMusicPosition(0.05F); } m_FadeAmount = static_cast(LERP(0, 1.0F, 255.0F, 0, m_SectionProgress)); @@ -376,7 +375,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(0.5F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); m_FadeAmount = 0; - g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); } m_ScrollOffset.SetY(EaseOut(m_PreMainMenuScrollOffsetY, 0, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(120, m_GameLogoMainMenuOffsetY, m_SectionProgress))); @@ -413,7 +412,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(1.0F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); g_GUISound.SplashSound()->Play(); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); } m_ScrollOffset.SetY(EaseOut(0, m_PlanetViewScrollOffsetY, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(m_GameLogoMainMenuOffsetY, m_GameLogoPlanetViewOffsetY, m_SectionProgress))); @@ -422,7 +421,7 @@ namespace RTE { case TitleTransition::PlanetToMainMenu: if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(1.0F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); - g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); } m_ScrollOffset.SetY(EaseOut(m_PlanetViewScrollOffsetY, 0, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(m_GameLogoPlanetViewOffsetY, m_GameLogoMainMenuOffsetY, m_SectionProgress))); @@ -446,7 +445,7 @@ namespace RTE { m_ScrollOffset.SetY(m_PlanetViewScrollOffsetY); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), m_GameLogoPlanetViewOffsetY)); m_StationOrbitTimer.SetElapsedRealTimeS(m_StationOrbitTimerElapsedTime); - g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); + g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); } g_AudioMan.SetTempMusicVolume(EaseOut(0, 1.0F, m_SectionProgress)); m_FadeAmount = static_cast(LERP(0, 1.0F, 255.0F, 0, m_SectionProgress)); @@ -462,7 +461,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(0.75F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); m_StationOrbitTimer.SetElapsedRealTimeS(m_StationOrbitTimerElapsedTime); - g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); } g_AudioMan.SetTempMusicVolume(EaseOut(0, 1.0F, m_SectionProgress)); m_ScrollOffset.SetY(EaseOut(250, 0, m_SectionProgress)); From 88403a38c53f62222541bd5a2e23844d5087f140 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 17:40:27 +0200 Subject: [PATCH 03/40] simplify IsModuleOfficial --- Managers/PresetMan.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index b7b76f5f0..3d2cabcb3 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,8 +29,6 @@ #include "LoadingScreen.h" #include "SettingsMan.h" -static const std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; - namespace RTE { ////////////////////////////////////////////////////////////////////////////////////////// @@ -166,6 +164,7 @@ bool PresetMan::LoadAllDataModules() { FindAndExtractZippedModules(); // Load all the official modules first! + std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; for (const std::string &officialModule : officialModules) { if (!LoadDataModule(officialModule, true, &LoadingScreen::LoadingSplashProgressReport)) { return false; @@ -310,7 +309,6 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) return GetModuleID(dataPath.substr(0, slashPos)); } - ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetModuleIDFromPath ////////////////////////////////////////////////////////////////////////////////////////// @@ -320,10 +318,9 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) bool PresetMan::IsModuleOfficial(int whichModule) { - return std::find(officialModules.begin(), officialModules.end(), GetDataModuleName(whichModule)) != officialModules.end(); + return whichModule < m_OfficialModuleCount; } - ////////////////////////////////////////////////////////////////////////////////////////// // Method: AddEntityPreset ////////////////////////////////////////////////////////////////////////////////////////// From c7ecfe32224d2a35c19534781c7e982e6c0ba316 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 17:42:03 +0200 Subject: [PATCH 04/40] Fix m_DataModuleName and includeFilePath in StartIncludeFile --- System/Reader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/System/Reader.cpp b/System/Reader.cpp index 116ec0293..781891147 100644 --- a/System/Reader.cpp +++ b/System/Reader.cpp @@ -34,7 +34,8 @@ namespace RTE { } // Extract the file name and module name from the path m_FileName = m_FilePath.substr(m_FilePath.find_last_of("/\\") + 1); - m_DataModuleName = m_FilePath.substr(0, m_FilePath.find_first_of("/\\")); + const int nameLength = m_FilePath.find_last_of("/\\") - m_FilePath.find_first_of("/\\") -1; + m_DataModuleName = m_FilePath.substr(m_FilePath.find_first_of("/\\") + 1, nameLength); m_DataModuleID = g_PresetMan.GetModuleID(m_DataModuleName); m_CanFail = failOK; @@ -266,8 +267,9 @@ namespace RTE { // Report that we're including a file if (m_ReportProgress) { m_ReportProgress(m_ReportTabs + m_FileName + " on line " + std::to_string(m_CurrentLine) + " includes:", false); } + const std::string moduleFolder = g_PresetMan.IsModuleOfficial(GetReadModuleID()) ? "Data/" : "Mods/"; // Get the file path from the current stream before pushing it into the StreamStack, otherwise we can't open a new stream after releasing it because we can't read. - std::string includeFilePath = std::filesystem::path(ReadPropValue()).generic_string(); + std::string includeFilePath = moduleFolder + std::filesystem::path(ReadPropValue()).generic_string(); // Push the current stream onto the StreamStack for future retrieval when the new include file has run out of data. m_StreamStack.push(StreamInfo(m_Stream.release(), m_FilePath, m_CurrentLine, m_PreviousIndent)); From fd47e176798bc14ed132cf759bec664d3ebe12fe Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 17:43:11 +0200 Subject: [PATCH 05/40] fix GetAsBitmap --- System/ContentFile.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index bba05a1c2..688efaae8 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -109,6 +109,8 @@ namespace RTE { BITMAP *returnBitmap = nullptr; const int bitDepth = (conversionMode == COLORCONV_8_TO_32) ? BitDepths::ThirtyTwo : BitDepths::Eight; std::string dataPathToLoad = dataPathToSpecificFrame.empty() ? m_DataPath : dataPathToSpecificFrame; + const std::string moduleFolder = g_PresetMan.IsModuleOfficial(GetDataModuleID()) ? "Data/" : "Mods/"; + dataPathToLoad = moduleFolder + dataPathToLoad; SetFormattedReaderPosition(GetFormattedReaderPosition()); // Check if the file has already been read and loaded from the disk and, if so, use that data. From 5ea695f643a049ccd59f3e6213fc184caa34dcfc Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 17:43:39 +0200 Subject: [PATCH 06/40] Revert "Change hardcoded path from Base.rte/ to Data/Base.rte" This reverts commit dfb3f1fe1067c4f6192da02e0986aeb1a805fe6e. --- Activities/AreaEditor.cpp | 4 +- Activities/AssemblyEditor.cpp | 2 +- Activities/EditorActivity.cpp | 4 +- Activities/GATutorial.cpp | 16 ++--- Activities/GameActivity.cpp | 44 +++++++------- Activities/GibEditor.cpp | 4 +- Activities/MultiplayerGame.cpp | 4 +- Activities/MultiplayerServerLobby.cpp | 8 +-- Activities/SceneEditor.cpp | 4 +- Entities/Actor.cpp | 28 ++++----- Entities/Deployment.cpp | 8 +-- Entities/Icon.cpp | 2 +- Entities/Scene.cpp | 2 +- GUI/GUISound.cpp | 78 ++++++++++++------------- Main.cpp | 2 +- Managers/ActivityMan.cpp | 4 +- Managers/ConsoleMan.cpp | 6 +- Managers/FrameMan.cpp | 8 +-- Managers/PostProcessMan.cpp | 6 +- Managers/SettingsMan.cpp | 2 +- Menus/AreaPickerGUI.cpp | 8 +-- Menus/AssemblyEditorGUI.cpp | 4 +- Menus/BuyMenuGUI.cpp | 14 ++--- Menus/InventoryMenuGUI.cpp | 6 +- Menus/LoadingScreen.cpp | 6 +- Menus/MainMenuGUI.cpp | 8 +-- Menus/MetagameGUI.cpp | 18 +++--- Menus/ModManagerGUI.cpp | 4 +- Menus/ObjectPickerGUI.cpp | 6 +- Menus/PieMenuGUI.cpp | 2 +- Menus/ScenarioGUI.cpp | 6 +- Menus/SceneEditorGUI.cpp | 4 +- Menus/SettingsGUI.cpp | 4 +- Menus/SettingsInputMappingWizardGUI.cpp | 6 +- Menus/TitleScreen.cpp | 52 ++++++++--------- 35 files changed, 192 insertions(+), 192 deletions(-) diff --git a/Activities/AreaEditor.cpp b/Activities/AreaEditor.cpp index 9ab18b100..466238fa0 100644 --- a/Activities/AreaEditor.cpp +++ b/Activities/AreaEditor.cpp @@ -166,7 +166,7 @@ int AreaEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Data/Base.rte/GUIs/AreaEditorGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/AreaEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -202,7 +202,7 @@ int AreaEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Activities/AssemblyEditor.cpp b/Activities/AssemblyEditor.cpp index c9a064995..59006c0e5 100644 --- a/Activities/AssemblyEditor.cpp +++ b/Activities/AssemblyEditor.cpp @@ -167,7 +167,7 @@ int AssemblyEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Data/Base.rte/GUIs/AssemblyEditorGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/AssemblyEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); diff --git a/Activities/EditorActivity.cpp b/Activities/EditorActivity.cpp index 4b14c12b3..bf3895774 100644 --- a/Activities/EditorActivity.cpp +++ b/Activities/EditorActivity.cpp @@ -212,7 +212,7 @@ int EditorActivity::Start() // Play editing music g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg"); // Force the split screen config to just be one big screen for editing g_FrameMan.ResetSplitScreens(false, false); @@ -226,7 +226,7 @@ int EditorActivity::Start() m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } diff --git a/Activities/GATutorial.cpp b/Activities/GATutorial.cpp index b46c7b242..c4e6b2891 100644 --- a/Activities/GATutorial.cpp +++ b/Activities/GATutorial.cpp @@ -385,13 +385,13 @@ int GATutorial::Start() /* // Start special tutorial playlist g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); */ return error; } @@ -443,14 +443,14 @@ void GATutorial::End() if (playerWon) { g_AudioMan.ClearMusicQueue(); // Loop it twice, nice tune! - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); } else { g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); } } } diff --git a/Activities/GameActivity.cpp b/Activities/GameActivity.cpp index e0be1d5d6..65a3a255a 100644 --- a/Activities/GameActivity.cpp +++ b/Activities/GameActivity.cpp @@ -984,14 +984,14 @@ int GameActivity::Start() m_pBannerRed[player]->Destroy(); else m_pBannerRed[player] = new GUIBanner; - m_pBannerRed[player]->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 8); + m_pBannerRed[player]->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 8); // Allocate and (re)create the banners if (m_pBannerYellow[player]) m_pBannerYellow[player]->Destroy(); else m_pBannerYellow[player] = new GUIBanner; - m_pBannerYellow[player]->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 8); + m_pBannerYellow[player]->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 8); // Resetting the banner repeat counter m_BannerRepeats[player] = 0; @@ -1024,35 +1024,35 @@ int GameActivity::Start() if (m_aLZCursor[0].empty()) { - ContentFile cursorFile("Data/Base.rte/GUIs/Indicators/LZArrowRedL.png"); + ContentFile cursorFile("Base.rte/GUIs/Indicators/LZArrowRedL.png"); cursorFile.GetAsAnimation(m_aLZCursor[0], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowGreenL.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowGreenL.png"); cursorFile.GetAsAnimation(m_aLZCursor[1], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowBlueL.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowBlueL.png"); cursorFile.GetAsAnimation(m_aLZCursor[2], LZCURSORFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/LZArrowYellowL.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/LZArrowYellowL.png"); cursorFile.GetAsAnimation(m_aLZCursor[3], LZCURSORFRAMECOUNT); } if (m_aObjCursor[0].empty()) { - ContentFile cursorFile("Data/Base.rte/GUIs/Indicators/ObjArrowRed.png"); + ContentFile cursorFile("Base.rte/GUIs/Indicators/ObjArrowRed.png"); cursorFile.GetAsAnimation(m_aObjCursor[0], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowGreen.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowGreen.png"); cursorFile.GetAsAnimation(m_aObjCursor[1], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowBlue.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowBlue.png"); cursorFile.GetAsAnimation(m_aObjCursor[2], OBJARROWFRAMECOUNT); - cursorFile.SetDataPath("Data/Base.rte/GUIs/Indicators/ObjArrowYellow.png"); + cursorFile.SetDataPath("Base.rte/GUIs/Indicators/ObjArrowYellow.png"); cursorFile.GetAsAnimation(m_aObjCursor[3], OBJARROWFRAMECOUNT); } // Start the in-game music g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/cc2g.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/cc2g.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); return error; } @@ -1111,20 +1111,20 @@ void GameActivity::End() if (playerWon) { // Didn't work well, has gap between intro and loop tracks -// g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinintro.ogg", 0); -// g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/uwinloop.ogg"); +// g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinintro.ogg", 0); +// g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/uwinloop.ogg"); g_AudioMan.ClearMusicQueue(); // Loop it twice, nice tune! - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/uwinfinal.ogg", 2); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); } else { g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/udiedfinal.ogg", 0); g_AudioMan.QueueSilence(10); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/ccambient4.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/ccambient4.ogg"); } */ @@ -1275,11 +1275,11 @@ void GameActivity::UpdateEditing() g_SceneMan.GetScene()->ResetPathFinding(); // Start the in-game track g_AudioMan.ClearMusicQueue(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/cc2g.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/cc2g.ogg", 0); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); } } } diff --git a/Activities/GibEditor.cpp b/Activities/GibEditor.cpp index 467fe16ff..4ee588654 100644 --- a/Activities/GibEditor.cpp +++ b/Activities/GibEditor.cpp @@ -172,7 +172,7 @@ int GibEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Data/Base.rte/GUIs/GibEditorGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/GibEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -207,7 +207,7 @@ int GibEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Activities/MultiplayerGame.cpp b/Activities/MultiplayerGame.cpp index 7c047dbdd..6a6af4fca 100644 --- a/Activities/MultiplayerGame.cpp +++ b/Activities/MultiplayerGame.cpp @@ -173,11 +173,11 @@ namespace RTE { m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Data/Base.rte/GUIs/MultiplayerGameGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/MultiplayerGameGUI.ini"); m_pGUIController->EnableMouse(true); // Resize the invisible root container so it matches the screen rez diff --git a/Activities/MultiplayerServerLobby.cpp b/Activities/MultiplayerServerLobby.cpp index 13f7296b8..ece99b263 100644 --- a/Activities/MultiplayerServerLobby.cpp +++ b/Activities/MultiplayerServerLobby.cpp @@ -225,11 +225,11 @@ namespace RTE { m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Data/Base.rte/GUIs/MultiplayerServerLobbyGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/MultiplayerServerLobbyGUI.ini"); m_pGUIController->EnableMouse(true); // Resize the invisible root container so it matches the screen rez @@ -326,7 +326,7 @@ namespace RTE { m_pScenePreviewBitmap = create_bitmap_ex(8, 140, 55); //m_pScenePreviewBitmap = create_bitmap_ex(8, c_ScenePreviewWidth, c_ScenePreviewHeight); - ContentFile defaultPreview("Data/Base.rte/GUIs/DefaultPreview000.png"); + ContentFile defaultPreview("Base.rte/GUIs/DefaultPreview000.png"); m_pDefaultPreviewBitmap = defaultPreview.GetAsBitmap(COLORCONV_NONE, false); clear_to_color(m_pScenePreviewBitmap, g_MaskColor); @@ -343,7 +343,7 @@ namespace RTE { if (!m_pCursor) { - ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); m_pCursor = cursorFile.GetAsBitmap(); } diff --git a/Activities/SceneEditor.cpp b/Activities/SceneEditor.cpp index d45e98f65..bcaf1b603 100644 --- a/Activities/SceneEditor.cpp +++ b/Activities/SceneEditor.cpp @@ -170,7 +170,7 @@ int SceneEditor::Start() ////////////////////////////////////////////////////////////// // Hooking up directly to the controls defined in the GUI ini - m_pGUIController->Load("Data/Base.rte/GUIs/SceneEditorGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/SceneEditorGUI.ini"); // Resize the invisible root container so it matches the screen rez GUICollectionBox *pRootBox = dynamic_cast(m_pGUIController->GetControl("base")); @@ -215,7 +215,7 @@ int SceneEditor::Start() m_pSaveDialogBox = dynamic_cast(m_pGUIController->GetControl("SaveDialogBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); // m_pSaveDialogBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pSaveDialogBox->SetDrawBackground(true); // m_pSaveDialogBox->SetDrawType(GUICollectionBox::Image); diff --git a/Entities/Actor.cpp b/Entities/Actor.cpp index c04d873e7..7dc2e1aa9 100644 --- a/Entities/Actor.cpp +++ b/Entities/Actor.cpp @@ -239,34 +239,34 @@ int Actor::Create(const Actor &reference) // Only load the static AI mode icons once if (!m_sIconsLoaded) { - ContentFile("Data/Base.rte/GUIs/TeamIcons/NoTeam.png").GetAsAnimation(m_apNoTeamIcon, 2); + ContentFile("Base.rte/GUIs/TeamIcons/NoTeam.png").GetAsAnimation(m_apNoTeamIcon, 2); - ContentFile iconFile("Data/Base.rte/GUIs/PieIcons/Blank000.png"); + ContentFile iconFile("Base.rte/GUIs/PieIcons/Blank000.png"); m_apAIIcons[AIMODE_NONE] = iconFile.GetAsBitmap(); m_apAIIcons[AIMODE_BOMB] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Eye000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Eye000.png"); m_apAIIcons[AIMODE_SENTRY] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Cycle000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Cycle000.png"); m_apAIIcons[AIMODE_PATROL] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/GoTo000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/GoTo000.png"); m_apAIIcons[AIMODE_GOTO] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Brain000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Brain000.png"); m_apAIIcons[AIMODE_BRAINHUNT] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Dig000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Dig000.png"); m_apAIIcons[AIMODE_GOLDDIG] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Return000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Return000.png"); m_apAIIcons[AIMODE_RETURN] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Land000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Land000.png"); m_apAIIcons[AIMODE_STAY] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Launch000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Launch000.png"); m_apAIIcons[AIMODE_DELIVER] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Death000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Death000.png"); m_apAIIcons[AIMODE_SCUTTLE] = iconFile.GetAsBitmap(); - iconFile.SetDataPath("Data/Base.rte/GUIs/PieIcons/Follow000.png"); + iconFile.SetDataPath("Base.rte/GUIs/PieIcons/Follow000.png"); m_apAIIcons[AIMODE_SQUAD] = iconFile.GetAsBitmap(); - ContentFile("Data/Base.rte/GUIs/Indicators/SelectArrow.png").GetAsAnimation(m_apSelectArrow, 4); - ContentFile("Data/Base.rte/GUIs/Indicators/AlarmExclamation.png").GetAsAnimation(m_apAlarmExclamation, 2); + ContentFile("Base.rte/GUIs/Indicators/SelectArrow.png").GetAsAnimation(m_apSelectArrow, 4); + ContentFile("Base.rte/GUIs/Indicators/AlarmExclamation.png").GetAsAnimation(m_apAlarmExclamation, 2); m_sIconsLoaded = true; } diff --git a/Entities/Deployment.cpp b/Entities/Deployment.cpp index 55ee865cf..1e3b089d7 100644 --- a/Entities/Deployment.cpp +++ b/Entities/Deployment.cpp @@ -60,11 +60,11 @@ int Deployment::Create() if (m_apArrowLeftBitmap.empty()) { - ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); + ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); } if (m_apArrowRightBitmap.empty()) { - ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); + ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); } return 0; @@ -87,11 +87,11 @@ int Deployment::Create(string loadoutName, const Icon &icon, float spawnRadius) if (m_apArrowLeftBitmap.empty()) { - ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); + ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowLeft.png").GetAsAnimation(m_apArrowLeftBitmap, 1); } if (m_apArrowRightBitmap.empty()) { - ContentFile("Data/Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); + ContentFile("Base.rte/GUIs/DeploymentIcons/ArrowRight.png").GetAsAnimation(m_apArrowRightBitmap, 1); } return 0; diff --git a/Entities/Icon.cpp b/Entities/Icon.cpp index 9fa0d7840..cddfeb66a 100644 --- a/Entities/Icon.cpp +++ b/Entities/Icon.cpp @@ -17,7 +17,7 @@ namespace RTE { int Icon::Create() { if (m_BitmapsIndexed.empty() || m_BitmapsTrueColor.empty()) { - if (m_BitmapFile.GetDataPath().empty()) { m_BitmapFile.SetDataPath("Data/Base.rte/GUIs/DefaultIcon.png"); } + if (m_BitmapFile.GetDataPath().empty()) { m_BitmapFile.SetDataPath("Base.rte/GUIs/DefaultIcon.png"); } m_BitmapFile.GetAsAnimation(m_BitmapsIndexed, m_FrameCount, COLORCONV_REDUCE_TO_256); m_BitmapFile.GetAsAnimation(m_BitmapsTrueColor, m_FrameCount, COLORCONV_8_TO_32); diff --git a/Entities/Scene.cpp b/Entities/Scene.cpp index 3d72e04dc..1e5cb2a0b 100644 --- a/Entities/Scene.cpp +++ b/Entities/Scene.cpp @@ -1066,7 +1066,7 @@ int Scene::SavePreview(const std::string &bitmapPath) { } if (!m_pPreviewBitmap) { m_pPreviewBitmap = create_bitmap_ex(8, c_ScenePreviewWidth, c_ScenePreviewHeight); } - ContentFile scenePreviewGradient("Data/Base.rte/GUIs/PreviewSkyGradient.png"); + ContentFile scenePreviewGradient("Base.rte/GUIs/PreviewSkyGradient.png"); draw_sprite(m_pPreviewBitmap, scenePreviewGradient.GetAsBitmap(COLORCONV_NONE, true), 0, 0); int sceneWidth = m_pTerrain->GetBitmap()->w; diff --git a/GUI/GUISound.cpp b/GUI/GUISound.cpp index 059caa05d..79ac23da5 100644 --- a/GUI/GUISound.cpp +++ b/GUI/GUISound.cpp @@ -39,76 +39,76 @@ namespace RTE { void GUISound::Initialize() { // Interface sounds should not be pitched to reinforce the appearance of time decoupling between simulation and UI. - m_SplashSound.Create("Data/Base.rte/Sounds/GUIs/MetaStart.flac", true, false); + m_SplashSound.Create("Base.rte/Sounds/GUIs/MetaStart.flac", true, false); - m_EnterMenuSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + m_EnterMenuSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); - m_ExitMenuSound.Create("Data/Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); - m_ExitMenuSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/MenuExit2.flac", true); + m_ExitMenuSound.Create("Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); + m_ExitMenuSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/MenuExit2.flac", true); - m_FocusChangeSound.Create("Data/Base.rte/Sounds/GUIs/FocusChange.flac", true, false); + m_FocusChangeSound.Create("Base.rte/Sounds/GUIs/FocusChange.flac", true, false); - m_SelectionChangeSound.Create("Data/Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); + m_SelectionChangeSound.Create("Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); - m_ItemChangeSound.Create("Data/Base.rte/Sounds/GUIs/ItemChange.flac", true, false); + m_ItemChangeSound.Create("Base.rte/Sounds/GUIs/ItemChange.flac", true, false); - m_ButtonPressSound.Create("Data/Base.rte/Sounds/GUIs/ButtonPress.flac", true, false); + m_ButtonPressSound.Create("Base.rte/Sounds/GUIs/ButtonPress.flac", true, false); - m_BackButtonPressSound.Create("Data/Base.rte/Sounds/GUIs/BackButtonPress.flac", true, false); + m_BackButtonPressSound.Create("Base.rte/Sounds/GUIs/BackButtonPress.flac", true, false); - m_ConfirmSound.Create("Data/Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); + m_ConfirmSound.Create("Base.rte/Sounds/GUIs/MenuExit1.flac", true, false); - m_UserErrorSound.Create("Data/Base.rte/Sounds/GUIs/UserError.flac", true, false); + m_UserErrorSound.Create("Base.rte/Sounds/GUIs/UserError.flac", true, false); - m_TestSound.Create("Data/Base.rte/Sounds/GUIs/Test.flac", true, false); + m_TestSound.Create("Base.rte/Sounds/GUIs/Test.flac", true, false); - m_PieMenuEnterSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuEnter.flac", true, false); + m_PieMenuEnterSound.Create("Base.rte/Sounds/GUIs/PieMenuEnter.flac", true, false); - m_PieMenuExitSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); + m_PieMenuExitSound.Create("Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); - // m_HoverChangeSound.Create("Data/Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); + // m_HoverChangeSound.Create("Base.rte/Sounds/GUIs/SelectionChange.flac", true, false); m_HoverChangeSound = m_SelectionChangeSound; - m_HoverDisabledSound.Create("Data/Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); + m_HoverDisabledSound.Create("Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); - m_SlicePickedSound.Create("Data/Base.rte/Sounds/GUIs/SlicePicked.flac", true, false); + m_SlicePickedSound.Create("Base.rte/Sounds/GUIs/SlicePicked.flac", true, false); - // m_DisabledPickedSound.Create("Data/Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); + // m_DisabledPickedSound.Create("Base.rte/Sounds/GUIs/PieMenuExit.flac", true, false); m_DisabledPickedSound = m_PieMenuExitSound; - m_FundsChangedSound.Create("Data/Base.rte/Sounds/GUIs/FundsChanged1.flac", true, false); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged2.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged3.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged4.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged5.flac", true); - m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/FundsChanged6.flac", true); + m_FundsChangedSound.Create("Base.rte/Sounds/GUIs/FundsChanged1.flac", true, false); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged2.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged3.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged4.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged5.flac", true); + m_FundsChangedSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/FundsChanged6.flac", true); m_FundsChangedSound.SetSoundOverlapMode(SoundContainer::SoundOverlapMode::RESTART); - m_ActorSwitchSound.Create("Data/Base.rte/Sounds/GUIs/ActorSwitch.flac", true, false); + m_ActorSwitchSound.Create("Base.rte/Sounds/GUIs/ActorSwitch.flac", true, false); - m_BrainSwitchSound.Create("Data/Base.rte/Sounds/GUIs/BrainSwitch.flac", true, false); + m_BrainSwitchSound.Create("Base.rte/Sounds/GUIs/BrainSwitch.flac", true, false); - m_CameraTravelSound.Create("Data/Base.rte/Sounds/GUIs/CameraTravel1.flac", true, false); - m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/CameraTravel2.flac", true); - m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/CameraTravel3.flac", true); + m_CameraTravelSound.Create("Base.rte/Sounds/GUIs/CameraTravel1.flac", true, false); + m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/CameraTravel2.flac", true); + m_CameraTravelSound.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/CameraTravel3.flac", true); - // m_AreaPickedSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_AreaPickedSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_AreaPickedSound = m_ConfirmSound; - // m_ObjectPickedSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_ObjectPickedSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_ObjectPickedSound = m_ConfirmSound; - // m_PurchaseMadeSound.Create("Data/Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); + // m_PurchaseMadeSound.Create("Base.rte/Sounds/GUIs/MenuEnter.flac", true, false); m_PurchaseMadeSound = m_ConfirmSound; - m_PlacementBlip.Create("Data/Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); + m_PlacementBlip.Create("Base.rte/Sounds/GUIs/PlacementBlip.flac", true, false); - m_PlacementThud.Create("Data/Base.rte/Sounds/GUIs/PlacementThud1.flac", true, false); - m_PlacementThud.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementThud2.flac", true); + m_PlacementThud.Create("Base.rte/Sounds/GUIs/PlacementThud1.flac", true, false); + m_PlacementThud.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementThud2.flac", true); - m_PlacementGravel.Create("Data/Base.rte/Sounds/GUIs/PlacementGravel1.flac", true, false); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel2.flac", true); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel3.flac", true); - m_PlacementGravel.GetTopLevelSoundSet().AddSound("Data/Base.rte/Sounds/GUIs/PlacementGravel4.flac", true); + m_PlacementGravel.Create("Base.rte/Sounds/GUIs/PlacementGravel1.flac", true, false); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel2.flac", true); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel3.flac", true); + m_PlacementGravel.GetTopLevelSoundSet().AddSound("Base.rte/Sounds/GUIs/PlacementGravel4.flac", true); } } diff --git a/Main.cpp b/Main.cpp index 74a0c5a8b..0ff6d48fe 100644 --- a/Main.cpp +++ b/Main.cpp @@ -279,7 +279,7 @@ namespace RTE { /// Implementation of the main function. /// int main(int argc, char **argv) { - set_config_file("Data/Base.rte/AllegroConfig.txt"); + set_config_file("Base.rte/AllegroConfig.txt"); allegro_init(); loadpng_init(); set_close_button_callback(System::WindowCloseButtonHandler); diff --git a/Managers/ActivityMan.cpp b/Managers/ActivityMan.cpp index 2f91894b3..0640c100d 100644 --- a/Managers/ActivityMan.cpp +++ b/Managers/ActivityMan.cpp @@ -233,9 +233,9 @@ namespace RTE { g_AudioMan.PlayMusic(m_LastMusicPath.c_str()); g_AudioMan.SetMusicPosition(m_LastMusicPos); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/Watts/Last Man.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/Watts/Last Man.ogg"); g_AudioMan.QueueSilence(30); - g_AudioMan.QueueMusicStream("Data/Base.rte/Music/dBSoundworks/cc2g.ogg"); + g_AudioMan.QueueMusicStream("Base.rte/Music/dBSoundworks/cc2g.ogg"); } } diff --git a/Managers/ConsoleMan.cpp b/Managers/ConsoleMan.cpp index 1e3419d4d..adfd778ef 100644 --- a/Managers/ConsoleMan.cpp +++ b/Managers/ConsoleMan.cpp @@ -43,11 +43,11 @@ namespace RTE { if (!m_GUIInput) { m_GUIInput = new AllegroInput(-1); } if (!m_GUIControlManager) { m_GUIControlManager = new GUIControlManager(); } - if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Data/Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { + if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/ConsoleSkin.ini"); } - m_GUIControlManager->Load("Data/Base.rte/GUIs/ConsoleGUI.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/ConsoleGUI.ini"); m_GUIControlManager->EnableMouse(false); // Stretch the invisible root box to fill the screen @@ -134,7 +134,7 @@ namespace RTE { void ConsoleMan::SetConsoleUseMonospaceFont(bool useFont) { m_ConsoleUseMonospaceFont = useFont; - if (m_GUIControlManager) { m_GUIControlManager->ChangeSkin("Data/Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini"); } + if (m_GUIControlManager) { m_GUIControlManager->ChangeSkin("Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini"); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/FrameMan.cpp b/Managers/FrameMan.cpp index beb4f2c05..748d67e65 100644 --- a/Managers/FrameMan.cpp +++ b/Managers/FrameMan.cpp @@ -79,7 +79,7 @@ namespace RTE { m_StoreNetworkBackBuffer = false; m_NetworkFrameCurrent = 0; m_NetworkFrameReady = 1; - m_PaletteFile = ContentFile("Data/Base.rte/palette.bmp"); + m_PaletteFile = ContentFile("Base.rte/palette.bmp"); m_BlackColor = 245; m_AlmostBlackColor = 245; m_GUIScreen = nullptr; @@ -301,7 +301,7 @@ namespace RTE { CreateBackBuffers(); - ContentFile scenePreviewGradientFile("Data/Base.rte/GUIs/PreviewSkyGradient.png"); + ContentFile scenePreviewGradientFile("Base.rte/GUIs/PreviewSkyGradient.png"); m_ScenePreviewDumpGradient = scenePreviewGradientFile.GetAsBitmap(COLORCONV_8_TO_32, false); return 0; @@ -922,13 +922,13 @@ namespace RTE { if (isSmall) { if (!m_SmallFont) { m_SmallFont = new GUIFont("SmallFont"); - m_SmallFont->Load(m_GUIScreen, "Data/Base.rte/GUIs/Skins/FontSmall.png"); + m_SmallFont->Load(m_GUIScreen, "Base.rte/GUIs/Skins/FontSmall.png"); } return m_SmallFont; } if (!m_LargeFont) { m_LargeFont = new GUIFont("FatFont"); - m_LargeFont->Load(m_GUIScreen, "Data/Base.rte/GUIs/Skins/FontLarge.png"); + m_LargeFont->Load(m_GUIScreen, "Base.rte/GUIs/Skins/FontLarge.png"); } return m_LargeFont; } diff --git a/Managers/PostProcessMan.cpp b/Managers/PostProcessMan.cpp index 7641ad6ad..d95b18444 100644 --- a/Managers/PostProcessMan.cpp +++ b/Managers/PostProcessMan.cpp @@ -27,13 +27,13 @@ namespace RTE { int PostProcessMan::Initialize() { // TODO: Make more robust and load more glows! - ContentFile glowFile("Data/Base.rte/Effects/Glows/YellowTiny.png"); + ContentFile glowFile("Base.rte/Effects/Glows/YellowTiny.png"); m_YellowGlow = glowFile.GetAsBitmap(); m_YellowGlowHash = glowFile.GetHash(); - glowFile.SetDataPath("Data/Base.rte/Effects/Glows/RedTiny.png"); + glowFile.SetDataPath("Base.rte/Effects/Glows/RedTiny.png"); m_RedGlow = glowFile.GetAsBitmap(); m_RedGlowHash = glowFile.GetHash(); - glowFile.SetDataPath("Data/Base.rte/Effects/Glows/BlueTiny.png"); + glowFile.SetDataPath("Base.rte/Effects/Glows/BlueTiny.png"); m_BlueGlow = glowFile.GetAsBitmap(); m_BlueGlowHash = glowFile.GetHash(); diff --git a/Managers/SettingsMan.cpp b/Managers/SettingsMan.cpp index 7f232b226..4daad43c1 100644 --- a/Managers/SettingsMan.cpp +++ b/Managers/SettingsMan.cpp @@ -16,7 +16,7 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SettingsMan::Clear() { - m_SettingsPath = "Data/Base.rte/Settings.ini"; + m_SettingsPath = "Base.rte/Settings.ini"; m_SettingsNeedOverwrite = false; m_FlashOnBrainDamage = true; diff --git a/Menus/AreaPickerGUI.cpp b/Menus/AreaPickerGUI.cpp index b59fca8b0..22a35be80 100644 --- a/Menus/AreaPickerGUI.cpp +++ b/Menus/AreaPickerGUI.cpp @@ -80,15 +80,15 @@ int AreaPickerGUI::Create(Controller *pController, string onlyOfType) m_pGUIInput = new AllegroInput(pController->GetPlayer()); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Data/Base.rte/GUIs/AreaPickerGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/AreaPickerGUI.ini"); m_pGUIController->EnableMouse(pController->IsMouseControlled()); if (!s_pCursor) { - ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); s_pCursor = cursorFile.GetAsBitmap(); } @@ -101,7 +101,7 @@ int AreaPickerGUI::Create(Controller *pController, string onlyOfType) m_pParentBox = dynamic_cast(m_pGUIController->GetControl("PickerGUIBox")); // Set the background image of the parent collection box -// ContentFile backgroundFile("Data/Base.rte/GUIs/BuyMenuBackground.png"); +// ContentFile backgroundFile("Base.rte/GUIs/BuyMenuBackground.png"); // m_pParentBox->SetDrawImage(new AllegroBitmap(backgroundFile.GetAsBitmap())); // m_pParentBox->SetDrawBackground(true); // m_pParentBox->SetDrawType(GUICollectionBox::Image); diff --git a/Menus/AssemblyEditorGUI.cpp b/Menus/AssemblyEditorGUI.cpp index 393c88954..02be26a2d 100644 --- a/Menus/AssemblyEditorGUI.cpp +++ b/Menus/AssemblyEditorGUI.cpp @@ -153,9 +153,9 @@ int AssemblyEditorGUI::Create(Controller *pController, FeatureSets featureSet, i // Only load the static dot bitmaps once if (!s_pValidPathDot) { - ContentFile dotFile("Data/Base.rte/GUIs/Indicators/PathDotValid.png"); + ContentFile dotFile("Base.rte/GUIs/Indicators/PathDotValid.png"); s_pValidPathDot = dotFile.GetAsBitmap(); - dotFile.SetDataPath("Data/Base.rte/GUIs/Indicators/PathDotInvalid.png"); + dotFile.SetDataPath("Base.rte/GUIs/Indicators/PathDotInvalid.png"); s_pInvalidPathDot = dotFile.GetAsBitmap(); } diff --git a/Menus/BuyMenuGUI.cpp b/Menus/BuyMenuGUI.cpp index e4a736b5f..f37617d3d 100644 --- a/Menus/BuyMenuGUI.cpp +++ b/Menus/BuyMenuGUI.cpp @@ -142,15 +142,15 @@ int BuyMenuGUI::Create(Controller *pController) m_pGUIInput = new AllegroInput(pController->GetPlayer()); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins", "DefaultSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); } - m_pGUIController->Load("Data/Base.rte/GUIs/BuyMenuGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/BuyMenuGUI.ini"); m_pGUIController->EnableMouse(pController->IsMouseControlled()); if (!s_pCursor) { - ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); s_pCursor = cursorFile.GetAsBitmap(); } @@ -176,8 +176,8 @@ int BuyMenuGUI::Create(Controller *pController) // Set the images for the logo and header decorations GUICollectionBox *pHeader = dynamic_cast(m_pGUIController->GetControl("CatalogHeader")); m_pLogo = dynamic_cast(m_pGUIController->GetControl("CatalogLogo")); - ContentFile headerFile("Data/Base.rte/GUIs/Skins/BuyMenu/BuyMenuHeader.png"); - ContentFile logoFile("Data/Base.rte/GUIs/Skins/BuyMenu/BuyMenuLogo.png"); + ContentFile headerFile("Base.rte/GUIs/Skins/BuyMenu/BuyMenuHeader.png"); + ContentFile logoFile("Base.rte/GUIs/Skins/BuyMenu/BuyMenuLogo.png"); pHeader->SetDrawImage(new AllegroBitmap(headerFile.GetAsBitmap())); m_pLogo->SetDrawImage(new AllegroBitmap(logoFile.GetAsBitmap())); pHeader->SetDrawType(GUICollectionBox::Image); @@ -380,7 +380,7 @@ bool BuyMenuGUI::LoadAllLoadoutsFromFile() // Not a metagame player, just a regular scenario player else { - std::snprintf(loadoutPath, sizeof(loadoutPath), "Data/Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); + std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); } @@ -487,7 +487,7 @@ bool BuyMenuGUI::SaveAllLoadoutsToFile() std::snprintf(loadoutPath, sizeof(loadoutPath), "Metagames.rte/%s - LoadoutsMP%d.ini", g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1); } else - std::snprintf(loadoutPath, sizeof(loadoutPath), "Data/Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); + std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1); // Open the file Writer loadoutFile(loadoutPath, false); diff --git a/Menus/InventoryMenuGUI.cpp b/Menus/InventoryMenuGUI.cpp index 42da527e6..8c15edf97 100644 --- a/Menus/InventoryMenuGUI.cpp +++ b/Menus/InventoryMenuGUI.cpp @@ -192,16 +192,16 @@ namespace RTE { if (!m_GUIControlManager) { m_GUIControlManager = std::make_unique(); } if (!m_GUIScreen) { m_GUIScreen = std::make_unique(g_FrameMan.GetBackBuffer8()); } if (!m_GUIInput) { m_GUIInput = std::make_unique(m_MenuController->GetPlayer()); } - RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Data/Base.rte/GUIs/Skins", "InventoryMenuSkin.ini"), "Failed to create InventoryMenuGUI GUIControlManager and load it from Base.rte/GUIs/Skins/Menus/InventoryMenuSkin.ini"); + RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Base.rte/GUIs/Skins", "InventoryMenuSkin.ini"), "Failed to create InventoryMenuGUI GUIControlManager and load it from Base.rte/GUIs/Skins/Menus/InventoryMenuSkin.ini"); //TODO When this is split into 2 classes, full mode should use the fonts from its gui control manager while transfer mode, will need to get its fonts from FrameMan. May be good for the ingame menu base class to have these font pointers, even if some subclasses set em up in different ways. //if (!m_SmallFont) { m_SmallFont = m_GUIControlManager->GetSkin()->GetFont("FontSmall.png"); } //if (!m_LargeFont) { m_LargeFont = m_GUIControlManager->GetSkin()->GetFont("FontLarge.png"); } - m_GUIControlManager->Load("Data/Base.rte/GUIs/InventoryMenuGUI.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/InventoryMenuGUI.ini"); m_GUIControlManager->EnableMouse(m_MenuController->IsMouseControlled()); if (!s_CursorBitmap) { - ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); s_CursorBitmap = cursorFile.GetAsBitmap(); } diff --git a/Menus/LoadingScreen.cpp b/Menus/LoadingScreen.cpp index c3a4eeb13..4d801ac88 100644 --- a/Menus/LoadingScreen.cpp +++ b/Menus/LoadingScreen.cpp @@ -25,8 +25,8 @@ namespace RTE { void LoadingScreen::Create(AllegroScreen *guiScreen, AllegroInput *guiInput, bool progressReportDisabled) { GUIControlManager loadingScreenManager; - RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); - loadingScreenManager.Load("Data/Base.rte/GUIs/LoadingGUI.ini"); + RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); + loadingScreenManager.Load("Base.rte/GUIs/LoadingGUI.ini"); int loadingSplashOffset = 0; if (!progressReportDisabled) { @@ -34,7 +34,7 @@ namespace RTE { loadingSplashOffset = m_ProgressListboxPosX / 4; } SceneLayer loadingSplash; - loadingSplash.Create(ContentFile("Data/Base.rte/GUIs/Title/LoadingSplash.png").GetAsBitmap(COLORCONV_NONE, false), false, Vector(), true, false, Vector(1.0F, 0)); + loadingSplash.Create(ContentFile("Base.rte/GUIs/Title/LoadingSplash.png").GetAsBitmap(COLORCONV_NONE, false), false, Vector(), true, false, Vector(1.0F, 0)); loadingSplash.SetOffset(Vector(static_cast(((loadingSplash.GetBitmap()->w - g_FrameMan.GetResX()) / 2) + loadingSplashOffset), 0)); Box loadingSplashTargetBox(Vector(0, static_cast((g_FrameMan.GetResY() - loadingSplash.GetBitmap()->h) / 2)), static_cast(g_FrameMan.GetResX()), static_cast(loadingSplash.GetBitmap()->h)); diff --git a/Menus/MainMenuGUI.cpp b/Menus/MainMenuGUI.cpp index 832226611..3f4455c76 100644 --- a/Menus/MainMenuGUI.cpp +++ b/Menus/MainMenuGUI.cpp @@ -50,12 +50,12 @@ namespace RTE { void MainMenuGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_MainMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); - m_MainMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuGUI.ini"); + RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); + m_MainMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuGUI.ini"); m_SubMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_SubMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuSubMenuGUI.ini"); + RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_SubMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuSubMenuGUI.ini"); GUICollectionBox *mainScreenRootBox = dynamic_cast(m_MainMenuScreenGUIControlManager->GetControl("root")); mainScreenRootBox->Resize(g_FrameMan.GetResX(), mainScreenRootBox->GetHeight()); diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index 5612cc5d3..73b29276f 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -370,10 +370,10 @@ int MetagameGUI::Create(Controller *pController) m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); } - m_pGUIController->Load("Data/Base.rte/GUIs/MetagameGUI.ini"); + m_pGUIController->Load("Base.rte/GUIs/MetagameGUI.ini"); // Make sure we have convenient points to the containing GUI colleciton boxes that we will manipulate the positions of GUICollectionBox *pRootBox = m_apScreenBox[ROOTBOX] = dynamic_cast(m_pGUIController->GetControl("root")); @@ -386,10 +386,10 @@ int MetagameGUI::Create(Controller *pController) m_pBannerRedBottom = new GUIBanner(); m_pBannerYellowTop = new GUIBanner(); m_pBannerYellowBottom = new GUIBanner(); - m_pBannerRedTop->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); - m_pBannerRedBottom->Create("Data/Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); - m_pBannerYellowTop->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); - m_pBannerYellowBottom->Create("Data/Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Data/Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); + m_pBannerRedTop->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); + m_pBannerRedBottom->Create("Base.rte/GUIs/Fonts/BannerFontRedReg.png", "Base.rte/GUIs/Fonts/BannerFontRedBlur.png", 32); + m_pBannerYellowTop->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); + m_pBannerYellowBottom->Create("Base.rte/GUIs/Fonts/BannerFontYellowReg.png", "Base.rte/GUIs/Fonts/BannerFontYellowBlur.png", 32); // General game message label m_pGameMessageLabel = dynamic_cast(m_pGUIController->GetControl("GameMessageLabel")); @@ -2483,7 +2483,7 @@ void MetagameGUI::UpdateInput() g_MetaMan.m_Players[metaPlayer].m_Funds -= SCANCOST; // Set up and start the scripted activity for scanning the site for this' team GAScripted *pScanActivity = new GAScripted; - pScanActivity->Create("Data/Base.rte/Activities/SiteScan.lua", "SiteScan"); + pScanActivity->Create("Base.rte/Activities/SiteScan.lua", "SiteScan"); char str[64]; std::snprintf(str, sizeof(str), "R%dScan", g_MetaMan.m_CurrentRound + 1); pScanActivity->SetPresetName(g_MetaMan.GetGameName() + str); @@ -2980,7 +2980,7 @@ void MetagameGUI::CompletedActivity() UpdateScenesBox(true); // Play some nice ambient music - g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1, 0.4); + g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1, 0.4); } } } @@ -4238,7 +4238,7 @@ void MetagameGUI::SetupOffensives() { // Set up the MetaFight activity GAScripted *pOffensive = new GAScripted; - pOffensive->Create("Data/Base.rte/Activities/MetaFight.lua", "MetaFight"); + pOffensive->Create("Base.rte/Activities/MetaFight.lua", "MetaFight"); char str[64]; std::snprintf(str, sizeof(str), "R%dA%d", g_MetaMan.m_CurrentRound + 1, offensiveCount); pOffensive->SetPresetName(g_MetaMan.GetGameName() + str); diff --git a/Menus/ModManagerGUI.cpp b/Menus/ModManagerGUI.cpp index 9dc667484..c269ea97e 100644 --- a/Menus/ModManagerGUI.cpp +++ b/Menus/ModManagerGUI.cpp @@ -19,8 +19,8 @@ namespace RTE { ModManagerGUI::ModManagerGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Data/Base.rte/GUIs/ModManagerGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/ModManagerGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/ObjectPickerGUI.cpp b/Menus/ObjectPickerGUI.cpp index 90ae3ba4b..1bd31847b 100644 --- a/Menus/ObjectPickerGUI.cpp +++ b/Menus/ObjectPickerGUI.cpp @@ -66,13 +66,13 @@ namespace RTE { if (!m_GUIScreen) { m_GUIScreen = std::make_unique(g_FrameMan.GetBackBuffer8()); } if (!m_GUIInput) { m_GUIInput = std::make_unique(controller->GetPlayer()); } if (!m_GUIControlManager) { m_GUIControlManager = std::make_unique(); } - RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Data/Base.rte/GUIs/Skins", "DefaultSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); + RTEAssert(m_GUIControlManager->Create(m_GUIScreen.get(), m_GUIInput.get(), "Base.rte/GUIs/Skins", "DefaultSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/DefaultSkin.ini"); - m_GUIControlManager->Load("Data/Base.rte/GUIs/ObjectPickerGUI.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/ObjectPickerGUI.ini"); m_GUIControlManager->EnableMouse(controller->IsMouseControlled()); if (!s_Cursor) { - ContentFile cursorFile("Data/Base.rte/GUIs/Skins/Cursor.png"); + ContentFile cursorFile("Base.rte/GUIs/Skins/Cursor.png"); s_Cursor = cursorFile.GetAsBitmap(); } diff --git a/Menus/PieMenuGUI.cpp b/Menus/PieMenuGUI.cpp index 279303be3..9de92ae73 100644 --- a/Menus/PieMenuGUI.cpp +++ b/Menus/PieMenuGUI.cpp @@ -51,7 +51,7 @@ namespace RTE { int PieMenuGUI::Create(Controller *controller, MovableObject *affectedObject) { RTEAssert(controller, "No controller sent to PieMenuGUI on creation!"); - if (!s_CursorBitmap) { s_CursorBitmap = ContentFile("Data/Base.rte/GUIs/Skins/PieCursor.png").GetAsBitmap(); } + if (!s_CursorBitmap) { s_CursorBitmap = ContentFile("Base.rte/GUIs/Skins/PieCursor.png").GetAsBitmap(); } if (!m_LargeFont) { m_LargeFont = g_FrameMan.GetLargeFont(); } diff --git a/Menus/ScenarioGUI.cpp b/Menus/ScenarioGUI.cpp index ab4594c39..30c52a5d5 100644 --- a/Menus/ScenarioGUI.cpp +++ b/Menus/ScenarioGUI.cpp @@ -52,8 +52,8 @@ namespace RTE { void ScenarioGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Data/Base.rte/GUIs/ScenarioGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/ScenarioGUI.ini"); m_RootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); m_RootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); @@ -95,7 +95,7 @@ namespace RTE { m_ScenePreviewImageBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxScenePreview")); m_StartActivityConfigButton = dynamic_cast(m_GUIControlManager->GetControl("ButtonStartActivityConfig")); - m_DefaultScenePreview.Create(ContentFile("Data/Base.rte/GUIs/DefaultPreview.png"), 5); + m_DefaultScenePreview.Create(ContentFile("Base.rte/GUIs/DefaultPreview.png"), 5); m_DefaultScenePreview.SetSpriteAnimMode(MOSprite::SpriteAnimMode::ALWAYSLOOP); m_DefaultScenePreview.SetSpriteAnimDuration(200); m_DefaultScenePreview.SetPos(Vector(static_cast(m_ScenePreviewImageBox->GetXPos() + (m_ScenePreviewImageBox->GetWidth() / 2)), static_cast(m_ScenePreviewImageBox->GetYPos() + (m_ScenePreviewImageBox->GetHeight() / 2)))); diff --git a/Menus/SceneEditorGUI.cpp b/Menus/SceneEditorGUI.cpp index 7a0a505b5..119b0397b 100644 --- a/Menus/SceneEditorGUI.cpp +++ b/Menus/SceneEditorGUI.cpp @@ -152,9 +152,9 @@ int SceneEditorGUI::Create(Controller *pController, FeatureSets featureSet, int // Only load the static dot bitmaps once if (!s_pValidPathDot) { - ContentFile dotFile("Data/Base.rte/GUIs/Indicators/PathDotValid.png"); + ContentFile dotFile("Base.rte/GUIs/Indicators/PathDotValid.png"); s_pValidPathDot = dotFile.GetAsBitmap(); - dotFile.SetDataPath("Data/Base.rte/GUIs/Indicators/PathDotInvalid.png"); + dotFile.SetDataPath("Base.rte/GUIs/Indicators/PathDotInvalid.png"); s_pInvalidPathDot = dotFile.GetAsBitmap(); } diff --git a/Menus/SettingsGUI.cpp b/Menus/SettingsGUI.cpp index ad6b55da2..36347be91 100644 --- a/Menus/SettingsGUI.cpp +++ b/Menus/SettingsGUI.cpp @@ -14,8 +14,8 @@ namespace RTE { SettingsGUI::SettingsGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Data/Base.rte/GUIs/SettingsGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Base.rte/GUIs/SettingsGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/SettingsInputMappingWizardGUI.cpp b/Menus/SettingsInputMappingWizardGUI.cpp index 5b2774bb7..4b2d055e2 100644 --- a/Menus/SettingsInputMappingWizardGUI.cpp +++ b/Menus/SettingsInputMappingWizardGUI.cpp @@ -44,11 +44,11 @@ namespace RTE { m_InputWizardTitleLabel = dynamic_cast(m_GUIControlManager->GetControl("LabelPlayerInputMappingWizardTitle")); int dpadDiagramBitampCount = 13; - ContentFile("Data/Base.rte/GUIs/Controllers/D-Pad.png").GetAsAnimation(m_DPadDiagramBitmaps, dpadDiagramBitampCount, COLORCONV_8_TO_32); + ContentFile("Base.rte/GUIs/Controllers/D-Pad.png").GetAsAnimation(m_DPadDiagramBitmaps, dpadDiagramBitampCount, COLORCONV_8_TO_32); int analogDiagramBitmapCount = 21; - ContentFile("Data/Base.rte/GUIs/Controllers/DualAnalogDS.png").GetAsAnimation(m_DualAnalogDSDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); - ContentFile("Data/Base.rte/GUIs/Controllers/DualAnalogXB.png").GetAsAnimation(m_DualAnalogXBDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); + ContentFile("Base.rte/GUIs/Controllers/DualAnalogDS.png").GetAsAnimation(m_DualAnalogDSDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); + ContentFile("Base.rte/GUIs/Controllers/DualAnalogXB.png").GetAsAnimation(m_DualAnalogXBDiagramBitmaps, analogDiagramBitmapCount, COLORCONV_8_TO_32); CreateManualConfigScreen(); CreatePresetSelectionScreen(); diff --git a/Menus/TitleScreen.cpp b/Menus/TitleScreen.cpp index e248dac6b..d8b09ffe0 100644 --- a/Menus/TitleScreen.cpp +++ b/Menus/TitleScreen.cpp @@ -77,7 +77,7 @@ namespace RTE { if (!g_FrameMan.ResolutionChanged()) { if (!g_SettingsMan.SkipIntro() && !g_ActivityMan.IsSetToLaunchIntoActivity()) { m_IntroTextFont = std::make_unique("FontLarge"); - m_IntroTextFont->Load(guiScreen, "Data/Base.rte/GUIs/Skins/Menus/FontLarge.png"); + m_IntroTextFont->Load(guiScreen, "Base.rte/GUIs/Skins/Menus/FontLarge.png"); CreateIntroSequenceSlides(); } else { m_IntroSequenceState = IntroSequence::MainMenuAppear; @@ -91,32 +91,32 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void TitleScreen::CreateTitleElements() { - m_DataRealmsLogo = ContentFile("Data/Base.rte/GUIs/Title/Intro/DRLogo5x.png").GetAsBitmap(); - m_FmodLogo = ContentFile("Data/Base.rte/GUIs/Title/Intro/FMODLogo.png").GetAsBitmap(); - - m_PreGameLogoText.Create(ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitle.png")); - m_PreGameLogoTextGlow.Create(ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitleGlow.png")); - m_GameLogo.Create(ContentFile("Data/Base.rte/GUIs/Title/Title.png")); - m_GameLogoGlow.Create(ContentFile("Data/Base.rte/GUIs/Title/TitleGlow.png")); - m_Planet.Create(ContentFile("Data/Base.rte/GUIs/Title/Planet.png")); - m_Moon.Create(ContentFile("Data/Base.rte/GUIs/Title/Moon.png")); - m_Station.Create(ContentFile("Data/Base.rte/GUIs/Title/Station.png")); - m_Nebula.Create(ContentFile("Data/Base.rte/GUIs/Title/Nebula.png"), false, Vector(), false, false, Vector(0, -1.0F)); + m_DataRealmsLogo = ContentFile("Base.rte/GUIs/Title/Intro/DRLogo5x.png").GetAsBitmap(); + m_FmodLogo = ContentFile("Base.rte/GUIs/Title/Intro/FMODLogo.png").GetAsBitmap(); + + m_PreGameLogoText.Create(ContentFile("Base.rte/GUIs/Title/Intro/PreTitle.png")); + m_PreGameLogoTextGlow.Create(ContentFile("Base.rte/GUIs/Title/Intro/PreTitleGlow.png")); + m_GameLogo.Create(ContentFile("Base.rte/GUIs/Title/Title.png")); + m_GameLogoGlow.Create(ContentFile("Base.rte/GUIs/Title/TitleGlow.png")); + m_Planet.Create(ContentFile("Base.rte/GUIs/Title/Planet.png")); + m_Moon.Create(ContentFile("Base.rte/GUIs/Title/Moon.png")); + m_Station.Create(ContentFile("Base.rte/GUIs/Title/Station.png")); + m_Nebula.Create(ContentFile("Base.rte/GUIs/Title/Nebula.png"), false, Vector(), false, false, Vector(0, -1.0F)); set_write_alpha_blender(); - draw_trans_sprite(m_PreGameLogoText.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/Intro/PreTitleAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_GameLogo.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/TitleAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_Planet.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/PlanetAlpha.png").GetAsBitmap(), 0, 0); - draw_trans_sprite(m_Moon.GetSpriteFrame(0), ContentFile("Data/Base.rte/GUIs/Title/MoonAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_PreGameLogoText.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/Intro/PreTitleAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_GameLogo.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/TitleAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_Planet.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/PlanetAlpha.png").GetAsBitmap(), 0, 0); + draw_trans_sprite(m_Moon.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/MoonAlpha.png").GetAsBitmap(), 0, 0); int starSmallBitmapCount = 4; - std::vector starSmallBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarSmall.png").GetAsAnimation(starSmallBitmapCount); + std::vector starSmallBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarSmall.png").GetAsAnimation(starSmallBitmapCount); int starLargeBitmapCount = 1; - std::vector starLargeBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarLarge.png").GetAsAnimation(starLargeBitmapCount); + std::vector starLargeBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarLarge.png").GetAsAnimation(starLargeBitmapCount); int starHugeBitmapCount = 2; - std::vector starHugeBitmaps = ContentFile("Data/Base.rte/GUIs/Title/Stars/StarHuge.png").GetAsAnimation(starHugeBitmapCount); + std::vector starHugeBitmaps = ContentFile("Base.rte/GUIs/Title/Stars/StarHuge.png").GetAsAnimation(starHugeBitmapCount); int starCount = (g_FrameMan.GetResX() * m_Nebula.GetBitmap()->h) / 1000; for (int i = 0; i < starCount; ++i) { @@ -145,7 +145,7 @@ namespace RTE { void TitleScreen::CreateIntroSequenceSlides() { std::string highRes = (g_FrameMan.GetResY() >= 680) ? "HD" : ""; for (int slideNum = 0; slideNum < m_IntroSlides.size(); ++slideNum) { - m_IntroSlides.at(slideNum) = ContentFile(("Data/Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); + m_IntroSlides.at(slideNum) = ContentFile(("Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); } } @@ -249,7 +249,7 @@ namespace RTE { m_IntroScrollDuration = 66.6F - m_IntroScrollStartTime; m_ScrollOffset.SetY(m_IntroScrollStartOffsetY); - g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccintro.ogg", 0); + g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccintro.ogg", 0); g_AudioMan.SetMusicPosition(0.05F); } m_FadeAmount = static_cast(LERP(0, 1.0F, 255.0F, 0, m_SectionProgress)); @@ -375,7 +375,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(0.5F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); m_FadeAmount = 0; - g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); } m_ScrollOffset.SetY(EaseOut(m_PreMainMenuScrollOffsetY, 0, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(120, m_GameLogoMainMenuOffsetY, m_SectionProgress))); @@ -412,7 +412,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(1.0F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); g_GUISound.SplashSound()->Play(); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); } m_ScrollOffset.SetY(EaseOut(0, m_PlanetViewScrollOffsetY, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(m_GameLogoMainMenuOffsetY, m_GameLogoPlanetViewOffsetY, m_SectionProgress))); @@ -421,7 +421,7 @@ namespace RTE { case TitleTransition::PlanetToMainMenu: if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(1.0F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); - g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); } m_ScrollOffset.SetY(EaseOut(m_PlanetViewScrollOffsetY, 0, m_SectionProgress)); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), EaseOut(m_GameLogoPlanetViewOffsetY, m_GameLogoMainMenuOffsetY, m_SectionProgress))); @@ -445,7 +445,7 @@ namespace RTE { m_ScrollOffset.SetY(m_PlanetViewScrollOffsetY); m_GameLogo.SetPos(Vector(static_cast(g_FrameMan.GetResX() / 2), m_GameLogoPlanetViewOffsetY)); m_StationOrbitTimer.SetElapsedRealTimeS(m_StationOrbitTimerElapsedTime); - g_AudioMan.PlayMusic("Data/Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); + g_AudioMan.PlayMusic("Base.rte/Music/dBSoundworks/thisworld5.ogg", -1); } g_AudioMan.SetTempMusicVolume(EaseOut(0, 1.0F, m_SectionProgress)); m_FadeAmount = static_cast(LERP(0, 1.0F, 255.0F, 0, m_SectionProgress)); @@ -461,7 +461,7 @@ namespace RTE { if (m_SectionSwitch) { SetSectionDurationAndResetSwitch(0.75F * g_SettingsMan.GetMenuTransitionDurationMultiplier()); m_StationOrbitTimer.SetElapsedRealTimeS(m_StationOrbitTimerElapsedTime); - g_AudioMan.PlayMusic("Data/Base.rte/Music/Hubnester/ccmenu.ogg", -1); + g_AudioMan.PlayMusic("Base.rte/Music/Hubnester/ccmenu.ogg", -1); } g_AudioMan.SetTempMusicVolume(EaseOut(0, 1.0F, m_SectionProgress)); m_ScrollOffset.SetY(EaseOut(250, 0, m_SectionProgress)); From bae49413f204519556af35b7f7df33da156dd508 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 19:06:54 +0200 Subject: [PATCH 07/40] Change IsModuleOfficial to FullModulePath --- Managers/PresetMan.cpp | 17 ++++++++++++----- Managers/PresetMan.h | 17 +++++++++-------- System/ContentFile.cpp | 14 ++++++++------ System/DataModule.cpp | 5 ++--- System/Reader.cpp | 3 +-- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 3d2cabcb3..7d3cda8dc 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -310,15 +310,22 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) } ////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetModuleIDFromPath +// Method: FullModulePath ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns wether or not the module is vanilla. -// Arguments: The ID of the module to check. -// Return value: True if vanilla, false otherwise. +// Arguments: The Path to be completed. +// The ID of the module to check. +// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. -bool PresetMan::IsModuleOfficial(int whichModule) +std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) { - return whichModule < m_OfficialModuleCount; + const std::string moduleFolder = whichModule < m_OfficialModuleCount ? "Data/" : "Mods/"; + const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); + if (topFolder == moduleFolder) + { + return modulePath; + } + return moduleFolder + modulePath; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 2c0820d04..8c9d3e126 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -173,14 +173,15 @@ class PresetMan : public Singleton { int GetModuleIDFromPath(std::string dataPath); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModuleIDFromPath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns wether or not the module is vanilla. - // Arguments: The ID of the module to check. - // Return value: True if vanilla, false otherwise. - - bool IsModuleOfficial(int whichModule = 0);; +////////////////////////////////////////////////////////////////////////////////////////// +// Method: FullModulePath +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Returns wether or not the module is vanilla. +// Arguments: The Path to be completed. +// The ID of the module to check. +// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. + + std::string FullModulePath(std::string modulePath, int whichModule = 0); ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index 688efaae8..6099c31ce 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -109,8 +109,7 @@ namespace RTE { BITMAP *returnBitmap = nullptr; const int bitDepth = (conversionMode == COLORCONV_8_TO_32) ? BitDepths::ThirtyTwo : BitDepths::Eight; std::string dataPathToLoad = dataPathToSpecificFrame.empty() ? m_DataPath : dataPathToSpecificFrame; - const std::string moduleFolder = g_PresetMan.IsModuleOfficial(GetDataModuleID()) ? "Data/" : "Mods/"; - dataPathToLoad = moduleFolder + dataPathToLoad; + dataPathToLoad = g_PresetMan.FullModulePath(dataPathToLoad, GetDataModuleID()); SetFormattedReaderPosition(GetFormattedReaderPosition()); // Check if the file has already been read and loaded from the disk and, if so, use that data. @@ -196,16 +195,18 @@ namespace RTE { if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) { return nullptr; } + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath, GetDataModuleID()); + FMOD::Sound *returnSample = nullptr; - std::unordered_map::iterator foundSound = s_LoadedSamples.find(m_DataPath); + std::unordered_map::iterator foundSound = s_LoadedSamples.find(dataPathToLoad); if (foundSound != s_LoadedSamples.end()) { returnSample = (*foundSound).second; } else { returnSample = LoadAndReleaseSound(abortGameForInvalidSound, asyncLoading); //NOTE: This takes ownership of the sample file // Insert the Sound object into the map, PASSING OVER OWNERSHIP OF THE LOADED FILE - s_LoadedSamples.try_emplace(m_DataPath, returnSample); + s_LoadedSamples.try_emplace(dataPathToLoad, returnSample); } return returnSample; } @@ -220,9 +221,10 @@ namespace RTE { if (!System::PathExistsCaseSensitive(m_DataPath)) { bool foundAltExtension = false; for (const std::string &altFileExtension : c_SupportedAudioFormats) { - if (System::PathExistsCaseSensitive(m_DataPathWithoutExtension + altFileExtension)) { + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension + altFileExtension, GetDataModuleID()); + if (System::PathExistsCaseSensitive(dataPathToLoad)) { g_ConsoleMan.AddLoadWarningLogEntry(m_DataPath, m_FormattedReaderPosition, altFileExtension); - SetDataPath(m_DataPathWithoutExtension + altFileExtension); + SetDataPath(dataPathToLoad); foundAltExtension = true; break; } diff --git a/System/DataModule.cpp b/System/DataModule.cpp index 413f1540a..4f8b39964 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -40,10 +40,9 @@ namespace RTE { // Report that we're starting to read a new DataModule if (progressCallback) { progressCallback(m_FileName + " " + static_cast(-43) + " loading:", true); } - const std::string moduleFolder = g_PresetMan.IsModuleOfficial(m_ModuleID) ? "Data/" : "Mods/"; Reader reader; - std::string indexPath(moduleFolder + m_FileName + "/Index.ini"); - std::string mergedIndexPath(moduleFolder + m_FileName + "/MergedIndex.ini"); + std::string indexPath = g_PresetMan.FullModulePath(m_FileName + "/Index.ini", m_ModuleID); + std::string mergedIndexPath = g_PresetMan.FullModulePath(m_FileName + "/MergedIndex.ini", m_ModuleID); // NOTE: This looks for the MergedIndex.ini generated by the index merger tool. The tool is mostly superseded by disabling loading visuals, but still provides some benefit. if (std::filesystem::exists(mergedIndexPath)) { indexPath = mergedIndexPath; } diff --git a/System/Reader.cpp b/System/Reader.cpp index 781891147..168527c7d 100644 --- a/System/Reader.cpp +++ b/System/Reader.cpp @@ -267,9 +267,8 @@ namespace RTE { // Report that we're including a file if (m_ReportProgress) { m_ReportProgress(m_ReportTabs + m_FileName + " on line " + std::to_string(m_CurrentLine) + " includes:", false); } - const std::string moduleFolder = g_PresetMan.IsModuleOfficial(GetReadModuleID()) ? "Data/" : "Mods/"; // Get the file path from the current stream before pushing it into the StreamStack, otherwise we can't open a new stream after releasing it because we can't read. - std::string includeFilePath = moduleFolder + std::filesystem::path(ReadPropValue()).generic_string(); + std::string includeFilePath = g_PresetMan.FullModulePath(std::filesystem::path(ReadPropValue()).generic_string(), GetReadModuleID()); // Push the current stream onto the StreamStack for future retrieval when the new include file has run out of data. m_StreamStack.push(StreamInfo(m_Stream.release(), m_FilePath, m_CurrentLine, m_PreviousIndent)); From cf3c98aa4bc885416324c6af55bec74df8de0a3e Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 19:38:35 +0200 Subject: [PATCH 08/40] Get Base.rte stuff to load --- Entities/MovableObject.cpp | 2 +- Managers/ConsoleMan.cpp | 4 ++-- Managers/SettingsMan.cpp | 2 +- Menus/LoadingScreen.cpp | 4 ++-- Menus/MainMenuGUI.cpp | 8 ++++---- Menus/MetagameGUI.cpp | 4 ++-- Menus/ModManagerGUI.cpp | 4 ++-- Menus/ScenarioGUI.cpp | 4 ++-- Menus/SettingsGUI.cpp | 4 ++-- System/ContentFile.cpp | 12 +++++++----- 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Entities/MovableObject.cpp b/Entities/MovableObject.cpp index 8b2196934..e0e75cf55 100644 --- a/Entities/MovableObject.cpp +++ b/Entities/MovableObject.cpp @@ -342,7 +342,7 @@ int MovableObject::ReadProperty(const std::string_view &propName, Reader &reader PieMenuGUI::StoreCustomLuaPieSlice(newSlice); } else if (propName == "ScriptPath") { - std::string scriptPath = CorrectBackslashesInPath(reader.ReadPropValue()); + std::string scriptPath = g_PresetMan.FullModulePath(CorrectBackslashesInPath(reader.ReadPropValue()), GetModuleID()); switch (LoadScript(CorrectBackslashesInPath(scriptPath))) { case 0: break; diff --git a/Managers/ConsoleMan.cpp b/Managers/ConsoleMan.cpp index adfd778ef..baa91afa0 100644 --- a/Managers/ConsoleMan.cpp +++ b/Managers/ConsoleMan.cpp @@ -43,11 +43,11 @@ namespace RTE { if (!m_GUIInput) { m_GUIInput = new AllegroInput(-1); } if (!m_GUIControlManager) { m_GUIControlManager = new GUIControlManager(); } - if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { + if (!m_GUIControlManager->Create(m_GUIScreen, m_GUIInput, "Data/Base.rte/GUIs/Skins/Menus", m_ConsoleUseMonospaceFont ? "ConsoleMonospaceSkin.ini" : "ConsoleSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/ConsoleSkin.ini"); } - m_GUIControlManager->Load("Base.rte/GUIs/ConsoleGUI.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ConsoleGUI.ini"); m_GUIControlManager->EnableMouse(false); // Stretch the invisible root box to fill the screen diff --git a/Managers/SettingsMan.cpp b/Managers/SettingsMan.cpp index 4daad43c1..7f232b226 100644 --- a/Managers/SettingsMan.cpp +++ b/Managers/SettingsMan.cpp @@ -16,7 +16,7 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SettingsMan::Clear() { - m_SettingsPath = "Base.rte/Settings.ini"; + m_SettingsPath = "Data/Base.rte/Settings.ini"; m_SettingsNeedOverwrite = false; m_FlashOnBrainDamage = true; diff --git a/Menus/LoadingScreen.cpp b/Menus/LoadingScreen.cpp index 4d801ac88..d69438b09 100644 --- a/Menus/LoadingScreen.cpp +++ b/Menus/LoadingScreen.cpp @@ -25,8 +25,8 @@ namespace RTE { void LoadingScreen::Create(AllegroScreen *guiScreen, AllegroInput *guiInput, bool progressReportDisabled) { GUIControlManager loadingScreenManager; - RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); - loadingScreenManager.Load("Base.rte/GUIs/LoadingGUI.ini"); + RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); + loadingScreenManager.Load("Data/Base.rte/GUIs/LoadingGUI.ini"); int loadingSplashOffset = 0; if (!progressReportDisabled) { diff --git a/Menus/MainMenuGUI.cpp b/Menus/MainMenuGUI.cpp index 3f4455c76..832226611 100644 --- a/Menus/MainMenuGUI.cpp +++ b/Menus/MainMenuGUI.cpp @@ -50,12 +50,12 @@ namespace RTE { void MainMenuGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_MainMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); - m_MainMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuGUI.ini"); + RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); + m_MainMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuGUI.ini"); m_SubMenuScreenGUIControlManager = std::make_unique(); - RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_SubMenuScreenGUIControlManager->Load("Base.rte/GUIs/MainMenuSubMenuGUI.ini"); + RTEAssert(m_SubMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_SubMenuScreenGUIControlManager->Load("Data/Base.rte/GUIs/MainMenuSubMenuGUI.ini"); GUICollectionBox *mainScreenRootBox = dynamic_cast(m_MainMenuScreenGUIControlManager->GetControl("root")); mainScreenRootBox->Resize(g_FrameMan.GetResX(), mainScreenRootBox->GetHeight()); diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index 73b29276f..fdde9fa3d 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -370,10 +370,10 @@ int MetagameGUI::Create(Controller *pController) m_pGUIInput = new AllegroInput(-1, true); if (!m_pGUIController) m_pGUIController = new GUIControlManager(); - if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { + if (!m_pGUIController->Create(m_pGUIScreen, m_pGUIInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini")) { RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); } - m_pGUIController->Load("Base.rte/GUIs/MetagameGUI.ini"); + m_pGUIController->Load("Data/Base.rte/GUIs/MetagameGUI.ini"); // Make sure we have convenient points to the containing GUI colleciton boxes that we will manipulate the positions of GUICollectionBox *pRootBox = m_apScreenBox[ROOTBOX] = dynamic_cast(m_pGUIController->GetControl("root")); diff --git a/Menus/ModManagerGUI.cpp b/Menus/ModManagerGUI.cpp index c269ea97e..9dc667484 100644 --- a/Menus/ModManagerGUI.cpp +++ b/Menus/ModManagerGUI.cpp @@ -19,8 +19,8 @@ namespace RTE { ModManagerGUI::ModManagerGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/ModManagerGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ModManagerGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/ScenarioGUI.cpp b/Menus/ScenarioGUI.cpp index 30c52a5d5..4602ed336 100644 --- a/Menus/ScenarioGUI.cpp +++ b/Menus/ScenarioGUI.cpp @@ -52,8 +52,8 @@ namespace RTE { void ScenarioGUI::Create(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/ScenarioGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/ScenarioGUI.ini"); m_RootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); m_RootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/Menus/SettingsGUI.cpp b/Menus/SettingsGUI.cpp index 36347be91..ad6b55da2 100644 --- a/Menus/SettingsGUI.cpp +++ b/Menus/SettingsGUI.cpp @@ -14,8 +14,8 @@ namespace RTE { SettingsGUI::SettingsGUI(AllegroScreen *guiScreen, AllegroInput *guiInput) { m_GUIControlManager = std::make_unique(); - RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); - m_GUIControlManager->Load("Base.rte/GUIs/SettingsGUI.ini"); + RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Data/Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); + m_GUIControlManager->Load("Data/Base.rte/GUIs/SettingsGUI.ini"); GUICollectionBox *rootBox = dynamic_cast(m_GUIControlManager->GetControl("root")); rootBox->Resize(g_FrameMan.GetResX(), g_FrameMan.GetResY()); diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index 6099c31ce..e807ba553 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -143,19 +143,21 @@ namespace RTE { if (m_DataPath.empty() || frameCount < 1) { return; } + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath, GetDataModuleID()); + const std::string dataPathWithoutExtensionToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension, GetDataModuleID()); vectorToFill.reserve(frameCount); SetFormattedReaderPosition(GetFormattedReaderPosition()); if (frameCount == 1) { // Check for 000 in the file name in case it is part of an animation but the FrameCount was set to 1. Do not warn about this because it's normal operation, but warn about incorrect extension. - if (!System::PathExistsCaseSensitive(m_DataPath)) { + if (!System::PathExistsCaseSensitive(dataPathToLoad)) { const std::string altFileExtension = (m_DataPathExtension == ".png") ? ".bmp" : ".png"; - if (System::PathExistsCaseSensitive(m_DataPathWithoutExtension + "000" + m_DataPathExtension)) { - SetDataPath(m_DataPathWithoutExtension + "000" + m_DataPathExtension); - } else if (System::PathExistsCaseSensitive(m_DataPathWithoutExtension + "000" + altFileExtension)) { + if (System::PathExistsCaseSensitive(dataPathWithoutExtensionToLoad + "000" + m_DataPathExtension)) { + SetDataPath(dataPathWithoutExtensionToLoad + "000" + m_DataPathExtension); + } else if (System::PathExistsCaseSensitive(dataPathWithoutExtensionToLoad + "000" + altFileExtension)) { g_ConsoleMan.AddLoadWarningLogEntry(m_DataPath, m_FormattedReaderPosition, altFileExtension); - SetDataPath(m_DataPathWithoutExtension + "000" + altFileExtension); + SetDataPath(dataPathWithoutExtensionToLoad + "000" + altFileExtension); } } vectorToFill.emplace_back(GetAsBitmap(conversionMode)); From 7452a39f416f6df1309bd3079d04e30f6521f1f4 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 20:01:10 +0200 Subject: [PATCH 09/40] Get Scenes.rte and Metagames.rte to load --- Managers/PresetMan.cpp | 1005 +++++++++++++++++++++------------------- System/DataModule.cpp | 3 +- 2 files changed, 527 insertions(+), 481 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 7d3cda8dc..b184043d5 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,7 +29,8 @@ #include "LoadingScreen.h" #include "SettingsMan.h" -namespace RTE { +namespace RTE +{ ////////////////////////////////////////////////////////////////////////////////////////// // Method: Clear @@ -73,9 +74,9 @@ int PresetMan::Save(Writer &writer) const void PresetMan::Destroy() { - for (vector::iterator dmItr = m_pDataModules.begin(); dmItr != m_pDataModules.end(); ++dmItr) - { - delete (*dmItr); + for( vector::iterator dmItr = m_pDataModules.begin(); dmItr != m_pDataModules.end(); + ++dmItr ) { + delete( *dmItr ); } Clear(); @@ -88,63 +89,63 @@ void PresetMan::Destroy() // Description: Reads an entire data module and adds it to this. NOTE that official // modules can't be loaded after any non-official ones! -bool PresetMan::LoadDataModule(string moduleName, bool official, ProgressCallback fpProgressCallback) +bool PresetMan::LoadDataModule( string moduleName, bool official, + ProgressCallback fpProgressCallback ) { - if (moduleName.empty()) + if( moduleName.empty() ) { return false; + } vector::iterator itr; // Make a lowercase-version of the module name so it makes it easier to compare to and find case-agnostically string lowercaseName = moduleName; - std::transform(lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), ::tolower); + std::transform( lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), ::tolower ); // Make sure we don't add the same module twice - for (itr = m_pDataModules.begin(); itr != m_pDataModules.end(); ++itr) - { - if ((*itr)->GetFileName() == moduleName) + for( itr = m_pDataModules.begin(); itr != m_pDataModules.end(); ++itr ) { + if( ( *itr )->GetFileName() == moduleName ) { return false; + } } // Only instantiate it here, because it needs to be in the lists of this before being created DataModule *pModule = new DataModule(); // Official modules are stacked in the beginning of the vector - if (official) - { + if( official ) { // Halt if an official module is being loaded after any non-official ones! -// We need to disable this because Metagames.rte gets loaded after non-official modules -// RTEAssert(m_pDataModules.size() == m_OfficialModuleCount, "Trying to load an official module after a non-official one has been loaded!"); + // We need to disable this because Metagames.rte gets loaded after non-official modules + // RTEAssert(m_pDataModules.size() == m_OfficialModuleCount, "Trying to load an official module after a non-official one has been loaded!"); // Find where the offical modules end in the vector itr = m_pDataModules.begin(); int i = 0; - for (; i < m_OfficialModuleCount; ++i) + for( ; i < m_OfficialModuleCount; ++i ) { itr++; + } // Insert into after the last official one - m_pDataModules.insert(itr, pModule); + m_pDataModules.insert( itr, pModule ); // Add the name to ID mapping // Adding the lowercase name version so we can more easily find with case-agnostic search - m_DataModuleIDs.insert(pair(lowercaseName, i)); + m_DataModuleIDs.insert( pair( lowercaseName, i ) ); // Adjust offical tally m_OfficialModuleCount++; } // Non-official modules are just added the end - else - { - m_pDataModules.push_back(pModule); + else { + m_pDataModules.push_back( pModule ); // Add the name to ID mapping - note that official modules can't be loaded after any non-official ones! // Adding the lowercase name version so we can more easily find with case-agnostic search - m_DataModuleIDs.insert(pair(lowercaseName, m_pDataModules.size() - 1)); + m_DataModuleIDs.insert( pair( lowercaseName, m_pDataModules.size() - 1 ) ); } // Now actually create it - if (pModule->Create(moduleName, fpProgressCallback) < 0) - { - RTEAbort("Failed to find the " + moduleName + " Data Module!"); + if( pModule->Create( moduleName, fpProgressCallback ) < 0 ) { + RTEAbort( "Failed to find the " + moduleName + " Data Module!" ); return false; } @@ -155,60 +156,76 @@ bool PresetMan::LoadDataModule(string moduleName, bool official, ProgressCallbac ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool PresetMan::LoadAllDataModules() { - auto moduleLoadTimerStart = std::chrono::high_resolution_clock::now(); - - // Destroy any possible loaded modules - Destroy(); - - FindAndExtractZippedModules(); - - // Load all the official modules first! - std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; - for (const std::string &officialModule : officialModules) { - if (!LoadDataModule(officialModule, true, &LoadingScreen::LoadingSplashProgressReport)) { - return false; - } - } - - // If a single module is specified, skip loading all other unofficial modules and load specified module only. - if (!m_SingleModuleToLoad.empty() && std::find(officialModules.begin(), officialModules.end(), m_SingleModuleToLoad) == officialModules.end()) { - if (!LoadDataModule(m_SingleModuleToLoad, false, &LoadingScreen::LoadingSplashProgressReport)) { - g_ConsoleMan.PrintString("ERROR: Failed to load DataModule \"" + m_SingleModuleToLoad + "\"! Only official modules were loaded!"); - return false; - } - } else { - std::vector workingDirectoryFolders; - std::copy_if(std::filesystem::directory_iterator(System::GetWorkingDirectory()), std::filesystem::directory_iterator(), std::back_inserter(workingDirectoryFolders), - [](auto dirEntry){ return std::filesystem::is_directory(dirEntry); } - ); - std::sort(workingDirectoryFolders.begin(), workingDirectoryFolders.end()); - - for (const std::filesystem::directory_entry &directoryEntry : workingDirectoryFolders) { - std::string directoryEntryPath = directoryEntry.path().generic_string(); - if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) { - std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos); - if (!g_SettingsMan.IsModDisabled(moduleName) && (std::find(officialModules.begin(), officialModules.end(), moduleName) == officialModules.end() && moduleName != "Metagames.rte" && moduleName != "Scenes.rte")) { - int moduleID = GetModuleID(moduleName); - // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. - if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) { LoadDataModule(moduleName, false, &LoadingScreen::LoadingSplashProgressReport); } - } - } - } - // Load scenes and MetaGames AFTER all other techs etc are loaded; might be referring to stuff in user mods. - if (!LoadDataModule("Scenes.rte", false, &LoadingScreen::LoadingSplashProgressReport)) { - return false; - } - if (!LoadDataModule("Metagames.rte", false, &LoadingScreen::LoadingSplashProgressReport)) { - return false; - } - } - - if (g_SettingsMan.IsMeasuringModuleLoadTime()) { - std::chrono::milliseconds moduleLoadElapsedTime = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - moduleLoadTimerStart); - g_ConsoleMan.PrintString("Module load duration is: " + std::to_string(moduleLoadElapsedTime.count()) + "ms"); - } - return true; +bool PresetMan::LoadAllDataModules() +{ + auto moduleLoadTimerStart = std::chrono::high_resolution_clock::now(); + + // Destroy any possible loaded modules + Destroy(); + + FindAndExtractZippedModules(); + + // Load all the official modules first! + std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; + for( const std::string &officialModule : officialModules ) { + if( !LoadDataModule( officialModule, true, &LoadingScreen::LoadingSplashProgressReport ) ) { + return false; + } + } + + // If a single module is specified, skip loading all other unofficial modules and load specified module only. + if( !m_SingleModuleToLoad.empty() && + std::find( officialModules.begin(), officialModules.end(), + m_SingleModuleToLoad ) == officialModules.end() ) { + if( !LoadDataModule( m_SingleModuleToLoad, false, &LoadingScreen::LoadingSplashProgressReport ) ) { + g_ConsoleMan.PrintString( "ERROR: Failed to load DataModule \"" + m_SingleModuleToLoad + + "\"! Only official modules were loaded!" ); + return false; + } + } else { + std::vector workingDirectoryFolders; + std::copy_if( std::filesystem::directory_iterator( System::GetWorkingDirectory() ), + std::filesystem::directory_iterator(), std::back_inserter( workingDirectoryFolders ), + []( auto dirEntry ) { + return std::filesystem::is_directory( dirEntry ); + } + ); + std::sort( workingDirectoryFolders.begin(), workingDirectoryFolders.end() ); + + for( const std::filesystem::directory_entry &directoryEntry : workingDirectoryFolders ) { + std::string directoryEntryPath = directoryEntry.path().generic_string(); + if( std::regex_match( directoryEntryPath, std::regex( ".*\.rte" ) ) ) { + std::string moduleName = directoryEntryPath.substr( directoryEntryPath.find_last_of( '/' ) + 1, + std::string::npos ); + if( !g_SettingsMan.IsModDisabled( moduleName ) && + ( std::find( officialModules.begin(), officialModules.end(), + moduleName ) == officialModules.end() && moduleName != "Metagames.rte" && + moduleName != "Scenes.rte" ) ) { + int moduleID = GetModuleID( moduleName ); + // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. + if( moduleID < 0 || moduleID >= GetOfficialModuleCount() ) { + LoadDataModule( moduleName, false, &LoadingScreen::LoadingSplashProgressReport ); + } + } + } + } + // Load scenes and MetaGames AFTER all other techs etc are loaded; might be referring to stuff in user mods. + if( !LoadDataModule( "Scenes.rte", false, &LoadingScreen::LoadingSplashProgressReport ) ) { + return false; + } + if( !LoadDataModule( "Metagames.rte", false, &LoadingScreen::LoadingSplashProgressReport ) ) { + return false; + } + } + + if( g_SettingsMan.IsMeasuringModuleLoadTime() ) { + std::chrono::milliseconds moduleLoadElapsedTime = + std::chrono::duration_cast( std::chrono::high_resolution_clock::now() - + moduleLoadTimerStart ); + g_ConsoleMan.PrintString( "Module load duration is: " + std::to_string( + moduleLoadElapsedTime.count() ) + "ms" ); + } + return true; } @@ -217,9 +234,10 @@ bool PresetMan::LoadAllDataModules() { ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a specific loaded DataModule -const DataModule * PresetMan::GetDataModule(int whichModule) +const DataModule *PresetMan::GetDataModule( int whichModule ) { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); return m_pDataModules[whichModule]; } @@ -228,9 +246,10 @@ const DataModule * PresetMan::GetDataModule(int whichModule) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a name specific loaded DataModule -const std::string PresetMan::GetDataModuleName(int whichModule) +const std::string PresetMan::GetDataModuleName( int whichModule ) { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); return m_pDataModules[whichModule]->GetFileName(); } @@ -241,53 +260,57 @@ const std::string PresetMan::GetDataModuleName(int whichModule) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule. -int PresetMan::GetModuleID(string moduleName) +int PresetMan::GetModuleID( string moduleName ) { // Lower-case search name so we can match up against the already-lowercase names in m_DataModuleIDs - std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); + std::transform( moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower ); // First pass - map::iterator itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; + map::iterator itr = m_DataModuleIDs.find( moduleName ); + if( itr != m_DataModuleIDs.end() ) { + return ( *itr ).second; + } // Try with or without the .rte on the end before giving up - int dotPos = moduleName.find_last_of('.'); + int dotPos = moduleName.find_last_of( '.' ); // Wasnt, so try adding it - if (dotPos == string::npos) + if( dotPos == string::npos ) { moduleName = moduleName + System::GetModulePackageExtension(); + } // There was ".rte", so try to shave it off the name - else - moduleName = moduleName.substr(0, dotPos); + else { + moduleName = moduleName.substr( 0, dotPos ); + } // Try to find the module again! - itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; - -/* No need to do this second pass now; we immediately do the case-agnostic search - // Add .rte and try to find the module in case-agnostic fashion - moduleName += ".rte"; - std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); - - itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; + itr = m_DataModuleIDs.find( moduleName ); + if( itr != m_DataModuleIDs.end() ) { + return ( *itr ).second; + } - // Try with or without the .rte on the end before giving up - dotPos = moduleName.find_last_of('.'); - // Wasnt, so try adding it - if (dotPos == string::npos) - moduleName = moduleName + System::GetModulePackageExtension(); - // There was ".rte", so try to shave it off the name - else - moduleName = moduleName.substr(0, dotPos); + /* No need to do this second pass now; we immediately do the case-agnostic search + // Add .rte and try to find the module in case-agnostic fashion + moduleName += ".rte"; + std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); + + itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; + + // Try with or without the .rte on the end before giving up + dotPos = moduleName.find_last_of('.'); + // Wasnt, so try adding it + if (dotPos == string::npos) + moduleName = moduleName + System::GetModulePackageExtension(); + // There was ".rte", so try to shave it off the name + else + moduleName = moduleName.substr(0, dotPos); - // Try to find the module again! - itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; -*/ + // Try to find the module again! + itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; + */ return -1; } @@ -297,16 +320,18 @@ int PresetMan::GetModuleID(string moduleName) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule, from a full data file path. -int PresetMan::GetModuleIDFromPath(std::string dataPath) +int PresetMan::GetModuleIDFromPath( std::string dataPath ) { - if (dataPath.empty()) + if( dataPath.empty() ) { return -1; + } - int slashPos = dataPath.find_first_of('/'); - if (slashPos == string::npos) - slashPos = dataPath.find_first_of('\\'); + int slashPos = dataPath.find_first_of( '/' ); + if( slashPos == string::npos ) { + slashPos = dataPath.find_first_of( '\\' ); + } - return GetModuleID(dataPath.substr(0, slashPos)); + return GetModuleID( dataPath.substr( 0, slashPos ) ); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -317,12 +342,12 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) // The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. -std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) +std::string PresetMan::FullModulePath( std::string modulePath, int whichModule ) { - const std::string moduleFolder = whichModule < m_OfficialModuleCount ? "Data/" : "Mods/"; - const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); - if (topFolder == moduleFolder) - { + const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; + const std::string moduleFolder = whichModule < m_OfficialModuleCount || isSpecialCase ? "Data/" : "Mods/"; + const std::string topFolder = modulePath.substr( 0, modulePath.find_first_of( "/\\" ) + 1 ); + if( topFolder == moduleFolder ) { return modulePath; } return moduleFolder + modulePath; @@ -336,11 +361,13 @@ std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) // If there already is an instance defined, nothing happens. If there // is not, a clone is made of the passed-in Entity and added to the library. -bool PresetMan::AddEntityPreset(Entity *pEntToAdd, int whichModule, bool overwriteSame, string readFromFile) +bool PresetMan::AddEntityPreset( Entity *pEntToAdd, int whichModule, bool overwriteSame, + string readFromFile ) { - RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule >= 0 && + whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!" ); - return m_pDataModules[whichModule]->AddEntityPreset(pEntToAdd, overwriteSame, readFromFile); + return m_pDataModules[whichModule]->AddEntityPreset( pEntToAdd, overwriteSame, readFromFile ); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -348,41 +375,39 @@ bool PresetMan::AddEntityPreset(Entity *pEntToAdd, int whichModule, bool overwri ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a previously read in (defined) Entity, by type and instance name. -const Entity * PresetMan::GetEntityPreset(string type, string preset, int whichModule) +const Entity *PresetMan::GetEntityPreset( string type, string preset, int whichModule ) { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); const Entity *pRetEntity = 0; // Preset name might have "[ModuleName]/" preceding it, detect it here and select proper module! - int slashPos = preset.find_first_of('/'); - if (slashPos != string::npos) - { + int slashPos = preset.find_first_of( '/' ); + if( slashPos != string::npos ) { // Get the module ID and cut off the module specifier in the string - whichModule = GetModuleID(preset.substr(0, slashPos)); - preset = preset.substr(slashPos + 1); + whichModule = GetModuleID( preset.substr( 0, slashPos ) ); + preset = preset.substr( slashPos + 1 ); } // All modules - if (whichModule < 0) - { + if( whichModule < 0 ) { // Search all modules - for (int i = 0; i < m_pDataModules.size() && !pRetEntity; ++i) - pRetEntity = m_pDataModules[i]->GetEntityPreset(type, preset); + for( int i = 0; i < m_pDataModules.size() && !pRetEntity; ++i ) { + pRetEntity = m_pDataModules[i]->GetEntityPreset( type, preset ); + } } // Specific module - else - { + else { // Try to get it from the asked for module - pRetEntity = m_pDataModules[whichModule]->GetEntityPreset(type, preset); + pRetEntity = m_pDataModules[whichModule]->GetEntityPreset( type, preset ); // If couldn't find it in there, then try all the official modules! - if (!pRetEntity) - { - RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); - for (int i = 0; i < m_OfficialModuleCount && !pRetEntity; ++i) - { - pRetEntity = m_pDataModules[i]->GetEntityPreset(type, preset); + if( !pRetEntity ) { + RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), + "More official modules than modules loaded?!" ); + for( int i = 0; i < m_OfficialModuleCount && !pRetEntity; ++i ) { + pRetEntity = m_pDataModules[i]->GetEntityPreset( type, preset ); } } } @@ -401,11 +426,12 @@ const Entity * PresetMan::GetEntityPreset(string type, string preset, int whichM // add the newly read in one to this PresetMan's list if not found to // exist there previously. Ownership is NOT transferred! -const Entity * PresetMan::GetEntityPreset(Reader &reader) +const Entity *PresetMan::GetEntityPreset( Reader &reader ) { // The reader is aware of which DataModule it is reading within int whichModule = reader.GetReadModuleID(); - RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!"); + RTEAssert( whichModule >= 0 && + whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!" ); string ClassName; const Entity::ClassInfo *pClass = 0; @@ -413,43 +439,47 @@ const Entity * PresetMan::GetEntityPreset(Reader &reader) const Entity *pReturnPreset = 0; // Load class name and then preset instance reader >> ClassName; - pClass = Entity::ClassInfo::GetClass(ClassName); - - if (pClass && pClass->IsConcrete()) - { - // Instantiate - pNewInstance = pClass->NewInstance(); - - // Get this before reading entity, since if it's the last one in its datafile, the stream will show the parent file instead - string entityFilePath = reader.GetCurrentFilePath(); - - // Try to read in the preset instance's data from the reader - if (pNewInstance && pNewInstance->Create(reader, false) < 0) - { - // Abort loading if we can't create entity and it's not in Scenes.rte - if (!g_PresetMan.GetDataModule(whichModule)->GetIgnoreMissingItems()) - RTEAbort("Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + ", shortly before line #" + reader.GetCurrentFileLine()); - } - else if (pNewInstance) - { - // Try to add the instance to the collection - m_pDataModules[whichModule]->AddEntityPreset(pNewInstance, reader.GetPresetOverwriting(), entityFilePath); - - // Regardless of whether there was a collision or not, use whatever now exists in the instance map of that class and name - pReturnPreset = m_pDataModules[whichModule]->GetEntityPreset(pNewInstance->GetClassName(), pNewInstance->GetPresetName()); - // If the instance wasn't found in the specific DataModule, try to find it in all the official ones instead - if (!pReturnPreset) - { - RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); - for (int i = 0; i < m_OfficialModuleCount && !pReturnPreset; ++i) - pReturnPreset = m_pDataModules[i]->GetEntityPreset(pNewInstance->GetClassName(), pNewInstance->GetPresetName()); - } - } + pClass = Entity::ClassInfo::GetClass( ClassName ); + + if( pClass && pClass->IsConcrete() ) { + // Instantiate + pNewInstance = pClass->NewInstance(); + + // Get this before reading entity, since if it's the last one in its datafile, the stream will show the parent file instead + string entityFilePath = reader.GetCurrentFilePath(); + + // Try to read in the preset instance's data from the reader + if( pNewInstance && pNewInstance->Create( reader, false ) < 0 ) { + // Abort loading if we can't create entity and it's not in Scenes.rte + if( !g_PresetMan.GetDataModule( whichModule )->GetIgnoreMissingItems() ) { + RTEAbort( "Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + + ", shortly before line #" + reader.GetCurrentFileLine() ); + } + } else if( pNewInstance ) { + // Try to add the instance to the collection + m_pDataModules[whichModule]->AddEntityPreset( pNewInstance, reader.GetPresetOverwriting(), + entityFilePath ); + + // Regardless of whether there was a collision or not, use whatever now exists in the instance map of that class and name + pReturnPreset = m_pDataModules[whichModule]->GetEntityPreset( pNewInstance->GetClassName(), + pNewInstance->GetPresetName() ); + // If the instance wasn't found in the specific DataModule, try to find it in all the official ones instead + if( !pReturnPreset ) { + RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), + "More official modules than modules loaded?!" ); + for( int i = 0; i < m_OfficialModuleCount && !pReturnPreset; ++i ) { + pReturnPreset = m_pDataModules[i]->GetEntityPreset( pNewInstance->GetClassName(), + pNewInstance->GetPresetName() ); + } + } + } // Get rid of the read-in instance as its copy is now either added to the map, or discarded as there already was somehting in there of the same name. - delete pNewInstance; pNewInstance = 0; - } - else + delete pNewInstance; + pNewInstance = 0; + } else { pReturnPreset = 0; + } return pReturnPreset; } @@ -462,21 +492,21 @@ const Entity * PresetMan::GetEntityPreset(Reader &reader) // read-in presets. Regardless of whether there is a name collision, // the read-in preset will be returned, ownership TRANSFERRED! -Entity * PresetMan::ReadReflectedPreset(Reader &reader) +Entity *PresetMan::ReadReflectedPreset( Reader &reader ) { // The reader is aware of which DataModule it's reading within int whichModule = reader.GetReadModuleID(); - RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!"); + RTEAssert( whichModule >= 0 && + whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!" ); string ClassName; const Entity::ClassInfo *pClass = 0; Entity *pNewInstance = 0; // Load class name and then preset instance reader >> ClassName; - pClass = Entity::ClassInfo::GetClass(ClassName); + pClass = Entity::ClassInfo::GetClass( ClassName ); - if (pClass && pClass->IsConcrete()) - { + if( pClass && pClass->IsConcrete() ) { // Instantiate pNewInstance = pClass->NewInstance(); @@ -484,21 +514,22 @@ Entity * PresetMan::ReadReflectedPreset(Reader &reader) string entityFilePath = reader.GetCurrentFilePath(); // Try to read in the preset instance's data from the reader - if (pNewInstance && pNewInstance->Create(reader, false) < 0) - { - if (!g_PresetMan.GetDataModule(whichModule)->GetIgnoreMissingItems()) - RTEAbort("Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + ", shortly before line #" + reader.GetCurrentFileLine()); - } - else - { - // Try to add the instance to the collection. - // Note that we'll return this instance regardless of whether the adding was succesful or not - m_pDataModules[whichModule]->AddEntityPreset(pNewInstance, reader.GetPresetOverwriting(), entityFilePath); - return pNewInstance; - } + if( pNewInstance && pNewInstance->Create( reader, false ) < 0 ) { + if( !g_PresetMan.GetDataModule( whichModule )->GetIgnoreMissingItems() ) { + RTEAbort( "Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + + ", shortly before line #" + reader.GetCurrentFileLine() ); + } + } else { + // Try to add the instance to the collection. + // Note that we'll return this instance regardless of whether the adding was succesful or not + m_pDataModules[whichModule]->AddEntityPreset( pNewInstance, reader.GetPresetOverwriting(), + entityFilePath ); + return pNewInstance; + } } - return 0; + return 0; } @@ -507,25 +538,26 @@ Entity * PresetMan::ReadReflectedPreset(Reader &reader) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Adds to a list all previously read in (defined) Entitys, by type. -bool PresetMan::GetAllOfType(list &entityList, string type, int whichModule) +bool PresetMan::GetAllOfType( list &entityList, string type, int whichModule ) { - if (type.empty()) + if( type.empty() ) { return false; + } bool foundAny = false; // All modules - if (whichModule < 0) - { + if( whichModule < 0 ) { // Send the list to each module - for (int i = 0; i < m_pDataModules.size(); ++i) - foundAny = m_pDataModules[i]->GetAllOfType(entityList, type) || foundAny; + for( int i = 0; i < m_pDataModules.size(); ++i ) { + foundAny = m_pDataModules[i]->GetAllOfType( entityList, type ) || foundAny; + } } // Specific module - else - { - RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); - foundAny = m_pDataModules[whichModule]->GetAllOfType(entityList, type); + else { + RTEAssert( whichModule < m_pDataModules.size(), + "Trying to get from an out of bounds DataModule ID!" ); + foundAny = m_pDataModules[whichModule]->GetAllOfType( entityList, type ); } return foundAny; @@ -538,25 +570,28 @@ bool PresetMan::GetAllOfType(list &entityList, string type, int whichM // Description: Adds to a list all previously read in (defined) Entitys which are // of a specific type, and only exist in a specific module space. -bool PresetMan::GetAllOfTypeInModuleSpace(std::list &entityList, std::string type, int whichModuleSpace) +bool PresetMan::GetAllOfTypeInModuleSpace( std::list &entityList, std::string type, + int whichModuleSpace ) { - if (type.empty()) + if( type.empty() ) { return false; + } bool foundAny = false; // All modules - if (whichModuleSpace < 0) - foundAny = GetAllOfType(entityList, type, whichModuleSpace); + if( whichModuleSpace < 0 ) { + foundAny = GetAllOfType( entityList, type, whichModuleSpace ); + } // Specific module space - else - { + else { // Get all entitys of the specific type in the official modules loaded before the specified one - for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) - foundAny = GetAllOfType(entityList, type, module) || foundAny; + for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { + foundAny = GetAllOfType( entityList, type, module ) || foundAny; + } // Now get the groups of the specified module (official or not) - foundAny = GetAllOfType(entityList, type, whichModuleSpace) || foundAny; + foundAny = GetAllOfType( entityList, type, whichModuleSpace ) || foundAny; } return foundAny; @@ -569,25 +604,27 @@ bool PresetMan::GetAllOfTypeInModuleSpace(std::list &entityList, std:: // Description: Adds to a list all previously read in (defined) Entitys which are // associated with a specific group. -bool PresetMan::GetAllOfGroup(list &entityList, string group, string type, int whichModule) +bool PresetMan::GetAllOfGroup( list &entityList, string group, string type, + int whichModule ) { - RTEAssert(!group.empty(), "Looking for empty group!"); + RTEAssert( !group.empty(), "Looking for empty group!" ); bool foundAny = false; // All modules - if (whichModule < 0) - { + if( whichModule < 0 ) { // Get from all modules - for (int i = 0; i < m_pDataModules.size(); ++i) + for( int i = 0; i < m_pDataModules.size(); ++i ) // Send the list to each module, let them add - foundAny = m_pDataModules[i]->GetAllOfGroup(entityList, group, type) || foundAny; + { + foundAny = m_pDataModules[i]->GetAllOfGroup( entityList, group, type ) || foundAny; + } } // Specific one - else - { - RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup(entityList, group, type); + else { + RTEAssert( whichModule < m_pDataModules.size(), + "Trying to get from an out of bounds DataModule ID!" ); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup( entityList, group, type ); } return foundAny; @@ -600,44 +637,46 @@ bool PresetMan::GetAllOfGroup(list &entityList, string group, string t // Description: Returns a previously read in (defined) Entity which is randomly // selected from a specific group. -Entity * PresetMan::GetRandomOfGroup(string group, string type, int whichModule) +Entity *PresetMan::GetRandomOfGroup( string group, string type, int whichModule ) { - RTEAssert(!group.empty(), "Looking for empty group!"); + RTEAssert( !group.empty(), "Looking for empty group!" ); bool foundAny = false; // The total list we'll select a random one from list entityList; // All modules - if (whichModule < 0) - { + if( whichModule < 0 ) { // Get from all modules - for (int i = 0; i < m_pDataModules.size(); ++i) + for( int i = 0; i < m_pDataModules.size(); ++i ) // Send the list to each module, let them add - foundAny = m_pDataModules[i]->GetAllOfGroup(entityList, group, type) || foundAny; + { + foundAny = m_pDataModules[i]->GetAllOfGroup( entityList, group, type ) || foundAny; + } } // Specific one - else - { - RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup(entityList, group, type); + else { + RTEAssert( whichModule < m_pDataModules.size(), + "Trying to get from an out of bounds DataModule ID!" ); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup( entityList, group, type ); } // Didn't find any of that group in those module(s) - if (!foundAny) + if( !foundAny ) { return 0; + } // Pick one and return it int current = 0; - int selection = RandomNum(0, entityList.size() - 1); - for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) - { - if (current == selection) - return (*itr); + int selection = RandomNum( 0, entityList.size() - 1 ); + for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { + if( current == selection ) { + return ( *itr ); + } current++; } - RTEAssert(0, "Tried selecting randomly but didn't?"); + RTEAssert( 0, "Tried selecting randomly but didn't?" ); return 0; } @@ -648,110 +687,104 @@ Entity * PresetMan::GetRandomOfGroup(string group, string type, int whichModule) // Description: Returns a previously read in (defined) Entity which is randomly // selected from a specific group. -Entity * PresetMan::GetRandomBuyableOfGroupFromTech(string group, string type, int whichModule) +Entity *PresetMan::GetRandomBuyableOfGroupFromTech( string group, string type, int whichModule ) { - RTEAssert(!group.empty(), "Looking for empty group!"); + RTEAssert( !group.empty(), "Looking for empty group!" ); bool foundAny = false; // The total list we'll select a random one from list entityList; list tempList; - // All modules - if (whichModule < 0) { - for (DataModule *dataModule : m_pDataModules) { - if (dataModule->IsFaction()) { foundAny = dataModule->GetAllOfGroup(tempList, group, type) || foundAny; } - } - } else { - RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup(tempList, group, type); - } - - //Filter found entities, we need only buyables - if (foundAny) - { - //Do not filter anything if we're looking for brains - if (group == "Brains") - { - foundAny = false; - for (list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr) - { - entityList.push_back(*oItr); - foundAny = true; - } - } - else - { - foundAny = false; - for (list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr) - { - SceneObject * pSObject = dynamic_cast(*oItr); - // Buyable and not brain? - if (pSObject && pSObject->IsBuyable() && !pSObject->IsBuyableInObjectPickerOnly() && !pSObject->IsInGroup("Brains")) - { - entityList.push_back(*oItr); - foundAny = true; - } - } - } - } - - // Didn't find any of that group in those module(s) - if (!foundAny) + // All modules + if( whichModule < 0 ) { + for( DataModule *dataModule : m_pDataModules ) { + if( dataModule->IsFaction() ) { + foundAny = dataModule->GetAllOfGroup( tempList, group, type ) || foundAny; + } + } + } else { + RTEAssert( whichModule < m_pDataModules.size(), + "Trying to get from an out of bounds DataModule ID!" ); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup( tempList, group, type ); + } + + //Filter found entities, we need only buyables + if( foundAny ) { + //Do not filter anything if we're looking for brains + if( group == "Brains" ) { + foundAny = false; + for( list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr ) { + entityList.push_back( *oItr ); + foundAny = true; + } + } else { + foundAny = false; + for( list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr ) { + SceneObject *pSObject = dynamic_cast( *oItr ); + // Buyable and not brain? + if( pSObject && pSObject->IsBuyable() && !pSObject->IsBuyableInObjectPickerOnly() && + !pSObject->IsInGroup( "Brains" ) ) { + entityList.push_back( *oItr ); + foundAny = true; + } + } + } + } + + // Didn't find any of that group in those module(s) + if( !foundAny ) { return 0; + } // Pick one and return it int current = 0; - int selection = RandomNum(0, entityList.size() - 1); - - int totalWeight = 0; - for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) - totalWeight += (*itr)->GetRandomWeight(); - - // Use random weights if looking in specific modules - if (whichModule >= 0) - { - if (totalWeight == 0) - return 0; - - selection = RandomNum(0, totalWeight - 1); - - for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) - { - bool found = false; - int bucketCounter = 0; - - if ((*itr)->GetRandomWeight() > 0) - { - while (bucketCounter < (*itr)->GetRandomWeight()) - { - if (current == selection) - { - found = true; - break; - } - - current++; - bucketCounter++; - } - } - - if (found) - return (*itr); - } - } - else - { - for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) - { - if (current == selection) - return (*itr); - - current++; - } - } - - RTEAssert(0, "Tried selecting randomly but didn't?"); + int selection = RandomNum( 0, entityList.size() - 1 ); + + int totalWeight = 0; + for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { + totalWeight += ( *itr )->GetRandomWeight(); + } + + // Use random weights if looking in specific modules + if( whichModule >= 0 ) { + if( totalWeight == 0 ) { + return 0; + } + + selection = RandomNum( 0, totalWeight - 1 ); + + for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { + bool found = false; + int bucketCounter = 0; + + if( ( *itr )->GetRandomWeight() > 0 ) { + while( bucketCounter < ( *itr )->GetRandomWeight() ) { + if( current == selection ) { + found = true; + break; + } + + current++; + bucketCounter++; + } + } + + if( found ) { + return ( *itr ); + } + } + } else { + for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { + if( current == selection ) { + return ( *itr ); + } + + current++; + } + } + + RTEAssert( 0, "Tried selecting randomly but didn't?" ); return 0; } @@ -762,24 +795,26 @@ Entity * PresetMan::GetRandomBuyableOfGroupFromTech(string group, string type, i // associated with a specific group, and only exist in a specific module // space. -bool PresetMan::GetAllOfGroupInModuleSpace(list &entityList, string group, string type, int whichModuleSpace) +bool PresetMan::GetAllOfGroupInModuleSpace( list &entityList, string group, string type, + int whichModuleSpace ) { - RTEAssert(!group.empty(), "Looking for empty group!"); + RTEAssert( !group.empty(), "Looking for empty group!" ); bool foundAny = false; // All modules - if (whichModuleSpace < 0) - foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace); + if( whichModuleSpace < 0 ) { + foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ); + } // Specific module space - else - { + else { // Get all entitys of the specific group the official modules loaded before the specified one - for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) - foundAny = GetAllOfGroup(entityList, group, type, module) || foundAny; + for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { + foundAny = GetAllOfGroup( entityList, group, type, module ) || foundAny; + } // Now get the groups of the specified module (official or not) - foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace) || foundAny; + foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ) || foundAny; } return foundAny; @@ -793,43 +828,45 @@ bool PresetMan::GetAllOfGroupInModuleSpace(list &entityList, string gr // a specific group, randomly selected and only exist in a specific module // space. -Entity * PresetMan::GetRandomOfGroupInModuleSpace(string group, string type, int whichModuleSpace) +Entity *PresetMan::GetRandomOfGroupInModuleSpace( string group, string type, int whichModuleSpace ) { - RTEAssert(!group.empty(), "Looking for empty group!"); + RTEAssert( !group.empty(), "Looking for empty group!" ); bool foundAny = false; // The total list we'll select a random one from list entityList; // All modules - if (whichModuleSpace < 0) - foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace); + if( whichModuleSpace < 0 ) { + foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ); + } // Specific module space - else - { + else { // Get all entitys of the specific group the official modules loaded before the specified one - for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) - foundAny = GetAllOfGroup(entityList, group, type, module) || foundAny; + for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { + foundAny = GetAllOfGroup( entityList, group, type, module ) || foundAny; + } // Now get the groups of the specified module (official or not) - foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace) || foundAny; + foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ) || foundAny; } // Didn't find any of that group in those module(s) - if (!foundAny) + if( !foundAny ) { return 0; + } // Pick one and return it int current = 0; - int selection = RandomNum(0, entityList.size() - 1); - for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) - { - if (current == selection) - return (*itr); + int selection = RandomNum( 0, entityList.size() - 1 ); + for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { + if( current == selection ) { + return ( *itr ); + } current++; } - RTEAssert(0, "Tried selecting randomly but didn't?"); + RTEAssert( 0, "Tried selecting randomly but didn't?" ); return 0; } @@ -839,32 +876,31 @@ Entity * PresetMan::GetRandomOfGroupInModuleSpace(string group, string type, int ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the data file path of a previously read in (defined) Entity. -string PresetMan::GetEntityDataLocation(string type, string preset, int whichModule) +string PresetMan::GetEntityDataLocation( string type, string preset, int whichModule ) { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); string pRetPath = ""; // All modules - if (whichModule < 0) - { + if( whichModule < 0 ) { // Search all modules - for (int i = 0; i < m_pDataModules.size() && pRetPath.empty(); ++i) - pRetPath = m_pDataModules[i]->GetEntityDataLocation(type, preset); + for( int i = 0; i < m_pDataModules.size() && pRetPath.empty(); ++i ) { + pRetPath = m_pDataModules[i]->GetEntityDataLocation( type, preset ); + } } // Specific module - else - { + else { // Try to get it from the asked for module - pRetPath = m_pDataModules[whichModule]->GetEntityDataLocation(type, preset); + pRetPath = m_pDataModules[whichModule]->GetEntityDataLocation( type, preset ); // If couldn't find it in there, then try all the official modules! - if (pRetPath.empty()) - { - RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); - for (int i = 0; i < m_OfficialModuleCount && pRetPath.empty(); ++i) - { - pRetPath = m_pDataModules[i]->GetEntityDataLocation(type, preset); + if( pRetPath.empty() ) { + RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), + "More official modules than modules loaded?!" ); + for( int i = 0; i < m_OfficialModuleCount && pRetPath.empty(); ++i ) { + pRetPath = m_pDataModules[i]->GetEntityDataLocation( type, preset ); } } } @@ -881,11 +917,12 @@ string PresetMan::GetEntityDataLocation(string type, string preset, int whichMod void PresetMan::ReloadAllScripts() { - g_LuaMan.ClearUserModuleCache(); + g_LuaMan.ClearUserModuleCache(); // Go through all modules and reset all scripts in all their Presets - for (int i = 0; i < m_pDataModules.size(); ++i) + for( int i = 0; i < m_pDataModules.size(); ++i ) { m_pDataModules[i]->ReloadAllScripts(); + } } @@ -897,11 +934,13 @@ void PresetMan::ReloadAllScripts() // resolve the conflicts by mapping their materials to ID's different than // those specified in the data files. -bool PresetMan::AddMaterialMapping(int fromID, int toID, int whichModule) +bool PresetMan::AddMaterialMapping( int fromID, int toID, int whichModule ) { - RTEAssert(whichModule >= m_OfficialModuleCount && whichModule < m_pDataModules.size(), "Tried to make a material mapping in an offical or out-of-bounds DataModule!"); + RTEAssert( whichModule >= m_OfficialModuleCount && + whichModule < m_pDataModules.size(), + "Tried to make a material mapping in an offical or out-of-bounds DataModule!" ); - return m_pDataModules[whichModule]->AddMaterialMapping(fromID, toID); + return m_pDataModules[whichModule]->AddMaterialMapping( fromID, toID ); } @@ -910,17 +949,19 @@ bool PresetMan::AddMaterialMapping(int fromID, int toID, int whichModule) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Registers the existence of an Entity group, and in which module. -void PresetMan::RegisterGroup(std::string newGroup, int whichModule) +void PresetMan::RegisterGroup( std::string newGroup, int whichModule ) { - RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule >= 0 && + whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); // Register in the handy total list - m_TotalGroupRegister.push_back(newGroup); + m_TotalGroupRegister.push_back( newGroup ); m_TotalGroupRegister.sort(); m_TotalGroupRegister.unique(); // Register in the specified module too - m_pDataModules[whichModule]->RegisterGroup(newGroup); + m_pDataModules[whichModule]->RegisterGroup( newGroup ); } @@ -929,45 +970,46 @@ void PresetMan::RegisterGroup(std::string newGroup, int whichModule) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the list of all groups registered in a specific module. -bool PresetMan::GetGroups(list &groupList, int whichModule, string withType) const +bool PresetMan::GetGroups( list &groupList, int whichModule, string withType ) const { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); bool foundAny = false; // Asked for ALL groups ever registered - if (whichModule < 0) - { + if( whichModule < 0 ) { // Get all applicable groups - if (withType == "All" || withType.empty()) - { - for (list::const_iterator gItr = m_TotalGroupRegister.begin(); gItr != m_TotalGroupRegister.end(); ++gItr) - groupList.push_back(*gItr); + if( withType == "All" || withType.empty() ) { + for( list::const_iterator gItr = m_TotalGroupRegister.begin(); + gItr != m_TotalGroupRegister.end(); ++gItr ) { + groupList.push_back( *gItr ); + } foundAny = !m_TotalGroupRegister.empty(); } // Filter out groups without any entitys of the specified type - else - { - for (int module = 0; module < (int)m_pDataModules.size(); ++module) - foundAny = m_pDataModules[module]->GetGroupsWithType(groupList, withType) || foundAny; + else { + for( int module = 0; module < ( int )m_pDataModules.size(); ++module ) { + foundAny = m_pDataModules[module]->GetGroupsWithType( groupList, withType ) || foundAny; + } } } // Asked for specific DataModule's groups - else if (!m_pDataModules[whichModule]->GetGroupRegister()->empty()) - { + else if( !m_pDataModules[whichModule]->GetGroupRegister()->empty() ) { // Get ALL groups of that module - if (withType == "All" || withType.empty()) - { + if( withType == "All" || withType.empty() ) { const list *pGroupList = m_pDataModules[whichModule]->GetGroupRegister(); - for (list::const_iterator gItr = pGroupList->begin(); gItr != pGroupList->end(); ++gItr) - groupList.push_back(*gItr); + for( list::const_iterator gItr = pGroupList->begin(); gItr != pGroupList->end(); ++gItr ) { + groupList.push_back( *gItr ); + } foundAny = !pGroupList->empty(); } - // Get only modules that contain an entity of valid type - else - foundAny = m_pDataModules[whichModule]->GetGroupsWithType(groupList, withType) || foundAny; + // Get only modules that contain an entity of valid type + else { + foundAny = m_pDataModules[whichModule]->GetGroupsWithType( groupList, withType ) || foundAny; + } } return foundAny; @@ -980,39 +1022,41 @@ bool PresetMan::GetGroups(list &groupList, int whichModule, string withT // Description: Fills out a list with all groups registered in all official, PLUS a // a specific non-official module as well. -bool PresetMan::GetModuleSpaceGroups(list &groupList, int whichModule, string withType) const +bool PresetMan::GetModuleSpaceGroups( list &groupList, int whichModule, + string withType ) const { - RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); + RTEAssert( whichModule < ( int )m_pDataModules.size(), + "Tried to access an out of bounds data module number!" ); bool foundAny = false; // If all, then just copy the total register - if (whichModule < 0) - { + if( whichModule < 0 ) { // Just get all groups ever registered - if (withType == "All" || withType.empty()) - { - for (list::const_iterator gItr = m_TotalGroupRegister.begin(); gItr != m_TotalGroupRegister.end(); ++gItr) - groupList.push_back(*gItr); + if( withType == "All" || withType.empty() ) { + for( list::const_iterator gItr = m_TotalGroupRegister.begin(); + gItr != m_TotalGroupRegister.end(); ++gItr ) { + groupList.push_back( *gItr ); + } foundAny = !m_TotalGroupRegister.empty(); } // Get type filtered groups from ALL data modules - else - { - for (int module = 0; module < (int)m_pDataModules.size(); ++module) - foundAny = GetGroups(groupList, module, withType) || foundAny; + else { + for( int module = 0; module < ( int )m_pDataModules.size(); ++module ) { + foundAny = GetGroups( groupList, module, withType ) || foundAny; + } } } // Getting modulespace of specific module - else - { + else { // Get all groups of the official modules that are loaded before the specified one - for (int module = 0; module < m_OfficialModuleCount && module < whichModule; ++module) - foundAny = GetGroups(groupList, module, withType) || foundAny; + for( int module = 0; module < m_OfficialModuleCount && module < whichModule; ++module ) { + foundAny = GetGroups( groupList, module, withType ) || foundAny; + } // Now get the groups of the specified module (official or not) - foundAny = GetGroups(groupList, whichModule, withType) || foundAny; + foundAny = GetGroups( groupList, whichModule, withType ) || foundAny; // Make sure there are no dupe groups in the list groupList.sort(); @@ -1027,9 +1071,9 @@ bool PresetMan::GetModuleSpaceGroups(list &groupList, int whichModule, s ////////////////////////////////////////////////////////////////////////////////////////// // Description: Creates and returns actor defined in the specified loadout. -Actor * PresetMan::GetLoadout(std::string loadoutName, std::string module, bool spawnDropShip) +Actor *PresetMan::GetLoadout( std::string loadoutName, std::string module, bool spawnDropShip ) { - return GetLoadout(loadoutName, GetModuleID(module), spawnDropShip); + return GetLoadout( loadoutName, GetModuleID( module ), spawnDropShip ); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -1037,58 +1081,59 @@ Actor * PresetMan::GetLoadout(std::string loadoutName, std::string module, bool ////////////////////////////////////////////////////////////////////////////////////////// // Description: Creates and returns actor defined in the specified loadout. -Actor * PresetMan::GetLoadout(std::string loadoutName, int moduleNumber, bool spawnDropShip) +Actor *PresetMan::GetLoadout( std::string loadoutName, int moduleNumber, bool spawnDropShip ) { - if (spawnDropShip) - { - // Find the Loadout that this Deployment is referring to - const Loadout *pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", loadoutName, moduleNumber)); - if (pLoadout) - { - const ACraft * pCraftPreset = pLoadout->GetDeliveryCraft(); - if (pCraftPreset) - { - ACraft * pCraft = dynamic_cast(pCraftPreset->Clone()); - if (pCraft) - { - float tally = 0; - // Create and pass along the first Actor and his inventory defined in the Loadout - Actor * pActor = pLoadout->CreateFirstActor(moduleNumber, 1, 1, tally); - // Set the position and team etc for the Actor we are prepping to spawn - if (pActor) - pCraft->AddInventoryItem(pActor); - } - return pCraft; - } - } - } - else - { - // Find the Loadout that this Deployment is referring to - const Loadout *pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", loadoutName, moduleNumber)); - if (pLoadout) - { - float tally = 0; - // Create and pass along the first Actor and his inventory defined in the Loadout - Actor * pReturnActor = pLoadout->CreateFirstActor(moduleNumber, 1, 1, tally); - // Set the position and team etc for the Actor we are prepping to spawn - return pReturnActor; - } - } - - return 0; + if( spawnDropShip ) { + // Find the Loadout that this Deployment is referring to + const Loadout *pLoadout = dynamic_cast( g_PresetMan.GetEntityPreset( "Loadout", + loadoutName, moduleNumber ) ); + if( pLoadout ) { + const ACraft *pCraftPreset = pLoadout->GetDeliveryCraft(); + if( pCraftPreset ) { + ACraft *pCraft = dynamic_cast( pCraftPreset->Clone() ); + if( pCraft ) { + float tally = 0; + // Create and pass along the first Actor and his inventory defined in the Loadout + Actor *pActor = pLoadout->CreateFirstActor( moduleNumber, 1, 1, tally ); + // Set the position and team etc for the Actor we are prepping to spawn + if( pActor ) { + pCraft->AddInventoryItem( pActor ); + } + } + return pCraft; + } + } + } else { + // Find the Loadout that this Deployment is referring to + const Loadout *pLoadout = dynamic_cast( g_PresetMan.GetEntityPreset( "Loadout", + loadoutName, moduleNumber ) ); + if( pLoadout ) { + float tally = 0; + // Create and pass along the first Actor and his inventory defined in the Loadout + Actor *pReturnActor = pLoadout->CreateFirstActor( moduleNumber, 1, 1, tally ); + // Set the position and team etc for the Actor we are prepping to spawn + return pReturnActor; + } + } + + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void PresetMan::FindAndExtractZippedModules() const { - for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory())) { - std::string zippedModulePath = std::filesystem::path(directoryEntry).generic_string(); - if (zippedModulePath.find(System::GetZippedModulePackageExtension()) == zippedModulePath.length() - System::GetZippedModulePackageExtension().length()) { - LoadingScreen::LoadingSplashProgressReport("Extracting Data Module from: " + directoryEntry.path().filename().generic_string(), true); - LoadingScreen::LoadingSplashProgressReport(System::ExtractZippedDataModule(zippedModulePath), true); - } - } +void PresetMan::FindAndExtractZippedModules() const +{ + for( const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator( + System::GetWorkingDirectory() ) ) { + std::string zippedModulePath = std::filesystem::path( directoryEntry ).generic_string(); + if( zippedModulePath.find( System::GetZippedModulePackageExtension() ) == zippedModulePath.length() + - System::GetZippedModulePackageExtension().length() ) { + LoadingScreen::LoadingSplashProgressReport( "Extracting Data Module from: " + + directoryEntry.path().filename().generic_string(), true ); + LoadingScreen::LoadingSplashProgressReport( System::ExtractZippedDataModule( zippedModulePath ), + true ); + } + } } } // namespace RTE diff --git a/System/DataModule.cpp b/System/DataModule.cpp index 4f8b39964..cc3ccd4b4 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -366,7 +366,8 @@ namespace RTE { int DataModule::FindAndRead(const ProgressCallback &progressCallback) { int result = 0; - for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory() + m_FileName)) { + const std::string directoryToScan = g_PresetMan.FullModulePath(m_FileName, m_ModuleID); + for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory() + directoryToScan)) { if (directoryEntry.path().extension() == ".ini" && directoryEntry.path().filename() != "Index.ini") { Reader iniReader; if (iniReader.Create(m_FileName + "/" + directoryEntry.path().filename().generic_string(), false, progressCallback) >= 0) { From 944613f5e49fdaae984002843ff0bf23dc788b1a Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 20:11:40 +0200 Subject: [PATCH 10/40] revert accidental astyle --- Managers/PresetMan.cpp | 1001 +++++++++++++++++++--------------------- 1 file changed, 478 insertions(+), 523 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index b184043d5..4540afc21 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,8 +29,7 @@ #include "LoadingScreen.h" #include "SettingsMan.h" -namespace RTE -{ +namespace RTE { ////////////////////////////////////////////////////////////////////////////////////////// // Method: Clear @@ -74,9 +73,9 @@ int PresetMan::Save(Writer &writer) const void PresetMan::Destroy() { - for( vector::iterator dmItr = m_pDataModules.begin(); dmItr != m_pDataModules.end(); - ++dmItr ) { - delete( *dmItr ); + for (vector::iterator dmItr = m_pDataModules.begin(); dmItr != m_pDataModules.end(); ++dmItr) + { + delete (*dmItr); } Clear(); @@ -89,63 +88,63 @@ void PresetMan::Destroy() // Description: Reads an entire data module and adds it to this. NOTE that official // modules can't be loaded after any non-official ones! -bool PresetMan::LoadDataModule( string moduleName, bool official, - ProgressCallback fpProgressCallback ) +bool PresetMan::LoadDataModule(string moduleName, bool official, ProgressCallback fpProgressCallback) { - if( moduleName.empty() ) { + if (moduleName.empty()) return false; - } vector::iterator itr; // Make a lowercase-version of the module name so it makes it easier to compare to and find case-agnostically string lowercaseName = moduleName; - std::transform( lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), ::tolower ); + std::transform(lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), ::tolower); // Make sure we don't add the same module twice - for( itr = m_pDataModules.begin(); itr != m_pDataModules.end(); ++itr ) { - if( ( *itr )->GetFileName() == moduleName ) { + for (itr = m_pDataModules.begin(); itr != m_pDataModules.end(); ++itr) + { + if ((*itr)->GetFileName() == moduleName) return false; - } } // Only instantiate it here, because it needs to be in the lists of this before being created DataModule *pModule = new DataModule(); // Official modules are stacked in the beginning of the vector - if( official ) { + if (official) + { // Halt if an official module is being loaded after any non-official ones! - // We need to disable this because Metagames.rte gets loaded after non-official modules - // RTEAssert(m_pDataModules.size() == m_OfficialModuleCount, "Trying to load an official module after a non-official one has been loaded!"); +// We need to disable this because Metagames.rte gets loaded after non-official modules +// RTEAssert(m_pDataModules.size() == m_OfficialModuleCount, "Trying to load an official module after a non-official one has been loaded!"); // Find where the offical modules end in the vector itr = m_pDataModules.begin(); int i = 0; - for( ; i < m_OfficialModuleCount; ++i ) { + for (; i < m_OfficialModuleCount; ++i) itr++; - } // Insert into after the last official one - m_pDataModules.insert( itr, pModule ); + m_pDataModules.insert(itr, pModule); // Add the name to ID mapping // Adding the lowercase name version so we can more easily find with case-agnostic search - m_DataModuleIDs.insert( pair( lowercaseName, i ) ); + m_DataModuleIDs.insert(pair(lowercaseName, i)); // Adjust offical tally m_OfficialModuleCount++; } // Non-official modules are just added the end - else { - m_pDataModules.push_back( pModule ); + else + { + m_pDataModules.push_back(pModule); // Add the name to ID mapping - note that official modules can't be loaded after any non-official ones! // Adding the lowercase name version so we can more easily find with case-agnostic search - m_DataModuleIDs.insert( pair( lowercaseName, m_pDataModules.size() - 1 ) ); + m_DataModuleIDs.insert(pair(lowercaseName, m_pDataModules.size() - 1)); } // Now actually create it - if( pModule->Create( moduleName, fpProgressCallback ) < 0 ) { - RTEAbort( "Failed to find the " + moduleName + " Data Module!" ); + if (pModule->Create(moduleName, fpProgressCallback) < 0) + { + RTEAbort("Failed to find the " + moduleName + " Data Module!"); return false; } @@ -156,76 +155,60 @@ bool PresetMan::LoadDataModule( string moduleName, bool official, ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool PresetMan::LoadAllDataModules() -{ - auto moduleLoadTimerStart = std::chrono::high_resolution_clock::now(); - - // Destroy any possible loaded modules - Destroy(); - - FindAndExtractZippedModules(); - - // Load all the official modules first! - std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; - for( const std::string &officialModule : officialModules ) { - if( !LoadDataModule( officialModule, true, &LoadingScreen::LoadingSplashProgressReport ) ) { - return false; - } - } - - // If a single module is specified, skip loading all other unofficial modules and load specified module only. - if( !m_SingleModuleToLoad.empty() && - std::find( officialModules.begin(), officialModules.end(), - m_SingleModuleToLoad ) == officialModules.end() ) { - if( !LoadDataModule( m_SingleModuleToLoad, false, &LoadingScreen::LoadingSplashProgressReport ) ) { - g_ConsoleMan.PrintString( "ERROR: Failed to load DataModule \"" + m_SingleModuleToLoad + - "\"! Only official modules were loaded!" ); - return false; - } - } else { - std::vector workingDirectoryFolders; - std::copy_if( std::filesystem::directory_iterator( System::GetWorkingDirectory() ), - std::filesystem::directory_iterator(), std::back_inserter( workingDirectoryFolders ), - []( auto dirEntry ) { - return std::filesystem::is_directory( dirEntry ); - } - ); - std::sort( workingDirectoryFolders.begin(), workingDirectoryFolders.end() ); - - for( const std::filesystem::directory_entry &directoryEntry : workingDirectoryFolders ) { - std::string directoryEntryPath = directoryEntry.path().generic_string(); - if( std::regex_match( directoryEntryPath, std::regex( ".*\.rte" ) ) ) { - std::string moduleName = directoryEntryPath.substr( directoryEntryPath.find_last_of( '/' ) + 1, - std::string::npos ); - if( !g_SettingsMan.IsModDisabled( moduleName ) && - ( std::find( officialModules.begin(), officialModules.end(), - moduleName ) == officialModules.end() && moduleName != "Metagames.rte" && - moduleName != "Scenes.rte" ) ) { - int moduleID = GetModuleID( moduleName ); - // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. - if( moduleID < 0 || moduleID >= GetOfficialModuleCount() ) { - LoadDataModule( moduleName, false, &LoadingScreen::LoadingSplashProgressReport ); - } - } - } - } - // Load scenes and MetaGames AFTER all other techs etc are loaded; might be referring to stuff in user mods. - if( !LoadDataModule( "Scenes.rte", false, &LoadingScreen::LoadingSplashProgressReport ) ) { - return false; - } - if( !LoadDataModule( "Metagames.rte", false, &LoadingScreen::LoadingSplashProgressReport ) ) { - return false; - } - } - - if( g_SettingsMan.IsMeasuringModuleLoadTime() ) { - std::chrono::milliseconds moduleLoadElapsedTime = - std::chrono::duration_cast( std::chrono::high_resolution_clock::now() - - moduleLoadTimerStart ); - g_ConsoleMan.PrintString( "Module load duration is: " + std::to_string( - moduleLoadElapsedTime.count() ) + "ms" ); - } - return true; +bool PresetMan::LoadAllDataModules() { + auto moduleLoadTimerStart = std::chrono::high_resolution_clock::now(); + + // Destroy any possible loaded modules + Destroy(); + + FindAndExtractZippedModules(); + + // Load all the official modules first! + std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; + for (const std::string &officialModule : officialModules) { + if (!LoadDataModule(officialModule, true, &LoadingScreen::LoadingSplashProgressReport)) { + return false; + } + } + + // If a single module is specified, skip loading all other unofficial modules and load specified module only. + if (!m_SingleModuleToLoad.empty() && std::find(officialModules.begin(), officialModules.end(), m_SingleModuleToLoad) == officialModules.end()) { + if (!LoadDataModule(m_SingleModuleToLoad, false, &LoadingScreen::LoadingSplashProgressReport)) { + g_ConsoleMan.PrintString("ERROR: Failed to load DataModule \"" + m_SingleModuleToLoad + "\"! Only official modules were loaded!"); + return false; + } + } else { + std::vector workingDirectoryFolders; + std::copy_if(std::filesystem::directory_iterator(System::GetWorkingDirectory()), std::filesystem::directory_iterator(), std::back_inserter(workingDirectoryFolders), + [](auto dirEntry){ return std::filesystem::is_directory(dirEntry); } + ); + std::sort(workingDirectoryFolders.begin(), workingDirectoryFolders.end()); + + for (const std::filesystem::directory_entry &directoryEntry : workingDirectoryFolders) { + std::string directoryEntryPath = directoryEntry.path().generic_string(); + if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) { + std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos); + if (!g_SettingsMan.IsModDisabled(moduleName) && (std::find(officialModules.begin(), officialModules.end(), moduleName) == officialModules.end() && moduleName != "Metagames.rte" && moduleName != "Scenes.rte")) { + int moduleID = GetModuleID(moduleName); + // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. + if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) { LoadDataModule(moduleName, false, &LoadingScreen::LoadingSplashProgressReport); } + } + } + } + // Load scenes and MetaGames AFTER all other techs etc are loaded; might be referring to stuff in user mods. + if (!LoadDataModule("Scenes.rte", false, &LoadingScreen::LoadingSplashProgressReport)) { + return false; + } + if (!LoadDataModule("Metagames.rte", false, &LoadingScreen::LoadingSplashProgressReport)) { + return false; + } + } + + if (g_SettingsMan.IsMeasuringModuleLoadTime()) { + std::chrono::milliseconds moduleLoadElapsedTime = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - moduleLoadTimerStart); + g_ConsoleMan.PrintString("Module load duration is: " + std::to_string(moduleLoadElapsedTime.count()) + "ms"); + } + return true; } @@ -234,10 +217,9 @@ bool PresetMan::LoadAllDataModules() ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a specific loaded DataModule -const DataModule *PresetMan::GetDataModule( int whichModule ) +const DataModule * PresetMan::GetDataModule(int whichModule) { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); return m_pDataModules[whichModule]; } @@ -246,10 +228,9 @@ const DataModule *PresetMan::GetDataModule( int whichModule ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a name specific loaded DataModule -const std::string PresetMan::GetDataModuleName( int whichModule ) +const std::string PresetMan::GetDataModuleName(int whichModule) { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); return m_pDataModules[whichModule]->GetFileName(); } @@ -260,57 +241,53 @@ const std::string PresetMan::GetDataModuleName( int whichModule ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule. -int PresetMan::GetModuleID( string moduleName ) +int PresetMan::GetModuleID(string moduleName) { // Lower-case search name so we can match up against the already-lowercase names in m_DataModuleIDs - std::transform( moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower ); + std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); // First pass - map::iterator itr = m_DataModuleIDs.find( moduleName ); - if( itr != m_DataModuleIDs.end() ) { - return ( *itr ).second; - } + map::iterator itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; // Try with or without the .rte on the end before giving up - int dotPos = moduleName.find_last_of( '.' ); + int dotPos = moduleName.find_last_of('.'); // Wasnt, so try adding it - if( dotPos == string::npos ) { + if (dotPos == string::npos) moduleName = moduleName + System::GetModulePackageExtension(); - } // There was ".rte", so try to shave it off the name - else { - moduleName = moduleName.substr( 0, dotPos ); - } + else + moduleName = moduleName.substr(0, dotPos); // Try to find the module again! - itr = m_DataModuleIDs.find( moduleName ); - if( itr != m_DataModuleIDs.end() ) { - return ( *itr ).second; - } + itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; - /* No need to do this second pass now; we immediately do the case-agnostic search - // Add .rte and try to find the module in case-agnostic fashion - moduleName += ".rte"; - std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); - - itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; - - // Try with or without the .rte on the end before giving up - dotPos = moduleName.find_last_of('.'); - // Wasnt, so try adding it - if (dotPos == string::npos) - moduleName = moduleName + System::GetModulePackageExtension(); - // There was ".rte", so try to shave it off the name - else - moduleName = moduleName.substr(0, dotPos); +/* No need to do this second pass now; we immediately do the case-agnostic search + // Add .rte and try to find the module in case-agnostic fashion + moduleName += ".rte"; + std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); + + itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; + + // Try with or without the .rte on the end before giving up + dotPos = moduleName.find_last_of('.'); + // Wasnt, so try adding it + if (dotPos == string::npos) + moduleName = moduleName + System::GetModulePackageExtension(); + // There was ".rte", so try to shave it off the name + else + moduleName = moduleName.substr(0, dotPos); - // Try to find the module again! - itr = m_DataModuleIDs.find(moduleName); - if (itr != m_DataModuleIDs.end()) - return (*itr).second; - */ + // Try to find the module again! + itr = m_DataModuleIDs.find(moduleName); + if (itr != m_DataModuleIDs.end()) + return (*itr).second; +*/ return -1; } @@ -320,18 +297,16 @@ int PresetMan::GetModuleID( string moduleName ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule, from a full data file path. -int PresetMan::GetModuleIDFromPath( std::string dataPath ) +int PresetMan::GetModuleIDFromPath(std::string dataPath) { - if( dataPath.empty() ) { + if (dataPath.empty()) return -1; - } - int slashPos = dataPath.find_first_of( '/' ); - if( slashPos == string::npos ) { - slashPos = dataPath.find_first_of( '\\' ); - } + int slashPos = dataPath.find_first_of('/'); + if (slashPos == string::npos) + slashPos = dataPath.find_first_of('\\'); - return GetModuleID( dataPath.substr( 0, slashPos ) ); + return GetModuleID(dataPath.substr(0, slashPos)); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -342,12 +317,12 @@ int PresetMan::GetModuleIDFromPath( std::string dataPath ) // The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. -std::string PresetMan::FullModulePath( std::string modulePath, int whichModule ) +std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) { const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; const std::string moduleFolder = whichModule < m_OfficialModuleCount || isSpecialCase ? "Data/" : "Mods/"; - const std::string topFolder = modulePath.substr( 0, modulePath.find_first_of( "/\\" ) + 1 ); - if( topFolder == moduleFolder ) { + const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); + if (topFolder == moduleFolder) { return modulePath; } return moduleFolder + modulePath; @@ -361,13 +336,11 @@ std::string PresetMan::FullModulePath( std::string modulePath, int whichModule ) // If there already is an instance defined, nothing happens. If there // is not, a clone is made of the passed-in Entity and added to the library. -bool PresetMan::AddEntityPreset( Entity *pEntToAdd, int whichModule, bool overwriteSame, - string readFromFile ) +bool PresetMan::AddEntityPreset(Entity *pEntToAdd, int whichModule, bool overwriteSame, string readFromFile) { - RTEAssert( whichModule >= 0 && - whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!"); - return m_pDataModules[whichModule]->AddEntityPreset( pEntToAdd, overwriteSame, readFromFile ); + return m_pDataModules[whichModule]->AddEntityPreset(pEntToAdd, overwriteSame, readFromFile); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -375,39 +348,41 @@ bool PresetMan::AddEntityPreset( Entity *pEntToAdd, int whichModule, bool overwr ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets a previously read in (defined) Entity, by type and instance name. -const Entity *PresetMan::GetEntityPreset( string type, string preset, int whichModule ) +const Entity * PresetMan::GetEntityPreset(string type, string preset, int whichModule) { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); const Entity *pRetEntity = 0; // Preset name might have "[ModuleName]/" preceding it, detect it here and select proper module! - int slashPos = preset.find_first_of( '/' ); - if( slashPos != string::npos ) { + int slashPos = preset.find_first_of('/'); + if (slashPos != string::npos) + { // Get the module ID and cut off the module specifier in the string - whichModule = GetModuleID( preset.substr( 0, slashPos ) ); - preset = preset.substr( slashPos + 1 ); + whichModule = GetModuleID(preset.substr(0, slashPos)); + preset = preset.substr(slashPos + 1); } // All modules - if( whichModule < 0 ) { + if (whichModule < 0) + { // Search all modules - for( int i = 0; i < m_pDataModules.size() && !pRetEntity; ++i ) { - pRetEntity = m_pDataModules[i]->GetEntityPreset( type, preset ); - } + for (int i = 0; i < m_pDataModules.size() && !pRetEntity; ++i) + pRetEntity = m_pDataModules[i]->GetEntityPreset(type, preset); } // Specific module - else { + else + { // Try to get it from the asked for module - pRetEntity = m_pDataModules[whichModule]->GetEntityPreset( type, preset ); + pRetEntity = m_pDataModules[whichModule]->GetEntityPreset(type, preset); // If couldn't find it in there, then try all the official modules! - if( !pRetEntity ) { - RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), - "More official modules than modules loaded?!" ); - for( int i = 0; i < m_OfficialModuleCount && !pRetEntity; ++i ) { - pRetEntity = m_pDataModules[i]->GetEntityPreset( type, preset ); + if (!pRetEntity) + { + RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); + for (int i = 0; i < m_OfficialModuleCount && !pRetEntity; ++i) + { + pRetEntity = m_pDataModules[i]->GetEntityPreset(type, preset); } } } @@ -426,12 +401,11 @@ const Entity *PresetMan::GetEntityPreset( string type, string preset, int whichM // add the newly read in one to this PresetMan's list if not found to // exist there previously. Ownership is NOT transferred! -const Entity *PresetMan::GetEntityPreset( Reader &reader ) +const Entity * PresetMan::GetEntityPreset(Reader &reader) { // The reader is aware of which DataModule it is reading within int whichModule = reader.GetReadModuleID(); - RTEAssert( whichModule >= 0 && - whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!" ); + RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!"); string ClassName; const Entity::ClassInfo *pClass = 0; @@ -439,47 +413,43 @@ const Entity *PresetMan::GetEntityPreset( Reader &reader ) const Entity *pReturnPreset = 0; // Load class name and then preset instance reader >> ClassName; - pClass = Entity::ClassInfo::GetClass( ClassName ); - - if( pClass && pClass->IsConcrete() ) { - // Instantiate - pNewInstance = pClass->NewInstance(); - - // Get this before reading entity, since if it's the last one in its datafile, the stream will show the parent file instead - string entityFilePath = reader.GetCurrentFilePath(); - - // Try to read in the preset instance's data from the reader - if( pNewInstance && pNewInstance->Create( reader, false ) < 0 ) { - // Abort loading if we can't create entity and it's not in Scenes.rte - if( !g_PresetMan.GetDataModule( whichModule )->GetIgnoreMissingItems() ) { - RTEAbort( "Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + - pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + - ", shortly before line #" + reader.GetCurrentFileLine() ); - } - } else if( pNewInstance ) { - // Try to add the instance to the collection - m_pDataModules[whichModule]->AddEntityPreset( pNewInstance, reader.GetPresetOverwriting(), - entityFilePath ); - - // Regardless of whether there was a collision or not, use whatever now exists in the instance map of that class and name - pReturnPreset = m_pDataModules[whichModule]->GetEntityPreset( pNewInstance->GetClassName(), - pNewInstance->GetPresetName() ); - // If the instance wasn't found in the specific DataModule, try to find it in all the official ones instead - if( !pReturnPreset ) { - RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), - "More official modules than modules loaded?!" ); - for( int i = 0; i < m_OfficialModuleCount && !pReturnPreset; ++i ) { - pReturnPreset = m_pDataModules[i]->GetEntityPreset( pNewInstance->GetClassName(), - pNewInstance->GetPresetName() ); - } - } - } + pClass = Entity::ClassInfo::GetClass(ClassName); + + if (pClass && pClass->IsConcrete()) + { + // Instantiate + pNewInstance = pClass->NewInstance(); + + // Get this before reading entity, since if it's the last one in its datafile, the stream will show the parent file instead + string entityFilePath = reader.GetCurrentFilePath(); + + // Try to read in the preset instance's data from the reader + if (pNewInstance && pNewInstance->Create(reader, false) < 0) + { + // Abort loading if we can't create entity and it's not in Scenes.rte + if (!g_PresetMan.GetDataModule(whichModule)->GetIgnoreMissingItems()) + RTEAbort("Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + ", shortly before line #" + reader.GetCurrentFileLine()); + } + else if (pNewInstance) + { + // Try to add the instance to the collection + m_pDataModules[whichModule]->AddEntityPreset(pNewInstance, reader.GetPresetOverwriting(), entityFilePath); + + // Regardless of whether there was a collision or not, use whatever now exists in the instance map of that class and name + pReturnPreset = m_pDataModules[whichModule]->GetEntityPreset(pNewInstance->GetClassName(), pNewInstance->GetPresetName()); + // If the instance wasn't found in the specific DataModule, try to find it in all the official ones instead + if (!pReturnPreset) + { + RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); + for (int i = 0; i < m_OfficialModuleCount && !pReturnPreset; ++i) + pReturnPreset = m_pDataModules[i]->GetEntityPreset(pNewInstance->GetClassName(), pNewInstance->GetPresetName()); + } + } // Get rid of the read-in instance as its copy is now either added to the map, or discarded as there already was somehting in there of the same name. - delete pNewInstance; - pNewInstance = 0; - } else { - pReturnPreset = 0; + delete pNewInstance; pNewInstance = 0; } + else + pReturnPreset = 0; return pReturnPreset; } @@ -492,21 +462,21 @@ const Entity *PresetMan::GetEntityPreset( Reader &reader ) // read-in presets. Regardless of whether there is a name collision, // the read-in preset will be returned, ownership TRANSFERRED! -Entity *PresetMan::ReadReflectedPreset( Reader &reader ) +Entity * PresetMan::ReadReflectedPreset(Reader &reader) { // The reader is aware of which DataModule it's reading within int whichModule = reader.GetReadModuleID(); - RTEAssert( whichModule >= 0 && - whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!" ); + RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Reader has an out of bounds module number!"); string ClassName; const Entity::ClassInfo *pClass = 0; Entity *pNewInstance = 0; // Load class name and then preset instance reader >> ClassName; - pClass = Entity::ClassInfo::GetClass( ClassName ); + pClass = Entity::ClassInfo::GetClass(ClassName); - if( pClass && pClass->IsConcrete() ) { + if (pClass && pClass->IsConcrete()) + { // Instantiate pNewInstance = pClass->NewInstance(); @@ -514,22 +484,21 @@ Entity *PresetMan::ReadReflectedPreset( Reader &reader ) string entityFilePath = reader.GetCurrentFilePath(); // Try to read in the preset instance's data from the reader - if( pNewInstance && pNewInstance->Create( reader, false ) < 0 ) { - if( !g_PresetMan.GetDataModule( whichModule )->GetIgnoreMissingItems() ) { - RTEAbort( "Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + - pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + - ", shortly before line #" + reader.GetCurrentFileLine() ); - } - } else { - // Try to add the instance to the collection. - // Note that we'll return this instance regardless of whether the adding was succesful or not - m_pDataModules[whichModule]->AddEntityPreset( pNewInstance, reader.GetPresetOverwriting(), - entityFilePath ); - return pNewInstance; - } + if (pNewInstance && pNewInstance->Create(reader, false) < 0) + { + if (!g_PresetMan.GetDataModule(whichModule)->GetIgnoreMissingItems()) + RTEAbort("Reading of a preset instance \"" + pNewInstance->GetPresetName() + "\" of class " + pNewInstance->GetClassName() + " failed in file " + reader.GetCurrentFilePath() + ", shortly before line #" + reader.GetCurrentFileLine()); + } + else + { + // Try to add the instance to the collection. + // Note that we'll return this instance regardless of whether the adding was succesful or not + m_pDataModules[whichModule]->AddEntityPreset(pNewInstance, reader.GetPresetOverwriting(), entityFilePath); + return pNewInstance; + } } - return 0; + return 0; } @@ -538,26 +507,25 @@ Entity *PresetMan::ReadReflectedPreset( Reader &reader ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Adds to a list all previously read in (defined) Entitys, by type. -bool PresetMan::GetAllOfType( list &entityList, string type, int whichModule ) +bool PresetMan::GetAllOfType(list &entityList, string type, int whichModule) { - if( type.empty() ) { + if (type.empty()) return false; - } bool foundAny = false; // All modules - if( whichModule < 0 ) { + if (whichModule < 0) + { // Send the list to each module - for( int i = 0; i < m_pDataModules.size(); ++i ) { - foundAny = m_pDataModules[i]->GetAllOfType( entityList, type ) || foundAny; - } + for (int i = 0; i < m_pDataModules.size(); ++i) + foundAny = m_pDataModules[i]->GetAllOfType(entityList, type) || foundAny; } // Specific module - else { - RTEAssert( whichModule < m_pDataModules.size(), - "Trying to get from an out of bounds DataModule ID!" ); - foundAny = m_pDataModules[whichModule]->GetAllOfType( entityList, type ); + else + { + RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); + foundAny = m_pDataModules[whichModule]->GetAllOfType(entityList, type); } return foundAny; @@ -570,28 +538,25 @@ bool PresetMan::GetAllOfType( list &entityList, string type, int which // Description: Adds to a list all previously read in (defined) Entitys which are // of a specific type, and only exist in a specific module space. -bool PresetMan::GetAllOfTypeInModuleSpace( std::list &entityList, std::string type, - int whichModuleSpace ) +bool PresetMan::GetAllOfTypeInModuleSpace(std::list &entityList, std::string type, int whichModuleSpace) { - if( type.empty() ) { + if (type.empty()) return false; - } bool foundAny = false; // All modules - if( whichModuleSpace < 0 ) { - foundAny = GetAllOfType( entityList, type, whichModuleSpace ); - } + if (whichModuleSpace < 0) + foundAny = GetAllOfType(entityList, type, whichModuleSpace); // Specific module space - else { + else + { // Get all entitys of the specific type in the official modules loaded before the specified one - for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { - foundAny = GetAllOfType( entityList, type, module ) || foundAny; - } + for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) + foundAny = GetAllOfType(entityList, type, module) || foundAny; // Now get the groups of the specified module (official or not) - foundAny = GetAllOfType( entityList, type, whichModuleSpace ) || foundAny; + foundAny = GetAllOfType(entityList, type, whichModuleSpace) || foundAny; } return foundAny; @@ -604,27 +569,25 @@ bool PresetMan::GetAllOfTypeInModuleSpace( std::list &entityList, std: // Description: Adds to a list all previously read in (defined) Entitys which are // associated with a specific group. -bool PresetMan::GetAllOfGroup( list &entityList, string group, string type, - int whichModule ) +bool PresetMan::GetAllOfGroup(list &entityList, string group, string type, int whichModule) { - RTEAssert( !group.empty(), "Looking for empty group!" ); + RTEAssert(!group.empty(), "Looking for empty group!"); bool foundAny = false; // All modules - if( whichModule < 0 ) { + if (whichModule < 0) + { // Get from all modules - for( int i = 0; i < m_pDataModules.size(); ++i ) + for (int i = 0; i < m_pDataModules.size(); ++i) // Send the list to each module, let them add - { - foundAny = m_pDataModules[i]->GetAllOfGroup( entityList, group, type ) || foundAny; - } + foundAny = m_pDataModules[i]->GetAllOfGroup(entityList, group, type) || foundAny; } // Specific one - else { - RTEAssert( whichModule < m_pDataModules.size(), - "Trying to get from an out of bounds DataModule ID!" ); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup( entityList, group, type ); + else + { + RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup(entityList, group, type); } return foundAny; @@ -637,46 +600,44 @@ bool PresetMan::GetAllOfGroup( list &entityList, string group, string // Description: Returns a previously read in (defined) Entity which is randomly // selected from a specific group. -Entity *PresetMan::GetRandomOfGroup( string group, string type, int whichModule ) +Entity * PresetMan::GetRandomOfGroup(string group, string type, int whichModule) { - RTEAssert( !group.empty(), "Looking for empty group!" ); + RTEAssert(!group.empty(), "Looking for empty group!"); bool foundAny = false; // The total list we'll select a random one from list entityList; // All modules - if( whichModule < 0 ) { + if (whichModule < 0) + { // Get from all modules - for( int i = 0; i < m_pDataModules.size(); ++i ) + for (int i = 0; i < m_pDataModules.size(); ++i) // Send the list to each module, let them add - { - foundAny = m_pDataModules[i]->GetAllOfGroup( entityList, group, type ) || foundAny; - } + foundAny = m_pDataModules[i]->GetAllOfGroup(entityList, group, type) || foundAny; } // Specific one - else { - RTEAssert( whichModule < m_pDataModules.size(), - "Trying to get from an out of bounds DataModule ID!" ); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup( entityList, group, type ); + else + { + RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup(entityList, group, type); } // Didn't find any of that group in those module(s) - if( !foundAny ) { + if (!foundAny) return 0; - } // Pick one and return it int current = 0; - int selection = RandomNum( 0, entityList.size() - 1 ); - for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { - if( current == selection ) { - return ( *itr ); - } + int selection = RandomNum(0, entityList.size() - 1); + for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) + { + if (current == selection) + return (*itr); current++; } - RTEAssert( 0, "Tried selecting randomly but didn't?" ); + RTEAssert(0, "Tried selecting randomly but didn't?"); return 0; } @@ -687,104 +648,110 @@ Entity *PresetMan::GetRandomOfGroup( string group, string type, int whichModule // Description: Returns a previously read in (defined) Entity which is randomly // selected from a specific group. -Entity *PresetMan::GetRandomBuyableOfGroupFromTech( string group, string type, int whichModule ) +Entity * PresetMan::GetRandomBuyableOfGroupFromTech(string group, string type, int whichModule) { - RTEAssert( !group.empty(), "Looking for empty group!" ); + RTEAssert(!group.empty(), "Looking for empty group!"); bool foundAny = false; // The total list we'll select a random one from list entityList; list tempList; - // All modules - if( whichModule < 0 ) { - for( DataModule *dataModule : m_pDataModules ) { - if( dataModule->IsFaction() ) { - foundAny = dataModule->GetAllOfGroup( tempList, group, type ) || foundAny; - } - } - } else { - RTEAssert( whichModule < m_pDataModules.size(), - "Trying to get from an out of bounds DataModule ID!" ); - foundAny = m_pDataModules[whichModule]->GetAllOfGroup( tempList, group, type ); - } - - //Filter found entities, we need only buyables - if( foundAny ) { - //Do not filter anything if we're looking for brains - if( group == "Brains" ) { - foundAny = false; - for( list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr ) { - entityList.push_back( *oItr ); - foundAny = true; - } - } else { - foundAny = false; - for( list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr ) { - SceneObject *pSObject = dynamic_cast( *oItr ); - // Buyable and not brain? - if( pSObject && pSObject->IsBuyable() && !pSObject->IsBuyableInObjectPickerOnly() && - !pSObject->IsInGroup( "Brains" ) ) { - entityList.push_back( *oItr ); - foundAny = true; - } - } - } - } - - // Didn't find any of that group in those module(s) - if( !foundAny ) { + // All modules + if (whichModule < 0) { + for (DataModule *dataModule : m_pDataModules) { + if (dataModule->IsFaction()) { foundAny = dataModule->GetAllOfGroup(tempList, group, type) || foundAny; } + } + } else { + RTEAssert(whichModule < m_pDataModules.size(), "Trying to get from an out of bounds DataModule ID!"); + foundAny = m_pDataModules[whichModule]->GetAllOfGroup(tempList, group, type); + } + + //Filter found entities, we need only buyables + if (foundAny) + { + //Do not filter anything if we're looking for brains + if (group == "Brains") + { + foundAny = false; + for (list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr) + { + entityList.push_back(*oItr); + foundAny = true; + } + } + else + { + foundAny = false; + for (list::iterator oItr = tempList.begin(); oItr != tempList.end(); ++oItr) + { + SceneObject * pSObject = dynamic_cast(*oItr); + // Buyable and not brain? + if (pSObject && pSObject->IsBuyable() && !pSObject->IsBuyableInObjectPickerOnly() && !pSObject->IsInGroup("Brains")) + { + entityList.push_back(*oItr); + foundAny = true; + } + } + } + } + + // Didn't find any of that group in those module(s) + if (!foundAny) return 0; - } // Pick one and return it int current = 0; - int selection = RandomNum( 0, entityList.size() - 1 ); - - int totalWeight = 0; - for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { - totalWeight += ( *itr )->GetRandomWeight(); - } - - // Use random weights if looking in specific modules - if( whichModule >= 0 ) { - if( totalWeight == 0 ) { - return 0; - } - - selection = RandomNum( 0, totalWeight - 1 ); - - for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { - bool found = false; - int bucketCounter = 0; - - if( ( *itr )->GetRandomWeight() > 0 ) { - while( bucketCounter < ( *itr )->GetRandomWeight() ) { - if( current == selection ) { - found = true; - break; - } - - current++; - bucketCounter++; - } - } - - if( found ) { - return ( *itr ); - } - } - } else { - for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { - if( current == selection ) { - return ( *itr ); - } - - current++; - } - } - - RTEAssert( 0, "Tried selecting randomly but didn't?" ); + int selection = RandomNum(0, entityList.size() - 1); + + int totalWeight = 0; + for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) + totalWeight += (*itr)->GetRandomWeight(); + + // Use random weights if looking in specific modules + if (whichModule >= 0) + { + if (totalWeight == 0) + return 0; + + selection = RandomNum(0, totalWeight - 1); + + for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) + { + bool found = false; + int bucketCounter = 0; + + if ((*itr)->GetRandomWeight() > 0) + { + while (bucketCounter < (*itr)->GetRandomWeight()) + { + if (current == selection) + { + found = true; + break; + } + + current++; + bucketCounter++; + } + } + + if (found) + return (*itr); + } + } + else + { + for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) + { + if (current == selection) + return (*itr); + + current++; + } + } + + RTEAssert(0, "Tried selecting randomly but didn't?"); return 0; } @@ -795,26 +762,24 @@ Entity *PresetMan::GetRandomBuyableOfGroupFromTech( string group, string type, i // associated with a specific group, and only exist in a specific module // space. -bool PresetMan::GetAllOfGroupInModuleSpace( list &entityList, string group, string type, - int whichModuleSpace ) +bool PresetMan::GetAllOfGroupInModuleSpace(list &entityList, string group, string type, int whichModuleSpace) { - RTEAssert( !group.empty(), "Looking for empty group!" ); + RTEAssert(!group.empty(), "Looking for empty group!"); bool foundAny = false; // All modules - if( whichModuleSpace < 0 ) { - foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ); - } + if (whichModuleSpace < 0) + foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace); // Specific module space - else { + else + { // Get all entitys of the specific group the official modules loaded before the specified one - for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { - foundAny = GetAllOfGroup( entityList, group, type, module ) || foundAny; - } + for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) + foundAny = GetAllOfGroup(entityList, group, type, module) || foundAny; // Now get the groups of the specified module (official or not) - foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ) || foundAny; + foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace) || foundAny; } return foundAny; @@ -828,45 +793,43 @@ bool PresetMan::GetAllOfGroupInModuleSpace( list &entityList, string g // a specific group, randomly selected and only exist in a specific module // space. -Entity *PresetMan::GetRandomOfGroupInModuleSpace( string group, string type, int whichModuleSpace ) +Entity * PresetMan::GetRandomOfGroupInModuleSpace(string group, string type, int whichModuleSpace) { - RTEAssert( !group.empty(), "Looking for empty group!" ); + RTEAssert(!group.empty(), "Looking for empty group!"); bool foundAny = false; // The total list we'll select a random one from list entityList; // All modules - if( whichModuleSpace < 0 ) { - foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ); - } + if (whichModuleSpace < 0) + foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace); // Specific module space - else { + else + { // Get all entitys of the specific group the official modules loaded before the specified one - for( int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module ) { - foundAny = GetAllOfGroup( entityList, group, type, module ) || foundAny; - } + for (int module = 0; module < m_OfficialModuleCount && module < whichModuleSpace; ++module) + foundAny = GetAllOfGroup(entityList, group, type, module) || foundAny; // Now get the groups of the specified module (official or not) - foundAny = GetAllOfGroup( entityList, group, type, whichModuleSpace ) || foundAny; + foundAny = GetAllOfGroup(entityList, group, type, whichModuleSpace) || foundAny; } // Didn't find any of that group in those module(s) - if( !foundAny ) { + if (!foundAny) return 0; - } // Pick one and return it int current = 0; - int selection = RandomNum( 0, entityList.size() - 1 ); - for( list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr ) { - if( current == selection ) { - return ( *itr ); - } + int selection = RandomNum(0, entityList.size() - 1); + for (list::iterator itr = entityList.begin(); itr != entityList.end(); ++itr) + { + if (current == selection) + return (*itr); current++; } - RTEAssert( 0, "Tried selecting randomly but didn't?" ); + RTEAssert(0, "Tried selecting randomly but didn't?"); return 0; } @@ -876,31 +839,32 @@ Entity *PresetMan::GetRandomOfGroupInModuleSpace( string group, string type, int ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the data file path of a previously read in (defined) Entity. -string PresetMan::GetEntityDataLocation( string type, string preset, int whichModule ) +string PresetMan::GetEntityDataLocation(string type, string preset, int whichModule) { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); string pRetPath = ""; // All modules - if( whichModule < 0 ) { + if (whichModule < 0) + { // Search all modules - for( int i = 0; i < m_pDataModules.size() && pRetPath.empty(); ++i ) { - pRetPath = m_pDataModules[i]->GetEntityDataLocation( type, preset ); - } + for (int i = 0; i < m_pDataModules.size() && pRetPath.empty(); ++i) + pRetPath = m_pDataModules[i]->GetEntityDataLocation(type, preset); } // Specific module - else { + else + { // Try to get it from the asked for module - pRetPath = m_pDataModules[whichModule]->GetEntityDataLocation( type, preset ); + pRetPath = m_pDataModules[whichModule]->GetEntityDataLocation(type, preset); // If couldn't find it in there, then try all the official modules! - if( pRetPath.empty() ) { - RTEAssert( m_OfficialModuleCount <= m_pDataModules.size(), - "More official modules than modules loaded?!" ); - for( int i = 0; i < m_OfficialModuleCount && pRetPath.empty(); ++i ) { - pRetPath = m_pDataModules[i]->GetEntityDataLocation( type, preset ); + if (pRetPath.empty()) + { + RTEAssert(m_OfficialModuleCount <= m_pDataModules.size(), "More official modules than modules loaded?!"); + for (int i = 0; i < m_OfficialModuleCount && pRetPath.empty(); ++i) + { + pRetPath = m_pDataModules[i]->GetEntityDataLocation(type, preset); } } } @@ -917,12 +881,11 @@ string PresetMan::GetEntityDataLocation( string type, string preset, int whichMo void PresetMan::ReloadAllScripts() { - g_LuaMan.ClearUserModuleCache(); + g_LuaMan.ClearUserModuleCache(); // Go through all modules and reset all scripts in all their Presets - for( int i = 0; i < m_pDataModules.size(); ++i ) { + for (int i = 0; i < m_pDataModules.size(); ++i) m_pDataModules[i]->ReloadAllScripts(); - } } @@ -934,13 +897,11 @@ void PresetMan::ReloadAllScripts() // resolve the conflicts by mapping their materials to ID's different than // those specified in the data files. -bool PresetMan::AddMaterialMapping( int fromID, int toID, int whichModule ) +bool PresetMan::AddMaterialMapping(int fromID, int toID, int whichModule) { - RTEAssert( whichModule >= m_OfficialModuleCount && - whichModule < m_pDataModules.size(), - "Tried to make a material mapping in an offical or out-of-bounds DataModule!" ); + RTEAssert(whichModule >= m_OfficialModuleCount && whichModule < m_pDataModules.size(), "Tried to make a material mapping in an offical or out-of-bounds DataModule!"); - return m_pDataModules[whichModule]->AddMaterialMapping( fromID, toID ); + return m_pDataModules[whichModule]->AddMaterialMapping(fromID, toID); } @@ -949,19 +910,17 @@ bool PresetMan::AddMaterialMapping( int fromID, int toID, int whichModule ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Registers the existence of an Entity group, and in which module. -void PresetMan::RegisterGroup( std::string newGroup, int whichModule ) +void PresetMan::RegisterGroup(std::string newGroup, int whichModule) { - RTEAssert( whichModule >= 0 && - whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); // Register in the handy total list - m_TotalGroupRegister.push_back( newGroup ); + m_TotalGroupRegister.push_back(newGroup); m_TotalGroupRegister.sort(); m_TotalGroupRegister.unique(); // Register in the specified module too - m_pDataModules[whichModule]->RegisterGroup( newGroup ); + m_pDataModules[whichModule]->RegisterGroup(newGroup); } @@ -970,46 +929,45 @@ void PresetMan::RegisterGroup( std::string newGroup, int whichModule ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the list of all groups registered in a specific module. -bool PresetMan::GetGroups( list &groupList, int whichModule, string withType ) const +bool PresetMan::GetGroups(list &groupList, int whichModule, string withType) const { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); bool foundAny = false; // Asked for ALL groups ever registered - if( whichModule < 0 ) { + if (whichModule < 0) + { // Get all applicable groups - if( withType == "All" || withType.empty() ) { - for( list::const_iterator gItr = m_TotalGroupRegister.begin(); - gItr != m_TotalGroupRegister.end(); ++gItr ) { - groupList.push_back( *gItr ); - } + if (withType == "All" || withType.empty()) + { + for (list::const_iterator gItr = m_TotalGroupRegister.begin(); gItr != m_TotalGroupRegister.end(); ++gItr) + groupList.push_back(*gItr); foundAny = !m_TotalGroupRegister.empty(); } // Filter out groups without any entitys of the specified type - else { - for( int module = 0; module < ( int )m_pDataModules.size(); ++module ) { - foundAny = m_pDataModules[module]->GetGroupsWithType( groupList, withType ) || foundAny; - } + else + { + for (int module = 0; module < (int)m_pDataModules.size(); ++module) + foundAny = m_pDataModules[module]->GetGroupsWithType(groupList, withType) || foundAny; } } // Asked for specific DataModule's groups - else if( !m_pDataModules[whichModule]->GetGroupRegister()->empty() ) { + else if (!m_pDataModules[whichModule]->GetGroupRegister()->empty()) + { // Get ALL groups of that module - if( withType == "All" || withType.empty() ) { + if (withType == "All" || withType.empty()) + { const list *pGroupList = m_pDataModules[whichModule]->GetGroupRegister(); - for( list::const_iterator gItr = pGroupList->begin(); gItr != pGroupList->end(); ++gItr ) { - groupList.push_back( *gItr ); - } + for (list::const_iterator gItr = pGroupList->begin(); gItr != pGroupList->end(); ++gItr) + groupList.push_back(*gItr); foundAny = !pGroupList->empty(); } - // Get only modules that contain an entity of valid type - else { - foundAny = m_pDataModules[whichModule]->GetGroupsWithType( groupList, withType ) || foundAny; - } + // Get only modules that contain an entity of valid type + else + foundAny = m_pDataModules[whichModule]->GetGroupsWithType(groupList, withType) || foundAny; } return foundAny; @@ -1022,41 +980,39 @@ bool PresetMan::GetGroups( list &groupList, int whichModule, string with // Description: Fills out a list with all groups registered in all official, PLUS a // a specific non-official module as well. -bool PresetMan::GetModuleSpaceGroups( list &groupList, int whichModule, - string withType ) const +bool PresetMan::GetModuleSpaceGroups(list &groupList, int whichModule, string withType) const { - RTEAssert( whichModule < ( int )m_pDataModules.size(), - "Tried to access an out of bounds data module number!" ); + RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); bool foundAny = false; // If all, then just copy the total register - if( whichModule < 0 ) { + if (whichModule < 0) + { // Just get all groups ever registered - if( withType == "All" || withType.empty() ) { - for( list::const_iterator gItr = m_TotalGroupRegister.begin(); - gItr != m_TotalGroupRegister.end(); ++gItr ) { - groupList.push_back( *gItr ); - } + if (withType == "All" || withType.empty()) + { + for (list::const_iterator gItr = m_TotalGroupRegister.begin(); gItr != m_TotalGroupRegister.end(); ++gItr) + groupList.push_back(*gItr); foundAny = !m_TotalGroupRegister.empty(); } // Get type filtered groups from ALL data modules - else { - for( int module = 0; module < ( int )m_pDataModules.size(); ++module ) { - foundAny = GetGroups( groupList, module, withType ) || foundAny; - } + else + { + for (int module = 0; module < (int)m_pDataModules.size(); ++module) + foundAny = GetGroups(groupList, module, withType) || foundAny; } } // Getting modulespace of specific module - else { + else + { // Get all groups of the official modules that are loaded before the specified one - for( int module = 0; module < m_OfficialModuleCount && module < whichModule; ++module ) { - foundAny = GetGroups( groupList, module, withType ) || foundAny; - } + for (int module = 0; module < m_OfficialModuleCount && module < whichModule; ++module) + foundAny = GetGroups(groupList, module, withType) || foundAny; // Now get the groups of the specified module (official or not) - foundAny = GetGroups( groupList, whichModule, withType ) || foundAny; + foundAny = GetGroups(groupList, whichModule, withType) || foundAny; // Make sure there are no dupe groups in the list groupList.sort(); @@ -1071,9 +1027,9 @@ bool PresetMan::GetModuleSpaceGroups( list &groupList, int whichModule, ////////////////////////////////////////////////////////////////////////////////////////// // Description: Creates and returns actor defined in the specified loadout. -Actor *PresetMan::GetLoadout( std::string loadoutName, std::string module, bool spawnDropShip ) +Actor * PresetMan::GetLoadout(std::string loadoutName, std::string module, bool spawnDropShip) { - return GetLoadout( loadoutName, GetModuleID( module ), spawnDropShip ); + return GetLoadout(loadoutName, GetModuleID(module), spawnDropShip); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -1081,59 +1037,58 @@ Actor *PresetMan::GetLoadout( std::string loadoutName, std::string module, bool ////////////////////////////////////////////////////////////////////////////////////////// // Description: Creates and returns actor defined in the specified loadout. -Actor *PresetMan::GetLoadout( std::string loadoutName, int moduleNumber, bool spawnDropShip ) +Actor * PresetMan::GetLoadout(std::string loadoutName, int moduleNumber, bool spawnDropShip) { - if( spawnDropShip ) { - // Find the Loadout that this Deployment is referring to - const Loadout *pLoadout = dynamic_cast( g_PresetMan.GetEntityPreset( "Loadout", - loadoutName, moduleNumber ) ); - if( pLoadout ) { - const ACraft *pCraftPreset = pLoadout->GetDeliveryCraft(); - if( pCraftPreset ) { - ACraft *pCraft = dynamic_cast( pCraftPreset->Clone() ); - if( pCraft ) { - float tally = 0; - // Create and pass along the first Actor and his inventory defined in the Loadout - Actor *pActor = pLoadout->CreateFirstActor( moduleNumber, 1, 1, tally ); - // Set the position and team etc for the Actor we are prepping to spawn - if( pActor ) { - pCraft->AddInventoryItem( pActor ); - } - } - return pCraft; - } - } - } else { - // Find the Loadout that this Deployment is referring to - const Loadout *pLoadout = dynamic_cast( g_PresetMan.GetEntityPreset( "Loadout", - loadoutName, moduleNumber ) ); - if( pLoadout ) { - float tally = 0; - // Create and pass along the first Actor and his inventory defined in the Loadout - Actor *pReturnActor = pLoadout->CreateFirstActor( moduleNumber, 1, 1, tally ); - // Set the position and team etc for the Actor we are prepping to spawn - return pReturnActor; - } - } - - return 0; + if (spawnDropShip) + { + // Find the Loadout that this Deployment is referring to + const Loadout *pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", loadoutName, moduleNumber)); + if (pLoadout) + { + const ACraft * pCraftPreset = pLoadout->GetDeliveryCraft(); + if (pCraftPreset) + { + ACraft * pCraft = dynamic_cast(pCraftPreset->Clone()); + if (pCraft) + { + float tally = 0; + // Create and pass along the first Actor and his inventory defined in the Loadout + Actor * pActor = pLoadout->CreateFirstActor(moduleNumber, 1, 1, tally); + // Set the position and team etc for the Actor we are prepping to spawn + if (pActor) + pCraft->AddInventoryItem(pActor); + } + return pCraft; + } + } + } + else + { + // Find the Loadout that this Deployment is referring to + const Loadout *pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", loadoutName, moduleNumber)); + if (pLoadout) + { + float tally = 0; + // Create and pass along the first Actor and his inventory defined in the Loadout + Actor * pReturnActor = pLoadout->CreateFirstActor(moduleNumber, 1, 1, tally); + // Set the position and team etc for the Actor we are prepping to spawn + return pReturnActor; + } + } + + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void PresetMan::FindAndExtractZippedModules() const -{ - for( const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator( - System::GetWorkingDirectory() ) ) { - std::string zippedModulePath = std::filesystem::path( directoryEntry ).generic_string(); - if( zippedModulePath.find( System::GetZippedModulePackageExtension() ) == zippedModulePath.length() - - System::GetZippedModulePackageExtension().length() ) { - LoadingScreen::LoadingSplashProgressReport( "Extracting Data Module from: " + - directoryEntry.path().filename().generic_string(), true ); - LoadingScreen::LoadingSplashProgressReport( System::ExtractZippedDataModule( zippedModulePath ), - true ); - } - } +void PresetMan::FindAndExtractZippedModules() const { + for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory())) { + std::string zippedModulePath = std::filesystem::path(directoryEntry).generic_string(); + if (zippedModulePath.find(System::GetZippedModulePackageExtension()) == zippedModulePath.length() - System::GetZippedModulePackageExtension().length()) { + LoadingScreen::LoadingSplashProgressReport("Extracting Data Module from: " + directoryEntry.path().filename().generic_string(), true); + LoadingScreen::LoadingSplashProgressReport(System::ExtractZippedDataModule(zippedModulePath), true); + } + } } } // namespace RTE From 59dd5e8284fcab07a4a0232b3e9a9f047a0fb982 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 24 May 2022 22:11:26 +0200 Subject: [PATCH 11/40] add comment --- Managers/PresetMan.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 4540afc21..6d0d888d2 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -319,6 +319,7 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) { + // Scenes.rte and Metagames.rte are loaded last but are official modules anyway const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; const std::string moduleFolder = whichModule < m_OfficialModuleCount || isSpecialCase ? "Data/" : "Mods/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); From 51f7c34ba6c1f245e7b80f447ca58a5656218df9 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Wed, 25 May 2022 15:29:28 +0200 Subject: [PATCH 12/40] properly set package.path for lua scripts --- Managers/LuaMan.cpp | 23 ++++++++++++++++++ Managers/LuaMan.h | 7 ++++++ Managers/PresetMan.cpp | 55 ++++++++++++++++++++++++++++++++++-------- Managers/PresetMan.h | 19 ++++++++++++++- 4 files changed, 93 insertions(+), 11 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index 4895fe6e3..03c3429ce 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -294,6 +294,7 @@ namespace RTE { int error = 0; lua_pushcfunction(m_MasterState, &AddFileAndLineToError); + SetLuaPath(m_MasterState, filePath); // Load the script file's contents onto the stack and then execute it with pcall. Pcall will call the file and line error handler if there's an error by pointing 2 up the stack to it. if (luaL_loadfile(m_MasterState, filePath.c_str()) || lua_pcall(m_MasterState, 0, LUA_MULTRET, -2)) { m_LastError = lua_tostring(m_MasterState, -1); @@ -310,6 +311,28 @@ namespace RTE { return error; } + void LuaMan::SetLuaPath( lua_State *luaState, const std::string &filePath ) + { + const std::string moduleName = g_PresetMan.GetModuleNameFromPath( filePath ); + const int moduleID = g_PresetMan.GetModuleID( moduleName ); + const std::string moduleFolder = g_PresetMan.IsModuleOfficial( moduleID ) ? "Data/" : "Mods/"; + const std::string scriptPath = moduleFolder + moduleName + "/?.lua"; + + lua_getglobal( m_MasterState, "package" ); + lua_getfield( m_MasterState, -1, "path" ); // get field "path" from table at top of stack (-1) + std::string cur_path = lua_tostring( m_MasterState, -1 ); // grab path string from top of stack + + if( cur_path.find( scriptPath ) == cur_path.npos ) { // check if scriptPath is already in there + cur_path.append( ";" ); + cur_path.append( scriptPath ); // if not add it + } + + lua_pop( m_MasterState, 1 ); // get rid of the string on the stack we just pushed previously + lua_pushstring( m_MasterState, cur_path.c_str() ); // push the new one + lua_setfield( m_MasterState, -2, "path" ); // set the field "path" in table at -2 with value at top of stack + lua_pop( m_MasterState, 1 ); // get rid of package table from top of stack + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool LuaMan::ExpressionIsTrue(const std::string &expression, bool consoleErrors) { diff --git a/Managers/LuaMan.h b/Managers/LuaMan.h index f2415736c..03a23de5d 100644 --- a/Managers/LuaMan.h +++ b/Managers/LuaMan.h @@ -108,6 +108,13 @@ namespace RTE { /// Whether to report any errors to the console immediately. /// Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. int RunScriptFile(const std::string &filePath, bool consoleErrors = true); + + /// + /// Sets the proper package.path for the script to run. + /// + /// The script parent state. + /// The path to the file to load and run. + void SetLuaPath(lua_State* luaState, const std::string& filePath); #pragma endregion #pragma region diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 6d0d888d2..949177fbc 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -291,37 +291,72 @@ int PresetMan::GetModuleID(string moduleName) return -1; } +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetModuleNameFromPath +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the Name of a loaded DataModule, from a full data file path. +std::string PresetMan::GetModuleNameFromPath( std::string dataPath ) +{ + if( dataPath.empty() ) { + return ""; + } + + int slashPos = dataPath.find_first_of( '/' ); + if( slashPos == string::npos ) { + slashPos = dataPath.find_first_of( '\\' ); + } + std::string moduleName = dataPath.substr( 0, slashPos ); + // check if path starts with Data/ or Mods/ and remove that part to get to the actual module name + if( moduleName == "Data" || moduleName == "Mods" ) { + std::string shortenPath = dataPath.substr( slashPos + 1 ); + slashPos = shortenPath.find_first_of( '/' ); + if( slashPos == string::npos ) { + slashPos = shortenPath.find_first_of( '\\' ); + } + moduleName = shortenPath.substr( 0, slashPos ); + } + + return moduleName; +} ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetModuleIDFromPath ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule, from a full data file path. -int PresetMan::GetModuleIDFromPath(std::string dataPath) +int PresetMan::GetModuleIDFromPath( std::string dataPath ) { - if (dataPath.empty()) + if( dataPath.empty() ) { return -1; + } - int slashPos = dataPath.find_first_of('/'); - if (slashPos == string::npos) - slashPos = dataPath.find_first_of('\\'); + const std::string moduleName = GetModuleNameFromPath( dataPath ); + return GetModuleID( moduleName ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: IsModuleOfficial +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Returns wether or not the module is vanilla. - return GetModuleID(dataPath.substr(0, slashPos)); +bool PresetMan::IsModuleOfficial(int whichModule) +{ + // Scenes.rte and Metagames.rte are loaded last but are official modules anyway + const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; + return whichModule < m_OfficialModuleCount || isSpecialCase; } ////////////////////////////////////////////////////////////////////////////////////////// // Method: FullModulePath ////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns wether or not the module is vanilla. +// Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. // The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) { - // Scenes.rte and Metagames.rte are loaded last but are official modules anyway - const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; - const std::string moduleFolder = whichModule < m_OfficialModuleCount || isSpecialCase ? "Data/" : "Mods/"; + const std::string moduleFolder = IsModuleOfficial(whichModule) ? "Data/" : "Mods/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); if (topFolder == moduleFolder) { return modulePath; diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 8c9d3e126..e4dd60a6d 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -163,6 +163,14 @@ class PresetMan : public Singleton { int GetModuleID(std::string moduleName); +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetModuleNameFromPath +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the Name of a loaded DataModule, from a full data file path. +// Arguments: The full path to a data file inside the data module id you want to get. +// Return value: The requested Name. If no module of the name was found, "" will be returned. + + std::string GetModuleNameFromPath(std::string dataPath); ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetModuleIDFromPath @@ -174,9 +182,18 @@ class PresetMan : public Singleton { int GetModuleIDFromPath(std::string dataPath); ////////////////////////////////////////////////////////////////////////////////////////// -// Method: FullModulePath +// Method: IsModuleOfficial ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns wether or not the module is vanilla. +// Arguments: The ID of the module to check. +// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. + + bool IsModuleOfficial(int whichModule = 0); + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: FullModulePath +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. // The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. From 72ad09ca31064f536d3a114869383c911a2bc107 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Wed, 25 May 2022 21:59:45 +0200 Subject: [PATCH 13/40] Try override dofile --- Entities/MovableObject.cpp | 2 +- Lua/LuaBindingsManagers.cpp | 4 +++- Managers/LuaMan.cpp | 11 +++++++++++ Managers/PresetMan.cpp | 3 ++- Managers/PresetMan.h | 3 +-- System/ContentFile.cpp | 10 +++++----- System/DataModule.cpp | 6 +++--- System/Reader.cpp | 2 +- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Entities/MovableObject.cpp b/Entities/MovableObject.cpp index e0e75cf55..0d6e89344 100644 --- a/Entities/MovableObject.cpp +++ b/Entities/MovableObject.cpp @@ -342,7 +342,7 @@ int MovableObject::ReadProperty(const std::string_view &propName, Reader &reader PieMenuGUI::StoreCustomLuaPieSlice(newSlice); } else if (propName == "ScriptPath") { - std::string scriptPath = g_PresetMan.FullModulePath(CorrectBackslashesInPath(reader.ReadPropValue()), GetModuleID()); + std::string scriptPath = g_PresetMan.FullModulePath(CorrectBackslashesInPath(reader.ReadPropValue())); switch (LoadScript(CorrectBackslashesInPath(scriptPath))) { case 0: break; diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index bbdaf0b13..d57d8ad22 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -188,7 +188,9 @@ namespace RTE { .def("GetRandomOfGroupInModuleSpace", &PresetMan::GetRandomOfGroupInModuleSpace) .def("GetEntityDataLocation", &PresetMan::GetEntityDataLocation) .def("ReadReflectedPreset", &PresetMan::ReadReflectedPreset) - .def("ReloadAllScripts", &PresetMan::ReloadAllScripts); + .def("ReloadAllScripts", &PresetMan::ReloadAllScripts) + .def("IsModuleOfficial", &PresetMan::IsModuleOfficial) + .def("FullModulePath", &PresetMan::FullModulePath); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index 03c3429ce..a690eb63f 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -176,6 +176,17 @@ namespace RTE { // Add package path to the defaults. "package.path = package.path .. \";Base.rte/?.lua\";\n" ); + // Override dofile() to be able to account for Data/ or Mods/ subfolder + luaL_dostring(m_MasterState, + "OriginalDoFile = dofile;" + "dofile = function(filePath);" + "filePath = FullModulePath(filePath);" + "if filePath ~= \"\";" + "then;" + "return OriginalDoFile(filePath);" + "end;" + "end;" + ); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 949177fbc..b7f9a2023 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -354,8 +354,9 @@ bool PresetMan::IsModuleOfficial(int whichModule) // The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. -std::string PresetMan::FullModulePath(std::string modulePath, int whichModule) +std::string PresetMan::FullModulePath(std::string modulePath) { + const int whichModule = GetModuleIDFromPath(modulePath); const std::string moduleFolder = IsModuleOfficial(whichModule) ? "Data/" : "Mods/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); if (topFolder == moduleFolder) { diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index e4dd60a6d..856760a4a 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -195,10 +195,9 @@ class PresetMan : public Singleton { ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. -// The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. - std::string FullModulePath(std::string modulePath, int whichModule = 0); + std::string FullModulePath(std::string modulePath); ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index e807ba553..bb4b3f198 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -109,7 +109,7 @@ namespace RTE { BITMAP *returnBitmap = nullptr; const int bitDepth = (conversionMode == COLORCONV_8_TO_32) ? BitDepths::ThirtyTwo : BitDepths::Eight; std::string dataPathToLoad = dataPathToSpecificFrame.empty() ? m_DataPath : dataPathToSpecificFrame; - dataPathToLoad = g_PresetMan.FullModulePath(dataPathToLoad, GetDataModuleID()); + dataPathToLoad = g_PresetMan.FullModulePath(dataPathToLoad); SetFormattedReaderPosition(GetFormattedReaderPosition()); // Check if the file has already been read and loaded from the disk and, if so, use that data. @@ -143,8 +143,8 @@ namespace RTE { if (m_DataPath.empty() || frameCount < 1) { return; } - const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath, GetDataModuleID()); - const std::string dataPathWithoutExtensionToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension, GetDataModuleID()); + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath); + const std::string dataPathWithoutExtensionToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension); vectorToFill.reserve(frameCount); SetFormattedReaderPosition(GetFormattedReaderPosition()); @@ -197,7 +197,7 @@ namespace RTE { if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) { return nullptr; } - const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath, GetDataModuleID()); + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath); FMOD::Sound *returnSample = nullptr; @@ -223,7 +223,7 @@ namespace RTE { if (!System::PathExistsCaseSensitive(m_DataPath)) { bool foundAltExtension = false; for (const std::string &altFileExtension : c_SupportedAudioFormats) { - const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension + altFileExtension, GetDataModuleID()); + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension + altFileExtension); if (System::PathExistsCaseSensitive(dataPathToLoad)) { g_ConsoleMan.AddLoadWarningLogEntry(m_DataPath, m_FormattedReaderPosition, altFileExtension); SetDataPath(dataPathToLoad); diff --git a/System/DataModule.cpp b/System/DataModule.cpp index cc3ccd4b4..0a8cc5e56 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -41,8 +41,8 @@ namespace RTE { if (progressCallback) { progressCallback(m_FileName + " " + static_cast(-43) + " loading:", true); } Reader reader; - std::string indexPath = g_PresetMan.FullModulePath(m_FileName + "/Index.ini", m_ModuleID); - std::string mergedIndexPath = g_PresetMan.FullModulePath(m_FileName + "/MergedIndex.ini", m_ModuleID); + std::string indexPath = g_PresetMan.FullModulePath(m_FileName + "/Index.ini"); + std::string mergedIndexPath = g_PresetMan.FullModulePath(m_FileName + "/MergedIndex.ini"); // NOTE: This looks for the MergedIndex.ini generated by the index merger tool. The tool is mostly superseded by disabling loading visuals, but still provides some benefit. if (std::filesystem::exists(mergedIndexPath)) { indexPath = mergedIndexPath; } @@ -366,7 +366,7 @@ namespace RTE { int DataModule::FindAndRead(const ProgressCallback &progressCallback) { int result = 0; - const std::string directoryToScan = g_PresetMan.FullModulePath(m_FileName, m_ModuleID); + const std::string directoryToScan = g_PresetMan.FullModulePath(m_FileName); for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory() + directoryToScan)) { if (directoryEntry.path().extension() == ".ini" && directoryEntry.path().filename() != "Index.ini") { Reader iniReader; diff --git a/System/Reader.cpp b/System/Reader.cpp index 168527c7d..64b18af56 100644 --- a/System/Reader.cpp +++ b/System/Reader.cpp @@ -268,7 +268,7 @@ namespace RTE { if (m_ReportProgress) { m_ReportProgress(m_ReportTabs + m_FileName + " on line " + std::to_string(m_CurrentLine) + " includes:", false); } // Get the file path from the current stream before pushing it into the StreamStack, otherwise we can't open a new stream after releasing it because we can't read. - std::string includeFilePath = g_PresetMan.FullModulePath(std::filesystem::path(ReadPropValue()).generic_string(), GetReadModuleID()); + std::string includeFilePath = g_PresetMan.FullModulePath(std::filesystem::path(ReadPropValue()).generic_string()); // Push the current stream onto the StreamStack for future retrieval when the new include file has run out of data. m_StreamStack.push(StreamInfo(m_Stream.release(), m_FilePath, m_CurrentLine, m_PreviousIndent)); From bc144bd27ef67ad2424e06b7ebaeeb09d0b90ba9 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 30 May 2022 19:00:32 +0200 Subject: [PATCH 14/40] Override dofile to get correct path accordign to module --- Managers/LuaMan.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index a690eb63f..503e4ddea 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -178,14 +178,7 @@ namespace RTE { ); // Override dofile() to be able to account for Data/ or Mods/ subfolder luaL_dostring(m_MasterState, - "OriginalDoFile = dofile;" - "dofile = function(filePath);" - "filePath = FullModulePath(filePath);" - "if filePath ~= \"\";" - "then;" - "return OriginalDoFile(filePath);" - "end;" - "end;" + "OriginalDoFile = dofile dofile = function(filePath) filePath = PresetMan:FullModulePath(filePath) if filePath ~= '' then return OriginalDoFile(filePath) end end;" ); } From 7d3a1791d29723ce617452ea205a19552a401b69 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 30 May 2022 19:51:52 +0200 Subject: [PATCH 15/40] Fix script loading --- System/DataModule.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/System/DataModule.cpp b/System/DataModule.cpp index 0a8cc5e56..fa500e6c0 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -350,7 +350,11 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int DataModule::LoadScripts() const { - return m_ScriptPath.empty() ? 0 : g_LuaMan.RunScriptFile(m_ScriptPath); + if(m_ScriptPath.empty()) { + return 0; + } + const std::string fullScriptPath = g_PresetMan.FullModulePath(m_ScriptPath); + return g_LuaMan.RunScriptFile(fullScriptPath); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// From 9dedcd4498b6ee746eb7cd93afbf530b03ac6013 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 30 May 2022 20:06:07 +0200 Subject: [PATCH 16/40] Fix play music --- Managers/AudioMan.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Managers/AudioMan.cpp b/Managers/AudioMan.cpp index 7cff5e8ec..33485d0fa 100644 --- a/Managers/AudioMan.cpp +++ b/Managers/AudioMan.cpp @@ -6,6 +6,7 @@ #include "ActivityMan.h" #include "SoundContainer.h" #include "GUISound.h" +#include "PresetMan.h" namespace RTE { @@ -235,7 +236,8 @@ namespace RTE { void AudioMan::PlayMusic(const char *filePath, int loops, float volumeOverrideIfNotMuted) { if (m_AudioEnabled) { - if (m_IsInMultiplayerMode) { RegisterMusicEvent(-1, MUSIC_PLAY, filePath, loops); } + const char *fullFilePath = g_PresetMan.FullModulePath(filePath).c_str(); + if (m_IsInMultiplayerMode) { RegisterMusicEvent(-1, MUSIC_PLAY, fullFilePath, loops); } bool musicIsPlaying; FMOD_RESULT result = m_MusicChannelGroup->isPlaying(&musicIsPlaying); @@ -252,7 +254,7 @@ namespace RTE { FMOD::Sound *musicStream; - result = m_AudioSystem->createStream(filePath, FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream); + result = m_AudioSystem->createStream(fullFilePath, FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream); if (result != FMOD_OK) { g_ConsoleMan.PrintString("ERROR: Could not open music file " + std::string(filePath) + ": " + std::string(FMOD_ErrorString(result))); return; @@ -285,7 +287,7 @@ namespace RTE { } } - m_MusicPath = filePath; + m_MusicPath = fullFilePath; result = musicChannel->setCallback(MusicChannelEndedCallback); if (result != FMOD_OK) { From 6b1cdecbf6f0778081c690955c3e928a1e883d2e Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 31 May 2022 11:37:24 +0200 Subject: [PATCH 17/40] Fix sound loading --- System/ContentFile.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index bb4b3f198..9435f4bc5 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -219,14 +219,14 @@ namespace RTE { if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) { return nullptr; } - - if (!System::PathExistsCaseSensitive(m_DataPath)) { + const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPath); + if (!System::PathExistsCaseSensitive(dataPathToLoad)) { bool foundAltExtension = false; for (const std::string &altFileExtension : c_SupportedAudioFormats) { - const std::string dataPathToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension + altFileExtension); - if (System::PathExistsCaseSensitive(dataPathToLoad)) { + const std::string altDataPathToLoad = g_PresetMan.FullModulePath(m_DataPathWithoutExtension + altFileExtension); + if (System::PathExistsCaseSensitive(altDataPathToLoad)) { g_ConsoleMan.AddLoadWarningLogEntry(m_DataPath, m_FormattedReaderPosition, altFileExtension); - SetDataPath(dataPathToLoad); + SetDataPath(altDataPathToLoad); foundAltExtension = true; break; } @@ -238,7 +238,7 @@ namespace RTE { return nullptr; } } - if (std::filesystem::file_size(m_DataPath) == 0) { + if (std::filesystem::file_size(dataPathToLoad) == 0) { const std::string errorMessage = "Failed to create sound because the file was empty. The path and name were: "; RTEAssert(!abortGameForInvalidSound, errorMessage + "\n\n" + m_DataPathAndReaderPosition); g_ConsoleMan.PrintString("ERROR: " + errorMessage + m_DataPath); @@ -247,7 +247,7 @@ namespace RTE { FMOD::Sound *returnSample = nullptr; FMOD_MODE fmodFlags = FMOD_CREATESAMPLE | FMOD_3D | (asyncLoading ? FMOD_NONBLOCKING : FMOD_DEFAULT); - FMOD_RESULT result = g_AudioMan.GetAudioSystem()->createSound(m_DataPath.c_str(), fmodFlags, nullptr, &returnSample); + FMOD_RESULT result = g_AudioMan.GetAudioSystem()->createSound(dataPathToLoad.c_str(), fmodFlags, nullptr, &returnSample); if (result != FMOD_OK) { const std::string errorMessage = "Failed to create sound because of FMOD error:\n" + std::string(FMOD_ErrorString(result)) + "\nThe path and name were: "; From 4bc46c5ba2c451122ff3a31fe0fa0dc41bb91673 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 31 May 2022 11:58:04 +0200 Subject: [PATCH 18/40] fix GUI loading --- GUI/GUIControlManager.cpp | 4 +++- GUI/GUISkin.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/GUI/GUIControlManager.cpp b/GUI/GUIControlManager.cpp index 065a165bb..7566bc062 100644 --- a/GUI/GUIControlManager.cpp +++ b/GUI/GUIControlManager.cpp @@ -1,4 +1,5 @@ #include "GUI.h" +#include "PresetMan.h" using namespace RTE; @@ -404,7 +405,8 @@ bool GUIControlManager::Save(GUIWriter *W) { bool GUIControlManager::Load(const std::string &Filename, bool keepOld) { GUIReader reader; - if (reader.Create(Filename.c_str()) != 0) { + const std::string pathFile = g_PresetMan.FullModulePath(Filename); + if (reader.Create(pathFile.c_str()) != 0) { return false; } diff --git a/GUI/GUISkin.cpp b/GUI/GUISkin.cpp index bc2d4454f..877b1f50d 100644 --- a/GUI/GUISkin.cpp +++ b/GUI/GUISkin.cpp @@ -1,5 +1,6 @@ #include "GUI.h" #include "GUIReader.h" +#include "PresetMan.h" using namespace RTE; @@ -37,7 +38,7 @@ bool GUISkin::Load(const std::string &directory, const std::string &fileName) { // Destroy any previous instances Destroy(); - m_Directory = directory; + m_Directory = g_PresetMan.FullModulePath(directory); GUIReader skinFile; if (skinFile.Create((m_Directory + "/" + fileName).c_str()) == -1) { From 8128f5fa4fd62f8ba805e61d712c0c56a18bd582 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 31 May 2022 12:16:54 +0200 Subject: [PATCH 19/40] fix load script take 2 --- Managers/LuaMan.cpp | 9 +++++---- System/DataModule.cpp | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index 503e4ddea..0d572cf64 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -281,12 +281,13 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int LuaMan::RunScriptFile(const std::string &filePath, bool consoleErrors) { - if (filePath.empty()) { + const std::string fullScriptPath = g_PresetMan.FullModulePath(filePath); + if (fullScriptPath.empty()) { m_LastError = "Can't run a script file with an empty filepath!"; return -1; } - if (!System::PathExistsCaseSensitive(filePath)) { + if (!System::PathExistsCaseSensitive(fullScriptPath)) { m_LastError = "Script file: " + filePath + " doesn't exist!"; if (consoleErrors) { g_ConsoleMan.PrintString("ERROR: " + m_LastError); @@ -298,9 +299,9 @@ namespace RTE { int error = 0; lua_pushcfunction(m_MasterState, &AddFileAndLineToError); - SetLuaPath(m_MasterState, filePath); + SetLuaPath(m_MasterState, fullScriptPath); // Load the script file's contents onto the stack and then execute it with pcall. Pcall will call the file and line error handler if there's an error by pointing 2 up the stack to it. - if (luaL_loadfile(m_MasterState, filePath.c_str()) || lua_pcall(m_MasterState, 0, LUA_MULTRET, -2)) { + if (luaL_loadfile(m_MasterState, fullScriptPath.c_str()) || lua_pcall(m_MasterState, 0, LUA_MULTRET, -2)) { m_LastError = lua_tostring(m_MasterState, -1); lua_pop(m_MasterState, 1); if (consoleErrors) { diff --git a/System/DataModule.cpp b/System/DataModule.cpp index fa500e6c0..0a8cc5e56 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -350,11 +350,7 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int DataModule::LoadScripts() const { - if(m_ScriptPath.empty()) { - return 0; - } - const std::string fullScriptPath = g_PresetMan.FullModulePath(m_ScriptPath); - return g_LuaMan.RunScriptFile(fullScriptPath); + return m_ScriptPath.empty() ? 0 : g_LuaMan.RunScriptFile(m_ScriptPath); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// From 32632795b0ed776a822f9d9475e8468955e854a9 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 31 May 2022 14:01:14 +0200 Subject: [PATCH 20/40] save load cycle --- Entities/Scene.cpp | 7 ++++--- Menus/MetagameGUI.cpp | 5 +++-- System/Reader.cpp | 7 +++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Entities/Scene.cpp b/Entities/Scene.cpp index 1e5cb2a0b..c032d429e 100644 --- a/Entities/Scene.cpp +++ b/Entities/Scene.cpp @@ -1013,14 +1013,15 @@ int Scene::ExpandAIPlanAssemblySchemes() int Scene::SaveData(string pathBase) { - if (pathBase.empty()) + const std::string fullPathBase = g_PresetMan.FullModulePath(pathBase); + if (fullPathBase.empty()) return -1; if (!m_pTerrain) return 0; // Save Terrain's data - if (m_pTerrain->SaveData(pathBase) < 0) + if (m_pTerrain->SaveData(fullPathBase) < 0) { RTEAbort("Saving Terrain " + m_pTerrain->GetPresetName() + "\'s data failed!"); return -1; @@ -1036,7 +1037,7 @@ int Scene::SaveData(string pathBase) { std::snprintf(str, sizeof(str), "T%d", team); // Save unseen layer data to disk - if (m_apUnseenLayer[team]->SaveData(pathBase + " US" + str + ".png") < 0) + if (m_apUnseenLayer[team]->SaveData(fullPathBase + " US" + str + ".bmp") < 0) { g_ConsoleMan.PrintString("ERROR: Saving unseen layer " + m_apUnseenLayer[team]->GetPresetName() + "\'s data failed!"); return -1; diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index fdde9fa3d..845342783 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -1244,6 +1244,7 @@ bool MetagameGUI::LoadGame() bool MetagameGUI::SaveGame(string saveName, string savePath, bool resaveSceneData) { + const std::string fullSavePath = g_PresetMan.FullModulePath(savePath); // If specified, first load all bitmap data of all Scenes in the current Metagame that have once saved em, so we can re-save them to the new files if (resaveSceneData) g_MetaMan.LoadSceneData(); @@ -1256,7 +1257,7 @@ bool MetagameGUI::SaveGame(string saveName, string savePath, bool resaveSceneDat g_MetaMan.SaveSceneData(METASAVEPATH + saveName); // Whichever new or existing, create a writer with the path - Writer metaWriter(savePath.c_str()); + Writer metaWriter(fullSavePath.c_str()); // Now that all the updated data files have been written to disk and their paths updated, send the MetaMan state for actual writing to an ini if (g_MetaMan.Save(metaWriter) < 0) return false; @@ -1269,7 +1270,7 @@ bool MetagameGUI::SaveGame(string saveName, string savePath, bool resaveSceneDat // Create a new MetaSave preset that will hold the runtime info of this new save (so it shows up as something we can overwrite later this same runtime) MetaSave newSave; // This will automatically set all internal members to represent what MetaMan's current state is - newSave.Create(savePath); + newSave.Create(fullSavePath); newSave.SetPresetName(saveName); // Now add or update the actual Preset diff --git a/System/Reader.cpp b/System/Reader.cpp index 64b18af56..d819d70ac 100644 --- a/System/Reader.cpp +++ b/System/Reader.cpp @@ -27,15 +27,14 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int Reader::Create(const std::string &fileName, bool overwrites, const ProgressCallback &progressCallback, bool failOK) { - m_FilePath = std::filesystem::path(fileName).generic_string(); + m_FilePath = g_PresetMan.FullModulePath(std::filesystem::path(fileName).generic_string()); if (m_FilePath.empty()) { return -1; } // Extract the file name and module name from the path - m_FileName = m_FilePath.substr(m_FilePath.find_last_of("/\\") + 1); - const int nameLength = m_FilePath.find_last_of("/\\") - m_FilePath.find_first_of("/\\") -1; - m_DataModuleName = m_FilePath.substr(m_FilePath.find_first_of("/\\") + 1, nameLength); + m_FileName = m_FilePath.substr(m_FilePath.find_last_of("/\\") + 1); + m_DataModuleName = g_PresetMan.GetModuleNameFromPath(m_FilePath); m_DataModuleID = g_PresetMan.GetModuleID(m_DataModuleName); m_CanFail = failOK; From e0395543c57ce8dc3caf1de5009134983aed860b Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 31 May 2022 15:39:40 +0200 Subject: [PATCH 21/40] Fix IsOfficialModule --- Managers/LuaMan.cpp | 3 +-- Managers/PresetMan.cpp | 21 +++++++++++---------- Managers/PresetMan.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index 0d572cf64..df2302304 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -319,8 +319,7 @@ namespace RTE { void LuaMan::SetLuaPath( lua_State *luaState, const std::string &filePath ) { const std::string moduleName = g_PresetMan.GetModuleNameFromPath( filePath ); - const int moduleID = g_PresetMan.GetModuleID( moduleName ); - const std::string moduleFolder = g_PresetMan.IsModuleOfficial( moduleID ) ? "Data/" : "Mods/"; + const std::string moduleFolder = g_PresetMan.IsModuleOfficial(moduleName) ? "Data/" : "Mods/"; const std::string scriptPath = moduleFolder + moduleName + "/?.lua"; lua_getglobal( m_MasterState, "package" ); diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index b7f9a2023..c2da14c9e 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,6 +29,8 @@ #include "LoadingScreen.h" #include "SettingsMan.h" +static const std::array allOfficialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte", "Scenes.rte", "Metagames.rte" }; + namespace RTE { ////////////////////////////////////////////////////////////////////////////////////////// @@ -178,13 +180,14 @@ bool PresetMan::LoadAllDataModules() { return false; } } else { - std::vector workingDirectoryFolders; - std::copy_if(std::filesystem::directory_iterator(System::GetWorkingDirectory()), std::filesystem::directory_iterator(), std::back_inserter(workingDirectoryFolders), + std::vector modDirectoryFolders; + const std::string modDirectory = System::GetWorkingDirectory() + "Mods/"; + std::copy_if(std::filesystem::directory_iterator(modDirectory), std::filesystem::directory_iterator(), std::back_inserter(modDirectoryFolders), [](auto dirEntry){ return std::filesystem::is_directory(dirEntry); } ); - std::sort(workingDirectoryFolders.begin(), workingDirectoryFolders.end()); + std::sort(modDirectoryFolders.begin(), modDirectoryFolders.end()); - for (const std::filesystem::directory_entry &directoryEntry : workingDirectoryFolders) { + for (const std::filesystem::directory_entry &directoryEntry : modDirectoryFolders) { std::string directoryEntryPath = directoryEntry.path().generic_string(); if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) { std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos); @@ -339,11 +342,9 @@ int PresetMan::GetModuleIDFromPath( std::string dataPath ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns wether or not the module is vanilla. -bool PresetMan::IsModuleOfficial(int whichModule) +bool PresetMan::IsModuleOfficial(std::string moduleName) { - // Scenes.rte and Metagames.rte are loaded last but are official modules anyway - const bool isSpecialCase = whichModule >= m_pDataModules.size() - 2; - return whichModule < m_OfficialModuleCount || isSpecialCase; + return std::find(allOfficialModules.begin(), allOfficialModules.end(), moduleName) != allOfficialModules.end(); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -356,8 +357,8 @@ bool PresetMan::IsModuleOfficial(int whichModule) std::string PresetMan::FullModulePath(std::string modulePath) { - const int whichModule = GetModuleIDFromPath(modulePath); - const std::string moduleFolder = IsModuleOfficial(whichModule) ? "Data/" : "Mods/"; + const std::string moduleName = GetModuleNameFromPath(modulePath); + const std::string moduleFolder = IsModuleOfficial(moduleName) ? "Data/" : "Mods/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); if (topFolder == moduleFolder) { return modulePath; diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 856760a4a..467601d35 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -185,10 +185,10 @@ class PresetMan : public Singleton { // Method: IsModuleOfficial ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns wether or not the module is vanilla. -// Arguments: The ID of the module to check. +// Arguments: The Name of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. - bool IsModuleOfficial(int whichModule = 0); + bool IsModuleOfficial(std::string moduleName); ////////////////////////////////////////////////////////////////////////////////////////// // Method: FullModulePath From 7c7fad7782a6d5116dfdcd11eb674a8cfb658f8d Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 6 Jun 2022 13:32:06 +0200 Subject: [PATCH 22/40] fix CollectRequiredAreas --- Activities/GAScripted.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Activities/GAScripted.cpp b/Activities/GAScripted.cpp index 7c383314b..acb715f30 100644 --- a/Activities/GAScripted.cpp +++ b/Activities/GAScripted.cpp @@ -460,7 +460,7 @@ void GAScripted::Draw(BITMAP *pTargetBitmap, const Vector &targetPos) void GAScripted::CollectRequiredAreas() { // Open the script file so we can check it out - std::ifstream *pScriptFile = new std::ifstream(m_ScriptPath.c_str()); + std::ifstream *pScriptFile = new std::ifstream( g_PresetMan.FullModulePath(m_ScriptPath.c_str())); if (!pScriptFile->good()) return; From 6245b1cb71a0bfa25f9ee95afbbf219e97a20a14 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Tue, 19 Jul 2022 18:52:09 +0200 Subject: [PATCH 23/40] Fix PlayMusic not able to load sounds --- Managers/AudioMan.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Managers/AudioMan.cpp b/Managers/AudioMan.cpp index 33485d0fa..d7e3aa82e 100644 --- a/Managers/AudioMan.cpp +++ b/Managers/AudioMan.cpp @@ -236,8 +236,8 @@ namespace RTE { void AudioMan::PlayMusic(const char *filePath, int loops, float volumeOverrideIfNotMuted) { if (m_AudioEnabled) { - const char *fullFilePath = g_PresetMan.FullModulePath(filePath).c_str(); - if (m_IsInMultiplayerMode) { RegisterMusicEvent(-1, MUSIC_PLAY, fullFilePath, loops); } + const std::string fullFilePath = g_PresetMan.FullModulePath(filePath); + if (m_IsInMultiplayerMode) { RegisterMusicEvent(-1, MUSIC_PLAY, fullFilePath.c_str(), loops); } bool musicIsPlaying; FMOD_RESULT result = m_MusicChannelGroup->isPlaying(&musicIsPlaying); @@ -254,15 +254,15 @@ namespace RTE { FMOD::Sound *musicStream; - result = m_AudioSystem->createStream(fullFilePath, FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream); + result = m_AudioSystem->createStream(fullFilePath.c_str(), FMOD_3D_HEADRELATIVE | ((loops == 0 || loops == 1) ? FMOD_LOOP_OFF : FMOD_LOOP_NORMAL), nullptr, &musicStream); if (result != FMOD_OK) { - g_ConsoleMan.PrintString("ERROR: Could not open music file " + std::string(filePath) + ": " + std::string(FMOD_ErrorString(result))); + g_ConsoleMan.PrintString("ERROR: Could not open music file " + fullFilePath + ": " + std::string(FMOD_ErrorString(result))); return; } result = musicStream->setLoopCount(loops); if (result != FMOD_OK && (loops != 0 && loops != 1)) { - g_ConsoleMan.PrintString("ERROR: Failed to set looping for music file: " + std::string(filePath) + ". This means it will only play 1 time, instead of " + (loops == 0 ? "looping endlessly." : loops + " times.") + std::string(FMOD_ErrorString(result))); + g_ConsoleMan.PrintString("ERROR: Failed to set looping for music file: " + fullFilePath + ". This means it will only play 1 time, instead of " + (loops == 0 ? "looping endlessly." : loops + " times.") + std::string(FMOD_ErrorString(result))); } FMOD::Channel *musicChannel; @@ -273,7 +273,7 @@ namespace RTE { result = musicChannel->set3DAttributes(&zero_vector, nullptr); } if (result != FMOD_OK) { - g_ConsoleMan.PrintString("ERROR: Could not play music file: " + std::string(filePath) + ": " + std::string(FMOD_ErrorString(result))); + g_ConsoleMan.PrintString("ERROR: Could not play music file: " + fullFilePath + ": " + std::string(FMOD_ErrorString(result))); return; } result = musicChannel->setPriority(PRIORITY_HIGH); @@ -283,7 +283,7 @@ namespace RTE { volumeOverrideIfNotMuted = std::clamp((volumeOverrideIfNotMuted > 1.0F ? volumeOverrideIfNotMuted / 100.0F : volumeOverrideIfNotMuted), 0.0F, 1.0F); result = musicChannel->setVolume(volumeOverrideIfNotMuted); if (result != FMOD_OK && (loops != 0 && loops != 1)) { - g_ConsoleMan.PrintString("ERROR: Failed to set volume override for music file: " + std::string(filePath) + ". This means it will stay at " + std::to_string(m_MusicVolume) + ": " + std::string(FMOD_ErrorString(result))); + g_ConsoleMan.PrintString("ERROR: Failed to set volume override for music file: " + fullFilePath + ". This means it will stay at " + std::to_string(m_MusicVolume) + ": " + std::string(FMOD_ErrorString(result))); } } From 63de08cd1b37ac1bccaed277349e6ca54d1ef0dc Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 28 Aug 2022 14:31:54 +0200 Subject: [PATCH 24/40] post rebase fixes --- Managers/FrameMan.cpp | 6 ++++-- Menus/ScenarioGUI.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Managers/FrameMan.cpp b/Managers/FrameMan.cpp index 748d67e65..340cce06d 100644 --- a/Managers/FrameMan.cpp +++ b/Managers/FrameMan.cpp @@ -1,5 +1,6 @@ #include "FrameMan.h" #include "PostProcessMan.h" +#include "PresetMan.h" #include "PrimitiveMan.h" #include "PerformanceMan.h" #include "ActivityMan.h" @@ -689,8 +690,9 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool FrameMan::LoadPalette(const std::string &palettePath) { - BITMAP *tempBitmap = load_bitmap(palettePath.c_str(), m_Palette); - RTEAssert(tempBitmap, ("Failed to load palette from bitmap with following path:\n\n" + palettePath).c_str()); + const std::string fullPalettePath = g_PresetMan.FullModulePath(palettePath); + BITMAP *tempBitmap = load_bitmap(fullPalettePath.c_str(), m_Palette); + RTEAssert(tempBitmap, ("Failed to load palette from bitmap with following path:\n\n" + fullPalettePath).c_str()); set_palette(m_Palette); diff --git a/Menus/ScenarioGUI.cpp b/Menus/ScenarioGUI.cpp index 4602ed336..c223c123a 100644 --- a/Menus/ScenarioGUI.cpp +++ b/Menus/ScenarioGUI.cpp @@ -96,7 +96,7 @@ namespace RTE { m_StartActivityConfigButton = dynamic_cast(m_GUIControlManager->GetControl("ButtonStartActivityConfig")); m_DefaultScenePreview.Create(ContentFile("Base.rte/GUIs/DefaultPreview.png"), 5); - m_DefaultScenePreview.SetSpriteAnimMode(MOSprite::SpriteAnimMode::ALWAYSLOOP); + m_DefaultScenePreview.SetSpriteAnimMode(SpriteAnimMode::ALWAYSLOOP); m_DefaultScenePreview.SetSpriteAnimDuration(200); m_DefaultScenePreview.SetPos(Vector(static_cast(m_ScenePreviewImageBox->GetXPos() + (m_ScenePreviewImageBox->GetWidth() / 2)), static_cast(m_ScenePreviewImageBox->GetYPos() + (m_ScenePreviewImageBox->GetHeight() / 2)))); From 51bfbd932ff8ce6ea1cb5e17e940dac52d9e0831 Mon Sep 17 00:00:00 2001 From: Fris0uman <41293484+Fris0uman@users.noreply.github.com> Date: Sun, 25 Sep 2022 11:52:39 +0200 Subject: [PATCH 25/40] Apply suggestions from code review Co-authored-by: MyNameIsTrez <32989873+MyNameIsTrez@users.noreply.github.com> --- Managers/LuaMan.cpp | 2 +- Managers/PresetMan.cpp | 12 ++++++------ System/Reader.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index df2302304..1072f56be 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -326,7 +326,7 @@ namespace RTE { lua_getfield( m_MasterState, -1, "path" ); // get field "path" from table at top of stack (-1) std::string cur_path = lua_tostring( m_MasterState, -1 ); // grab path string from top of stack - if( cur_path.find( scriptPath ) == cur_path.npos ) { // check if scriptPath is already in there + if (cur_path.find(scriptPath) == cur_path.npos) { // check if scriptPath is already in there cur_path.append( ";" ); cur_path.append( scriptPath ); // if not add it } diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index c2da14c9e..a1c053af0 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -300,20 +300,20 @@ int PresetMan::GetModuleID(string moduleName) // Description: Gets the Name of a loaded DataModule, from a full data file path. std::string PresetMan::GetModuleNameFromPath( std::string dataPath ) { - if( dataPath.empty() ) { + if (dataPath.empty()) { return ""; } int slashPos = dataPath.find_first_of( '/' ); - if( slashPos == string::npos ) { + if (slashPos == string::npos) { slashPos = dataPath.find_first_of( '\\' ); } std::string moduleName = dataPath.substr( 0, slashPos ); // check if path starts with Data/ or Mods/ and remove that part to get to the actual module name - if( moduleName == "Data" || moduleName == "Mods" ) { + if (moduleName == "Data" || moduleName == "Mods") { std::string shortenPath = dataPath.substr( slashPos + 1 ); slashPos = shortenPath.find_first_of( '/' ); - if( slashPos == string::npos ) { + if (slashPos == string::npos) { slashPos = shortenPath.find_first_of( '\\' ); } moduleName = shortenPath.substr( 0, slashPos ); @@ -329,7 +329,7 @@ std::string PresetMan::GetModuleNameFromPath( std::string dataPath ) int PresetMan::GetModuleIDFromPath( std::string dataPath ) { - if( dataPath.empty() ) { + if (dataPath.empty()) { return -1; } @@ -353,7 +353,7 @@ bool PresetMan::IsModuleOfficial(std::string moduleName) // Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. // The ID of the module to check. -// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. +// Return value: The complete path to the file, including Data/ or Mods/ based on whether or not it's part of an official module. std::string PresetMan::FullModulePath(std::string modulePath) { diff --git a/System/Reader.cpp b/System/Reader.cpp index d819d70ac..54605071d 100644 --- a/System/Reader.cpp +++ b/System/Reader.cpp @@ -33,7 +33,7 @@ namespace RTE { return -1; } // Extract the file name and module name from the path - m_FileName = m_FilePath.substr(m_FilePath.find_last_of("/\\") + 1); + m_FileName = m_FilePath.substr(m_FilePath.find_last_of("/\\") + 1); m_DataModuleName = g_PresetMan.GetModuleNameFromPath(m_FilePath); m_DataModuleID = g_PresetMan.GetModuleID(m_DataModuleName); From 71b4462f7b68c9ad53beaaf4ea96f5d8fc491b26 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 25 Sep 2022 12:56:54 +0200 Subject: [PATCH 26/40] clean up --- Managers/PresetMan.cpp | 9 ++++----- Menus/TitleScreen.cpp | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index a1c053af0..562da9604 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -298,7 +298,7 @@ int PresetMan::GetModuleID(string moduleName) // Method: GetModuleNameFromPath ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the Name of a loaded DataModule, from a full data file path. -std::string PresetMan::GetModuleNameFromPath( std::string dataPath ) +std::string PresetMan::GetModuleNameFromPath(std::string dataPath) { if (dataPath.empty()) { return ""; @@ -327,14 +327,14 @@ std::string PresetMan::GetModuleNameFromPath( std::string dataPath ) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Gets the ID of a loaded DataModule, from a full data file path. -int PresetMan::GetModuleIDFromPath( std::string dataPath ) +int PresetMan::GetModuleIDFromPath(std::string dataPath) { if (dataPath.empty()) { return -1; } - const std::string moduleName = GetModuleNameFromPath( dataPath ); - return GetModuleID( moduleName ); + const std::string moduleName = GetModuleNameFromPath(dataPath); + return GetModuleID(moduleName); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,6 @@ bool PresetMan::IsModuleOfficial(std::string moduleName) ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. -// The ID of the module to check. // Return value: The complete path to the file, including Data/ or Mods/ based on whether or not it's part of an official module. std::string PresetMan::FullModulePath(std::string modulePath) diff --git a/Menus/TitleScreen.cpp b/Menus/TitleScreen.cpp index 857d7a3cc..2ba29038a 100644 --- a/Menus/TitleScreen.cpp +++ b/Menus/TitleScreen.cpp @@ -102,6 +102,7 @@ namespace RTE { m_Moon.Create(ContentFile("Base.rte/GUIs/Title/Moon.png")); m_Station.Create(ContentFile("Base.rte/GUIs/Title/Station.png")); m_Nebula.Create(ContentFile("Base.rte/GUIs/Title/Nebula.png"), false, Vector(), false, false, Vector(0, -1.0F)); + m_Nebula.SetScrollRatio(Vector(-1.0F, 1.0F / 3.0F)); set_write_alpha_blender(); draw_trans_sprite(m_PreGameLogoText.GetSpriteFrame(0), ContentFile("Base.rte/GUIs/Title/Intro/PreTitleAlpha.png").GetAsBitmap(), 0, 0); @@ -145,7 +146,7 @@ namespace RTE { void TitleScreen::CreateIntroSequenceSlides() { std::string highRes = (g_FrameMan.GetResY() >= 680) ? "HD" : ""; for (int slideNum = 0; slideNum < m_IntroSlides.size(); ++slideNum) { - m_IntroSlides.at(slideNum) = ContentFile(("Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); + m_IntroSlides[slideNum] = ContentFile(("Base.rte/GUIs/Title/Intro/IntroSlide" + std::to_string(slideNum + 1) + highRes + ".png").c_str()).GetAsBitmap(); } } From 447e4cf8ead28bb349ea8d2533dfc7a05586876b Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Thu, 17 Nov 2022 13:56:00 +0100 Subject: [PATCH 27/40] format --- Lua/LuaBindingsManagers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index 604a1636b..597247d5e 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -191,7 +191,7 @@ namespace RTE { .def("ReloadEntityPreset", ReloadEntityPreset1) .def("ReloadEntityPreset", ReloadEntityPreset2) .def("ReloadAllScripts", &PresetMan::ReloadAllScripts) - .def("IsModuleOfficial", &PresetMan::IsModuleOfficial) + .def("IsModuleOfficial", &PresetMan::IsModuleOfficial) .def("FullModulePath", &PresetMan::FullModulePath); } From bc8be6897a757477f658c8f0e1bbde04dac91836 Mon Sep 17 00:00:00 2001 From: Stuart Date: Mon, 26 Dec 2022 19:34:48 +1030 Subject: [PATCH 28/40] fix: update `ContentFile::GetImageFileInfo()` to check module path --- System/ContentFile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/System/ContentFile.cpp b/System/ContentFile.cpp index 264fcc8a9..b0a099391 100644 --- a/System/ContentFile.cpp +++ b/System/ContentFile.cpp @@ -117,7 +117,8 @@ namespace RTE { } } if (fetchFileInfo) { - FILE *imageFile = fopen(m_DataPath.c_str(), "rb"); + std::string altDataPath = g_PresetMan.FullModulePath(m_DataPath); + FILE *imageFile = fopen(altDataPath.c_str(), "rb"); RTEAssert(imageFile, "Failed to open file prior to reading info of image file with following path and name:\n\n" + m_DataPath + "\n\nThe file may not exist or be corrupt."); if (m_DataPathExtension == ".png") { From 4e1d67c6498d79093397fac9cd98576eba1fc26a Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:16:13 +1030 Subject: [PATCH 29/40] style: ignore vscode workspace settings --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c4018379e..494d42a58 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ compile_commands.json /NATPunchServer/Server/NATCompleteServer/Debug /NATPunchServer/Server/NATCompleteServer/Release /Documentation/Doxygen/Output -MemCleanupInfo.txt \ No newline at end of file +MemCleanupInfo.txt +.vscode From a4f7bbc26c1d2e1bff2d16ccf01eaba968c7c764 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:17:15 +1030 Subject: [PATCH 30/40] style: updated XML doc comments to match standard --- Managers/PresetMan.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 20f0dc045..0c58df17f 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -173,13 +173,11 @@ class PresetMan : public Singleton { int GetModuleIDFromPath(std::string dataPath); -////////////////////////////////////////////////////////////////////////////////////////// -// Method: IsModuleOfficial -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns wether or not the module is vanilla. -// Arguments: The Name of the module to check. -// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. - + /// + /// Returns whether or not the module is vanilla. + /// + /// The name of the module to check, in the form "[moduleName].rte" + /// True if the module is an official data module, otherwise false. bool IsModuleOfficial(std::string moduleName); ////////////////////////////////////////////////////////////////////////////////////////// @@ -187,7 +185,7 @@ class PresetMan : public Singleton { ////////////////////////////////////////////////////////////////////////////////////////// // Description: Returns the Full path to the module including Data/ or Mods/. // Arguments: The Path to be completed. -// Return value: The complete path to the file, including Data/ or Mods/ wether or not it's part of an official module. +// Return value: The complete path to the file, including Data/ or Mods/ whether or not it's part of an official module. std::string FullModulePath(std::string modulePath); From b45def717d7ec718de12f4c0c30cf75f08cc927e Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:24:26 +1030 Subject: [PATCH 31/40] feat: add PresetMan utility function `IsModuleUserdata()` Refactor PresetMan to contain a static reference to all official & userdata modules. Add the new function `IsModuleUserdata()` that takes a module name and checks if it exists in our list of defined modules. Replaced some duplicated checks with these new utility functions (including `IsModuleOfficial()`) --- Managers/PresetMan.cpp | 35 +++++++++++++++++++---------------- Managers/PresetMan.h | 9 +++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index f9ecc400b..1f430c535 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -29,10 +29,17 @@ #include "LoadingScreen.h" #include "SettingsMan.h" -static const std::array allOfficialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte", "Scenes.rte", "Metagames.rte" }; + namespace RTE { + static const std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; + static const std::array, 3> userdataModules = { { + {c_UserScenesModuleName, "User Scenes"}, + {c_UserConquestSavesModuleName, "Conquest Saves"}, + {c_UserScriptedSavesModuleName, "Scripted Activity Saves" } + } }; + ////////////////////////////////////////////////////////////////////////////////////////// // Method: Clear ////////////////////////////////////////////////////////////////////////////////////////// @@ -144,13 +151,6 @@ bool PresetMan::LoadAllDataModules() { FindAndExtractZippedModules(); - std::array officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" }; - std::array, 3> userdataModules = {{ - {c_UserScenesModuleName, "User Scenes"}, - {c_UserConquestSavesModuleName, "Conquest Saves"}, - {c_UserScriptedSavesModuleName, "Scripted Activity Saves" } - }}; - // Load all the official modules first! for (const std::string &officialModule : officialModules) { if (!LoadDataModule(officialModule, true, false, LoadingScreen::LoadingSplashProgressReport)) { @@ -176,9 +176,8 @@ bool PresetMan::LoadAllDataModules() { std::string directoryEntryPath = directoryEntry.path().generic_string(); if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) { std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos); - if (!g_SettingsMan.IsModDisabled(moduleName) && std::find(officialModules.begin(), officialModules.end(), moduleName) == officialModules.end()) { - auto userdataModuleItr = std::find_if(userdataModules.begin(), userdataModules.end(), [&moduleName](const auto &userdataModulesEntry) { return userdataModulesEntry.first == moduleName; }); - if (userdataModuleItr == userdataModules.end()) { + if (!g_SettingsMan.IsModDisabled(moduleName) && !IsModuleOfficial(moduleName)) { + if (!IsModuleUserdata(moduleName)) { int moduleID = GetModuleID(moduleName); // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) { LoadDataModule(moduleName, false, false, LoadingScreen::LoadingSplashProgressReport); } @@ -329,14 +328,18 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath) return GetModuleID(moduleName); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: IsModuleOfficial -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns wether or not the module is vanilla. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool PresetMan::IsModuleOfficial(std::string moduleName) { - return std::find(allOfficialModules.begin(), allOfficialModules.end(), moduleName) != allOfficialModules.end(); + return std::find(officialModules.begin(), officialModules.end(), moduleName) != officialModules.end(); +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +bool PresetMan::IsModuleUserdata(std::string moduleName) { + auto userdataModuleItr = std::find_if(userdataModules.begin(), userdataModules.end(), [&moduleName](const auto &userdataModulesEntry) { return userdataModulesEntry.first == moduleName; }); + return userdataModuleItr != userdataModules.end(); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index 0c58df17f..ea155796d 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -179,6 +179,15 @@ class PresetMan : public Singleton { /// The name of the module to check, in the form "[moduleName].rte" /// True if the module is an official data module, otherwise false. bool IsModuleOfficial(std::string moduleName); + + + /// + /// Returns whether or not the module is vanilla. + /// + /// The name of the module to check, in the form "[moduleName].rte" + /// True if the module is a listed user data module, otherwise false. + bool IsModuleUserdata(std::string moduleName); + ////////////////////////////////////////////////////////////////////////////////////////// // Method: FullModulePath From d019d2b8cc09a9d23ce7effe815b1906e3b996c1 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:25:00 +1030 Subject: [PATCH 32/40] feat: reenable generation of an empty `Mods` directory on initialise --- System/System.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/System/System.cpp b/System/System.cpp index 0fa6d1ca2..83befb704 100644 --- a/System/System.cpp +++ b/System/System.cpp @@ -15,7 +15,7 @@ namespace RTE { std::filesystem::file_time_type System::s_ProgramStartTime = std::filesystem::file_time_type::clock::now(); bool System::s_CaseSensitive = true; const std::string System::s_ScreenshotDirectory = "_ScreenShots"; - const std::string System::s_ModDirectory = "_Mods"; + const std::string System::s_ModDirectory = "Mods"; const std::string System::s_ModulePackageExtension = ".rte"; const std::string System::s_ZippedModulePackageExtension = ".rte.zip"; const std::unordered_set System::s_SupportedExtensions = { ".ini", ".txt", ".lua", ".cfg", ".bmp", ".png", ".jpg", ".jpeg", ".wav", ".ogg", ".mp3", ".flac" }; @@ -27,7 +27,7 @@ namespace RTE { if (s_WorkingDirectory.back() != '/') { s_WorkingDirectory.append("/"); } if (!std::filesystem::exists(s_WorkingDirectory + s_ScreenshotDirectory)) { MakeDirectory(s_WorkingDirectory + s_ScreenshotDirectory); } - //if (!std::filesystem::exists(s_WorkingDirectory + s_ModDirectory)) { MakeDirectory(s_WorkingDirectory + s_ModDirectory); } + if (!std::filesystem::exists(s_WorkingDirectory + s_ModDirectory)) { MakeDirectory(s_WorkingDirectory + s_ModDirectory); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// From 594f9955eed5435382c89b5795280a687f056658 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:34:35 +1030 Subject: [PATCH 33/40] feat: `PresetMan::FullModulePath()` now distinguishes userdata modules and returns a path as such Update XML doc comments to match standard. --- Managers/PresetMan.cpp | 9 ++------- Managers/PresetMan.h | 14 +++++--------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 1f430c535..164e47070 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -342,17 +342,12 @@ bool PresetMan::IsModuleUserdata(std::string moduleName) { return userdataModuleItr != userdataModules.end(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: FullModulePath -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns the Full path to the module including Data/ or Mods/. -// Arguments: The Path to be completed. -// Return value: The complete path to the file, including Data/ or Mods/ based on whether or not it's part of an official module. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::string PresetMan::FullModulePath(std::string modulePath) { const std::string moduleName = GetModuleNameFromPath(modulePath); - const std::string moduleFolder = IsModuleOfficial(moduleName) ? "Data/" : "Mods/"; + const std::string moduleFolder = IsModuleOfficial(moduleName) ? "Data/" : IsModuleUserdata(moduleName) ? "Userdata/" : "Mods/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); if (topFolder == moduleFolder) { return modulePath; diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index ea155796d..a2c75b2c0 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -188,17 +188,13 @@ class PresetMan : public Singleton { /// True if the module is a listed user data module, otherwise false. bool IsModuleUserdata(std::string moduleName); - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: FullModulePath -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns the Full path to the module including Data/ or Mods/. -// Arguments: The Path to be completed. -// Return value: The complete path to the file, including Data/ or Mods/ whether or not it's part of an official module. - + /// + /// Returns the Full path to the module including Data/, Userdata/ or Mods/. + /// + /// The Path to be completed. + /// The complete path to the file, including Data/, Userdata/ or Mods/ based on whether or not it's part of an official module or userdata. std::string FullModulePath(std::string modulePath); - ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetTotalModuleCount ////////////////////////////////////////////////////////////////////////////////////////// From 634871003e8d3b15051fa5c2249ce23045072a50 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:37:37 +1030 Subject: [PATCH 34/40] feat: generate a `Userdata/` directory on `System` init Refactor all directory generation checks to use case-sensitive members. Remove the leading underscore from generated Screenshots directory. --- System/System.cpp | 8 +++++--- System/System.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/System/System.cpp b/System/System.cpp index 83befb704..b98900373 100644 --- a/System/System.cpp +++ b/System/System.cpp @@ -14,8 +14,9 @@ namespace RTE { std::vector System::s_WorkingTree; std::filesystem::file_time_type System::s_ProgramStartTime = std::filesystem::file_time_type::clock::now(); bool System::s_CaseSensitive = true; - const std::string System::s_ScreenshotDirectory = "_ScreenShots"; + const std::string System::s_ScreenshotDirectory = "ScreenShots"; const std::string System::s_ModDirectory = "Mods"; + const std::string System::s_UserdataDirectory = "Userdata"; const std::string System::s_ModulePackageExtension = ".rte"; const std::string System::s_ZippedModulePackageExtension = ".rte.zip"; const std::unordered_set System::s_SupportedExtensions = { ".ini", ".txt", ".lua", ".cfg", ".bmp", ".png", ".jpg", ".jpeg", ".wav", ".ogg", ".mp3", ".flac" }; @@ -26,8 +27,9 @@ namespace RTE { s_WorkingDirectory = std::filesystem::current_path().generic_string(); if (s_WorkingDirectory.back() != '/') { s_WorkingDirectory.append("/"); } - if (!std::filesystem::exists(s_WorkingDirectory + s_ScreenshotDirectory)) { MakeDirectory(s_WorkingDirectory + s_ScreenshotDirectory); } - if (!std::filesystem::exists(s_WorkingDirectory + s_ModDirectory)) { MakeDirectory(s_WorkingDirectory + s_ModDirectory); } + if (!PathExistsCaseSensitive(s_WorkingDirectory + s_ScreenshotDirectory)) { MakeDirectory(s_WorkingDirectory + s_ScreenshotDirectory); } + if (!PathExistsCaseSensitive(s_WorkingDirectory + s_ModDirectory)) { MakeDirectory(s_WorkingDirectory + s_ModDirectory); } + if (!PathExistsCaseSensitive(s_WorkingDirectory + s_UserdataDirectory)) { MakeDirectory(s_WorkingDirectory + s_UserdataDirectory); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/System/System.h b/System/System.h index 0b888fbb1..544ffd98a 100644 --- a/System/System.h +++ b/System/System.h @@ -156,6 +156,7 @@ namespace RTE { static bool s_CaseSensitive; //!< Whether case sensitivity is enforced when checking for file existence. static const std::string s_ScreenshotDirectory; //!< String containing the folder name of the screenshots directory. static const std::string s_ModDirectory; //!< String containing the folder name of the mod directory. + static const std::string s_UserdataDirectory; //!< String containing the folder name of the userdata directory. static const std::string s_ModulePackageExtension; //!< The extension that determines a directory/file is a RTE module. static const std::string s_ZippedModulePackageExtension; //!< The extension that determines a file is a zipped RTE module. From 73095f5f176e282b24add95a93a5a12336ce96c4 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:43:18 +1030 Subject: [PATCH 35/40] feat: add `System` userdata directory name getter --- System/System.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/System/System.h b/System/System.h index 544ffd98a..5dfd7a75a 100644 --- a/System/System.h +++ b/System/System.h @@ -55,6 +55,13 @@ namespace RTE { /// Folder name of the mod directory. static const std::string & GetModDirectory() { return s_ModDirectory; } + + /// + /// Gets the userdata directory name. + /// + /// Folder name of the userdata directory. + static const std::string &GetUserdataDirectory() { return s_UserdataDirectory; } + /// /// Gets the extension that determines a directory/file is an RTE module. /// From 9bf12c930f94a3d6bd265bec052e4ce2ea36cf68 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:51:39 +1030 Subject: [PATCH 36/40] feat!: `CreateOnDiskAsUserdata()` now creates modules in the userdata dir --- System/DataModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/System/DataModule.cpp b/System/DataModule.cpp index df5a93175..a54a7d006 100644 --- a/System/DataModule.cpp +++ b/System/DataModule.cpp @@ -70,7 +70,7 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool DataModule::CreateOnDiskAsUserdata(const std::string &moduleName, const std::string_view &friendlyName, bool ignoreMissingItems, bool scanFolderContents) { - std::string moduleNameWithPackageExtension = moduleName + ((moduleName.find(System::GetModulePackageExtension()) == moduleName.length() - System::GetModulePackageExtension().length()) ? "" : System::GetModulePackageExtension()); + std::string moduleNameWithPackageExtension = System::GetUserdataDirectory() + "/" + moduleName + ((moduleName.find(System::GetModulePackageExtension()) == moduleName.length() - System::GetModulePackageExtension().length()) ? "" : System::GetModulePackageExtension()); if (Writer writer(moduleNameWithPackageExtension + "/Index.ini", false, true); writer.WriterOK()) { DataModule newModule; newModule.m_IsUserdata = true; From 15f96748e8c915e3e6bb4ce20583ac84bfed0cfa Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 16:52:16 +1030 Subject: [PATCH 37/40] feat: `FullModulePath()` now gets directory names from `System` references. --- Managers/PresetMan.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 164e47070..fc523922d 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -159,14 +159,14 @@ bool PresetMan::LoadAllDataModules() { } // If a single module is specified, skip loading all other unofficial modules and load specified module only. - if (!m_SingleModuleToLoad.empty() && std::find(officialModules.begin(), officialModules.end(), m_SingleModuleToLoad) == officialModules.end()) { + if (!m_SingleModuleToLoad.empty() && !IsModuleOfficial(m_SingleModuleToLoad)) { if (!LoadDataModule(m_SingleModuleToLoad, false, false, LoadingScreen::LoadingSplashProgressReport)) { g_ConsoleMan.PrintString("ERROR: Failed to load DataModule \"" + m_SingleModuleToLoad + "\"! Only official modules were loaded!"); return false; } } else { std::vector modDirectoryFolders; - const std::string modDirectory = System::GetWorkingDirectory() + "Mods/"; + const std::string modDirectory = System::GetWorkingDirectory() + System::GetModDirectory() + "/"; std::copy_if(std::filesystem::directory_iterator(modDirectory), std::filesystem::directory_iterator(), std::back_inserter(modDirectoryFolders), [](auto dirEntry){ return std::filesystem::is_directory(dirEntry); } ); @@ -347,7 +347,7 @@ bool PresetMan::IsModuleUserdata(std::string moduleName) { std::string PresetMan::FullModulePath(std::string modulePath) { const std::string moduleName = GetModuleNameFromPath(modulePath); - const std::string moduleFolder = IsModuleOfficial(moduleName) ? "Data/" : IsModuleUserdata(moduleName) ? "Userdata/" : "Mods/"; + const std::string moduleFolder = (IsModuleOfficial(moduleName) ? "Data" : IsModuleUserdata(moduleName) ? System::GetUserdataDirectory() : System::GetModDirectory()) + "/"; const std::string topFolder = modulePath.substr(0, modulePath.find_first_of("/\\") + 1); if (topFolder == moduleFolder) { return modulePath; From 44fb3dda00994128edd21530efa19fb936a52bdf Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 17:05:35 +1030 Subject: [PATCH 38/40] fix: fixed hardcoded/missing dir name references XML Comment refactoring remove more hardcoded references to mods folder, accommodate userdata in path utilities --- Managers/LuaMan.cpp | 2 +- Managers/PresetMan.cpp | 11 +++++------ Managers/PresetMan.h | 12 +++++------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Managers/LuaMan.cpp b/Managers/LuaMan.cpp index a76254ad5..f703a33a9 100644 --- a/Managers/LuaMan.cpp +++ b/Managers/LuaMan.cpp @@ -375,7 +375,7 @@ namespace RTE { void LuaMan::SetLuaPath( lua_State *luaState, const std::string &filePath ) { const std::string moduleName = g_PresetMan.GetModuleNameFromPath( filePath ); - const std::string moduleFolder = g_PresetMan.IsModuleOfficial(moduleName) ? "Data/" : "Mods/"; + const std::string moduleFolder = g_PresetMan.IsModuleOfficial(moduleName) ? "Data/" : System::GetModDirectory() + "/"; const std::string scriptPath = moduleFolder + moduleName + "/?.lua"; lua_getglobal( m_MasterState, "package" ); diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index fc523922d..06ec900b5 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -285,10 +285,8 @@ int PresetMan::GetModuleID(std::string moduleName) return -1; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetModuleNameFromPath -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the Name of a loaded DataModule, from a full data file path. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + std::string PresetMan::GetModuleNameFromPath(std::string dataPath) { if (dataPath.empty()) { @@ -300,8 +298,9 @@ std::string PresetMan::GetModuleNameFromPath(std::string dataPath) slashPos = dataPath.find_first_of( '\\' ); } std::string moduleName = dataPath.substr( 0, slashPos ); - // check if path starts with Data/ or Mods/ and remove that part to get to the actual module name - if (moduleName == "Data" || moduleName == "Mods") { + + // Check if path starts with Data/ or the Mods/Userdata dir names and remove that part to get to the actual module name. + if (moduleName == "Data" || moduleName == System::GetModDirectory() || moduleName == System::GetUserdataDirectory()) { std::string shortenPath = dataPath.substr( slashPos + 1 ); slashPos = shortenPath.find_first_of( '/' ); if (slashPos == std::string::npos) { diff --git a/Managers/PresetMan.h b/Managers/PresetMan.h index a2c75b2c0..6979ea6c0 100644 --- a/Managers/PresetMan.h +++ b/Managers/PresetMan.h @@ -155,13 +155,11 @@ class PresetMan : public Singleton { int GetModuleID(std::string moduleName); -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetModuleNameFromPath -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the Name of a loaded DataModule, from a full data file path. -// Arguments: The full path to a data file inside the data module id you want to get. -// Return value: The requested Name. If no module of the name was found, "" will be returned. - + /// + /// Gets the Name of a loaded DataModule, from a full data file path. + /// + /// The full path to a data file inside the data module id you want to get. + /// The requested Name. If no module of the name was found, "" will be returned. std::string GetModuleNameFromPath(std::string dataPath); ////////////////////////////////////////////////////////////////////////////////////////// From eb74c0c96adc63d0904a5f3b1e9aad3a4c852492 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 21:02:54 +1030 Subject: [PATCH 39/40] feat: add Lua binding to check if module is userdata Fix un-needed indentation level --- Lua/LuaBindingsManagers.cpp | 1 + Managers/PresetMan.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index 0b6a6fe31..22d333c55 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -193,6 +193,7 @@ namespace RTE { .def("ReloadEntityPreset", &LuaAdaptersPresetMan::ReloadEntityPreset2) .def("ReloadAllScripts", &PresetMan::ReloadAllScripts) .def("IsModuleOfficial", &PresetMan::IsModuleOfficial) + .def("IsModuleUserdata", &PresetMan::IsModuleUserdata) .def("FullModulePath", &PresetMan::FullModulePath); } diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 06ec900b5..726311941 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -176,12 +176,10 @@ bool PresetMan::LoadAllDataModules() { std::string directoryEntryPath = directoryEntry.path().generic_string(); if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) { std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos); - if (!g_SettingsMan.IsModDisabled(moduleName) && !IsModuleOfficial(moduleName)) { - if (!IsModuleUserdata(moduleName)) { - int moduleID = GetModuleID(moduleName); - // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. - if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) { LoadDataModule(moduleName, false, false, LoadingScreen::LoadingSplashProgressReport); } - } + if (!g_SettingsMan.IsModDisabled(moduleName) && !IsModuleOfficial(moduleName) && !IsModuleUserdata(moduleName)) { + int moduleID = GetModuleID(moduleName); + // NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here. + if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) { LoadDataModule(moduleName, false, false, LoadingScreen::LoadingSplashProgressReport); } } } } From f67712d122438771d7d9e85f80b12b1f3e0cfc65 Mon Sep 17 00:00:00 2001 From: Stuart Date: Sun, 1 Jan 2023 21:04:39 +1030 Subject: [PATCH 40/40] fix: ensure activities can save and load to the correct directory Fix bugs in ActivityMan preventing writers/readers from targeting the correct save files GAScripted now reads in correct script path --- Activities/GAScripted.cpp | 2 +- Managers/ActivityMan.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Activities/GAScripted.cpp b/Activities/GAScripted.cpp index 863abf1b3..3fa46be3b 100644 --- a/Activities/GAScripted.cpp +++ b/Activities/GAScripted.cpp @@ -114,7 +114,7 @@ int GAScripted::Create(const GAScripted &reference) { int GAScripted::ReadProperty(const std::string_view &propName, Reader &reader) { if (propName == "ScriptPath") { - m_ScriptPath = CorrectBackslashesInPath(reader.ReadPropValue()); + m_ScriptPath = CorrectBackslashesInPath(g_PresetMan.FullModulePath(CorrectBackslashesInPath(reader.ReadPropValue()))); } else if (propName == "LuaClassName") { reader >> m_LuaClassName; } else if (propName == "AddPieSlice") { diff --git a/Managers/ActivityMan.cpp b/Managers/ActivityMan.cpp index fea8551ad..67a3d37f9 100644 --- a/Managers/ActivityMan.cpp +++ b/Managers/ActivityMan.cpp @@ -91,7 +91,7 @@ namespace RTE { modifiableScene->SetSavedGameInternal(true); // Block the main thread for a bit to let the Writer access the relevant data. - std::unique_ptr writer(std::make_unique(c_UserScriptedSavesModuleName + "/" + fileName + ".ini")); + std::unique_ptr writer(std::make_unique(g_PresetMan.FullModulePath(c_UserScriptedSavesModuleName) + "/" + fileName + ".ini")); writer->NewPropertyWithValue("Activity", activity); writer->NewPropertyWithValue("OriginalScenePresetName", scene->GetPresetName()); writer->NewPropertyWithValue("PlaceObjectsIfSceneIsRestarted", g_SceneMan.GetPlaceObjectsOnLoad()); @@ -120,7 +120,7 @@ namespace RTE { std::unique_ptr scene(std::make_unique()); std::unique_ptr activity(std::make_unique()); - Reader reader(c_UserScriptedSavesModuleName + "/" + fileName + ".ini", true, nullptr, true); + Reader reader(g_PresetMan.FullModulePath(c_UserScriptedSavesModuleName) + "/" + fileName + ".ini", true, nullptr, true); if (!reader.ReaderOK()) { g_ConsoleMan.PrintString("ERROR: Game loading failed! Make sure you have a saved game called \"" + fileName + "\""); return false;