diff --git a/.gitmodules b/.gitmodules index 7098d9d0822..6716a1dddd4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "libultraship"] path = libultraship url = https://github.com/kenix3/libultraship.git + branch = port-maintenance [submodule "ZAPDTR"] path = ZAPDTR url = https://github.com/harbourmasters/ZAPDTR diff --git a/libultraship b/libultraship index f30fe0ed1e9..1d982914044 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit f30fe0ed1e9a73ee6f47067a56fa22039c397baf +Subproject commit 1d9829140444268827a1369095bcc93518ff3b4d diff --git a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp index 13967b5662b..5a7935fd7cc 100644 --- a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp +++ b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp @@ -65,7 +65,7 @@ static void DeleteFileOnDeath() { SaveManager::Instance->DeleteZeldaFile(gSaveContext.fileNum); hasAffectedHealth = false; std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); } } diff --git a/soh/soh/Enhancements/FileSelectEnhancements.cpp b/soh/soh/Enhancements/FileSelectEnhancements.cpp index 08dd815094f..7f26d02c187 100644 --- a/soh/soh/Enhancements/FileSelectEnhancements.cpp +++ b/soh/soh/Enhancements/FileSelectEnhancements.cpp @@ -84,7 +84,7 @@ void SohFileSelect_ShowPresetModal() { return; } std::shared_ptr modal = static_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Modal Window")); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Modal Window")); if (modal->IsPopupOpen("Take a look at our presets!")) { modal->DismissPopup(); } else { diff --git a/soh/soh/Enhancements/Lang/Lang.cpp b/soh/soh/Enhancements/Lang/Lang.cpp index 76efe95a415..981e372c3f1 100644 --- a/soh/soh/Enhancements/Lang/Lang.cpp +++ b/soh/soh/Enhancements/Lang/Lang.cpp @@ -104,12 +104,12 @@ void Lang::LoadLangs() { initData->Type = static_cast(Ship::ResourceType::Json); initData->ResourceVersion = 0; const static std::string folder = "lang/*"; - auto langFiles = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder); + auto langFiles = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder); size_t start = std::string(folder).size() - 1; for (size_t i = 0; i < langFiles->size(); i++) { std::string filePath = langFiles->at(i); auto json = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath, true, initData)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath, true, initData)); std::string fileName = filePath.substr(start, filePath.size() - start - 5); // 5 for length of ".json" langs.insert_or_assign(fileName, json->Data); diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index 608e73c8bbc..ea241d302d6 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -110,7 +110,7 @@ void applyPreset(std::string presetName, std::vector includeSecti } else { auto block = item.value(); if (sectionStrategy == "merge") { - auto currentJson = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto currentJson = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); if (currentJson.contains("CVars") && currentJson["CVars"].contains(item.key())) { block = currentJson["CVars"][item.key()]; // Recursively merge the two json objects @@ -118,9 +118,9 @@ void applyPreset(std::string presetName, std::vector includeSecti } } - Ship::Context::GetInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), - block); - Ship::Context::GetInstance()->GetConsoleVariables()->Load(); + Ship::Context::GetRawInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), + block); + Ship::Context::GetRawInstance()->GetConsoleVariables()->Load(); } } if (i == PRESET_SECTION_RANDOMIZER) { @@ -162,7 +162,7 @@ void DrawPresetSelector(std::vector includeSections, std::string if (ImGui::Selectable(iter->c_str(), *iter == currentIndex)) { CVarSetString(selectorCvar.c_str(), iter->c_str()); currentIndex = *iter; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } @@ -237,12 +237,12 @@ void LoadPresets() { initData->Type = static_cast(Ship::ResourceType::Json); initData->ResourceVersion = 0; std::string folder = "presets/*"; - auto builtIns = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder); + auto builtIns = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder); size_t start = std::string(folder).size() - 1; for (size_t i = 0; i < builtIns->size(); i++) { std::string filePath = builtIns->at(i); auto json = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath, true, initData)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath, true, initData)); std::string fileName = filePath.substr(start, filePath.size() - start - 5); // 5 for length of ".json" ParsePreset(json->Data, fileName); @@ -256,7 +256,7 @@ void SavePreset(std::string& presetName) { presets[presetName].presetValues["presetName"] = presetName; presets[presetName].presetValues["fileType"] = FILE_TYPE_PRESET; std::ofstream file( - fmt::format("{}/{}.json", Ship::Context::GetInstance()->LocateFileAcrossAppDirs("presets"), presetName)); + fmt::format("{}/{}.json", Ship::Context::GetRawInstance()->LocateFileAcrossAppDirs("presets"), presetName)); file << presets[presetName].presetValues.dump(4); file.close(); LoadPresets(); @@ -296,7 +296,7 @@ void DrawNewPresetPopup() { .Padding({ 6.0f, 6.0f }) .Color(THEME_COLOR))) { presets[newPresetName] = {}; - auto config = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto config = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) { if (saveSection[i]) { for (size_t j = 0; j < blockInfo[i].sections.size(); j++) { @@ -462,7 +462,7 @@ void RegisterPresetsWidgets() { SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM) .CustomFunction(PresetsCustomWidget) .HideInSearch(true); - presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets"); + presetFolder = Ship::Context::GetRawInstance()->GetPathRelativeToAppDirectory("presets"); std::fill_n(saveSection, PRESET_SECTION_MAX, true); LoadPresets(); } diff --git a/soh/soh/Enhancements/ResetHotKey.cpp b/soh/soh/Enhancements/ResetHotKey.cpp index b57ae4ff2be..644b797f078 100644 --- a/soh/soh/Enhancements/ResetHotKey.cpp +++ b/soh/soh/Enhancements/ResetHotKey.cpp @@ -22,7 +22,7 @@ static void OnGameStateMainStartResetHotkey() { CHECK_BTN_ALL(gGameState->input[0].cur.button, mask)) { auto consoleWin = std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")); if (consoleWin) { consoleWin->Dispatch("reset"); diff --git a/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp b/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp index 78b1a45ba8a..676e05d953b 100644 --- a/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp +++ b/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp @@ -29,8 +29,10 @@ CollisionHeader* getGraveyardCollisionHeader() { * dspot02_sceneCollisionHeader_003C54. We have to scroll through the scene cmds to get the header the same way the * game does. */ - SOH::Scene* scene = - (SOH::Scene*)Ship::Context::GetInstance()->GetResourceManager()->LoadResource(GRAVEYARD_SCENE_FILEPATH).get(); + SOH::Scene* scene = (SOH::Scene*)Ship::Context::GetRawInstance() + ->GetResourceManager() + ->LoadResource(GRAVEYARD_SCENE_FILEPATH) + .get(); SOH::SetCollisionHeader* sceneCmd = nullptr; for (size_t i = 0; i < scene->commands.size(); i++) { auto cmd = scene->commands[i]; diff --git a/soh/soh/Enhancements/Restorations/N64WeirdFrames/WeirdAnimation.cpp b/soh/soh/Enhancements/Restorations/N64WeirdFrames/WeirdAnimation.cpp index c4cbc4bfeca..4fd64272326 100644 --- a/soh/soh/Enhancements/Restorations/N64WeirdFrames/WeirdAnimation.cpp +++ b/soh/soh/Enhancements/Restorations/N64WeirdFrames/WeirdAnimation.cpp @@ -36,7 +36,7 @@ void WeirdAnimation::Build() { auto& animation = animationData.emplace(); for (const auto& neighborName : neighborAnimations) { - const auto neighbor = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(neighborName); + const auto neighbor = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(neighborName); const auto prevSize = animation.size(); animation.resize(prevSize + neighbor->GetPointerSize()); diff --git a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp index 6125a3837eb..57ef0286ab4 100644 --- a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp +++ b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp @@ -8,6 +8,8 @@ #include +#include + extern "C" { #include "macros.h" #include "functions.h" @@ -86,18 +88,21 @@ static void TimeDisplayGetTimer(uint32_t timeID) { uint32_t timer1 = gSaveContext.timerSeconds; auto gui = std::dynamic_pointer_cast( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui())); switch (timeID) { case DISPLAY_IN_GAME_TIMER: + textureDisplay = gui->GetTextureByName("GAMEPLAY_TIMER"); textureDisplay = gui->GetTextureByName("GAMEPLAY_TIMER"); timeDisplayTime = formatTimeDisplay(GAMEPLAYSTAT_TOTAL_TIME).c_str(); break; case DISPLAY_TIME_OF_DAY: if (gSaveContext.dayTime >= DAY_BEGINS && gSaveContext.dayTime < NIGHT_BEGINS) { textureDisplay = gui->GetTextureByName("DAY_TIME_TIMER"); + textureDisplay = gui->GetTextureByName("DAY_TIME_TIMER"); } else { textureDisplay = gui->GetTextureByName("NIGHT_TIME_TIMER"); + textureDisplay = gui->GetTextureByName("NIGHT_TIME_TIMER"); } timeDisplayTime = convertDayTime(gSaveContext.dayTime).c_str(); break; @@ -114,11 +119,17 @@ static void TimeDisplayGetTimer(uint32_t timeID) { gui->GetTextureByName(gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3 ? itemMapping[ITEM_TUNIC_GORON].name : itemMapping[ITEM_TUNIC_ZORA].name); + textureDisplay = + gui->GetTextureByName(gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3 + ? itemMapping[ITEM_TUNIC_GORON].name + : itemMapping[ITEM_TUNIC_ZORA].name); } if (gSaveContext.timerState >= TIMER_STATE_DOWN_PREVIEW) { textureDisplay = gui->GetTextureByName(itemMapping[ITEM_SWORD_MASTER].name); + textureDisplay = gui->GetTextureByName(itemMapping[ITEM_SWORD_MASTER].name); } } else { + textureDisplay = gui->GetTextureByName(itemMapping[ITEM_TUNIC_KOKIRI].name); textureDisplay = gui->GetTextureByName(itemMapping[ITEM_TUNIC_KOKIRI].name); timeDisplayTime = "-:--"; } @@ -134,6 +145,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) { textColor = COLOR_GREY; } textureDisplay = gui->GetTextureByName("NAVI_TIMER"); + textureDisplay = gui->GetTextureByName("NAVI_TIMER"); break; default: break; @@ -205,13 +217,13 @@ void TimeDisplayWindow::Draw() { if (textToDecode[i] == '.') { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale)); ImGui::Image(std::dynamic_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(digitList[textureIndex].first), ImVec2(8.0f * fontScale, 8.0f * fontScale), ImVec2(0, 0.5f), ImVec2(1, 1), textColor, ImVec4(0, 0, 0, 0)); } else { ImGui::Image(std::dynamic_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(digitList[textureIndex].first), ImVec2(8.0f * fontScale, 16.0f * fontScale), ImVec2(0, 0), ImVec2(1, 1), textColor, ImVec4(0, 0, 0, 0)); @@ -250,17 +262,17 @@ static void TimeDisplayInitTimers() { } void TimeDisplayWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1)); for (auto& load : digitList) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(load.first.c_str(), load.second, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/Warping.cpp b/soh/soh/Enhancements/Warping.cpp index 0a21a21fc44..ad29a3c0c39 100644 --- a/soh/soh/Enhancements/Warping.cpp +++ b/soh/soh/Enhancements/Warping.cpp @@ -30,7 +30,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(WarpPoint, entranceId, roomNum, pos, rotY, bo std::map warpPoints; void LoadConfig() { - auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); if (allConfig.find("WarpPoints") == allConfig.end() || !allConfig["WarpPoints"].is_object()) { allConfig["WarpPoints"] = nlohmann::json::object(); } @@ -38,10 +38,10 @@ void LoadConfig() { } void SaveConfig() { - auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); allConfig["WarpPoints"] = warpPoints; - Ship::Context::GetInstance()->GetConfig()->SetBlock("WarpPoints", warpPoints); - Ship::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetRawInstance()->GetConfig()->SetBlock("WarpPoints", warpPoints); + Ship::Context::GetRawInstance()->GetConfig()->Save(); } void Warp(WarpPoint& warpPoint) { diff --git a/soh/soh/Enhancements/audio/AudioCollection.cpp b/soh/soh/Enhancements/audio/AudioCollection.cpp index 631d3094f1d..f1e323d7e93 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.cpp +++ b/soh/soh/Enhancements/audio/AudioCollection.cpp @@ -399,7 +399,7 @@ void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) { excludedSequences.insert(seqInfo); includedSequences.erase(seqInfo); CVarSetInteger(cvarKey.c_str(), 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { @@ -407,7 +407,7 @@ void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { includedSequences.insert(seqInfo); excludedSequences.erase(seqInfo); CVarClear(cvarKey.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AudioCollection::InitializeShufflePool() { diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 3f56ed07dc4..8038efdce74 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -264,7 +264,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); ResetGroup(map, type); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -276,7 +276,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); RandomizeGroup(type); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -288,7 +288,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); LockGroup(map, type); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -300,7 +300,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); UnlockGroup(map, type); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -361,7 +361,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN if (ImGui::Selectable(seqData.label.c_str())) { CVarSetInteger(cvarKey.c_str(), value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); UpdateCurrentBGM(defaultValue, type); } @@ -388,7 +388,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN .Color(THEME_COLOR))) { CVarClear(cvarKey.c_str()); CVarClear(cvarLockKey.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); UpdateCurrentBGM(defaultValue, seqData.category); } ImGui::SameLine(); @@ -412,7 +412,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN if (locked) { CVarClear(cvarLockKey.c_str()); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); UpdateCurrentBGM(defaultValue, type); } } @@ -429,7 +429,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN } else { CVarSetInteger(cvarLockKey.c_str(), 1); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } ImGui::EndTable(); @@ -816,7 +816,7 @@ void AudioEditor_RandomizeAll() { RandomizeGroup(type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } @@ -825,14 +825,14 @@ void AudioEditor_AutoRandomizeAll() { RandomizeGroup(type, false); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } void AudioEditor_RandomizeGroup(SeqType group) { RandomizeGroup(group); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } @@ -841,14 +841,14 @@ void AudioEditor_ResetAll() { ResetGroup(AudioCollection::Instance->GetAllSequences(), type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } void AudioEditor_ResetGroup(SeqType group) { ResetGroup(AudioCollection::Instance->GetAllSequences(), group); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } @@ -857,7 +857,7 @@ void AudioEditor_LockAll() { LockGroup(AudioCollection::Instance->GetAllSequences(), type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AudioEditor_UnlockAll() { @@ -865,7 +865,7 @@ void AudioEditor_UnlockAll() { UnlockGroup(AudioCollection::Instance->GetAllSequences(), type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void RegisterAudioWidgets() { diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 1d4745db512..c5855884131 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -15,6 +15,8 @@ #include +#include + using namespace UIWidgets; // Text colors @@ -49,7 +51,7 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex // Render Outline based on settings if (outlineMode == BUTTON_OUTLINE_ALWAYS_SHOWN || (outlineMode == BUTTON_OUTLINE_NOT_PRESSED && !state) || (outlineMode == BUTTON_OUTLINE_PRESSED && state)) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(btnOutlineTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -57,7 +59,7 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex if (state) { ImGui::SetCursorPos(pos); ImGui::SetNextItemAllowOverlap(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(btnTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -76,79 +78,79 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; if (!sButtonTexturesLoaded) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Start-Btn", "textures/buttons/StartBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Analog-Stick", "textures/buttons/AnalogStick.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Left", "textures/buttons/DPadLeft.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Right", "textures/buttons/DPadRight.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Down", "textures/buttons/DPadDown.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Modifier-1", "textures/buttons/Mod1.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Modifier-2", "textures/buttons/Mod2.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Right-Stick", "textures/buttons/RightStick.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("A-Btn Outline", "textures/buttons/ABtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("B-Btn Outline", "textures/buttons/BBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("L-Btn Outline", "textures/buttons/LBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("R-Btn Outline", "textures/buttons/RBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Left Outline", "textures/buttons/CLeftOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Right Outline", "textures/buttons/CRightOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Up Outline", "textures/buttons/CUpOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("C-Down Outline", "textures/buttons/CDownOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Modifier-1 Outline", "textures/buttons/Mod1Outline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Modifier-2 Outline", "textures/buttons/Mod2Outline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadTextureFromRawImage("Right-Stick Outline", "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; } @@ -166,8 +168,9 @@ void InputViewer::DrawElement() { CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED); const bool useGlobalOutlineMode = CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); - ImVec2 bgSize = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureSize("Input-Viewer-Background"); + ImVec2 bgSize = + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); ImGui::SetNextWindowSize( @@ -186,7 +189,7 @@ void InputViewer::DrawElement() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); OSContPad* pads = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetControlDeck())->GetPads(); ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | @@ -204,7 +207,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); // Background ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("Input-Viewer-Background"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -356,7 +359,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("Analog-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -369,7 +372,7 @@ void InputViewer::DrawElement() { ImVec2(aPos.x + maxStickDistance * ((float)(pads[0].stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("Analog-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -383,7 +386,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("Right-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -396,7 +399,7 @@ void InputViewer::DrawElement() { ImVec2(aPos.x + maxRightStickDistance * ((float)(pads[0].right_stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("Right-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 2346d97715f..2cf63ddefb0 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -77,7 +77,7 @@ void SohInputEditorWindow::UpdateElement() { } if (mInputEditorPopupOpen && ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId)) { - Ship::Context::GetInstance()->GetControlDeck()->BlockGameInput(INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); + Ship::Context::GetRawInstance()->GetControlDeck()->BlockGameInput(INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); // continue to block input for a third of a second after getting the mapping mGameInputBlockTimer = ImGui::GetIO().Framerate / 3; @@ -89,24 +89,24 @@ void SohInputEditorWindow::UpdateElement() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->BlockGamepadNavigation(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->BlockGamepadNavigation(); } else { if (mGameInputBlockTimer != INT32_MAX) { mGameInputBlockTimer--; if (mGameInputBlockTimer <= 0) { - Ship::Context::GetInstance()->GetControlDeck()->UnblockGameInput( + Ship::Context::GetRawInstance()->GetControlDeck()->UnblockGameInput( INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); mGameInputBlockTimer = INT32_MAX; } } - if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GamepadNavigationEnabled()) { + if (Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GamepadNavigationEnabled()) { mMappingInputBlockTimer = ImGui::GetIO().Framerate / 3; } else { mMappingInputBlockTimer = INT32_MAX; } - Ship::Context::GetInstance()->GetWindow()->GetGui()->UnblockGamepadNavigation(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->UnblockGamepadNavigation(); } } @@ -245,7 +245,7 @@ void SohInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, N64Butto ImGui::CloseCurrentPopup(); } // todo: figure out why optional params (using id = "" in the definition) wasn't working - if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -258,7 +258,7 @@ void SohInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, N64Butto } void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64ButtonMask bitmask, std::string id) { - auto mapping = Ship::Context::GetInstance() + auto mapping = Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -308,7 +308,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt mInputEditorPopupOpen = false; ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -348,7 +348,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::Text("Axis Threshold\n\nThe extent to which the joystick\nmust be moved or the trigger\npressed to " "initiate the assigned\nbutton action."); - auto globalSettings = Ship::Context::GetInstance()->GetControlDeck()->GetGlobalSDLDeviceSettings(); + auto globalSettings = Ship::Context::GetRawInstance()->GetControlDeck()->GetGlobalSDLDeviceSettings(); if (sdlAxisDirectionToButtonMapping->AxisIsStick()) { ImGui::Text("Stick axis threshold:"); @@ -443,7 +443,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeButtonMappingButton%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(ImGui::CalcTextSize(ICON_FA_TIMES).x + SCALE_IMGUI_SIZE(10.0f), 0.0f))) { - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -489,7 +489,7 @@ void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, } if (stick == Ship::LEFT) { if (mMappingInputBlockTimer == INT32_MAX && - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() @@ -499,7 +499,7 @@ void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, } } else { if (mMappingInputBlockTimer == INT32_MAX && - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -515,13 +515,13 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, Ship::Direction direction, std::string id) { std::shared_ptr mapping = nullptr; if (stick == Ship::LEFT) { - mapping = Ship::Context::GetInstance() + mapping = Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() ->GetAxisDirectionMappingById(direction, id); } else { - mapping = Ship::Context::GetInstance() + mapping = Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -576,7 +576,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (stick == Ship::LEFT) { if (mMappingInputBlockTimer == INT32_MAX && - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() @@ -586,7 +586,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, } } else { if (mMappingInputBlockTimer == INT32_MAX && - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -606,13 +606,13 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, StringHelper::Sprintf("%s###removeStickDirectionMappingButton%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(ImGui::CalcTextSize(ICON_FA_TIMES).x + SCALE_IMGUI_SIZE(10.0f), 0.0f))) { if (stick == Ship::LEFT) { - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() ->ClearAxisDirectionMapping(direction, id); } else { - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -646,9 +646,9 @@ void SohInputEditorWindow::DrawStickSection(uint8_t port, uint8_t stick, int32_t static int8_t sX, sY; std::shared_ptr controllerStick = nullptr; if (stick == Ship::LEFT) { - controllerStick = Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick(); + controllerStick = Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick(); } else { - controllerStick = Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick(); + controllerStick = Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick(); } controllerStick->Process(sX, sY); DrawAnalogPreview(StringHelper::Sprintf("##AnalogPreview%d", id).c_str(), ImVec2(sX, sY)); @@ -790,7 +790,7 @@ void SohInputEditorWindow::UpdateBitmaskToMappingIds(uint8_t port) { // todo: do we need this now that ControllerButton exists? for (auto [bitmask, button] : - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetAllButtons()) { + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetAllButtons()) { for (auto [id, mapping] : button->GetAllButtonMappings()) { // using a vector here instead of a set because i want newly added mappings // to go to the end of the list instead of autosorting @@ -806,10 +806,11 @@ void SohInputEditorWindow::UpdateStickDirectionToMappingIds(uint8_t port) { // todo: do we need this? for (auto stick : { std::make_pair>( - Ship::LEFT, Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), + Ship::LEFT, + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), std::make_pair>( Ship::RIGHT, - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick()) }) { + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick()) }) { for (auto direction : { Ship::LEFT, Ship::RIGHT, Ship::UP, Ship::DOWN }) { for (auto [id, mapping] : stick.second->GetAllAxisDirectionMappingByDirection(direction)) { // using a vector here instead of a set because i want newly added mappings @@ -829,7 +830,8 @@ void SohInputEditorWindow::DrawRemoveRumbleMappingButton(uint8_t port, std::stri ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeRumbleMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping(id); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping( + id); } ImGui::PopStyleVar(); } @@ -852,7 +854,7 @@ void SohInputEditorWindow::DrawAddRumbleMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRumble() @@ -869,7 +871,7 @@ bool SohInputEditorWindow::TestingRumble() { } void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { - for (auto [id, mapping] : Ship::Context::GetInstance() + for (auto [id, mapping] : Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRumble() @@ -1012,7 +1014,7 @@ void SohInputEditorWindow::DrawRemoveLEDMappingButton(uint8_t port, std::string ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeLEDMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->ClearLEDMapping(id); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->ClearLEDMapping(id); } ImGui::PopStyleVar(); } @@ -1035,7 +1037,7 @@ void SohInputEditorWindow::DrawAddLEDMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLED() @@ -1049,7 +1051,7 @@ void SohInputEditorWindow::DrawAddLEDMappingButton(uint8_t port) { void SohInputEditorWindow::DrawLEDSection(uint8_t port) { for (auto [id, mapping] : - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->GetAllLEDMappings()) { + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->GetAllLEDMappings()) { ImGui::AlignTextToFramePadding(); ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto open = ImGui::TreeNode( @@ -1105,7 +1107,7 @@ void SohInputEditorWindow::DrawLEDSection(uint8_t port) { color.b = colorVec.z * 255.0; CVarSetColor24(CVAR_SETTING("LEDPort1Color"), color); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); ImGui::Text("Custom Color"); @@ -1141,7 +1143,7 @@ void SohInputEditorWindow::DrawRemoveGyroMappingButton(uint8_t port, std::string ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeGyroMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->ClearGyroMapping(); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->ClearGyroMapping(); } ImGui::PopStyleVar(); } @@ -1164,7 +1166,7 @@ void SohInputEditorWindow::DrawAddGyroMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetGyro() @@ -1178,7 +1180,7 @@ void SohInputEditorWindow::DrawAddGyroMappingButton(uint8_t port) { void SohInputEditorWindow::DrawGyroSection(uint8_t port) { auto mapping = - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->GetGyroMapping(); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->GetGyroMapping(); if (mapping != nullptr) { auto id = mapping->GetGyroMappingId(); ImGui::AlignTextToFramePadding(); @@ -1322,7 +1324,7 @@ void SohInputEditorWindow::DrawMapping(CustomButtonMap& mapping, float labelWidt } if (ImGui::Selectable(i->second, i->first == currentButton)) { CVarSetInteger(mapping.cVarName, i->first); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } ImGui::EndCombo(); @@ -1409,7 +1411,7 @@ void SohInputEditorWindow::DrawCameraControlPanel() { if (!CVarGetInteger(CVAR_SETTING("FirstPersonCameraSensitivity.Enabled"), 0)) { CVarClear(CVAR_SETTING("FirstPersonCameraSensitivity.X")); CVarClear(CVAR_SETTING("FirstPersonCameraSensitivity.Y")); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } if (CVarGetInteger(CVAR_SETTING("FirstPersonCameraSensitivity.Enabled"), 0)) { @@ -1514,7 +1516,8 @@ void SohInputEditorWindow::DrawDeviceToggles(uint8_t portIndex) { ImGui::PopItemFlag(); - auto connectedDeviceManager = Ship::Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager(); + auto connectedDeviceManager = + Ship::Context::GetRawInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager(); for (const auto& [instanceId, name] : connectedDeviceManager->GetConnectedSDLGamepadNames()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); @@ -1743,7 +1746,7 @@ void SohInputEditorWindow::DrawClearAllButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Clear All")) { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->ClearAllMappings(); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(portIndex)->ClearAllMappings(); ImGui::CloseCurrentPopup(); } PopStyleButton(); @@ -1776,11 +1779,11 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set defaults")) { - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->ClearAllMappingsForDeviceType(Ship::PhysicalDeviceType::Keyboard); - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( Ship::PhysicalDeviceType::Keyboard); shouldClose = true; ImGui::CloseCurrentPopup(); @@ -1806,11 +1809,11 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set defaults")) { - Ship::Context::GetInstance() + Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->ClearAllMappingsForDeviceType(Ship::PhysicalDeviceType::SDLGamepad); - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( Ship::PhysicalDeviceType::SDLGamepad); shouldClose = true; ImGui::CloseCurrentPopup(); @@ -1869,7 +1872,7 @@ void RegisterInputEditorWidgets() { .Callback([](WidgetInfo& info) { bool enabled = CVarGetInteger(CVAR_SETTING("EnableMouse"), 0) && CVarGetInteger(CVAR_SETTING("AutoCaptureMouse"), 1); - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); wnd->SetAutoCaptureMouse(enabled); }) .Options( @@ -1885,7 +1888,7 @@ void RegisterInputEditorWidgets() { .Callback([](WidgetInfo& info) { bool enabled = CVarGetInteger(CVAR_SETTING("EnableMouse"), 0) && CVarGetInteger(CVAR_SETTING("AutoCaptureMouse"), 1); - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); wnd->SetAutoCaptureMouse(enabled); }) .Options(CheckboxOptions() diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 8ac4f8ee9f3..424ffd1bf2a 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1639,7 +1639,7 @@ void C_Button_Dropdown(const char* Header_Title, const char* Table_ID, const cha ImGui::EndTable(); } std::shared_ptr controller = - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(0); for (auto [id, mapping] : controller->GetButton(BTN_DDOWN)->GetAllButtonMappings()) { controller->GetButton(BTN_CUSTOM_OCARINA_NOTE_F4)->AddButtonMapping(mapping); } @@ -2217,7 +2217,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.changedCvar), 1); ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } // the longest option name ImGui::SameLine((ImGui::CalcTextSize("Message Light Blue (None No Shadow)").x * 1.0f) + 60.0f); @@ -2226,7 +2226,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { UIWidgets::ButtonOptions().Size(ImVec2(80, 31)).Padding(ImVec2(2.0f, 0.0f)).Color(THEME_COLOR))) { RandomizeColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } if (cosmeticOption.supportsRainbow) { ImGui::SameLine(); @@ -2235,7 +2235,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.changedCvar), 1); ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } ImGui::SameLine(); @@ -2249,7 +2249,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { UIWidgets::ButtonOptions().Size(ImVec2(80, 31)).Padding(ImVec2(2.0f, 0.0f)))) { ResetColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } } @@ -2622,7 +2622,7 @@ void CosmeticsEditorWindow::InitElement() { cosmeticOption.currentColor.z = cvarColor.b / 255.0f; cosmeticOption.currentColor.w = cvarColor.a / 255.0f; } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); ApplyAuthenticGfxPatches(); } @@ -2635,7 +2635,7 @@ void CosmeticsEditor_RandomizeAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2647,7 +2647,7 @@ void CosmeticsEditor_AutoRandomizeAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2660,7 +2660,7 @@ void CosmeticsEditor_RandomizeGroup(CosmeticGroup group) { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2671,7 +2671,7 @@ void CosmeticsEditor_ResetAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2682,7 +2682,7 @@ void CosmeticsEditor_ResetGroup(CosmeticGroup group) { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 1021543df22..6aabdb33a6b 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -36,15 +36,15 @@ extern PlayState* gPlayState; #include #include -#define CMD_REGISTER Ship::Context::GetInstance()->GetConsole()->AddCommand +#define CMD_REGISTER Ship::Context::GetRawInstance()->GetConsole()->AddCommand // TODO: Commands should be using the output passed in. -#define ERROR_MESSAGE \ - std::reinterpret_pointer_cast( \ - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ +#define ERROR_MESSAGE \ + std::reinterpret_pointer_cast( \ + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendErrorMessage -#define INFO_MESSAGE \ - std::reinterpret_pointer_cast( \ - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ +#define INFO_MESSAGE \ + std::reinterpret_pointer_cast( \ + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendInfoMessage static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args, @@ -527,7 +527,7 @@ static bool FileSelectHandler(std::shared_ptr Console, const std: static bool QuitHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { - Ship::Context::GetInstance()->GetWindow()->Close(); + Ship::Context::GetRawInstance()->GetWindow()->Close(); return 0; } @@ -1772,7 +1772,7 @@ void DebugConsole_Init(void) { "Available Checks - Process Undiscovered Exits", { { "enable", Ship::ArgumentType::NUMBER, true } } }); - Ship::Context::GetInstance()->GetConsole()->AddCommand( + Ship::Context::GetRawInstance()->GetConsole()->AddCommand( "acr", { AvailableChecksRecalculateHandler, "Available Checks - Recalculate", { @@ -1780,5 +1780,5 @@ void DebugConsole_Init(void) { { "ChildDay|ChildNight|AdultDay|AdultNight", Ship::ArgumentType::TEXT, true }, } }); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index c40d7cc22e8..dfd425eea04 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -521,7 +521,7 @@ void DrawInfoTab() { void DrawBGSItemFlag(uint8_t itemID) { const ItemMapEntry& slotEntry = itemMapping[itemID]; - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); } @@ -550,7 +550,7 @@ void DrawInventoryTab() { if (item == ITEM_ROCS_FEATHER) { auto ret = ImGui::ImageButton( "ROCS_FEATHER", - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("ROCS_FEATHER"), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -561,7 +561,7 @@ void DrawInventoryTab() { const ItemMapEntry& slotEntry = itemMapping.find(item)->second; auto ret = ImGui::ImageButton( slotEntry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(slotEntry.name), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -611,11 +611,11 @@ void DrawInventoryTab() { } const ItemMapEntry& slotEntry = possibleItems[pickerIndex]; PushStyleButton(Colors::DarkGray); - auto ret = ImGui::ImageButton( - slotEntry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(slotEntry.name), - ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); + auto ret = ImGui::ImageButton(slotEntry.name.c_str(), + std::dynamic_pointer_cast( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(slotEntry.name), + ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); PopStyleButton(); if (ret) { gSaveContext.inventory.items[selectedIndex] = slotEntry.id; @@ -647,9 +647,10 @@ void DrawInventoryTab() { ImGui::PushItemWidth(IMAGE_SIZE); ImGui::BeginGroup(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(itemMapping[item].name), - ImVec2(IMAGE_SIZE, IMAGE_SIZE)); + ImGui::Image( + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(itemMapping[item].name), + ImVec2(IMAGE_SIZE, IMAGE_SIZE)); PushStyleInput(THEME_COLOR); ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item)); PopStyleInput(); @@ -1242,7 +1243,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const const ItemMapEntry& slotEntry = itemMapping[item]; if (ImGui::ImageButton( slotEntry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1))) { ImGui::OpenPopup(upgradePopupPicker); @@ -1273,7 +1274,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const const ItemMapEntry& slotEntry = itemMapping[items[pickerIndex]]; auto ret = ImGui::ImageButton( slotEntry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1312,7 +1313,7 @@ void DrawEquipmentTab() { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasEquip ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1448,7 +1449,7 @@ void DrawQuestItemButton(uint32_t item) { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1470,7 +1471,7 @@ void DrawDungeonItemButton(uint32_t item, uint32_t scene) { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasItem ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1519,7 +1520,7 @@ void DrawQuestStatusTab() { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1599,7 +1600,7 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_JABU_JABU_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); ImGui::SameLine(); @@ -1990,6 +1991,6 @@ void SaveEditorWindow::DrawElement() { } void SaveEditorWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ROCS_FEATHER", gRocsFeatherTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/debugger/dlViewer.cpp b/soh/soh/Enhancements/debugger/dlViewer.cpp index 60a6e07c871..1447259c614 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.cpp +++ b/soh/soh/Enhancements/debugger/dlViewer.cpp @@ -67,7 +67,7 @@ std::map cmdMap = { }; void PerformDisplayListSearch() { - auto result = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles( + auto result = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles( "*" + std::string(searchString) + "*DL*"); displayListSearchResults.clear(); @@ -130,7 +130,7 @@ void DLViewerWindow::DrawElement() { try { auto res = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(activeDisplayList)); if (res->GetInitData()->Type != static_cast(Fast::ResourceType::DisplayList)) { ImGui::Text("Resource type is not a Display List. Please choose another."); diff --git a/soh/soh/Enhancements/debugger/valueViewer.cpp b/soh/soh/Enhancements/debugger/valueViewer.cpp index 5da68f52d5b..afc83ab507a 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -69,7 +69,7 @@ std::array valueTable = {{ // clang-format on void LoadValueConfig() { - auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); if (allConfig.find("ValueViewer") == allConfig.end() || !allConfig["ValueViewer"].is_array()) { allConfig["ValueViewer"] = nlohmann::json::array(); } @@ -77,10 +77,10 @@ void LoadValueConfig() { } void SaveValueConfig() { - auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); + auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson(); allConfig["ValueViewer"] = valueViewerSettings; - Ship::Context::GetInstance()->GetConfig()->SetBlock("ValueViewer", valueViewerSettings); - Ship::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetRawInstance()->GetConfig()->SetBlock("ValueViewer", valueViewerSettings); + Ship::Context::GetRawInstance()->GetConfig()->Save(); } extern "C" void ValueViewer_Draw(GfxPrint* printer) { diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index ff9a459baab..92e1fd9b8a2 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -54,7 +54,7 @@ void SetEnabledModsCVarValue() { } CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AfterModChange() { @@ -105,7 +105,7 @@ std::vector& GetModFiles(bool enabled) { } std::shared_ptr GetArchiveManager() { - return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager(); + return Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager(); } bool IsValidExtension(std::string extension) { @@ -334,8 +334,8 @@ void ModMenuWindow::DrawElement() { gfx_texture_cache_clear(); SOH::SkeletonPatcher::ClearSkeletons(); */ - Ship::Context::GetInstance()->GetConsoleVariables()->Save(); - Ship::Context::GetInstance()->GetWindow()->Close(); + Ship::Context::GetRawInstance()->GetConsoleVariables()->Save(); + Ship::Context::GetRawInstance()->GetWindow()->Close(); }); } } diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index b32d863e42a..314151efbd8 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -20,6 +20,8 @@ #include +#include + extern "C" { #include "include/z64item.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -308,7 +310,7 @@ ImVec4 plandomizerGetItemColor(Rando::Item randoItem) { } if (randoItem.GetItemType() == ITEMTYPE_SONG) { uint32_t questID = Rando::Logic::RandoGetToQuestItem[randoItem.GetRandomizerGet()]; - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(songMapping.at((QuestItem)questID).name); itemColor = songMapping.at((QuestItem)questID).color; imageSize = ImVec2(24.0f, 32.0f); @@ -382,20 +384,21 @@ void PlandomizerItemImageCorrection(Rando::Item randoItem) { itemColor = plandomizerGetItemColor(randoItem); if (randoItem.GetItemType() == ITEMTYPE_SMALLKEY || randoItem.GetItemType() == ITEMTYPE_FORTRESS_SMALLKEY) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("ITEM_KEY_SMALL"); return; } if (randoItem.GetItemType() == ITEMTYPE_BOSSKEY) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("ITEM_KEY_BOSS"); return; } for (auto& map : itemImageMap) { if (map.first == randoItem.GetRandomizerGet()) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(map.second.c_str()); + textureID = + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(map.second.c_str()); if (map.second.find("ITEM_ARROWS") != std::string::npos) { textureUV0 = ImVec2(0, 1); textureUV1 = ImVec2(1, 0); @@ -409,18 +412,18 @@ void PlandomizerItemImageCorrection(Rando::Item randoItem) { } if (randoItem.GetRandomizerGet() >= RG_GOHMA_SOUL && randoItem.GetRandomizerGet() <= RG_GANON_SOUL) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("BOSS_SOUL"); } if (randoItem.GetRandomizerGet() >= RG_OCARINA_A_BUTTON && randoItem.GetRandomizerGet() <= RG_OCARINA_C_RIGHT_BUTTON) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("ITEM_OCARINA_TIME"); } if (textureID == 0) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(itemMapping[randoItem.GetGIEntry()->itemId].name); } } @@ -980,15 +983,16 @@ void PlandomizerDrawOptions() { PlandoPushImageButtonStyle(); for (auto& hash : plandoHash) { ImGui::PushID(index); - textureID = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(gSeedTextures[hash].tex); + textureID = std::dynamic_pointer_cast( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(gSeedTextures[hash].tex); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); - auto upRet = ImGui::ImageButton( - "HASH_ARROW_UP", - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName("HASH_ARROW_UP"), - ImVec2(35.0f, 18.0f), ImVec2(1, 1), ImVec2(0, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); + auto upRet = ImGui::ImageButton("HASH_ARROW_UP", + std::dynamic_pointer_cast( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName("HASH_ARROW_UP"), + ImVec2(35.0f, 18.0f), ImVec2(1, 1), ImVec2(0, 0), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); ImGui::PopStyleVar(); if (upRet) { if (hash + 1 >= gSeedTextures.size()) { @@ -999,11 +1003,12 @@ void PlandomizerDrawOptions() { } ImGui::Image(textureID, ImVec2(35.0f, 35.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); - auto downRet = ImGui::ImageButton( - "HASH_ARROW_DWN", - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName("HASH_ARROW_DWN"), - ImVec2(35.0f, 18.0f), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); + auto downRet = ImGui::ImageButton("HASH_ARROW_DWN", + std::dynamic_pointer_cast( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName("HASH_ARROW_DWN"), + ImVec2(35.0f, 18.0f), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); ImGui::PopStyleVar(); if (downRet) { if (hash == 0) { @@ -1181,26 +1186,26 @@ void PlandomizerWindow::DrawElement() { } void PlandomizerWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_RUPEE_GRAYSCALE", gRupeeCounterIconTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_HEART_GRAYSCALE", gHeartFullTex, ImVec4(0.87f, 0.10f, 0.10f, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_ARROWS_SMALL", gDropArrows1Tex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_ARROWS_MEDIUM", gDropArrows2Tex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_ARROWS_LARGE", gDropArrows3Tex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("ITEM_ICE_TRAP", gMagicArrowEquipEffectTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("HASH_ARROW_UP", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("HASH_ARROW_DWN", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("BOSS_SOUL", gBossSoulTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("TRIFORCE_PIECE", gTriforcePieceTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index 8b714759e6f..9d386f12dd6 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -2420,7 +2420,7 @@ const std::vector& GetDungeonSmallKeyDoors(SceneID sceneId) { // Load the scene std::shared_ptr scene = std::dynamic_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(scenePath)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(scenePath)); if (scene == nullptr) { return emptyVector; } diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index 4ebdf0178f2..57ceced7d78 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -247,7 +247,7 @@ bool Option::RenderCheckbox() { if (UIWidgets::Checkbox(name.c_str(), &val, widgetOptions)) { CVarSetInteger(cvarName.c_str(), val); changed = true; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } return changed; } @@ -259,7 +259,7 @@ bool Option::RenderCombobox() { selected = static_cast(options.size()); CVarSetInteger(cvarName.c_str(), selected); changed = true; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } UIWidgets::ComboboxOptions widgetOptions = UIWidgets::ComboboxOptions().Color(THEME_COLOR).Tooltip(description.c_str()); @@ -271,7 +271,7 @@ bool Option::RenderCombobox() { if (UIWidgets::Combobox(name.c_str(), &selected, options, widgetOptions)) { CVarSetInteger(cvarName.c_str(), static_cast(selected)); changed = true; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } return changed; } @@ -304,7 +304,7 @@ bool Option::RenderSlider() { } if (changed) { CVarSetInteger(cvarName.c_str(), val); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } return changed; } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 8fad3d16fa1..706a8d2d789 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -89,7 +89,7 @@ Randomizer::Randomizer() { SpoilerfileHintTypeNameToEnum[Rando::StaticData::hintTypeNames[(HintType)c].GetEnglish(MF_CLEAN)] = (HintType)c; } - Ship::Context::GetInstance()->GetFileDropMgr()->RegisterDropHandler(Rando_HandleSpoilerDrop); + Ship::Context::GetRawInstance()->GetFileDropMgr()->RegisterDropHandler(Rando_HandleSpoilerDrop); } Randomizer::~Randomizer() { @@ -213,7 +213,7 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) { "\nwas made by a version that doesn't match the currently running version.\n" + "Loading for this file has been cancelled."); CVarClear(CVAR_GENERAL("SpoilerLog")); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } // Update cache @@ -4443,7 +4443,7 @@ std::thread randoThread; void GenerateRandomizerImgui(std::string seed = "") { CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); auto ctx = Rando::Context::GetInstance(); // RANDOTODO proper UI for selecting if a spoiler loaded should be used for settings Rando::Settings::GetInstance()->SetAllToContext(); @@ -4480,7 +4480,7 @@ void GenerateRandomizerImgui(std::string seed = "") { Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seed)); CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); generated = true; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 29418cb9184..a0238ed6bf1 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1030,7 +1030,8 @@ void CheckTrackerWindow::DrawElement() { int comboButton1Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; OSContPad* trackerButtonsPressed = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetControlDeck()) + ->GetPads(); bool comboButtonsHeld = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & comboButton1Mask && trackerButtonsPressed[0].button & comboButton2Mask; diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index 85326a66f98..410c0a21da0 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -841,7 +841,8 @@ void EntranceTrackerWindow::DrawElement() { int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_ENTRANCE("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; OSContPad* trackerButtonsPressed = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetControlDeck()) + ->GetPads(); bool comboButtonsHeld = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & comboButton1Mask && trackerButtonsPressed[0].button & comboButton2Mask; diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 4db72568050..ddd9435e95c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -808,7 +808,7 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) { void DrawEquip(ItemTrackerItem item) { bool hasEquip = HasEquipment(item); float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0.0f, 0.0f), ImVec2(1, 1)); @@ -819,9 +819,10 @@ void DrawQuest(ItemTrackerItem item) { bool hasQuestItem = HasQuestItem(item); float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImGui::BeginGroup(); - ImGui::ImageWithBg(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), - ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); + ImGui::ImageWithBg( + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); if (item.id == QUEST_SKULL_TOKEN) { DrawItemCount(item, false); @@ -1218,7 +1219,7 @@ void DrawItem(ItemTrackerItem item) { ImGui::BeginGroup(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); @@ -1304,7 +1305,7 @@ void DrawBottle(ItemTrackerItem item) { } float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); @@ -1320,11 +1321,11 @@ void DrawDungeonItem(ItemTrackerItem item) { bool hasSmallKey = GameInteractor::IsSaveLoaded() ? ((gSaveContext.inventory.dungeonKeys[item.data]) >= 0) : false; ImGui::BeginGroup(); if (itemId == ITEM_KEY_SMALL) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } else { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } @@ -1370,7 +1371,7 @@ void DrawSong(ItemTrackerItem item) { ImVec2 p = ImGui::GetCursorScreenPos(); bool hasSong = HasSong(item); ImGui::SetCursorScreenPos(ImVec2(p.x + 6, p.y)); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(hasSong && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize / 1.5f, iconSize), ImVec2(0, 0), ImVec2(1, 1)); Tooltip(SohUtils::GetQuestItemName(item.id).c_str()); @@ -1831,7 +1832,7 @@ void ItemTrackerWindow::DrawElement() { int comboButton1Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; OSContPad* buttonsPressed = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetControlDeck())->GetPads(); bool comboButtonsHeld = buttonsPressed != nullptr && buttonsPressed[0].button & comboButton1Mask && buttonsPressed[0].button & comboButton2Mask; bool isPaused = CVarGetInteger(CVAR_TRACKER_ITEM("ShowOnlyPaused"), 0) == 0 || diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 1acb4d78a8a..7cef5d9c531 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -2958,7 +2958,7 @@ void Settings::RandomizeAllSettings() { option.RunCallback(); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } std::shared_ptr Settings::GetInstance() { diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index 16fb98690b4..795ce86e4ce 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -818,8 +818,8 @@ extern "C" void ProcessSaveStateRequests(void) { } void SaveStateMgr::SetCurrentSlot(unsigned int slot) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, - "slot %u set", slot); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, + "slot %u set", slot); this->currentSlot = slot; } @@ -838,13 +838,13 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { std::make_shared(OTRGlobals::Instance->gSaveStateMgr, request.slot); } this->states[request.slot]->Save(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( 1.0f, true, "saved state %u", request.slot); break; case RequestType::LOAD: if (this->states.contains(request.slot)) { this->states[request.slot]->Load(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( 1.0f, true, "loaded state %u", request.slot); } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.slot); @@ -861,7 +861,7 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { if (gPlayState == nullptr) { SPDLOG_ERROR("[SOH] Can not save or load a state outside of \"GamePlay\""); - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( 1.0f, true, "states not available here", request.slot); return SaveStateReturn::FAIL_WRONG_GAMESTATE; } @@ -876,7 +876,7 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { return SaveStateReturn::SUCCESS; } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.slot); - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( 1.0f, true, "state slot %u empty", request.slot); return SaveStateReturn::FAIL_INVALID_SLOT; } diff --git a/soh/soh/Enhancements/timesplits/TimeSplits.cpp b/soh/soh/Enhancements/timesplits/TimeSplits.cpp index 8007a07e063..91eaa8a7a5b 100644 --- a/soh/soh/Enhancements/timesplits/TimeSplits.cpp +++ b/soh/soh/Enhancements/timesplits/TimeSplits.cpp @@ -12,6 +12,8 @@ #include +#include + extern "C" { #include "z64item.h" #include "macros.h" @@ -437,7 +439,7 @@ void TimeSplitsPopUpContext() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); ImGui::ImageButton( "QUEST_SKULL_TOKEN", - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName("QUEST_SKULL_TOKEN"), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0)); ImGui::PopStyleVar(); @@ -491,7 +493,7 @@ void TimeSplitsPopUpContext() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); auto ret = ImGui::ImageButton( popupObject.splitImage.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(popupObject.splitImage), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), popupObject.splitTint); ImGui::PopStyleVar(); @@ -668,7 +670,7 @@ void TimeSplitsDrawSplitsList() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( split.splitImage.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(split.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); @@ -753,7 +755,7 @@ void TimeSplitsDrawItemList(uint32_t type) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( split.splitImage.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(split.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); @@ -897,7 +899,7 @@ void TimeSplitsDrawManageList() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( data.splitImage.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(data.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), data.splitTint); ImGui::PopStyleVar(); @@ -983,9 +985,9 @@ void TimeSplitWindow::DrawElement() { void TimeSplitWindow::InitElement() { TimeSplitsUpdateWindowSize(); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("SPECIAL_TRIFORCE_PIECE_WHITE", gWTriforcePieceTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture("SPECIAL_SPLIT_ENTRANCE", gSplitEntranceTex, ImVec4(1, 1, 1, 1)); Color_RGBA8 defaultColour = { 0, 0, 0, 255 }; windowColor = VecFromRGBA8(CVarGetColor(CVAR_ENHANCEMENT("TimeSplits.WindowColor.Value"), defaultColour)); diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index fddcb77ce9a..6b31cdfb68d 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -1124,21 +1124,21 @@ void InitTTSBank() { initData->Type = static_cast(Ship::ResourceType::Json); initData->ResourceVersion = 0; - sceneMap = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + sceneMap = std::static_pointer_cast(Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource( "accessibility/texts/scenes" + languageSuffix, true, initData)) ->Data; - miscMap = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + miscMap = std::static_pointer_cast(Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource( "accessibility/texts/misc" + languageSuffix, true, initData)) ->Data; kaleidoMap = - std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource( "accessibility/texts/kaleidoscope" + languageSuffix, true, initData)) ->Data; fileChooseMap = - std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource( "accessibility/texts/filechoose" + languageSuffix, true, initData)) ->Data; } diff --git a/soh/soh/Network/Anchor/Menu.cpp b/soh/soh/Network/Anchor/Menu.cpp index 4a974532e4f..2930a405b20 100644 --- a/soh/soh/Network/Anchor/Menu.cpp +++ b/soh/soh/Network/Anchor/Menu.cpp @@ -34,7 +34,7 @@ void AnchorMainMenu(WidgetInfo& info) { ImVec2((ImGui::GetFontSize() * 5 + ImGui::GetStyle().ItemSpacing.x), 0)) .Color(THEME_COLOR))) { CVarSetString(CVAR_REMOTE_ANCHOR("Host"), host.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); @@ -42,7 +42,7 @@ void AnchorMainMenu(WidgetInfo& info) { ImGui::SetNextItemWidth(ImGui::GetFontSize() * 5); if (ImGui::InputScalar("##Port", ImGuiDataType_U16, &port)) { CVarSetInteger(CVAR_REMOTE_ANCHOR("Port"), port); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } UIWidgets::PopStyleInput(); @@ -53,20 +53,20 @@ void AnchorMainMenu(WidgetInfo& info) { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (UIWidgets::InputString("##Name", &anchorName, UIWidgets::InputOptions().Color(THEME_COLOR))) { CVarSetString(CVAR_REMOTE_ANCHOR("Name"), anchorName.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::Text("Room ID"); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (UIWidgets::InputString("##RoomId", &anchorRoomId, UIWidgets::InputOptions().IsSecret(anchor->isEnabled).Color(THEME_COLOR))) { CVarSetString(CVAR_REMOTE_ANCHOR("RoomId"), anchorRoomId.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::Text("Team ID (Items & Flags Shared)"); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (UIWidgets::InputString("##TeamId", &anchorTeamId, UIWidgets::InputOptions().Color(THEME_COLOR))) { CVarSetString(CVAR_REMOTE_ANCHOR("TeamId"), anchorTeamId.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::Spacing(); @@ -78,7 +78,7 @@ void AnchorMainMenu(WidgetInfo& info) { CVarSetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); CVarSetString(CVAR_REMOTE_ANCHOR("RoomId"), ""); CVarSetString(CVAR_REMOTE_ANCHOR("Name"), ""); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); @@ -91,7 +91,7 @@ void AnchorMainMenu(WidgetInfo& info) { CVarSetInteger(CVAR_REMOTE_ANCHOR("Port"), 43383); CVarSetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); CVarSetString(CVAR_REMOTE_ANCHOR("RoomId"), "soh-global"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::EndDisabled(); @@ -105,11 +105,11 @@ void AnchorMainMenu(WidgetInfo& info) { if (ImGui::Button(buttonLabel, ImVec2(-1.0f, 0.0f))) { if (anchor->isEnabled) { CVarClear(CVAR_REMOTE_ANCHOR("Enabled")); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); anchor->Disable(); } else { CVarSetInteger(CVAR_REMOTE_ANCHOR("Enabled"), 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); anchor->Enable(); } } diff --git a/soh/soh/Network/Anchor/Packets/AllClientState.cpp b/soh/soh/Network/Anchor/Packets/AllClientState.cpp index 7de1a67ec13..8e01d1f34ee 100644 --- a/soh/soh/Network/Anchor/Packets/AllClientState.cpp +++ b/soh/soh/Network/Anchor/Packets/AllClientState.cpp @@ -22,7 +22,7 @@ void Anchor::HandlePacket_AllClientState(nlohmann::json payload) { if (client.self) { ownClientId = client.clientId; CVarSetInteger(CVAR_REMOTE_ANCHOR("LastClientId"), ownClientId); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); clients[client.clientId].self = true; } else { clients[client.clientId].self = false; diff --git a/soh/soh/Network/Sail/Sail.cpp b/soh/soh/Network/Sail/Sail.cpp index ded32011067..4fb45350343 100644 --- a/soh/soh/Network/Sail/Sail.cpp +++ b/soh/soh/Network/Sail/Sail.cpp @@ -56,7 +56,7 @@ void Sail::OnIncomingJson(nlohmann::json payload) { std::string command = payload["command"].get(); std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch(command); responsePayload["status"] = "success"; SendJsonToRemote(responsePayload); @@ -80,7 +80,7 @@ void Sail::OnIncomingJson(nlohmann::json payload) { std::string command = payload["effect"]["command"].get(); std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch(command); responsePayload["status"] = "success"; SendJsonToRemote(responsePayload); diff --git a/soh/soh/Notification/Notification.cpp b/soh/soh/Notification/Notification.cpp index decb7d88587..03a7c031830 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -5,6 +5,8 @@ #include +#include + extern "C" { #include "functions.h" #include "macros.h" @@ -90,9 +92,10 @@ void Window::Draw() { ImGui::SetWindowPos(notificationPos); if (notification.itemIcon != nullptr) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) - ->GetTextureByName(notification.itemIcon), - ImVec2(24, 24)); + ImGui::Image( + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) + ->GetTextureByName(notification.itemIcon), + ImVec2(24, 24)); ImGui::SameLine(); } if (!notification.prefix.empty()) { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index cca670a842c..0e59ca310f2 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -322,7 +322,7 @@ OTRGlobals::OTRGlobals() { if (sohArchiveVersionMatch) { - auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); + auto overlay = context->GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf"); overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf"); overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); @@ -782,7 +782,7 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) { void InitGfxDebugger() { auto dbg = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow())->GetGfxDebugger(); + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow())->GetGfxDebugger(); if (dbg != nullptr) { return; @@ -821,7 +821,7 @@ void OTRGlobals::Initialize() { auto logLevel = static_cast(CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), defaultLogLevel)); context->InitLogging(logLevel, logLevel); - Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); + Ship::Context::GetRawInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); InitGfxDebugger(); context->InitFileDropMgr(); @@ -1004,10 +1004,10 @@ bool OTRGlobals::HasOriginal() { uint32_t OTRGlobals::GetInterpolationFPS() { if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) { - return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + return Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate(); } else if (CVarGetInteger(CVAR_VSYNC_ENABLED, 1) || - !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { - return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), + !Ship::Context::GetRawInstance()->GetWindow()->CanDisableVerticalSync()) { + return std::min(Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20)); } return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); @@ -1411,7 +1411,7 @@ extern "C" RandomizerGet RetrieveRandomizerGetFromItemID(ItemID itemID) { } extern "C" void OTRExtScanner() { - auto lst = *Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles().get(); + auto lst = *Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles().get(); for (auto& rPath : lst) { std::vector raw = StringHelper::Split(rPath, "."); @@ -1519,7 +1519,7 @@ extern "C" void InitOTR(int argc, char* argv[]) { CVarClear(CVAR_GENERAL("RandomizerDroppedFile")); // #endregion - Ship::Context::GetInstance()->GetFileDropMgr()->RegisterDropHandler(SoH_HandleConfigDrop); + Ship::Context::GetRawInstance()->GetFileDropMgr()->RegisterDropHandler(SoH_HandleConfigDrop); RegisterImGuiItemIcons(); @@ -1624,7 +1624,7 @@ extern "C" void Graph_StartFrame() { switch (dwScancode) { case KbScancode::LUS_KB_F1: { std::shared_ptr modal = static_pointer_cast( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGuiWindow("Modal Window")); if (modal->IsPopupOpen("Menu Moved")) { modal->DismissPopup(); @@ -1638,7 +1638,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F5: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGameOverlay() ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; @@ -1660,7 +1660,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F6: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGameOverlay() ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; @@ -1676,7 +1676,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F7: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGameOverlay() ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; @@ -1758,7 +1758,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { static int time; int fps = target_fps; int original_fps = 60 / R_UPDATE_RATE; - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); if (target_fps == 20 || original_fps > target_fps) { fps = original_fps; @@ -1807,7 +1807,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { bool curAltAssets = CVarGetInteger(CVAR_SETTING("AltAssets"), 1); if (prevAltAssets != curAltAssets) { prevAltAssets = curAltAssets; - Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); + Ship::Context::GetRawInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); gfx_texture_cache_clear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1819,7 +1819,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } extern "C" void OTRGetPixelDepthPrepare(float x, float y) { - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); if (wnd == nullptr) { return; } @@ -1828,7 +1828,7 @@ extern "C" void OTRGetPixelDepthPrepare(float x, float y) { } extern "C" uint16_t OTRGetPixelDepth(float x, float y) { - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); if (wnd == nullptr) { return 0; } @@ -1862,7 +1862,7 @@ ImFont* OTRGlobals::CreateFontWithSize(float size, std::string fontPath, bool is initData->ResourceVersion = 0; initData->Path = fontPath; std::shared_ptr fontData = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false, initData)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(fontPath, false, initData)); ImFontConfig fontConf; fontConf.FontDataOwnedByAtlas = false; const ImWchar* glyph_ranges = isJapaneseFont ? mImGuiIo->Fonts->GetGlyphRangesJapanese() : nullptr; @@ -2122,27 +2122,27 @@ Color_RGB8 GetColorForControllerLED() { extern "C" void OTRControllerCallback(uint8_t rumble) { // We call this every tick, SDL accounts for this use and prevents driver spam // https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144 - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor( + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor( GetColorForControllerLED()); static std::shared_ptr controllerConfigWindow = nullptr; if (controllerConfigWindow == nullptr) { controllerConfigWindow = std::dynamic_pointer_cast( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGuiWindow("Controller Configuration")); } else if (controllerConfigWindow->TestingRumble()) { return; } if (rumble) { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble(); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble(); } else { - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble(); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble(); } } extern "C" float OTRGetAspectRatio() { - return Ship::Context::GetInstance()->GetWindow()->GetAspectRatio(); + return Ship::Context::GetRawInstance()->GetWindow()->GetAspectRatio(); } extern "C" float OTRGetDimensionFromLeftEdge(float v) { @@ -2155,7 +2155,7 @@ extern "C" float OTRGetDimensionFromRightEdge(float v) { // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { - auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); auto intP = fastWnd->GetInterpreterWeak().lock(); if (!intP) { @@ -2171,7 +2171,7 @@ extern "C" uint32_t OTRGetGameRenderWidth() { // Gets the height of the current render target area extern "C" uint32_t OTRGetGameRenderHeight() { - auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); auto intP = fastWnd->GetInterpreterWeak().lock(); if (!intP) { @@ -2210,7 +2210,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { extern "C" int Controller_ShouldRumble(size_t slot) { // don't rumble if we don't have rumble mappings - if (Ship::Context::GetInstance() + if (Ship::Context::GetRawInstance() ->GetControlDeck() ->GetControllerByPort(static_cast(slot)) ->GetRumble() @@ -2220,7 +2220,7 @@ extern "C" int Controller_ShouldRumble(size_t slot) { } // don't rumble if we don't have connected gamepads - if (Ship::Context::GetInstance() + if (Ship::Context::GetRawInstance() ->GetControlDeck() ->GetConnectedPhysicalDeviceManager() ->GetConnectedSDLGamepadsForPort(slot) @@ -2362,7 +2362,7 @@ extern "C" void EntranceTracker_SetLastEntranceOverride(s16 entranceIndex) { } extern "C" void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* replacement) { - if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + if (auto intP = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()) ->GetInterpreterWeak() .lock()) { intP->RegisterBlendedTexture(name, mask, replacement); @@ -2372,7 +2372,7 @@ extern "C" void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* repla } extern "C" void Gfx_UnregisterBlendedTexture(const char* name) { - if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + if (auto intP = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()) ->GetInterpreterWeak() .lock()) { intP->UnregisterBlendedTexture(name); @@ -2392,7 +2392,7 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) { texAddr = (const uint8_t*)ResourceMgr_GetResourceDataByNameHandlingMQ(imgName); } - if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + if (auto intP = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()) ->GetInterpreterWeak() .lock()) { intP->TextureCacheDelete(texAddr); @@ -2443,7 +2443,7 @@ bool SoH_HandleConfigDrop(char* filePath) { } } - auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()); gui->GetGuiWindow("Console")->Hide(); gui->GetGuiWindow("Actor Viewer")->Hide(); gui->GetGuiWindow("Collision Viewer")->Hide(); @@ -2451,7 +2451,7 @@ bool SoH_HandleConfigDrop(char* filePath) { gui->GetGuiWindow("Display List Viewer")->Hide(); gui->GetGuiWindow("Stats")->Hide(); std::dynamic_pointer_cast( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetGuiWindow("Console")) ->ClearBindings(); @@ -2464,12 +2464,12 @@ bool SoH_HandleConfigDrop(char* filePath) { return true; } catch (std::exception& e) { SPDLOG_ERROR("Failed to load config file: {}", e.what()); - auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()); gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file"); return false; } catch (...) { SPDLOG_ERROR("Failed to load config file"); - auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()); gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file"); return false; } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index a0f797157bd..abd40dd4ba3 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -47,7 +47,7 @@ class OTRGlobals { public: static OTRGlobals* Instance; - std::shared_ptr context; + Ship::Context* context; std::shared_ptr gSaveStateMgr; std::shared_ptr gRandomizer; std::shared_ptr gRandoContext; diff --git a/soh/soh/ResourceManagerHelpers.cpp b/soh/soh/ResourceManagerHelpers.cpp index 56399e52ce6..59dfa2084bc 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -21,16 +21,16 @@ extern "C" PlayState* gPlayState; extern "C" uint32_t ResourceMgr_GetNumGameVersions() { - return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size(); + return Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size(); } extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { - return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + return Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; } extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { uint32_t version = - Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -55,7 +55,7 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { uint32_t version = - Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -130,11 +130,11 @@ extern "C" uint32_t ResourceMgr_IsGameMasterQuest() { } extern "C" void ResourceMgr_LoadDirectory(const char* resName) { - Ship::Context::GetInstance()->GetResourceManager()->LoadResources(resName); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResources(resName); } extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { - Ship::Context::GetInstance()->GetResourceManager()->DirtyResources(resName); + Ship::Context::GetRawInstance()->GetResourceManager()->DirtyResources(resName); } extern "C" void ResourceMgr_UnloadResource(const char* resName) { @@ -142,13 +142,13 @@ extern "C" void ResourceMgr_UnloadResource(const char* resName) { if (path.substr(0, 7) == "__OTR__") { path = path.substr(7); } - auto res = Ship::Context::GetInstance()->GetResourceManager()->UnloadResource(path); + auto res = Ship::Context::GetRawInstance()->GetResourceManager()->UnloadResource(path); } // OTRTODO: There is probably a more elegant way to go about this... // Caller must free each string and the array itself when done. extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { - auto lst = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask); + auto lst = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask); char** result = (char**)malloc(lst->size() * sizeof(char*)); for (size_t i = 0; i < lst->size(); i++) { @@ -185,7 +185,7 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { } extern "C" bool ResourceMgr_IsAltAssetsEnabled() { - return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled(); + return Ship::Context::GetRawInstance()->GetResourceManager()->IsAltAssetsEnabled(); } // Unloads a resource if an alternate version exists when alt assets are enabled @@ -204,7 +204,7 @@ std::shared_ptr ResourceMgr_GetResourceByNameHandlingMQ(const c Path.replace(pos, 7, "/mq/"); } } - return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str()); + return Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(Path.c_str()); } extern "C" char* ResourceMgr_GetResourceDataByNameHandlingMQ(const char* path) { @@ -328,7 +328,7 @@ std::unordered_map> origi // using OTRs instead (When that is available). Index can be found using the commented out section below. extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { auto res = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(path)); if (res == nullptr || static_cast(index) >= res->Instructions.size()) { return; @@ -371,7 +371,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) { auto res = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(path)); if (res == nullptr || static_cast(destinationIndex) >= res->Instructions.size() || static_cast(sourceIndex) >= res->Instructions.size()) { @@ -396,7 +396,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch extern "C" void ResourceMgr_PatchCustomGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { auto res = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(path)); if (res == nullptr || static_cast(index) >= res->Instructions.size()) { return; @@ -415,7 +415,7 @@ extern "C" void ResourceMgr_PatchCustomGfxByName(const char* path, const char* p extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { auto res = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(path)); // If the resource is unavailable (e.g. swapped out when toggling alt assets), clean up the record and bail. if (res == nullptr) { diff --git a/soh/soh/SohGui/ImGuiUtils.cpp b/soh/soh/SohGui/ImGuiUtils.cpp index 9ea36ebd08e..8cf65791069 100644 --- a/soh/soh/SohGui/ImGuiUtils.cpp +++ b/soh/soh/SohGui/ImGuiUtils.cpp @@ -7,6 +7,8 @@ #include +#include + std::map itemMapping = { ITEM_MAP_ENTRY(ITEM_STICK), ITEM_MAP_ENTRY(ITEM_NUT), @@ -217,9 +219,9 @@ const char* GetTextureForItemId(uint32_t itemId) { void RegisterImGuiItemIcons() { for (const auto& entry : itemMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } @@ -227,9 +229,9 @@ void RegisterImGuiItemIcons() { ImVec4 gregGreen = ImVec4(42.0f / 255.0f, 169.0f / 255.0f, 40.0f / 255.0f, 1.0f); ImVec4 gregFadedGreen = gregGreen; gregFadedGreen.w = 0.3f; - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); } @@ -237,53 +239,53 @@ void RegisterImGuiItemIcons() { ImVec4 aButtonBlue = ImVec4(90.f / 255.f, 90.f / 250.f, 255.f / 255.f, 255.f / 255.f); ImVec4 aButtonBlueFaded = aButtonBlue; aButtonBlueFaded.w = 0.3f; - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, aButtonBlue); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, aButtonBlueFaded); } for (const auto& entry : customItemsMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : jabbernutMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : questMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& [quest, entry] : songMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : vanillaSongMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : gSeedTextures) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->LoadGuiTexture(entry.tex, entry.tex, ImVec4(1, 1, 1, 1)); } } \ No newline at end of file diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index 145de6d1b05..472d479dc69 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -100,15 +100,15 @@ void Menu::RemoveSidebarSearch() { void Menu::UpdateWindowBackendObjects() { Fast::WindowBackend runningWindowBackend = - (Fast::WindowBackend)Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); - int32_t configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) { + (Fast::WindowBackend)Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend(); + int32_t configWindowBackendId = Ship::Context::GetRawInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (Ship::Context::GetRawInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) { configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; } - availableWindowBackends = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends(); + availableWindowBackends = Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends(); for (auto& backend : *availableWindowBackends) { availableWindowBackendsMap[(Fast::WindowBackend)backend] = windowBackendsMap.at((Fast::WindowBackend)backend); } @@ -337,14 +337,15 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me }; } break; case WIDGET_AUDIO_BACKEND: { - auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend(); + auto currentAudioBackend = Ship::Context::GetRawInstance()->GetAudio()->GetCurrentAudioBackend(); UIWidgets::ComboboxOptions options = {}; options.color = menuThemeIndex; options.tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect."; - options.disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1; + options.disabled = + Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1; options.disabledTooltip = "Only one audio API is available on this platform."; if (UIWidgets::Combobox("Audio API", ¤tAudioBackend, audioBackendsMap, options)) { - Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); + Ship::Context::GetRawInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); } } break; case WIDGET_VIDEO_BACKEND: { @@ -355,11 +356,11 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me options.disabledTooltip = "Only one renderer API is available on this platform."; if (UIWidgets::Combobox("Renderer API (Needs reload)", &configWindowBackend, availableWindowBackendsMap, options)) { - Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", - (int32_t)(configWindowBackend)); - Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", - windowBackendsMap.at(configWindowBackend)); - Ship::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetRawInstance()->GetConfig()->SetInt("Window.Backend.Id", + (int32_t)(configWindowBackend)); + Ship::Context::GetRawInstance()->GetConfig()->SetString("Window.Backend.Name", + windowBackendsMap.at(configWindowBackend)); + Ship::Context::GetRawInstance()->GetConfig()->Save(); UpdateWindowBackendObjects(); } } break; @@ -490,7 +491,7 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me SPDLOG_ERROR(msg.c_str()); break; } - auto window = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow(widget.windowName); + auto window = Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow(widget.windowName); if (!window) { std::string msg = fmt::format("Error drawing window contents: windowName {} does not exist", widget.windowName); @@ -766,11 +767,11 @@ void Menu::DrawElement() { "Quit SoH", "Are you sure you want to quit SoH?", "Quit", "Cancel", []() { std::shared_ptr menu = - static_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenu()); + static_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetMenu()); if (!menu->IsMenuPopped()) { menu->ToggleVisibility(); } - Ship::Context::GetInstance()->GetWindow()->Close(); + Ship::Context::GetRawInstance()->GetWindow()->Close(); }, nullptr); } @@ -790,7 +791,7 @@ void Menu::DrawElement() { ; if (UIWidgets::Button(ICON_FA_UNDO, options2)) { std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); } ImGui::SameLine(); @@ -803,7 +804,7 @@ void Menu::DrawElement() { // Update gamepad navigation after close based on if other menus are still visible auto mImGuiIo = &ImGui::GetIO(); if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible()) { + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible()) { mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; } else { mImGuiIo->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad; diff --git a/soh/soh/SohGui/ResolutionEditor.cpp b/soh/soh/SohGui/ResolutionEditor.cpp index db61e814cbc..778504c4b00 100644 --- a/soh/soh/SohGui/ResolutionEditor.cpp +++ b/soh/soh/SohGui/ResolutionEditor.cpp @@ -121,7 +121,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } UIWidgets::PopStyleCombobox(); // Horizontal Resolution, if visibility is enabled for it. @@ -191,7 +191,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { .Color(THEME_COLOR)); if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } // Integer Scaling @@ -225,7 +225,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { // This is just here to update the value shown on the slider. // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", integerScale_maximumBounds); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } // End of integer scaling settings UIWidgets::PopStyleHeader(); @@ -255,7 +255,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { " If the image is stretched and you don't know why, click this."); if (ImGui::Button("Click to reenable aspect correction.")) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } UIWidgets::Spacer(2); } @@ -306,7 +306,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } @@ -336,7 +336,7 @@ void ResolutionCustomWidget(WidgetInfo& info) { if (UIWidgets::Button("Click to reset a console variable that may be causing this.", UIWidgets::ButtonOptions().Color(THEME_COLOR))) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } } else { @@ -374,12 +374,12 @@ void ResolutionCustomWidget(WidgetInfo& info) { } CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } void RegisterResolutionWidgets() { - auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()); mInterpreter = fastWnd->GetInterpreterWeak(); WidgetPath path = { "Settings", "Graphics", SECTION_COLUMN_2 }; @@ -421,7 +421,7 @@ void RegisterResolutionWidgets() { .PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_LOW_RES_MODE, 0); }) .Callback([](WidgetInfo& info) { CVarSetInteger(CVAR_LOW_RES_MODE, 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }); // Aspect Ratio @@ -466,7 +466,7 @@ void RegisterResolutionWidgets() { CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); } CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }) .Options(ComboboxOptions().ComboMap(aspectRatioPresetLabels)); mSohMenu->AddWidget(path, "AspectRatioCustom", WIDGET_CUSTOM) @@ -543,7 +543,7 @@ void UpdateResolutionVars() { } CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } // Initialise update flags. for (uint8_t i = 0; i < sizeof(update); i++) { diff --git a/soh/soh/SohGui/SohGui.cpp b/soh/soh/SohGui/SohGui.cpp index 04c47b4b7e6..2aa79b1d000 100644 --- a/soh/soh/SohGui/SohGui.cpp +++ b/soh/soh/SohGui/SohGui.cpp @@ -101,7 +101,7 @@ std::shared_ptr GetSohMenu() { } void SetupMenu() { - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetRawInstance()->GetWindow()->GetGui(); mSohMenu = std::make_shared(CVAR_WINDOW("Menu"), "Port Menu"); gui->SetMenu(mSohMenu); @@ -115,7 +115,7 @@ void SetupMenuElements() { } void SetupGuiElements() { - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetRawInstance()->GetWindow()->GetGui(); mConsoleWindow = std::make_shared(CVAR_WINDOW("SohConsole"), "Console##SoH", ImVec2(820, 630)); gui->AddGuiWindow(mConsoleWindow); @@ -200,7 +200,7 @@ void SetupGuiElements() { } void Destroy() { - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetRawInstance()->GetWindow()->GetGui(); gui->RemoveAllGuiWindows(); mNotificationWindow = nullptr; diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index 218c84c80ee..ff793deb247 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -108,28 +108,28 @@ void SohMenu::InitElement() { disabledMap = { { DISABLE_FOR_NO_VSYNC, { [](disabledInfo& info) -> bool { - return !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync(); + return !Ship::Context::GetRawInstance()->GetWindow()->CanDisableVerticalSync(); }, "Disabling VSync not supported" } }, { DISABLE_FOR_NO_WINDOWED_FULLSCREEN, { [](disabledInfo& info) -> bool { - return !Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen(); + return !Ship::Context::GetRawInstance()->GetWindow()->SupportsWindowedFullscreen(); }, "Windowed Fullscreen not supported" } }, { DISABLE_FOR_NO_MULTI_VIEWPORT, { [](disabledInfo& info) -> bool { - return !Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports(); + return !Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SupportsViewports(); }, "Multi-viewports not supported" } }, { DISABLE_FOR_NOT_DIRECTX, { [](disabledInfo& info) -> bool { - return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != + return Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() != Fast::WindowBackend::FAST3D_DXGI_DX11; }, "Available Only on DirectX" } }, { DISABLE_FOR_DIRECTX, { [](disabledInfo& info) -> bool { - return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == + return Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() == Fast::WindowBackend::FAST3D_DXGI_DX11; }, "Not Available on DirectX" } }, diff --git a/soh/soh/SohGui/SohMenuDevTools.cpp b/soh/soh/SohGui/SohMenuDevTools.cpp index c5b88ce8fbc..43a6a7a5d13 100644 --- a/soh/soh/SohGui/SohMenuDevTools.cpp +++ b/soh/soh/SohGui/SohMenuDevTools.cpp @@ -120,7 +120,7 @@ void SohMenu::AddMenuDevTools() { .ComboMap(logLevels) .DefaultIndex(defaultLogLevel)) .Callback([](WidgetInfo& info) { - Ship::Context::GetInstance()->GetLogger()->set_level( + Ship::Context::GetRawInstance()->GetLogger()->set_level( (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), defaultLogLevel)); }); diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index c17a622e78a..38e94e06d91 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -362,7 +362,7 @@ void SohMenu::AddMenuEnhancements() { CVAR_INT_SHIP_INIT(CVAR_ENHANCEMENT("TimeSavers.SkipMiscInteractions"), true); CVAR_INT_SHIP_INIT(CVAR_ENHANCEMENT("TimeSavers.DisableTitleCard"), true); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }); AddWidget(path, "None##Skips", WIDGET_BUTTON) .SameLine(true) @@ -379,7 +379,7 @@ void SohMenu::AddMenuEnhancements() { CVAR_INT_SHIP_INIT(CVAR_ENHANCEMENT("TimeSavers.SkipMiscInteractions"), false); CVAR_INT_SHIP_INIT(CVAR_ENHANCEMENT("TimeSavers.DisableTitleCard"), false); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }); AddWidget(path, "Skip Intro", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Intro")) @@ -1857,7 +1857,7 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_CHEAT("SaveStatePromise")) .Callback([](WidgetInfo& info) { CVarSetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }); AddWidget(path, "I understand, enable save states", WIDGET_CVAR_CHECKBOX) .PreFunc([](WidgetInfo& info) { info.isHidden = CVarGetInteger(CVAR_CHEAT("SaveStatePromise"), 0) == 0; }) @@ -1875,9 +1875,9 @@ void SohMenu::AddMenuEnhancements() { CVarSetInteger(CVAR_CHEAT("BetaQuestWorld"), 0); } std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }) .Options(CheckboxOptions().Tooltip("Turns on OoT Beta Quest. *WARNING*: This will reset your game!")); AddWidget(path, "Beta Quest World: %d", WIDGET_CVAR_SLIDER_INT) @@ -1887,9 +1887,9 @@ void SohMenu::AddMenuEnhancements() { }) .Callback([](WidgetInfo& info) { std::reinterpret_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }) .Options(IntSliderOptions().DefaultValue(0).Min(0).Max(8).Tooltip( "Set the Beta Quest world to explore. *WARNING*: Changing this will reset your game!\n" diff --git a/soh/soh/SohGui/SohMenuNetwork.cpp b/soh/soh/SohGui/SohMenuNetwork.cpp index b136cb4cbae..8e2ba18f577 100644 --- a/soh/soh/SohGui/SohMenuNetwork.cpp +++ b/soh/soh/SohGui/SohMenuNetwork.cpp @@ -88,11 +88,11 @@ void SohMenu::AddMenuNetwork() { .Callback([](WidgetInfo& info) { if (Sail::Instance->isEnabled) { CVarClear(CVAR_REMOTE_SAIL("Enabled")); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); Sail::Instance->Disable(); } else { CVarSetInteger(CVAR_REMOTE_SAIL("Enabled"), 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); Sail::Instance->Enable(); } }); @@ -154,11 +154,11 @@ void SohMenu::AddMenuNetwork() { .Callback([](WidgetInfo& info) { if (CrowdControl::Instance->isEnabled) { CVarClear(CVAR_REMOTE_CROWD_CONTROL("Enabled")); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); CrowdControl::Instance->Disable(); } else { CVarSetInteger(CVAR_REMOTE_CROWD_CONTROL("Enabled"), 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); CrowdControl::Instance->Enable(); } }); diff --git a/soh/soh/SohGui/SohMenuRandomizer.cpp b/soh/soh/SohGui/SohMenuRandomizer.cpp index d53fdf6c519..24274a4d3d5 100644 --- a/soh/soh/SohGui/SohMenuRandomizer.cpp +++ b/soh/soh/SohGui/SohMenuRandomizer.cpp @@ -41,7 +41,7 @@ void SaveEnabledTricks() { } else { CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str()); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); tricksDirty = false; return; } @@ -111,7 +111,7 @@ void DrawLocationsMenu(WidgetInfo& info) { } CVarSetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), excludedLocationString.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); locationsDirty = true; } UIWidgets::PopStyleButton(); @@ -162,7 +162,7 @@ void DrawLocationsMenu(WidgetInfo& info) { CVarSetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), excludedLocationString.c_str()); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); locationsDirty = true; } UIWidgets::PopStyleButton(); diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index b806da560c7..0405ea8bd45 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -167,7 +167,7 @@ void SohMenu::AddMenuSettings() { .CVar(CVAR_SETTING("CursorVisibility")) .RaceDisable(false) .Callback([](WidgetInfo& info) { - Ship::Context::GetInstance()->GetWindow()->SetForceCursorVisibility( + Ship::Context::GetRawInstance()->GetWindow()->SetForceCursorVisibility( CVarGetInteger(CVAR_SETTING("CursorVisibility"), 0)); }) .Options(CheckboxOptions().Tooltip("Makes the cursor always visible, even in full screen.")); @@ -195,7 +195,7 @@ void SohMenu::AddMenuSettings() { AddWidget(path, "Open App Files Folder", WIDGET_BUTTON) .RaceDisable(false) .Callback([](WidgetInfo& info) { - std::string filesPath = Ship::Context::GetInstance()->GetAppDirectoryPath(); + std::string filesPath = Ship::Context::GetRawInstance()->GetAppDirectoryPath(); SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str()); }) .Options(ButtonOptions().Tooltip("Opens the folder that contains the save and mods folders, etc.")); @@ -330,13 +330,13 @@ void SohMenu::AddMenuSettings() { AddWidget(path, "Graphics Options", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Toggle Fullscreen", WIDGET_BUTTON) .RaceDisable(false) - .Callback([](WidgetInfo& info) { Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); }) + .Callback([](WidgetInfo& info) { Ship::Context::GetRawInstance()->GetWindow()->ToggleFullscreen(); }) .Options(ButtonOptions().Tooltip("Toggles Fullscreen On/Off.")); AddWidget(path, "Internal Resolution", WIDGET_CVAR_SLIDER_FLOAT) .CVar(CVAR_INTERNAL_RESOLUTION) .RaceDisable(false) .Callback([](WidgetInfo& info) { - Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( + Ship::Context::GetRawInstance()->GetWindow()->SetResolutionMultiplier( CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); }) .PreFunc([](WidgetInfo& info) { @@ -361,7 +361,7 @@ void SohMenu::AddMenuSettings() { .CVar(CVAR_MSAA_VALUE) .RaceDisable(false) .Callback([](WidgetInfo& info) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); + Ship::Context::GetRawInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); }) .Options( IntSliderOptions() @@ -437,9 +437,10 @@ void SohMenu::AddMenuSettings() { "This will completely erase the controls config, including registered devices.\nContinue?", "Clear", "Cancel", []() { - Ship::Context::GetInstance()->GetConsoleVariables()->ClearBlock(CVAR_PREFIX_SETTING ".Controllers"); + Ship::Context::GetRawInstance()->GetConsoleVariables()->ClearBlock(CVAR_PREFIX_SETTING + ".Controllers"); uint8_t bits = 0; - Ship::Context::GetInstance()->GetControlDeck()->Init(&bits); + Ship::Context::GetRawInstance()->GetControlDeck()->Init(&bits); }, nullptr); }) diff --git a/soh/soh/SohGui/UIWidgets.cpp b/soh/soh/SohGui/UIWidgets.cpp index fb104983219..f97e0dd5665 100644 --- a/soh/soh/SohGui/UIWidgets.cpp +++ b/soh/soh/SohGui/UIWidgets.cpp @@ -384,7 +384,7 @@ bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); if (Checkbox(label, &value, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -615,7 +615,7 @@ bool CVarSliderInt(const char* label, const char* cvarName, const IntSliderOptio int32_t value = CVarGetInteger(cvarName, options.defaultValue); if (SliderInt(label, &value, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -746,7 +746,7 @@ bool CVarSliderFloat(const char* label, const char* cvarName, const FloatSliderO float value = CVarGetFloat(cvarName, options.defaultValue); if (SliderFloat(label, &value, options)) { CVarSetFloat(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -822,7 +822,7 @@ bool CVarInputString(const char* label, const char* cvarName, const InputOptions std::string value = CVarGetString(cvarName, options.defaultValue.c_str()); if (InputString(label, &value, options)) { CVarSetString(cvarName, value.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -874,7 +874,7 @@ bool CVarInputInt(const char* label, const char* cvarName, const InputOptions& o int32_t value = CVarGetInteger(cvarName, defaultValue); if (InputInt(label, &value, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -919,7 +919,7 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul CVarClear((std::string(cvarName) + ".A").c_str()); CVarClear((std::string(cvarName) + ".Type").c_str()); CVarClearBlock(valueCVar.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } if (showRandom) { @@ -936,7 +936,7 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul CVarSetColor(valueCVar.c_str(), color); CVarSetInteger(rainbowCVar.c_str(), 0); // On click disable rainbow mode. ShipInit::Init(rainbowCVar.c_str()); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } if (showRainbow) { @@ -964,7 +964,7 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul color.b = (uint8_t)(colorVec.z * 255.0f); color.a = (uint8_t)(colorVec.w * 255.0f); CVarSetColor(valueCVar.c_str(), color); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(valueCVar.c_str()); changed = true; } @@ -1039,7 +1039,7 @@ bool CVarRadioButton(const char* text, const char* cvarName, int32_t id, const R PushStyleCheckbox(options.color); if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { CVarSetInteger(cvarName, id); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ret = true; } ImGui::SameLine(); @@ -1246,7 +1246,7 @@ bool CVarBtnSelector(const char* label, const char* cvarName, const BtnSelectorO int32_t value = CVarGetInteger(cvarName, options.defaultValue); if (BtnSelector(label, &value, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } diff --git a/soh/soh/SohGui/UIWidgets.hpp b/soh/soh/SohGui/UIWidgets.hpp index 8d0f25b2fcb..f9902f97d8b 100644 --- a/soh/soh/SohGui/UIWidgets.hpp +++ b/soh/soh/SohGui/UIWidgets.hpp @@ -1027,7 +1027,7 @@ bool CVarCombobox(const char* label, const char* cvarName, const std::map(label, &value, comboMap, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -1041,7 +1041,7 @@ bool CVarCombobox(const char* label, const char* cvarName, const std::vector(label, &value, comboVector, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -1055,7 +1055,7 @@ bool CVarCombobox(const char* label, const char* cvarName, const char* (&comboAr int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboArray, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index af8dd8ac382..643408c3c98 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -87,17 +87,17 @@ ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file, // Read the segment pointer (always 32 bit, doesn't adjust for system pointer size) std::string path = reader->ReadString(); auto animData = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(path.c_str())); // If direct load failed and alt assets are enabled, try with alt/ prefix - if (animData == nullptr && Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled()) { + if (animData == nullptr && Ship::Context::GetRawInstance()->GetResourceManager()->IsAltAssetsEnabled()) { std::string altPath = path; if (altPath.find("__OTR__") == 0) { altPath = altPath.substr(7); // Strip __OTR__ } altPath = "alt/" + altPath; animData = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(altPath.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(altPath.c_str())); } if (animData != nullptr) { diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 098efd23633..cdfe4311cc4 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -290,7 +290,7 @@ ResourceFactoryXMLAudioSampleV0::ReadResource(std::shared_ptr file, const char* path = child->Attribute("Path"); - auto sampleFile = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->LoadFile(path); + auto sampleFile = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->LoadFile(path); audioSample->sample.fileSize = sampleFile->Buffer.get()->size(); if (customFormatStr != nullptr) { // Compressed files can take a really long time to decode (~250ms per). diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index 313284f6a0b..5052acce2ec 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -342,7 +342,7 @@ ResourceFactoryXMLAudioSequenceV0::ReadResource(std::shared_ptr file const char* path = child->Attribute("Path"); std::shared_ptr seqFile; if (path != nullptr) { - seqFile = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->LoadFile(path); + seqFile = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->LoadFile(path); } if (!streamed) { diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index f71f31d1458..bb67ef29d9d 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -65,7 +65,8 @@ ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr if (sampleFileName.empty()) { drum->sound.sample = nullptr; } else { - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); drum->sound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } @@ -109,7 +110,8 @@ ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument->lowNotesSound.tuning = reader->ReadFloat(); - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument->lowNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument->lowNotesSound.sample = nullptr; @@ -122,7 +124,8 @@ ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument->normalNotesSound.tuning = reader->ReadFloat(); - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument->normalNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument->normalNotesSound.sample = nullptr; @@ -134,7 +137,8 @@ ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument->highNotesSound.tuning = reader->ReadFloat(); - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument->highNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument->highNotesSound.sample = nullptr; @@ -161,7 +165,8 @@ ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); soundEffect.tuning = reader->ReadFloat(); - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); soundEffect.sample = static_cast(res ? res->GetRawPointer() : nullptr); } @@ -232,7 +237,7 @@ void ResourceFactoryXMLSoundFontV0::ParseDrums(AudioSoundFont* soundFont, tinyxm const char* sampleStr = element->Attribute("SampleRef"); if (sampleStr != nullptr && sampleStr[0] != 0) { - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleStr); + auto res = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleStr); drum->sound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { drum->sound.sample = nullptr; @@ -308,7 +313,7 @@ void ResourceFactoryXMLSoundFontV0::ParseInstruments(AudioSoundFont* soundFont, const char* sampleStr = instrumentElement->Attribute("SampleRef"); if (sampleStr != nullptr && sampleStr[0] != 0) { std::shared_ptr res = static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); if (res->tuning != -1.0f) { instrument->lowNotesSound.tuning = res->tuning; } @@ -322,7 +327,7 @@ void ResourceFactoryXMLSoundFontV0::ParseInstruments(AudioSoundFont* soundFont, const char* sampleStr = instrumentElement->Attribute("SampleRef"); if (sampleStr != nullptr && sampleStr[0] != 0) { std::shared_ptr res = static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); if (res->tuning != -1.0f) { instrument->normalNotesSound.tuning = res->tuning; } @@ -336,7 +341,7 @@ void ResourceFactoryXMLSoundFontV0::ParseInstruments(AudioSoundFont* soundFont, const char* sampleStr = instrumentElement->Attribute("SampleRef"); if (sampleStr != nullptr && sampleStr[0] != 0) { std::shared_ptr res = static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); if (res->tuning != -1.0f) { instrument->highNotesSound.tuning = res->tuning; } @@ -376,7 +381,7 @@ void ResourceFactoryXMLSoundFontV0::ParseSfxTable(AudioSoundFont* soundFont, tin sound.tuning = element->FloatAttribute("Tuning"); if (sampleStr[0] != 0) { auto res = static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleStr)); if (res->tuning != -1.0f) { sound.tuning = res->tuning; } @@ -431,7 +436,7 @@ ResourceFactoryXMLSoundFontV0::ReadResource(std::shared_ptr file, std::string origName = "audio/fonts/"; origName += patch; audioSoundFont = dynamic_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(origName)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(origName)); } else { audioSoundFont = std::make_shared(initData); memset(&audioSoundFont->soundFont, 0, sizeof(audioSoundFont->soundFont)); diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index f8147652370..f44de85461b 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -46,7 +46,7 @@ ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file, for (size_t i = 0; i < skeleton->limbTable.size(); i++) { std::string limbStr = skeleton->limbTable[i]; - auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str()); + auto limb = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str()); skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } @@ -116,7 +116,7 @@ ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file, std::string limbName = child->Attribute("Path"); skel->limbTable.push_back(limbName); - auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str()); + auto limb = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str()); skel->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 5a6d35cc225..bf339d87dd2 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -19,7 +19,7 @@ SetAlternateHeadersFactory::ReadResource(std::shared_ptr auto headerName = reader->ReadString(); if (!headerName.empty()) { setAlternateHeaders->headers.push_back(std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); setAlternateHeaders->headerFileNames.push_back(headerName); } else { setAlternateHeaders->headers.push_back(nullptr); @@ -49,7 +49,8 @@ SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptrAttribute("Path")); if (!headerName.empty()) { setAlternateHeaders->headers.push_back(std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess( + headerName.c_str()))); } else { setAlternateHeaders->headers.push_back(nullptr); } diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index cc0a7b0057c..8e3a8f6d406 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -15,7 +15,8 @@ SetCollisionHeaderFactory::ReadResource(std::shared_ptr setCollisionHeader->fileName = reader->ReadString(); setCollisionHeader->collisionHeader = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess( + setCollisionHeader->fileName.c_str())); if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { LogSetCollisionHeaderAsXML(setCollisionHeader); @@ -33,7 +34,8 @@ SetCollisionHeaderFactoryXML::ReadResource(std::shared_ptrfileName = reader->Attribute("FileName"); setCollisionHeader->collisionHeader = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess( + setCollisionHeader->fileName.c_str())); return setCollisionHeader; } diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index a8883b2e4e4..3aee3231e1c 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -14,7 +14,7 @@ std::shared_ptr SetCutscenesFactory::ReadResource(std::shared_p setCutscenes->fileName = reader->ReadString(); setCutscenes->cutscene = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { LogCutscenesAsXML(setCutscenes); @@ -31,7 +31,7 @@ std::shared_ptr SetCutscenesFactoryXML::ReadResource(std::share setCutscenes->fileName = reader->Attribute("FileName"); setCutscenes->cutscene = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); return setCutscenes; } diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 62a3d0d7f91..36c42a2246e 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -17,7 +17,7 @@ std::shared_ptr SetPathwaysFactory::ReadResource(std::shared_pt for (uint32_t i = 0; i < setPathways->numPaths; i++) { std::string pathFileName = reader->ReadString(); auto path = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); setPathways->pathFileNames.push_back(pathFileName); } @@ -42,7 +42,7 @@ std::shared_ptr SetPathwaysFactoryXML::ReadResource(std::shared if (childName == "Pathway") { std::string pathFileName = child->Attribute("FilePath"); auto path = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); setPathways->pathFileNames.push_back(pathFileName); } diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 65cb9f825ea..35d29e0c9c4 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -106,7 +106,7 @@ void SkeletonPatcher::ClearSkeletons() { } void SkeletonPatcher::UpdateSkeletons() { - auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); + auto resourceMgr = Ship::Context::GetRawInstance()->GetResourceManager(); bool isAlt = resourceMgr->IsAltAssetsEnabled(); for (auto skel : skeletons) { Skeleton* newSkel = @@ -177,12 +177,12 @@ void SkeletonPatcher::UpdateTunicSkeletons(SkeletonPatchInfo& skel) { void SkeletonPatcher::UpdateCustomSkeletonFromPath(const std::string& skeletonPath, SkeletonPatchInfo& skel) { Skeleton* newSkel = nullptr; Skeleton* altSkel = nullptr; - auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); + auto resourceMgr = Ship::Context::GetRawInstance()->GetResourceManager(); bool isAlt = resourceMgr->IsAltAssetsEnabled(); // If alt assets are on, look for alt tagged skeletons if (isAlt) { - altSkel = (Skeleton*)Ship::Context::GetInstance() + altSkel = (Skeleton*)Ship::Context::GetRawInstance() ->GetResourceManager() ->LoadResource(Ship::IResource::gAltAssetPrefix + skeletonPath, true) .get(); @@ -195,7 +195,8 @@ void SkeletonPatcher::UpdateCustomSkeletonFromPath(const std::string& skeletonPa // Load new skeleton based on the custom model if it exists if (altSkel == nullptr) { - newSkel = (Skeleton*)Ship::Context::GetInstance()->GetResourceManager()->LoadResource(skeletonPath, true).get(); + newSkel = + (Skeleton*)Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(skeletonPath, true).get(); } // Change back to the original skeleton if no skeleton's were found diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 1a83970ffa1..a693d5078f0 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -23,11 +23,11 @@ static void SetMessageEntry(MessageTableEntry& entry, const SOH::MessageEntry& m } static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEntry*& table, size_t tableSize) { - auto lst = *Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); + auto lst = *Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); for (auto& tPath : lst) { auto file = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(tPath)); for (size_t j = 0; j < file->messages.size(); ++j) { // Check if same text ID exists already @@ -44,8 +44,8 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt } MessageTableEntry* OTRMessage_LoadTable(const std::string& filePath, bool isNES) { - auto file = - std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast( + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; @@ -95,7 +95,7 @@ extern "C" void OTRMessage_Init() { if (sStaffMessageEntryTablePtr == NULL) { auto file2 = - std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource( "text/staff_message_data_static/staff_message_data_static")); // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already // null. diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index f997c372843..892edd5fd0c 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -14,7 +14,7 @@ s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); // LUS::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { Ship::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName) { - auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fileName); + auto res = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(fileName); return res.get(); } @@ -81,7 +81,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { GameInteractor_ExecuteAfterSceneCommands(play->sceneNum); Play_InitEnvironment(play, play->skyboxId); - /* auto data = static_cast(Ship::Context::GetInstance() + /* auto data = static_cast(Ship::Context::GetRawInstance() ->GetResourceManager() ->ResourceLoad("object_link_child\\object_link_childVtx_01FE08") .get());