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..6125a3837eb 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,19 @@ 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"); + textureDisplay = gui->GetTextureByName("DAY_TIME_TIMER"); } else { - textureDisplay = - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NIGHT_TIME_TIMER"); + textureDisplay = gui->GetTextureByName("NIGHT_TIME_TIMER"); } timeDisplayTime = convertDayTime(gSaveContext.dayTime).c_str(); break; @@ -107,18 +110,16 @@ 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( - 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 = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - itemMapping[ITEM_SWORD_MASTER].name); + 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 +133,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,13 +204,15 @@ void TimeDisplayWindow::Draw() { } if (textToDecode[i] == '.') { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale)); - ImGui::Image(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(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)); } @@ -247,17 +250,18 @@ static void TimeDisplayInitTimers() { } void TimeDisplayWindow::InitElement() { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, - ImVec4(1, 1, 1, 1)); - 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, - 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("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) { - 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 9e46497b540..1d4745db512 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,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(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(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)); } } @@ -72,80 +76,80 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; if (!sButtonTexturesLoaded) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn", - "textures/buttons/ABtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn", - "textures/buttons/BBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn", - "textures/buttons/LBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", - "textures/buttons/RBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", - "textures/buttons/ZBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Start-Btn", "textures/buttons/StartBtn.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", - "textures/buttons/CLeft.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", - "textures/buttons/CRight.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", - "textures/buttons/CUp.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", - "textures/buttons/CDown.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Analog-Stick", "textures/buttons/AnalogStick.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Left", "textures/buttons/DPadLeft.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Right", "textures/buttons/DPadRight.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", - "textures/buttons/DPadUp.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Down", "textures/buttons/DPadDown.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1", - "textures/buttons/Mod1.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2", - "textures/buttons/Mod2.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Right-Stick", "textures/buttons/RightStick.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "A-Btn Outline", "textures/buttons/ABtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "B-Btn Outline", "textures/buttons/BBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "L-Btn Outline", "textures/buttons/LBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "R-Btn Outline", "textures/buttons/RBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "C-Left Outline", "textures/buttons/CLeftOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "C-Right Outline", "textures/buttons/CRightOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "C-Up Outline", "textures/buttons/CUpOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "C-Down Outline", "textures/buttons/CDownOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Modifier-1 Outline", "textures/buttons/Mod1Outline.png"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( - "Modifier-2 Outline", "textures/buttons/Mod2Outline.png"); - 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; } @@ -162,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 = 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 +204,8 @@ 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 +356,8 @@ 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,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(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 @@ -374,7 +383,8 @@ 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,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(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 267f3339ed0..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; diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 3c99ea19ee0..4393099dbbc 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,8 @@ 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 +549,8 @@ 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 +560,8 @@ 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 +612,8 @@ 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 +646,8 @@ 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)); @@ -1232,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(), - 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 { @@ -1263,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(), - 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); @@ -1299,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(), - 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; @@ -1434,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(), - 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; @@ -1457,7 +1469,8 @@ 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) { @@ -1503,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(), - 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; @@ -1583,9 +1597,10 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_JABU_JABU_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::Image(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, @@ -1974,6 +1989,6 @@ void SaveEditorWindow::DrawElement() { } void SaveEditorWindow::InitElement() { - 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 7efd9c99d6a..b32d863e42a 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,8 +308,8 @@ 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( - 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; @@ -380,17 +382,20 @@ 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,17 +409,19 @@ 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( - itemMapping[randoItem.GetGIEntry()->itemId].name); + textureID = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()) + ->GetTextureByName(itemMapping[randoItem.GetGIEntry()->itemId].name); } } @@ -974,11 +981,13 @@ 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 +1001,8 @@ 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 +1181,26 @@ void PlandomizerWindow::DrawElement() { } void PlandomizerWindow::InitElement() { - 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, - ImVec4(0.87f, 0.10f, 0.10f, 1)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("ITEM_SEEDS", gItemIconDekuSeedsTex, - ImVec4(1, 1, 1, 1)); - 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, - ImVec4(1, 1, 1, 1)); - 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, - ImVec4(1, 1, 1, 1)); - 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, - 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, - 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 0ccc205a6df..24730334a58 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,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(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()); @@ -816,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(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) { @@ -1215,8 +1217,8 @@ void DrawItem(ItemTrackerItem item) { ImGui::BeginGroup(); - ImGui::Image(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); @@ -1301,8 +1303,8 @@ void DrawBottle(ItemTrackerItem item) { } float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); - ImGui::Image(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()); @@ -1317,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(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(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)); } @@ -1367,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(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 e970b965cfe..8007a07e063 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,8 @@ 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 +491,8 @@ 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,8 +668,9 @@ 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, - 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); @@ -748,8 +753,9 @@ 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, - 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)) { @@ -891,8 +897,9 @@ 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, - 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; @@ -976,10 +983,10 @@ void TimeSplitWindow::DrawElement() { void TimeSplitWindow::InitElement() { TimeSplitsUpdateWindowSize(); - 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, - 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 5b6039cf8ce..decb7d88587 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,8 @@ 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..20b20ad7338 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,21 @@ 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 +811,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 +1631,8 @@ 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,8 +1645,9 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F5: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - 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(); @@ -1647,8 +1667,9 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F6: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - 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(); @@ -1662,8 +1683,9 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F7: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - 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(); @@ -2193,7 +2215,8 @@ 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 +2551,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 +2559,8 @@ 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 +2572,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..13be6b96047 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -15,6 +15,8 @@ #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..9ea36ebd08e 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,68 +217,73 @@ 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, - ImVec4(1, 1, 1, 1)); - 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; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, - gregGreen); - 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; - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, - aButtonBlue); - 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) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - 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) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - 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) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, - ImVec4(1, 1, 1, 1)); - 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) { - 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..145de6d1b05 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -99,17 +99,18 @@ 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,