From f734f6148897377ad2c2f45d8c05d45d043c2c30 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Fri, 8 May 2026 11:31:31 +0100 Subject: [PATCH 1/5] Attempt to update to latest LUS --- libultraship | 2 +- .../Enhancements/TimeDisplay/TimeDisplay.cpp | 33 ++++--- soh/soh/Enhancements/controls/InputViewer.cpp | 92 ++++++++++--------- soh/soh/Enhancements/custom-message/text.cpp | 7 +- .../Enhancements/debugger/debugSaveEditor.cpp | 28 +++--- .../Enhancements/randomizer/Plandomizer.cpp | 44 ++++----- .../randomizer/randomizer_item_tracker.cpp | 16 ++-- .../Enhancements/timesplits/TimeSplits.cpp | 16 ++-- soh/soh/Notification/Notification.cpp | 4 +- soh/soh/OTRGlobals.cpp | 37 ++++++-- soh/soh/ResourceManagerHelpers.cpp | 3 + soh/soh/ShipUtils.h | 1 + soh/soh/SohGui/ImGuiUtils.cpp | 36 ++++---- soh/soh/SohGui/Menu.cpp | 6 +- soh/soh/SohGui/Menu.h | 6 +- soh/soh/SohGui/MenuTypes.h | 9 +- soh/soh/SohGui/SohMenu.cpp | 4 +- 17 files changed, 192 insertions(+), 152 deletions(-) diff --git a/libultraship b/libultraship index fdcaf633677..42ecb8ed48e 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit fdcaf6336776d24a6408d016b0a52243f108f250 +Subproject commit 42ecb8ed48e4b15c21fe2e0d7e34cb5c02efa23d diff --git a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp index 5e213d26d3b..3849a40715d 100644 --- a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp +++ b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp @@ -6,6 +6,8 @@ #include "assets/soh_assets.h" #include "soh/SohGui/ImGuiUtils.h" +#include + extern "C" { #include "macros.h" #include "functions.h" @@ -83,18 +85,20 @@ static void TimeDisplayGetTimer(uint32_t timeID) { Player* player = GET_PLAYER(gPlayState); uint32_t timer1 = gSaveContext.timerSeconds; + auto gui = std::dynamic_pointer_cast(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())); + switch (timeID) { case DISPLAY_IN_GAME_TIMER: - textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->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 = - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("DAY_TIME_TIMER"); + gui->GetTextureByName("DAY_TIME_TIMER"); } else { textureDisplay = - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NIGHT_TIME_TIMER"); + gui->GetTextureByName("NIGHT_TIME_TIMER"); } timeDisplayTime = convertDayTime(gSaveContext.dayTime).c_str(); break; @@ -107,18 +111,17 @@ static void TimeDisplayGetTimer(uint32_t timeID) { : COLOR_LIGHT_BLUE) : COLOR_WHITE; if (gSaveContext.timerState <= TIMER_STATE_ENV_HAZARD_TICK) { - textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + 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 = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + textureDisplay = gui->GetTextureByName( itemMapping[ITEM_SWORD_MASTER].name); } } else { - textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - itemMapping[ITEM_TUNIC_KOKIRI].name); + textureDisplay = gui->GetTextureByName(itemMapping[ITEM_TUNIC_KOKIRI].name); timeDisplayTime = "-:--"; } break; @@ -132,7 +135,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) { timeDisplayTime = convertNaviTime(NAVI_COOLDOWN - gSaveContext.naviTimer).c_str(); textColor = COLOR_GREY; } - textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NAVI_TIMER"); + textureDisplay = gui->GetTextureByName("NAVI_TIMER"); break; default: break; @@ -203,12 +206,12 @@ void TimeDisplayWindow::Draw() { } if (textToDecode[i] == '.') { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale)); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->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)); @@ -247,16 +250,16 @@ static void TimeDisplayInitTimers() { } void TimeDisplayWindow::InitElement() { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1)); for (auto& load : digitList) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(load.first.c_str(), load.second, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(load.first.c_str(), load.second, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 9e46497b540..284284f4967 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -13,6 +13,8 @@ #include "soh/SohGui/UIWidgets.hpp" #include "soh/SohGui/SohGui.hpp" +#include + using namespace UIWidgets; // Text colors @@ -47,14 +49,14 @@ 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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnOutlineTexture), size, + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(btnOutlineTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Render button if pressed if (state) { ImGui::SetCursorPos(pos); ImGui::SetNextItemAllowOverlap(); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnTexture), size, + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(btnTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } } @@ -72,79 +74,79 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; if (!sButtonTexturesLoaded) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Start-Btn", "textures/buttons/StartBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Analog-Stick", "textures/buttons/AnalogStick.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Left", "textures/buttons/DPadLeft.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Right", "textures/buttons/DPadRight.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Down", "textures/buttons/DPadDown.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Modifier-1", "textures/buttons/Mod1.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Modifier-2", "textures/buttons/Mod2.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Right-Stick", "textures/buttons/RightStick.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "A-Btn Outline", "textures/buttons/ABtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "B-Btn Outline", "textures/buttons/BBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "L-Btn Outline", "textures/buttons/LBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "R-Btn Outline", "textures/buttons/RBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "C-Left Outline", "textures/buttons/CLeftOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "C-Right Outline", "textures/buttons/CRightOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "C-Up Outline", "textures/buttons/CUpOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "C-Down Outline", "textures/buttons/CDownOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Modifier-1 Outline", "textures/buttons/Mod1Outline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Modifier-2 Outline", "textures/buttons/Mod2Outline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( "Right-Stick Outline", "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; } @@ -162,7 +164,7 @@ void InputViewer::DrawElement() { CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED); const bool useGlobalOutlineMode = CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); - ImVec2 bgSize = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); + ImVec2 bgSize = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); ImGui::SetNextWindowSize( @@ -199,7 +201,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); // Background ImGui::Image( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Input-Viewer-Background"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Input-Viewer-Background"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -350,7 +352,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick Outline"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Analog-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int analogStickMode = @@ -361,7 +363,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( 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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Analog-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -374,7 +376,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick Outline"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Right-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int rightStickMode = @@ -385,7 +387,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( 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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Right-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } diff --git a/soh/soh/Enhancements/custom-message/text.cpp b/soh/soh/Enhancements/custom-message/text.cpp index 267f3339ed0..b8b7a8031e3 100644 --- a/soh/soh/Enhancements/custom-message/text.cpp +++ b/soh/soh/Enhancements/custom-message/text.cpp @@ -84,9 +84,10 @@ static void replaceAll(std::string& target, const std::string& oldStr, const std } void Text::Replace(const std::string& oldStr, const std::string& newStr) { - for (std::string& str : { std::ref(english), std::ref(french), std::ref(german), std::ref(spanish) }) { - replaceAll(str, oldStr, newStr); - } + replaceAll(english, oldStr, newStr); + replaceAll(french, oldStr, newStr); + replaceAll(german, oldStr, newStr); + replaceAll(spanish, oldStr,newStr); } void Text::Replace(const std::string& oldStr, const Text& newText) { diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 3c99ea19ee0..c26fff2a7ab 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -16,6 +16,8 @@ #include #include +#include + extern "C" { #include #include "variables.h" @@ -518,7 +520,7 @@ void DrawInfoTab() { void DrawBGSItemFlag(uint8_t itemID) { const ItemMapEntry& slotEntry = itemMapping[itemID]; - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); } @@ -546,7 +548,7 @@ void DrawInventoryTab() { if (item == ITEM_ROCS_FEATHER) { auto ret = ImGui::ImageButton( "ROCS_FEATHER", - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("ROCS_FEATHER"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ROCS_FEATHER"), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { selectedIndex = index; @@ -556,7 +558,7 @@ void DrawInventoryTab() { const ItemMapEntry& slotEntry = itemMapping.find(item)->second; auto ret = ImGui::ImageButton( slotEntry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { selectedIndex = index; @@ -607,7 +609,7 @@ void DrawInventoryTab() { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( slotEntry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); PopStyleButton(); if (ret) { @@ -640,7 +642,7 @@ void DrawInventoryTab() { ImGui::PushItemWidth(IMAGE_SIZE); ImGui::BeginGroup(); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(itemMapping[item].name), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(itemMapping[item].name), ImVec2(IMAGE_SIZE, IMAGE_SIZE)); PushStyleInput(THEME_COLOR); ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item)); @@ -1233,7 +1235,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping[item]; if (ImGui::ImageButton(slotEntry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1))) { ImGui::OpenPopup(upgradePopupPicker); } @@ -1263,7 +1265,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(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { Inventory_ChangeUpgrade(categoryId, pickerIndex); @@ -1300,7 +1302,7 @@ void DrawEquipmentTab() { const ItemMapEntry& entry = itemMapping[equipmentValues[i]]; PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton(entry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasEquip ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1435,7 +1437,7 @@ void DrawQuestItemButton(uint32_t item) { bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton(entry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasQuestItem ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1457,7 +1459,7 @@ void DrawDungeonItemButton(uint32_t item, uint32_t scene) { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( entry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem ? entry.name : entry.nameFaded), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(hasItem ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { if (hasItem) { @@ -1504,7 +1506,7 @@ void DrawQuestStatusTab() { bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton(entry.name.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasQuestItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { @@ -1583,7 +1585,7 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_JABU_JABU_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); ImGui::SameLine(); @@ -1974,6 +1976,6 @@ void SaveEditorWindow::DrawElement() { } void SaveEditorWindow::InitElement() { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ROCS_FEATHER", gRocsFeatherTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ROCS_FEATHER", gRocsFeatherTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index 7efd9c99d6a..a0166ac8d27 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -18,6 +18,8 @@ #include "soh/Enhancements/randomizer/Traps.h" #include "soh/Enhancements/randomizer/3drando/shops.hpp" +#include + extern "C" { #include "include/z64item.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -306,7 +308,7 @@ ImVec4 plandomizerGetItemColor(Rando::Item randoItem) { } if (randoItem.GetItemType() == ITEMTYPE_SONG) { uint32_t questID = Rando::Logic::RandoGetToQuestItem[randoItem.GetRandomizerGet()]; - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( songMapping.at((QuestItem)questID).name); itemColor = songMapping.at((QuestItem)questID).color; imageSize = ImVec2(24.0f, 32.0f); @@ -380,17 +382,17 @@ void PlandomizerItemImageCorrection(Rando::Item randoItem) { itemColor = plandomizerGetItemColor(randoItem); if (randoItem.GetItemType() == ITEMTYPE_SMALLKEY || randoItem.GetItemType() == ITEMTYPE_FORTRESS_SMALLKEY) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("ITEM_KEY_SMALL"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ITEM_KEY_SMALL"); return; } if (randoItem.GetItemType() == ITEMTYPE_BOSSKEY) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("ITEM_KEY_BOSS"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ITEM_KEY_BOSS"); return; } for (auto& map : itemImageMap) { if (map.first == randoItem.GetRandomizerGet()) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(map.second.c_str()); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(map.second.c_str()); if (map.second.find("ITEM_ARROWS") != std::string::npos) { textureUV0 = ImVec2(0, 1); textureUV1 = ImVec2(1, 0); @@ -404,16 +406,16 @@ void PlandomizerItemImageCorrection(Rando::Item randoItem) { } if (randoItem.GetRandomizerGet() >= RG_GOHMA_SOUL && randoItem.GetRandomizerGet() <= RG_GANON_SOUL) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("BOSS_SOUL"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("BOSS_SOUL"); } if (randoItem.GetRandomizerGet() >= RG_OCARINA_A_BUTTON && randoItem.GetRandomizerGet() <= RG_OCARINA_C_RIGHT_BUTTON) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("ITEM_OCARINA_TIME"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ITEM_OCARINA_TIME"); } if (textureID == 0) { - textureID = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( itemMapping[randoItem.GetGIEntry()->itemId].name); } } @@ -974,11 +976,11 @@ void PlandomizerDrawOptions() { for (auto& hash : plandoHash) { ImGui::PushID(index); textureID = - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(gSeedTextures[hash].tex); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(gSeedTextures[hash].tex); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); auto upRet = ImGui::ImageButton( "HASH_ARROW_UP", - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("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)); ImGui::PopStyleVar(); if (upRet) { @@ -992,7 +994,7 @@ void PlandomizerDrawOptions() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); auto downRet = ImGui::ImageButton( "HASH_ARROW_DWN", - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("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)); ImGui::PopStyleVar(); if (downRet) { @@ -1171,25 +1173,25 @@ void PlandomizerWindow::DrawElement() { } void PlandomizerWindow::InitElement() { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_RUPEE_GRAYSCALE", gRupeeCounterIconTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_RUPEE_GRAYSCALE", gRupeeCounterIconTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_HEART_GRAYSCALE", gHeartFullTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_HEART_GRAYSCALE", gHeartFullTex, ImVec4(0.87f, 0.10f, 0.10f, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_ARROWS_SMALL", gDropArrows1Tex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_SMALL", gDropArrows1Tex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_ARROWS_MEDIUM", gDropArrows2Tex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_MEDIUM", gDropArrows2Tex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_ARROWS_LARGE", gDropArrows3Tex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_LARGE", gDropArrows3Tex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_ICE_TRAP", gMagicArrowEquipEffectTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ICE_TRAP", gMagicArrowEquipEffectTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("HASH_ARROW_UP", gEmptyCDownArrowTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("HASH_ARROW_UP", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("HASH_ARROW_DWN", gEmptyCDownArrowTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("HASH_ARROW_DWN", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("BOSS_SOUL", gBossSoulTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("TRIFORCE_PIECE", gTriforcePieceTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("BOSS_SOUL", gBossSoulTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("TRIFORCE_PIECE", gTriforcePieceTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 0ccc205a6df..72213f08e1a 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -19,6 +19,8 @@ #include "soh/SohGui/UIWidgets.hpp" #include "soh/util.h" +#include + extern "C" { #include #include "variables.h" @@ -805,7 +807,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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0.0f, 0.0f), ImVec2(1, 1)); @@ -816,7 +818,7 @@ void DrawQuest(ItemTrackerItem item) { bool hasQuestItem = HasQuestItem(item); float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImGui::BeginGroup(); - ImGui::ImageWithBg(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + 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)); @@ -1215,7 +1217,7 @@ void DrawItem(ItemTrackerItem item) { ImGui::BeginGroup(); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); @@ -1301,7 +1303,7 @@ void DrawBottle(ItemTrackerItem item) { } float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); @@ -1317,11 +1319,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(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } else { - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } @@ -1367,7 +1369,7 @@ void DrawSong(ItemTrackerItem item) { ImVec2 p = ImGui::GetCursorScreenPos(); bool hasSong = HasSong(item); ImGui::SetCursorScreenPos(ImVec2(p.x + 6, p.y)); - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->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()); diff --git a/soh/soh/Enhancements/timesplits/TimeSplits.cpp b/soh/soh/Enhancements/timesplits/TimeSplits.cpp index e970b965cfe..d9cf19e91de 100644 --- a/soh/soh/Enhancements/timesplits/TimeSplits.cpp +++ b/soh/soh/Enhancements/timesplits/TimeSplits.cpp @@ -10,6 +10,8 @@ #include #include "soh/SohGui/UIWidgets.hpp" +#include + extern "C" { #include "z64item.h" #include "macros.h" @@ -435,7 +437,7 @@ void TimeSplitsPopUpContext() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); ImGui::ImageButton( "QUEST_SKULL_TOKEN", - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("QUEST_SKULL_TOKEN"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("QUEST_SKULL_TOKEN"), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0)); ImGui::PopStyleVar(); ImGui::TableNextColumn(); @@ -488,7 +490,7 @@ void TimeSplitsPopUpContext() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f)); auto ret = ImGui::ImageButton( popupObject.splitImage.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(popupObject.splitImage), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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(); if (ret) { @@ -664,7 +666,7 @@ void TimeSplitsDrawSplitsList() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( split.splitImage.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(split.splitImage), imageSize, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(split.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); if (ret) { @@ -748,7 +750,7 @@ void TimeSplitsDrawItemList(uint32_t type) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( split.splitImage.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(split.splitImage), imageSize, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(split.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); if (ret) { @@ -891,7 +893,7 @@ void TimeSplitsDrawManageList() { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(imagePadding, imagePadding)); auto ret = ImGui::ImageButton( data.splitImage.c_str(), - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(data.splitImage), imageSize, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(data.splitImage), imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), data.splitTint); ImGui::PopStyleVar(); if (ret) { @@ -976,9 +978,9 @@ void TimeSplitWindow::DrawElement() { void TimeSplitWindow::InitElement() { TimeSplitsUpdateWindowSize(); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("SPECIAL_TRIFORCE_PIECE_WHITE", + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("SPECIAL_TRIFORCE_PIECE_WHITE", gWTriforcePieceTex, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("SPECIAL_SPLIT_ENTRANCE", gSplitEntranceTex, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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/Notification/Notification.cpp b/soh/soh/Notification/Notification.cpp index 5b6039cf8ce..83a2994356f 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -3,6 +3,8 @@ #include #include "soh/OTRGlobals.h" +#include + extern "C" { #include "functions.h" #include "macros.h" @@ -88,7 +90,7 @@ void Window::Draw() { ImGui::SetWindowPos(notificationPos); if (notification.itemIcon != nullptr) { - ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(notification.itemIcon), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(notification.itemIcon), ImVec2(24, 24)); ImGui::SameLine(); } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 697f6e30eb7..c6e188a1fb1 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -44,6 +44,9 @@ #include "Enhancements/custom-message/CustomMessageManager.h" #include "util.h" +#include +#include + #if not defined(__SWITCH__) && not defined(__WIIU__) #include "Extractor/Extract.h" #endif @@ -765,6 +768,20 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) { #endif } +void InitGfxDebugger(){ + auto dbg = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow())->GetGfxDebugger(); + + if (dbg != nullptr){ + return; + } + + dbg = std::make_shared(); + + if (dbg != nullptr){ + SPDLOG_ERROR("Failed to initialize gfx debugger"); + } +} + void OTRGlobals::Initialize() { std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.o2r", appShortName); if (std::filesystem::exists(mqPath)) { @@ -793,7 +810,7 @@ void OTRGlobals::Initialize() { context->InitLogging(logLevel, logLevel); Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); - context->InitGfxDebugger(); + InitGfxDebugger(); context->InitFileDropMgr(); // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) @@ -1613,7 +1630,7 @@ extern "C" void Graph_StartFrame() { switch (dwScancode) { case KbScancode::LUS_KB_F1: { std::shared_ptr modal = static_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Modal Window")); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGuiWindow("Modal Window")); if (modal->IsPopupOpen("Menu Moved")) { modal->DismissPopup(); } else { @@ -1626,7 +1643,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F5: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGameOverlay()->TextDrawNotification( 6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -1647,7 +1664,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F6: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGameOverlay()->TextDrawNotification( 6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -1662,7 +1679,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F7: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGameOverlay()->TextDrawNotification( 6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -2193,7 +2210,7 @@ extern "C" void OTRControllerCallback(uint8_t rumble) { static std::shared_ptr controllerConfigWindow = nullptr; if (controllerConfigWindow == nullptr) { controllerConfigWindow = std::dynamic_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Controller Configuration")); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGuiWindow("Controller Configuration")); } else if (controllerConfigWindow->TestingRumble()) { return; } @@ -2528,7 +2545,7 @@ bool SoH_HandleConfigDrop(char* filePath) { } } - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()); gui->GetGuiWindow("Console")->Hide(); gui->GetGuiWindow("Actor Viewer")->Hide(); gui->GetGuiWindow("Collision Viewer")->Hide(); @@ -2536,7 +2553,7 @@ bool SoH_HandleConfigDrop(char* filePath) { gui->GetGuiWindow("Display List Viewer")->Hide(); gui->GetGuiWindow("Stats")->Hide(); std::dynamic_pointer_cast( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGuiWindow("Console")) ->ClearBindings(); Rando::Settings::GetInstance()->UpdateAllOptions(); @@ -2548,12 +2565,12 @@ bool SoH_HandleConfigDrop(char* filePath) { return true; } catch (std::exception& e) { SPDLOG_ERROR("Failed to load config file: {}", e.what()); - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->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 = Ship::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()); gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file"); return false; } diff --git a/soh/soh/ResourceManagerHelpers.cpp b/soh/soh/ResourceManagerHelpers.cpp index f6ddc23682a..fb807b9d583 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -15,6 +15,9 @@ #include #include +#include + + extern "C" PlayState* gPlayState; extern "C" uint32_t ResourceMgr_GetNumGameVersions() { diff --git a/soh/soh/ShipUtils.h b/soh/soh/ShipUtils.h index 9046ffb08ea..f0c85adaba5 100644 --- a/soh/soh/ShipUtils.h +++ b/soh/soh/ShipUtils.h @@ -4,6 +4,7 @@ #include #ifdef __cplusplus +#include void LoadGuiTextures(); diff --git a/soh/soh/SohGui/ImGuiUtils.cpp b/soh/soh/SohGui/ImGuiUtils.cpp index 3f01e6e5543..778edb88413 100644 --- a/soh/soh/SohGui/ImGuiUtils.cpp +++ b/soh/soh/SohGui/ImGuiUtils.cpp @@ -5,6 +5,8 @@ #include "soh/Enhancements/randomizer/rando_hash.h" #include "soh/Enhancements/randomizer/randomizerTypes.h" +#include + std::map itemMapping = { ITEM_MAP_ENTRY(ITEM_STICK), ITEM_MAP_ENTRY(ITEM_NUT), @@ -215,9 +217,9 @@ const char* GetTextureForItemId(uint32_t itemId) { void RegisterImGuiItemIcons() { for (const auto& entry : itemMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } @@ -225,9 +227,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; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); } @@ -235,48 +237,48 @@ 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; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, aButtonBlue); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, aButtonBlueFaded); } for (const auto& entry : customItemsMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : jabbernutMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : questMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& [quest, entry] : songMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : vanillaSongMapping) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : gSeedTextures) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.tex, entry.tex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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 607c5791732..48db2ca7432 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -99,17 +99,17 @@ void Menu::RemoveSidebarSearch() { } void Menu::UpdateWindowBackendObjects() { - Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); + 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)) { - configWindowBackend = static_cast(configWindowBackendId); + configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; } availableWindowBackends = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends(); for (auto& backend : *availableWindowBackends) { - availableWindowBackendsMap[backend] = windowBackendsMap.at(backend); + availableWindowBackendsMap[(Fast::WindowBackend)backend] = windowBackendsMap.at((Fast::WindowBackend)backend); } } diff --git a/soh/soh/SohGui/Menu.h b/soh/soh/SohGui/Menu.h index 915403e72ab..e8c3c0c2741 100644 --- a/soh/soh/SohGui/Menu.h +++ b/soh/soh/SohGui/Menu.h @@ -39,9 +39,9 @@ class Menu : public GuiWindow { ImGuiTextFilter menuSearch; uint8_t searchSidebarIndex; UIWidgets::Colors defaultThemeIndex; - std::shared_ptr> availableWindowBackends; - std::map availableWindowBackendsMap; - Ship::WindowBackend configWindowBackend; + std::shared_ptr> availableWindowBackends; + std::map availableWindowBackendsMap; + Fast::WindowBackend configWindowBackend; std::unordered_map disabledMap; std::vector disabledVector; diff --git a/soh/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index b3ceea0897c..192c49da301 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -2,6 +2,7 @@ #define MENUTYPES_H #include +#include #include "UIWidgets.hpp" typedef enum { @@ -271,10 +272,10 @@ static const std::map audioBackendsMap = { { Ship::AudioBackend::NUL, "Null" }, }; -static const std::map windowBackendsMap = { - { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, - { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" }, - { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" }, +static const std::map windowBackendsMap = { + { Fast::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, + { Fast::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" }, + { Fast::WindowBackend::FAST3D_SDL_METAL, "Metal" }, }; struct MenuInit { diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index 0e8ea5cf886..218c84c80ee 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -124,13 +124,13 @@ void SohMenu::InitElement() { { DISABLE_FOR_NOT_DIRECTX, { [](disabledInfo& info) -> bool { return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != - Ship::WindowBackend::FAST3D_DXGI_DX11; + Fast::WindowBackend::FAST3D_DXGI_DX11; }, "Available Only on DirectX" } }, { DISABLE_FOR_DIRECTX, { [](disabledInfo& info) -> bool { return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == - Ship::WindowBackend::FAST3D_DXGI_DX11; + Fast::WindowBackend::FAST3D_DXGI_DX11; }, "Not Available on DirectX" } }, { DISABLE_FOR_MATCH_REFRESH_RATE_ON, From e3b52005c09585527f9b35ee32d355088bf10404 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Fri, 8 May 2026 11:35:36 +0100 Subject: [PATCH 2/5] clang update --- .../Enhancements/TimeDisplay/TimeDisplay.cpp | 49 ++--- soh/soh/Enhancements/controls/InputViewer.cpp | 182 +++++++++--------- soh/soh/Enhancements/custom-message/text.cpp | 2 +- .../Enhancements/debugger/debugSaveEditor.cpp | 67 ++++--- .../Enhancements/randomizer/Plandomizer.cpp | 75 ++++---- .../randomizer/randomizer_item_tracker.cpp | 28 +-- .../Enhancements/timesplits/TimeSplits.cpp | 29 +-- soh/soh/Notification/Notification.cpp | 3 +- soh/soh/OTRGlobals.cpp | 33 ++-- soh/soh/ResourceManagerHelpers.cpp | 1 - soh/soh/SohGui/ImGuiUtils.cpp | 63 +++--- soh/soh/SohGui/Menu.cpp | 3 +- 12 files changed, 293 insertions(+), 242 deletions(-) diff --git a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp index 3849a40715d..6125a3837eb 100644 --- a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp +++ b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp @@ -85,7 +85,8 @@ static void TimeDisplayGetTimer(uint32_t timeID) { Player* player = GET_PLAYER(gPlayState); uint32_t timer1 = gSaveContext.timerSeconds; - auto gui = std::dynamic_pointer_cast(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())); + auto gui = std::dynamic_pointer_cast( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())); switch (timeID) { case DISPLAY_IN_GAME_TIMER: @@ -94,11 +95,9 @@ static void TimeDisplayGetTimer(uint32_t timeID) { 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; @@ -111,14 +110,13 @@ static void TimeDisplayGetTimer(uint32_t timeID) { : COLOR_LIGHT_BLUE) : COLOR_WHITE; if (gSaveContext.timerState <= TIMER_STATE_ENV_HAZARD_TICK) { - textureDisplay = 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); @@ -206,13 +204,15 @@ void TimeDisplayWindow::Draw() { } if (textToDecode[i] == '.') { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale)); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - digitList[textureIndex].first), + ImGui::Image(std::dynamic_pointer_cast( + Ship::Context::GetInstance()->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())->GetTextureByName( - digitList[textureIndex].first), + ImGui::Image(std::dynamic_pointer_cast( + Ship::Context::GetInstance()->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 +250,18 @@ static void TimeDisplayInitTimers() { } void TimeDisplayWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1)); for (auto& load : digitList) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(load.first.c_str(), load.second, - ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(load.first.c_str(), load.second, ImVec4(1, 1, 1, 1)); } TimeDisplayInitSettings(); diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 284284f4967..1d4745db512 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -49,15 +49,17 @@ 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())->GetTextureByName(btnOutlineTexture), size, - ImVec2(0, 0), ImVec2(1.0f, 1.0f)); + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(btnOutlineTexture), + size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Render button if pressed if (state) { ImGui::SetCursorPos(pos); ImGui::SetNextItemAllowOverlap(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(btnTexture), size, - ImVec2(0, 0), ImVec2(1.0f, 1.0f)); + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(btnTexture), + size, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } } @@ -74,80 +76,80 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; if (!sButtonTexturesLoaded) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("A-Btn", - "textures/buttons/ABtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("B-Btn", - "textures/buttons/BBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("L-Btn", - "textures/buttons/LBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("R-Btn", - "textures/buttons/RBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Z-Btn", - "textures/buttons/ZBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Start-Btn", "textures/buttons/StartBtn.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Left", - "textures/buttons/CLeft.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Right", - "textures/buttons/CRight.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Up", - "textures/buttons/CUp.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("C-Down", - "textures/buttons/CDown.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Analog-Stick", "textures/buttons/AnalogStick.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Left", "textures/buttons/DPadLeft.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Right", "textures/buttons/DPadRight.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Dpad-Up", - "textures/buttons/DPadUp.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Down", "textures/buttons/DPadDown.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Modifier-1", - "textures/buttons/Mod1.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage("Modifier-2", - "textures/buttons/Mod2.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Right-Stick", "textures/buttons/RightStick.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "A-Btn Outline", "textures/buttons/ABtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "B-Btn Outline", "textures/buttons/BBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "L-Btn Outline", "textures/buttons/LBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "R-Btn Outline", "textures/buttons/RBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "C-Left Outline", "textures/buttons/CLeftOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "C-Right Outline", "textures/buttons/CRightOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "C-Up Outline", "textures/buttons/CUpOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "C-Down Outline", "textures/buttons/CDownOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Modifier-1 Outline", "textures/buttons/Mod1Outline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Modifier-2 Outline", "textures/buttons/Mod2Outline.png"); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadTextureFromRawImage( - "Right-Stick Outline", "textures/buttons/RightStickOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Start-Btn", "textures/buttons/StartBtn.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Analog-Stick", "textures/buttons/AnalogStick.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Left", "textures/buttons/DPadLeft.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Right", "textures/buttons/DPadRight.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Down", "textures/buttons/DPadDown.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Modifier-1", "textures/buttons/Mod1.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Modifier-2", "textures/buttons/Mod2.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Right-Stick", "textures/buttons/RightStick.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("A-Btn Outline", "textures/buttons/ABtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("B-Btn Outline", "textures/buttons/BBtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("L-Btn Outline", "textures/buttons/LBtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("R-Btn Outline", "textures/buttons/RBtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Left Outline", "textures/buttons/CLeftOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Right Outline", "textures/buttons/CRightOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Up Outline", "textures/buttons/CUpOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("C-Down Outline", "textures/buttons/CDownOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Modifier-1 Outline", "textures/buttons/Mod1Outline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Modifier-2 Outline", "textures/buttons/Mod2Outline.png"); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadTextureFromRawImage("Right-Stick Outline", "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; } @@ -164,7 +166,8 @@ 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::GetInstance()->GetWindow()->GetGui()) + ->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); ImGui::SetNextWindowSize( @@ -201,7 +204,8 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); // Background ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Input-Viewer-Background"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("Input-Viewer-Background"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } @@ -352,7 +356,8 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Analog-Stick Outline"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("Analog-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int analogStickMode = @@ -363,8 +368,10 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( 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())->GetTextureByName("Analog-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); + ImGui::Image( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("Analog-Stick"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Right Stick @@ -376,7 +383,8 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("Right-Stick Outline"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("Right-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int rightStickMode = @@ -387,8 +395,10 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( 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())->GetTextureByName("Right-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); + ImGui::Image( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("Right-Stick"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Analog stick angle text diff --git a/soh/soh/Enhancements/custom-message/text.cpp b/soh/soh/Enhancements/custom-message/text.cpp index b8b7a8031e3..aec51ce683a 100644 --- a/soh/soh/Enhancements/custom-message/text.cpp +++ b/soh/soh/Enhancements/custom-message/text.cpp @@ -87,7 +87,7 @@ void Text::Replace(const std::string& oldStr, const std::string& newStr) { replaceAll(english, oldStr, newStr); replaceAll(french, oldStr, newStr); replaceAll(german, oldStr, newStr); - replaceAll(spanish, oldStr,newStr); + replaceAll(spanish, oldStr, newStr); } void Text::Replace(const std::string& oldStr, const Text& newText) { diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index c26fff2a7ab..4393099dbbc 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -520,7 +520,8 @@ void DrawInfoTab() { void DrawBGSItemFlag(uint8_t itemID) { const ItemMapEntry& slotEntry = itemMapping[itemID]; - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); } @@ -548,7 +549,8 @@ void DrawInventoryTab() { if (item == ITEM_ROCS_FEATHER) { auto ret = ImGui::ImageButton( "ROCS_FEATHER", - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ROCS_FEATHER"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("ROCS_FEATHER"), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { selectedIndex = index; @@ -558,7 +560,8 @@ 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())->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(slotEntry.name), ImVec2(48.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { selectedIndex = index; @@ -609,7 +612,8 @@ void DrawInventoryTab() { PushStyleButton(Colors::DarkGray); auto ret = ImGui::ImageButton( slotEntry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); PopStyleButton(); if (ret) { @@ -642,7 +646,8 @@ void DrawInventoryTab() { ImGui::PushItemWidth(IMAGE_SIZE); ImGui::BeginGroup(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(itemMapping[item].name), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(itemMapping[item].name), ImVec2(IMAGE_SIZE, IMAGE_SIZE)); PushStyleInput(THEME_COLOR); ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item)); @@ -1234,9 +1239,11 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const uint8_t item = value < items.size() ? items[value] : ITEM_NONE; if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping[item]; - if (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))) { + if (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))) { ImGui::OpenPopup(upgradePopupPicker); } } else { @@ -1265,7 +1272,8 @@ 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())->GetTextureByName(slotEntry.name), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(slotEntry.name), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { Inventory_ChangeUpgrade(categoryId, pickerIndex); @@ -1301,10 +1309,11 @@ void DrawEquipmentTab() { bool hasEquip = (bitMask & gSaveContext.inventory.equipment) != 0; const ItemMapEntry& entry = itemMapping[equipmentValues[i]]; PushStyleButton(Colors::DarkGray); - auto ret = ImGui::ImageButton(entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - hasEquip ? entry.name : entry.nameFaded), - ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); + auto ret = ImGui::ImageButton( + entry.name.c_str(), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasEquip ? entry.name : entry.nameFaded), + ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { if (hasEquip) { gSaveContext.inventory.equipment &= ~bitMask; @@ -1436,10 +1445,11 @@ void DrawQuestItemButton(uint32_t item) { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; PushStyleButton(Colors::DarkGray); - auto ret = ImGui::ImageButton(entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - hasQuestItem ? entry.name : entry.nameFaded), - ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); + auto ret = ImGui::ImageButton( + entry.name.c_str(), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1459,7 +1469,8 @@ 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())->GetTextureByName(hasItem ? entry.name : entry.nameFaded), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasItem ? entry.name : entry.nameFaded), ImVec2(IMAGE_SIZE, IMAGE_SIZE), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { if (hasItem) { @@ -1505,10 +1516,11 @@ void DrawQuestStatusTab() { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; PushStyleButton(Colors::DarkGray); - auto ret = ImGui::ImageButton(entry.name.c_str(), - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - hasQuestItem ? entry.name : entry.nameFaded), - ImVec2(32.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); + auto ret = ImGui::ImageButton( + entry.name.c_str(), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + ImVec2(32.0f, 48.0f), ImVec2(0, 0), ImVec2(1, 1)); if (ret) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1585,9 +1597,10 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_JABU_JABU_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - itemMapping[ITEM_KEY_SMALL].name), - ImVec2(lineHeight, lineHeight)); + ImGui::Image( + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), + ImVec2(lineHeight, lineHeight)); ImGui::SameLine(); PushStyleInput(THEME_COLOR); if (ImGui::InputScalar("##Keys", ImGuiDataType_S8, @@ -1976,6 +1989,6 @@ void SaveEditorWindow::DrawElement() { } void SaveEditorWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ROCS_FEATHER", gRocsFeatherTex, - ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ROCS_FEATHER", gRocsFeatherTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index a0166ac8d27..b32d863e42a 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -308,8 +308,8 @@ 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())->GetTextureByName( - songMapping.at((QuestItem)questID).name); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(songMapping.at((QuestItem)questID).name); itemColor = songMapping.at((QuestItem)questID).color; imageSize = ImVec2(24.0f, 32.0f); imagePadding = 6.0f; @@ -382,17 +382,20 @@ 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())->GetTextureByName("ITEM_KEY_SMALL"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("ITEM_KEY_SMALL"); return; } if (randoItem.GetItemType() == ITEMTYPE_BOSSKEY) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName("ITEM_KEY_BOSS"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->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::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(map.second.c_str()); if (map.second.find("ITEM_ARROWS") != std::string::npos) { textureUV0 = ImVec2(0, 1); textureUV1 = ImVec2(1, 0); @@ -406,17 +409,19 @@ 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())->GetTextureByName("BOSS_SOUL"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->GetTextureByName("ITEM_OCARINA_TIME"); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("ITEM_OCARINA_TIME"); } if (textureID == 0) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - itemMapping[randoItem.GetGIEntry()->itemId].name); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(itemMapping[randoItem.GetGIEntry()->itemId].name); } } @@ -976,11 +981,13 @@ void PlandomizerDrawOptions() { for (auto& hash : plandoHash) { ImGui::PushID(index); textureID = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(gSeedTextures[hash].tex); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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"), + 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)); ImGui::PopStyleVar(); if (upRet) { @@ -994,7 +1001,8 @@ void PlandomizerDrawOptions() { 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"), + 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)); ImGui::PopStyleVar(); if (downRet) { @@ -1173,25 +1181,26 @@ void PlandomizerWindow::DrawElement() { } void PlandomizerWindow::InitElement() { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_RUPEE_GRAYSCALE", gRupeeCounterIconTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_HEART_GRAYSCALE", gHeartFullTex, - ImVec4(0.87f, 0.10f, 0.10f, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_SMALL", gDropArrows1Tex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_MEDIUM", gDropArrows2Tex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ARROWS_LARGE", gDropArrows3Tex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("ITEM_ICE_TRAP", gMagicArrowEquipEffectTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("HASH_ARROW_UP", gEmptyCDownArrowTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("HASH_ARROW_DWN", gEmptyCDownArrowTex, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("BOSS_SOUL", gBossSoulTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("TRIFORCE_PIECE", gTriforcePieceTex, - ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_RUPEE_GRAYSCALE", gRupeeCounterIconTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_HEART_GRAYSCALE", gHeartFullTex, ImVec4(0.87f, 0.10f, 0.10f, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_ARROWS_SMALL", gDropArrows1Tex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_ARROWS_MEDIUM", gDropArrows2Tex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_ARROWS_LARGE", gDropArrows3Tex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("ITEM_ICE_TRAP", gMagicArrowEquipEffectTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("HASH_ARROW_UP", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("HASH_ARROW_DWN", gEmptyCDownArrowTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("BOSS_SOUL", gBossSoulTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("TRIFORCE_PIECE", gTriforcePieceTex, ImVec4(1, 1, 1, 1)); } diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 72213f08e1a..24730334a58 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -807,8 +807,8 @@ 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())->GetTextureByName( - hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0.0f, 0.0f), ImVec2(1, 1)); Tooltip(SohUtils::GetItemName(item.id).c_str()); @@ -818,8 +818,8 @@ 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), + 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)); if (item.id == QUEST_SKULL_TOKEN) { @@ -1217,8 +1217,8 @@ void DrawItem(ItemTrackerItem item) { ImGui::BeginGroup(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName( - hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); DrawItemCount(item, false); @@ -1303,8 +1303,8 @@ 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())->GetTextureByName( - hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); Tooltip(SohUtils::GetItemName(item.id).c_str()); @@ -1319,12 +1319,12 @@ 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())->GetTextureByName( - hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->GetTextureByName( - hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } @@ -1369,8 +1369,8 @@ 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())->GetTextureByName( - hasSong && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->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()); } diff --git a/soh/soh/Enhancements/timesplits/TimeSplits.cpp b/soh/soh/Enhancements/timesplits/TimeSplits.cpp index d9cf19e91de..8007a07e063 100644 --- a/soh/soh/Enhancements/timesplits/TimeSplits.cpp +++ b/soh/soh/Enhancements/timesplits/TimeSplits.cpp @@ -437,7 +437,8 @@ 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())->GetTextureByName("QUEST_SKULL_TOKEN"), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName("QUEST_SKULL_TOKEN"), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0)); ImGui::PopStyleVar(); ImGui::TableNextColumn(); @@ -490,7 +491,8 @@ 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())->GetTextureByName(popupObject.splitImage), + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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(); if (ret) { @@ -666,8 +668,9 @@ 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())->GetTextureByName(split.splitImage), imageSize, - ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(split.splitImage), + imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); if (ret) { TimeSplitsSkipSplit(dragIndex); @@ -750,8 +753,9 @@ 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())->GetTextureByName(split.splitImage), imageSize, - ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(split.splitImage), + imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), split.splitTint); ImGui::PopStyleVar(); if (ret) { if (popupList.contains(split.splitID) && (split.splitType < SPLIT_TYPE_BOSS)) { @@ -893,8 +897,9 @@ 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())->GetTextureByName(data.splitImage), imageSize, - ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), data.splitTint); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(data.splitImage), + imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), data.splitTint); ImGui::PopStyleVar(); if (ret) { removeIndex = index; @@ -978,10 +983,10 @@ void TimeSplitWindow::DrawElement() { void TimeSplitWindow::InitElement() { TimeSplitsUpdateWindowSize(); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("SPECIAL_TRIFORCE_PIECE_WHITE", - gWTriforcePieceTex, ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture("SPECIAL_SPLIT_ENTRANCE", gSplitEntranceTex, - ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture("SPECIAL_TRIFORCE_PIECE_WHITE", gWTriforcePieceTex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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/Notification/Notification.cpp b/soh/soh/Notification/Notification.cpp index 83a2994356f..decb7d88587 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -90,7 +90,8 @@ void Window::Draw() { ImGui::SetWindowPos(notificationPos); if (notification.itemIcon != nullptr) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetTextureByName(notification.itemIcon), + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(notification.itemIcon), ImVec2(24, 24)); ImGui::SameLine(); } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c6e188a1fb1..20b20ad7338 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -768,16 +768,17 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) { #endif } -void InitGfxDebugger(){ - auto dbg = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow())->GetGfxDebugger(); +void InitGfxDebugger() { + auto dbg = + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow())->GetGfxDebugger(); - if (dbg != nullptr){ + if (dbg != nullptr) { return; } dbg = std::make_shared(); - if (dbg != nullptr){ + if (dbg != nullptr) { SPDLOG_ERROR("Failed to initialize gfx debugger"); } } @@ -1630,7 +1631,8 @@ 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())->GetGuiWindow("Modal Window")); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGuiWindow("Modal Window")); if (modal->IsPopupOpen("Menu Moved")) { modal->DismissPopup(); } else { @@ -1643,8 +1645,9 @@ 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())->GetGameOverlay()->TextDrawNotification( - 6.0f, true, "Save states not enabled. Check Cheats Menu."); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGameOverlay() + ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); @@ -1664,8 +1667,9 @@ 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())->GetGameOverlay()->TextDrawNotification( - 6.0f, true, "Save states not enabled. Check Cheats Menu."); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGameOverlay() + ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); @@ -1679,8 +1683,9 @@ 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())->GetGameOverlay()->TextDrawNotification( - 6.0f, true, "Save states not enabled. Check Cheats Menu."); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGameOverlay() + ->TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); @@ -2210,7 +2215,8 @@ extern "C" void OTRControllerCallback(uint8_t rumble) { static std::shared_ptr controllerConfigWindow = nullptr; if (controllerConfigWindow == nullptr) { controllerConfigWindow = std::dynamic_pointer_cast( - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->GetGuiWindow("Controller Configuration")); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGuiWindow("Controller Configuration")); } else if (controllerConfigWindow->TestingRumble()) { return; } @@ -2553,7 +2559,8 @@ 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())->GetGuiWindow("Console")) + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetGuiWindow("Console")) ->ClearBindings(); Rando::Settings::GetInstance()->UpdateAllOptions(); diff --git a/soh/soh/ResourceManagerHelpers.cpp b/soh/soh/ResourceManagerHelpers.cpp index fb807b9d583..13be6b96047 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -17,7 +17,6 @@ #include - extern "C" PlayState* gPlayState; extern "C" uint32_t ResourceMgr_GetNumGameVersions() { diff --git a/soh/soh/SohGui/ImGuiUtils.cpp b/soh/soh/SohGui/ImGuiUtils.cpp index 778edb88413..9ea36ebd08e 100644 --- a/soh/soh/SohGui/ImGuiUtils.cpp +++ b/soh/soh/SohGui/ImGuiUtils.cpp @@ -217,68 +217,73 @@ const char* GetTextureForItemId(uint32_t itemId) { void RegisterImGuiItemIcons() { for (const auto& entry : itemMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( - entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : gregMapping) { 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())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - gregGreen); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.nameFaded, - entry.second.texturePath, gregFadedGreen); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); } for (const auto& entry : actionShuffleMapping) { 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())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - aButtonBlue); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.nameFaded, - entry.second.texturePath, aButtonBlueFaded); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, aButtonBlue); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, aButtonBlueFaded); } for (const auto& entry : customItemsMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( - entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( - entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture( - entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : vanillaSongMapping) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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())->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : gSeedTextures) { - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui())->LoadGuiTexture(entry.tex, entry.tex, ImVec4(1, 1, 1, 1)); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->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 48db2ca7432..145de6d1b05 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -99,7 +99,8 @@ void Menu::RemoveSidebarSearch() { } void Menu::UpdateWindowBackendObjects() { - Fast::WindowBackend runningWindowBackend = (Fast::WindowBackend)Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); + 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)) { configWindowBackend = static_cast(configWindowBackendId); From c59a7ad4ba3a00237d9caa3814780850327baa20 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Mon, 11 May 2026 12:37:46 +0100 Subject: [PATCH 3/5] re-roll text.cpp replace --- soh/soh/Enhancements/custom-message/text.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/custom-message/text.cpp b/soh/soh/Enhancements/custom-message/text.cpp index aec51ce683a..0023261dbc5 100644 --- a/soh/soh/Enhancements/custom-message/text.cpp +++ b/soh/soh/Enhancements/custom-message/text.cpp @@ -1,4 +1,5 @@ #include "text.h" +#include Text::Text() = default; @@ -84,10 +85,9 @@ static void replaceAll(std::string& target, const std::string& oldStr, const std } void Text::Replace(const std::string& oldStr, const std::string& newStr) { - replaceAll(english, oldStr, newStr); - replaceAll(french, oldStr, newStr); - replaceAll(german, oldStr, newStr); - replaceAll(spanish, oldStr, newStr); + for (std::string& str : { std::ref(english), std::ref(french), std::ref(german), std::ref(spanish) }) { + replaceAll(str, oldStr, newStr); + } } void Text::Replace(const std::string& oldStr, const Text& newText) { From ef2e2ec6074b77d33a1339cc2e1325be38335628 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Mon, 18 May 2026 14:38:29 +0100 Subject: [PATCH 4/5] Test build for the new PR --- libultraship | 2 +- .../Difficulty/PermanentLosses.cpp | 2 +- .../Enhancements/FileSelectEnhancements.cpp | 2 +- soh/soh/Enhancements/Lang/Lang.cpp | 4 +- soh/soh/Enhancements/Presets/Presets.cpp | 18 ++-- soh/soh/Enhancements/ResetHotKey.cpp | 2 +- .../Restorations/GraveHoleJumps.cpp | 2 +- .../N64WeirdFrames/WeirdAnimation.cpp | 2 +- .../Enhancements/TimeDisplay/TimeDisplay.cpp | 16 ++-- soh/soh/Enhancements/Warping.cpp | 8 +- .../Enhancements/audio/AudioCollection.cpp | 4 +- soh/soh/Enhancements/audio/AudioEditor.cpp | 30 +++--- soh/soh/Enhancements/controls/InputViewer.cpp | 92 +++++++++---------- .../controls/SohInputEditorWindow.cpp | 86 ++++++++--------- .../cosmetics/CosmeticsEditor.cpp | 22 ++--- soh/soh/Enhancements/debugconsole.cpp | 12 +-- .../Enhancements/debugger/debugSaveEditor.cpp | 26 +++--- soh/soh/Enhancements/debugger/dlViewer.cpp | 4 +- soh/soh/Enhancements/debugger/valueViewer.cpp | 8 +- soh/soh/Enhancements/mod_menu.cpp | 8 +- .../Enhancements/randomizer/Plandomizer.cpp | 42 ++++----- soh/soh/Enhancements/randomizer/logic.cpp | 2 +- soh/soh/Enhancements/randomizer/option.cpp | 8 +- .../Enhancements/randomizer/randomizer.cpp | 8 +- .../randomizer/randomizer_check_tracker.cpp | 2 +- .../randomizer_entrance_tracker.cpp | 2 +- .../randomizer/randomizer_item_tracker.cpp | 16 ++-- soh/soh/Enhancements/randomizer/settings.cpp | 2 +- soh/soh/Enhancements/savestates.cpp | 10 +- .../Enhancements/timesplits/TimeSplits.cpp | 14 +-- soh/soh/Enhancements/tts/tts.cpp | 8 +- soh/soh/Network/Anchor/Menu.cpp | 18 ++-- .../Network/Anchor/Packets/AllClientState.cpp | 2 +- soh/soh/Network/Sail/Sail.cpp | 4 +- soh/soh/Notification/Notification.cpp | 2 +- soh/soh/OTRGlobals.cpp | 68 +++++++------- soh/soh/OTRGlobals.h | 2 +- soh/soh/ResourceManagerHelpers.cpp | 28 +++--- soh/soh/SohGui/ImGuiUtils.cpp | 34 +++---- soh/soh/SohGui/Menu.cpp | 30 +++--- soh/soh/SohGui/ResolutionEditor.cpp | 22 ++--- soh/soh/SohGui/SohGui.cpp | 6 +- soh/soh/SohGui/SohMenu.cpp | 10 +- soh/soh/SohGui/SohMenuDevTools.cpp | 2 +- soh/soh/SohGui/SohMenuEnhancements.cpp | 14 +-- soh/soh/SohGui/SohMenuNetwork.cpp | 8 +- soh/soh/SohGui/SohMenuRandomizer.cpp | 6 +- soh/soh/SohGui/SohMenuSettings.cpp | 14 +-- soh/soh/SohGui/UIWidgets.cpp | 20 ++-- soh/soh/SohGui/UIWidgets.hpp | 6 +- .../resource/importer/AnimationFactory.cpp | 6 +- .../resource/importer/AudioSampleFactory.cpp | 2 +- .../importer/AudioSequenceFactory.cpp | 2 +- .../importer/AudioSoundFontFactory.cpp | 22 ++--- soh/soh/resource/importer/SkeletonFactory.cpp | 4 +- .../SetAlternateHeadersFactory.cpp | 4 +- .../SetCollisionHeaderFactory.cpp | 4 +- .../scenecommand/SetCutscenesFactory.cpp | 4 +- .../scenecommand/SetPathwaysFactory.cpp | 4 +- soh/soh/resource/type/Skeleton.cpp | 8 +- soh/soh/z_message_OTR.cpp | 8 +- soh/soh/z_play_otr.cpp | 4 +- 62 files changed, 416 insertions(+), 416 deletions(-) diff --git a/libultraship b/libultraship index 42ecb8ed48e..644626b65fd 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 42ecb8ed48e4b15c21fe2e0d7e34cb5c02efa23d +Subproject commit 644626b65fdbb37ae5d7dcfac122f3ea05607401 diff --git a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp index cab0aa7d439..02900c412eb 100644 --- a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp +++ b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp @@ -64,7 +64,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 12354dce415..472a88aea00 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -107,7 +107,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 @@ -115,9 +115,9 @@ void applyPreset(std::string presetName, std::vector includeSecti } } - Ship::Context::GetInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), + Ship::Context::GetRawInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), block); - Ship::Context::GetInstance()->GetConsoleVariables()->Load(); + Ship::Context::GetRawInstance()->GetConsoleVariables()->Load(); } } if (i == PRESET_SECTION_RANDOMIZER) { @@ -159,7 +159,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(); } } @@ -234,12 +234,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); @@ -253,7 +253,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(); @@ -293,7 +293,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++) { @@ -459,7 +459,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..8f7b452e474 100644 --- a/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp +++ b/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp @@ -30,7 +30,7 @@ CollisionHeader* getGraveyardCollisionHeader() { * game does. */ SOH::Scene* scene = - (SOH::Scene*)Ship::Context::GetInstance()->GetResourceManager()->LoadResource(GRAVEYARD_SCENE_FILEPATH).get(); + (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..723e9b0bb6d 100644 --- a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp +++ b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp @@ -86,7 +86,7 @@ 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: @@ -205,13 +205,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 +250,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 60a20805f7a..67383b85787 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -262,7 +262,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(); @@ -274,7 +274,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(); @@ -286,7 +286,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(); @@ -298,7 +298,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(); @@ -359,7 +359,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); } @@ -386,7 +386,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(); @@ -410,7 +410,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); } } @@ -427,7 +427,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(); @@ -814,7 +814,7 @@ void AudioEditor_RandomizeAll() { RandomizeGroup(type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ReplayCurrentBGM(); } @@ -823,14 +823,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(); } @@ -839,14 +839,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(); } @@ -855,7 +855,7 @@ void AudioEditor_LockAll() { LockGroup(AudioCollection::Instance->GetAllSequences(), type); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AudioEditor_UnlockAll() { @@ -863,7 +863,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..4617106efae 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -49,7 +49,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 +57,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 +76,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,7 +166,7 @@ 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()) + ImVec2 bgSize = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); @@ -186,7 +186,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 +204,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 +356,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 +369,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 +383,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 +396,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..f3b84de084f 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,10 @@ 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 +829,7 @@ 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 +852,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 +869,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 +1012,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 +1035,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 +1049,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 +1105,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 +1141,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 +1164,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 +1178,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 +1322,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 +1409,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 +1514,7 @@ 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 +1743,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 +1776,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 +1806,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 +1869,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 +1885,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 a02a658877d..07a331f5ed0 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1638,7 +1638,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); } @@ -2216,7 +2216,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); @@ -2225,7 +2225,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(); @@ -2234,7 +2234,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(); @@ -2248,7 +2248,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(); } } } @@ -2621,7 +2621,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(); } @@ -2634,7 +2634,7 @@ void CosmeticsEditor_RandomizeAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2646,7 +2646,7 @@ void CosmeticsEditor_AutoRandomizeAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2659,7 +2659,7 @@ void CosmeticsEditor_RandomizeGroup(CosmeticGroup group) { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2670,7 +2670,7 @@ void CosmeticsEditor_ResetAll() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ApplyOrResetCustomGfxPatches(); } @@ -2681,7 +2681,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 7fecad83ac2..99b9b1ec371 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -35,15 +35,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")) \ + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendErrorMessage #define INFO_MESSAGE \ std::reinterpret_pointer_cast( \ - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ + Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendInfoMessage static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args, @@ -526,7 +526,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; } @@ -1771,7 +1771,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", { @@ -1779,5 +1779,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 4393099dbbc..90ecf1573f7 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -520,7 +520,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)); } @@ -549,7 +549,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) { @@ -560,7 +560,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) { @@ -612,7 +612,7 @@ void DrawInventoryTab() { PushStyleButton(Colors::DarkGray); 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)); PopStyleButton(); @@ -646,7 +646,7 @@ void DrawInventoryTab() { ImGui::PushItemWidth(IMAGE_SIZE); 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(itemMapping[item].name), ImVec2(IMAGE_SIZE, IMAGE_SIZE)); PushStyleInput(THEME_COLOR); @@ -1241,7 +1241,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); @@ -1272,7 +1272,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) { @@ -1311,7 +1311,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) { @@ -1447,7 +1447,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) { @@ -1469,7 +1469,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) { @@ -1518,7 +1518,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) { @@ -1598,7 +1598,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(); @@ -1989,6 +1989,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 32cd8ddd2fd..f41d19bebaa 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -68,7 +68,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(); } @@ -76,10 +76,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..23e7b826bf7 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -308,7 +308,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,19 +382,19 @@ 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()) + 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); @@ -409,18 +409,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); } } @@ -981,12 +981,12 @@ void PlandomizerDrawOptions() { for (auto& hash : plandoHash) { ImGui::PushID(index); textureID = - std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + 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()) + 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(); @@ -1001,7 +1001,7 @@ void PlandomizerDrawOptions() { 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()) + 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(); @@ -1181,26 +1181,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 69008d3b68a..be448193ad5 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1001,7 +1001,7 @@ 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 95cb71c2e94..ab790f4d3cb 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -840,7 +840,7 @@ 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 24730334a58..03f9ab9d5f6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -807,7 +807,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)); @@ -818,7 +818,7 @@ 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()) + 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)); @@ -1217,7 +1217,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)); @@ -1303,7 +1303,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)); @@ -1319,11 +1319,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)); } @@ -1369,7 +1369,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()); @@ -1830,7 +1830,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..3700f3df0e2 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -818,7 +818,7 @@ extern "C" void ProcessSaveStateRequests(void) { } void SaveStateMgr::SetCurrentSlot(unsigned int slot) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, + 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..48f42db1ecd 100644 --- a/soh/soh/Enhancements/timesplits/TimeSplits.cpp +++ b/soh/soh/Enhancements/timesplits/TimeSplits.cpp @@ -437,7 +437,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 +491,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 +668,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 +753,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 +897,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 +983,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 ddaf059c589..8a110157644 100644 --- a/soh/soh/Network/Sail/Sail.cpp +++ b/soh/soh/Network/Sail/Sail.cpp @@ -55,7 +55,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); @@ -79,7 +79,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..d1b70566a98 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -90,7 +90,7 @@ void Window::Draw() { ImGui::SetWindowPos(notificationPos); if (notification.itemIcon != nullptr) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->GetWindow()->GetGui()) ->GetTextureByName(notification.itemIcon), ImVec2(24, 24)); ImGui::SameLine(); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 20b20ad7338..9c0386a38f0 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -310,7 +310,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")); @@ -770,7 +770,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; @@ -809,7 +809,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(); @@ -1011,10 +1011,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); @@ -1418,7 +1418,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, "."); @@ -1526,7 +1526,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(); @@ -1631,7 +1631,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(); @@ -1645,7 +1645,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; @@ -1667,7 +1667,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; @@ -1683,7 +1683,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; @@ -1765,7 +1765,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; @@ -1814,7 +1814,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(); @@ -1828,7 +1828,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { float divisor_num = 0.0f; 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; } @@ -1837,7 +1837,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; } @@ -1863,7 +1863,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { ExtensionEntry entry = ExtensionCache[path]; - auto sampleRaw = Ship::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); + auto sampleRaw = Ship::Context::GetRawInstance()->GetResourceManager()->LoadFile(entry.path); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint8_t* strem2 = (uint8_t*)strem; @@ -1927,7 +1927,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; @@ -2209,27 +2209,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) { @@ -2242,7 +2242,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) { @@ -2258,7 +2258,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) { @@ -2297,7 +2297,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() @@ -2307,7 +2307,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) @@ -2470,7 +2470,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); @@ -2480,7 +2480,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); @@ -2500,7 +2500,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); @@ -2551,7 +2551,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(); @@ -2559,7 +2559,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(); @@ -2572,12 +2572,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 424105f8cdf..8d4a0ab6329 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -49,7 +49,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 13be6b96047..84d26fedfe2 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -20,16 +20,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: @@ -54,7 +54,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: @@ -129,11 +129,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) { @@ -141,13 +141,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++) { @@ -184,7 +184,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 @@ -203,7 +203,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) { @@ -327,7 +327,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; @@ -370,7 +370,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()) { @@ -395,7 +395,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; @@ -414,7 +414,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..8c09ea60627 100644 --- a/soh/soh/SohGui/ImGuiUtils.cpp +++ b/soh/soh/SohGui/ImGuiUtils.cpp @@ -217,9 +217,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 +227,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 +237,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..4ea75d6b5f4 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,14 @@ 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 +355,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", + Ship::Context::GetRawInstance()->GetConfig()->SetInt("Window.Backend.Id", (int32_t)(configWindowBackend)); - Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + Ship::Context::GetRawInstance()->GetConfig()->SetString("Window.Backend.Name", windowBackendsMap.at(configWindowBackend)); - Ship::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetRawInstance()->GetConfig()->Save(); UpdateWindowBackendObjects(); } } break; @@ -490,7 +490,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 +766,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 +790,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 +803,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 fc4f9f95c80..f96a4dfec2e 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -361,7 +361,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) @@ -378,7 +378,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")) @@ -1856,7 +1856,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; }) @@ -1874,9 +1874,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) @@ -1886,9 +1886,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 716e4652cb2..22d806fad28 100644 --- a/soh/soh/SohGui/SohMenuNetwork.cpp +++ b/soh/soh/SohGui/SohMenuNetwork.cpp @@ -87,11 +87,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(); } }); @@ -153,11 +153,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 be64ac81587..f44538b2f86 100644 --- a/soh/soh/SohGui/SohMenuRandomizer.cpp +++ b/soh/soh/SohGui/SohMenuRandomizer.cpp @@ -39,7 +39,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; } @@ -109,7 +109,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(); @@ -160,7 +160,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..7d0a4232b8c 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,9 @@ 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..a6a99fbb674 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -65,7 +65,7 @@ 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 +109,7 @@ 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 +122,7 @@ 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 +134,7 @@ 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 +161,7 @@ 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 +232,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 +308,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 +322,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 +336,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 +376,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 +431,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..3af90da73f4 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,7 @@ 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..b082588d10a 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -15,7 +15,7 @@ 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 +33,7 @@ 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 b241209f679..067cb8c9735 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,7 @@ 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..673c5278b3e 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 @@ -45,7 +45,7 @@ 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)); + 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()); From 727f21de5c391a8d679d9978d4365b91186d9865 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Mon, 18 May 2026 14:48:32 +0100 Subject: [PATCH 5/5] clanging --- soh/soh/Enhancements/Presets/Presets.cpp | 2 +- .../Restorations/GraveHoleJumps.cpp | 6 ++-- soh/soh/Enhancements/controls/InputViewer.cpp | 5 +-- .../controls/SohInputEditorWindow.cpp | 9 +++-- soh/soh/Enhancements/debugconsole.cpp | 8 ++--- .../Enhancements/debugger/debugSaveEditor.cpp | 17 +++++----- .../Enhancements/randomizer/Plandomizer.cpp | 33 ++++++++++--------- .../randomizer/randomizer_check_tracker.cpp | 3 +- .../randomizer_entrance_tracker.cpp | 3 +- .../randomizer/randomizer_item_tracker.cpp | 7 ++-- soh/soh/Enhancements/savestates.cpp | 2 +- soh/soh/Notification/Notification.cpp | 7 ++-- soh/soh/SohGui/Menu.cpp | 7 ++-- soh/soh/SohGui/SohMenuSettings.cpp | 3 +- .../importer/AudioSoundFontFactory.cpp | 15 ++++++--- .../SetAlternateHeadersFactory.cpp | 3 +- .../SetCollisionHeaderFactory.cpp | 6 ++-- soh/soh/resource/type/Skeleton.cpp | 3 +- soh/soh/z_message_OTR.cpp | 4 +-- 19 files changed, 84 insertions(+), 59 deletions(-) diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index 472a88aea00..4e60fac5135 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -116,7 +116,7 @@ void applyPreset(std::string presetName, std::vector includeSecti } Ship::Context::GetRawInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), - block); + block); Ship::Context::GetRawInstance()->GetConsoleVariables()->Load(); } } diff --git a/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp b/soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp index 8f7b452e474..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::GetRawInstance()->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/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 4617106efae..214ca530de3 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -166,8 +166,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::GetRawInstance()->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( diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index f3b84de084f..2cf63ddefb0 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -806,7 +806,8 @@ void SohInputEditorWindow::UpdateStickDirectionToMappingIds(uint8_t port) { // todo: do we need this? for (auto stick : { std::make_pair>( - Ship::LEFT, Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), + Ship::LEFT, + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), std::make_pair>( Ship::RIGHT, Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick()) }) { @@ -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::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping(id); + Ship::Context::GetRawInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping( + id); } ImGui::PopStyleVar(); } @@ -1514,7 +1516,8 @@ void SohInputEditorWindow::DrawDeviceToggles(uint8_t portIndex) { ImGui::PopItemFlag(); - auto connectedDeviceManager = Ship::Context::GetRawInstance()->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); diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 99b9b1ec371..b8c2c45e276 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -37,12 +37,12 @@ extern PlayState* gPlayState; #define CMD_REGISTER Ship::Context::GetRawInstance()->GetConsole()->AddCommand // TODO: Commands should be using the output passed in. -#define ERROR_MESSAGE \ - std::reinterpret_pointer_cast( \ +#define ERROR_MESSAGE \ + std::reinterpret_pointer_cast( \ Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendErrorMessage -#define INFO_MESSAGE \ - std::reinterpret_pointer_cast( \ +#define INFO_MESSAGE \ + std::reinterpret_pointer_cast( \ Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendInfoMessage diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 90ecf1573f7..27d0ec33d75 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -610,11 +610,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::GetRawInstance()->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; @@ -646,9 +646,10 @@ void DrawInventoryTab() { ImGui::PushItemWidth(IMAGE_SIZE); ImGui::BeginGroup(); - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->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(); diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index 23e7b826bf7..c0062308c0c 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -394,8 +394,9 @@ void PlandomizerItemImageCorrection(Rando::Item randoItem) { for (auto& map : itemImageMap) { if (map.first == randoItem.GetRandomizerGet()) { - textureID = std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->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); @@ -980,15 +981,16 @@ void PlandomizerDrawOptions() { PlandoPushImageButtonStyle(); for (auto& hash : plandoHash) { ImGui::PushID(index); - textureID = - std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->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::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)); + 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 +1001,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::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)); + 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) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index be448193ad5..8a9183c5e4d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1001,7 +1001,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::GetRawInstance()->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 ab790f4d3cb..1e9b3a9d3a6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -840,7 +840,8 @@ void EntranceTrackerWindow::DrawElement() { int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_ENTRANCE("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; OSContPad* trackerButtonsPressed = - std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->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 03f9ab9d5f6..d730cf22b4f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -818,9 +818,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::GetRawInstance()->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); diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index 3700f3df0e2..795ce86e4ce 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -819,7 +819,7 @@ extern "C" void ProcessSaveStateRequests(void) { void SaveStateMgr::SetCurrentSlot(unsigned int slot) { Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, - "slot %u set", slot); + "slot %u set", slot); this->currentSlot = slot; } diff --git a/soh/soh/Notification/Notification.cpp b/soh/soh/Notification/Notification.cpp index d1b70566a98..618fbe46dd1 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -90,9 +90,10 @@ void Window::Draw() { ImGui::SetWindowPos(notificationPos); if (notification.itemIcon != nullptr) { - ImGui::Image(std::dynamic_pointer_cast(Ship::Context::GetRawInstance()->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/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index 4ea75d6b5f4..472d479dc69 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -341,7 +341,8 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me 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::GetRawInstance()->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::GetRawInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); @@ -356,9 +357,9 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me if (UIWidgets::Combobox("Renderer API (Needs reload)", &configWindowBackend, availableWindowBackendsMap, options)) { Ship::Context::GetRawInstance()->GetConfig()->SetInt("Window.Backend.Id", - (int32_t)(configWindowBackend)); + (int32_t)(configWindowBackend)); Ship::Context::GetRawInstance()->GetConfig()->SetString("Window.Backend.Name", - windowBackendsMap.at(configWindowBackend)); + windowBackendsMap.at(configWindowBackend)); Ship::Context::GetRawInstance()->GetConfig()->Save(); UpdateWindowBackendObjects(); } diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index 7d0a4232b8c..0405ea8bd45 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -437,7 +437,8 @@ void SohMenu::AddMenuSettings() { "This will completely erase the controls config, including registered devices.\nContinue?", "Clear", "Cancel", []() { - Ship::Context::GetRawInstance()->GetConsoleVariables()->ClearBlock(CVAR_PREFIX_SETTING ".Controllers"); + Ship::Context::GetRawInstance()->GetConsoleVariables()->ClearBlock(CVAR_PREFIX_SETTING + ".Controllers"); uint8_t bits = 0; Ship::Context::GetRawInstance()->GetControlDeck()->Init(&bits); }, diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index a6a99fbb674..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::GetRawInstance()->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::GetRawInstance()->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::GetRawInstance()->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::GetRawInstance()->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::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); soundEffect.sample = static_cast(res ? res->GetRawPointer() : nullptr); } diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 3af90da73f4..bf339d87dd2 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -49,7 +49,8 @@ SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptrAttribute("Path")); if (!headerName.empty()) { setAlternateHeaders->headers.push_back(std::static_pointer_cast( - Ship::Context::GetRawInstance()->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 b082588d10a..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::GetRawInstance()->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::GetRawInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess( + setCollisionHeader->fileName.c_str())); return setCollisionHeader; } diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 067cb8c9735..2b76caed3f6 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -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::GetRawInstance()->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 673c5278b3e..a693d5078f0 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -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::GetRawInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast( + Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr;