From 37c03455298a383789bc91643fe16aeb21611032 Mon Sep 17 00:00:00 2001 From: aMannus Date: Fri, 21 Apr 2023 22:05:38 +0200 Subject: [PATCH] ImGui Cleanup - Move Experimental entries, clean up presets (#2725) * ImGui cleanup * Fix Wii U * Fix Wii U build 2: Electric Boogaloo * Review comments * Review Comments 2: Electric Boogaloo --- soh/soh/Enhancements/presets.h | 29 ++++ soh/soh/GameMenuBar.cpp | 248 ++++++++++++++++----------------- soh/soh/UIWidgets.cpp | 8 +- soh/src/code/z_player_lib.c | 4 +- 4 files changed, 159 insertions(+), 130 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 1a2319cdd..ca8ded27d 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -182,6 +182,25 @@ const std::vector enhancementsCvars = { "gNoInputForCredits", "gFastFarores", "gNightGSAlwaysSpawn", + "gSkipText", + "gLinkDefaultName", + "gMarketSneak", + "gTimeTravel", + "gNutsExplodeBombs", + "gBowSlingShotAmmoFix", + "gBetterFW", + "gDisableFirstPersonChus", + "gHyperBosses", + "gRupeeDash", + "gDashInterval", + "gDogFollowsEverywhere", + "gDisableTunicWarningText", + "gDisableLOD", + "gDisableDrawDistance", + "gDisableKokiriDrawDistance", + "gLowResMode", + "gDrawLineupTick", + "gQuickBongoKill", }; const std::vector randomizerCvars = { @@ -320,6 +339,8 @@ const std::vector vanillaPlusPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32("gTextSpeed", 5), + // Skip Text + PRESET_ENTRY_S32("gSkipText", 1), // King Zora Speed (1 to 5) PRESET_ENTRY_S32("gMweepSpeed", 2), // Faster Block Push (+0 to +5) @@ -387,6 +408,8 @@ const std::vector enhancedPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32("gTextSpeed", 5), + // Skip Text + PRESET_ENTRY_S32("gSkipText", 1), // King Zora Speed (1 to 5) PRESET_ENTRY_S32("gMweepSpeed", 5), // Faster Block Push (+0 to +5) @@ -458,6 +481,8 @@ const std::vector enhancedPresetEntries = { PRESET_ENTRY_S32("gInstantPutaway", 1), // Instant Boomerang Recall PRESET_ENTRY_S32("gFastBoomerang", 1), + // Nuts Explode Bombs + PRESET_ENTRY_S32("gNutsExplodeBombs", 1), // Ask to Equip New Items PRESET_ENTRY_S32("gAskToEquip", 1), // Mask Select in Inventory @@ -506,6 +531,8 @@ const std::vector randomizerPresetEntries = { // Text Speed (1 to 5) PRESET_ENTRY_S32("gTextSpeed", 5), + // Skip Text + PRESET_ENTRY_S32("gSkipText", 1), // King Zora Speed (1 to 5) PRESET_ENTRY_S32("gMweepSpeed", 5), // Faster Block Push (+0 to +5) @@ -574,6 +601,8 @@ const std::vector randomizerPresetEntries = { PRESET_ENTRY_S32("gInstantPutaway", 1), // Instant Boomerang Recall PRESET_ENTRY_S32("gFastBoomerang", 1), + // Nuts Explode Bombs + PRESET_ENTRY_S32("gNutsExplodeBombs", 1), // Ask to Equip New Items PRESET_ENTRY_S32("gAskToEquip", 1), // Mask Select in Inventory diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index fd5d138dd..48e5ea682 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -35,13 +35,6 @@ #include "Enhancements/game-interactor/GameInteractor.h" -#define EXPERIMENTAL() \ - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 50, 50, 255)); \ - UIWidgets::Spacer(3.0f); \ - ImGui::Text("Experimental"); \ - ImGui::PopStyleColor(); \ - UIWidgets::PaddedSeparator(false, true); - bool isBetaQuestEnabled = false; extern "C" { @@ -201,12 +194,116 @@ namespace GameMenuBar { SohImGui::SetMSAALevel(CVarGetInteger("gMSAAValue", 1)); #endif + { // FPS Slider + const int minFps = 20; + static int maxFps; + if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { + maxFps = 360; + } else { + maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate(); + } + int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); + #ifdef __WIIU__ + UIWidgets::Spacer(0); + // only support divisors of 60 on the Wii U + if (currentFps > 60) { + currentFps = 60; + } else { + currentFps = 60 / (60 / currentFps); + } + + int fpsSlider = 1; + if (currentFps == 20) { + ImGui::Text("FPS: Original (20)"); + } else { + ImGui::Text("FPS: %d", currentFps); + if (currentFps == 30) { + fpsSlider = 2; + } else { // currentFps == 60 + fpsSlider = 3; + } + } + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (ImGui::Button(" - ##WiiUFPS")) { + fpsSlider--; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + UIWidgets::Spacer(0); + + ImGui::SliderInt("##WiiUFPSSlider", &fpsSlider, 1, 3, "", ImGuiSliderFlags_AlwaysClamp); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(" + ##WiiUFPS")) { + fpsSlider++; + } + + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::ReEnableComponent(""); + } + if (fpsSlider > 3) { + fpsSlider = 3; + } else if (fpsSlider < 1) { + fpsSlider = 1; + } + + if (fpsSlider == 1) { + currentFps = 20; + } else if (fpsSlider == 2) { + currentFps = 30; + } else if (fpsSlider == 3) { + currentFps = 60; + } + CVarSetInteger("gInterpolationFPS", currentFps); + SohImGui::RequestCvarSaveOnNextTick(); + #else + bool matchingRefreshRate = + CVarGetInteger("gMatchRefreshRate", 0) && SohImGui::WindowBackend() != SohImGui::Backend::DX11; + UIWidgets::PaddedEnhancementSliderInt( + (currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", + "##FPSInterpolation", "gInterpolationFPS", minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); + #endif + if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc.\n\n" + "A higher target FPS than your monitor's refresh rate will waste resources, and might give a worse result." + ); + } else { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc." + ); + } + } // END FPS Slider + + if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { + UIWidgets::Spacer(0); + if (ImGui::Button("Match Refresh Rate")) { + int hz = Ship::Window::GetInstance()->GetCurrentRefreshRate(); + if (hz >= 20 && hz <= 360) { + CVarSetInteger("gInterpolationFPS", hz); + SohImGui::RequestCvarSaveOnNextTick(); + } + } + } else { + UIWidgets::PaddedEnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate", true, false); + } + UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); + if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); } + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::Text("Renderer API (Needs reload)"); auto renderingBackends = SohImGui::GetAvailableRenderingBackends(); auto currentRenderingBackend = SohImGui::GetCurrentRenderingBackend(); @@ -240,8 +337,6 @@ namespace GameMenuBar { UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } - EXPERIMENTAL(); - // If more filters are added to LUS, make sure to add them to the filters list here ImGui::Text("Texture Filter (Needs reload)"); const char* filters[] = { SohImGui::GetSupportedTextureFilters()[0], @@ -293,13 +388,15 @@ namespace GameMenuBar { { DrawPresetSelector(PRESET_TYPE_ENHANCEMENTS); - UIWidgets::Spacer(0); + UIWidgets::PaddedSeparator(); if (ImGui::BeginMenu("Gameplay")) { if (ImGui::BeginMenu("Time Savers")) { UIWidgets::PaddedEnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", "gTextSpeed", 1, 5, "", 1, true, false, true); + UIWidgets::PaddedEnhancementCheckbox("Skip Text", "gSkipText", false, true); + UIWidgets::Tooltip("Holding down B skips text"); UIWidgets::PaddedEnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", "gMweepSpeed", 1, 5, "", 1, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Biggoron Forge Time: %d days", "##FORGETIME", "gForgeTime", 0, 3, "", 3, true, false, true); UIWidgets::Tooltip("Allows you to change the number of days it takes for Biggoron to forge the Biggoron Sword"); @@ -636,7 +733,7 @@ namespace GameMenuBar { UIWidgets::Tooltip("Hides most of the UI when not needed\nNote: Doesn't activate until after loading a new scene"); UIWidgets::PaddedEnhancementCheckbox("Disable Navi Call Audio", "gDisableNaviCallAudio", true, false); UIWidgets::Tooltip("Disables the voice audio when Navi calls you"); - UIWidgets::PaddedEnhancementCheckbox("Disable Hot/Underwater Warning Text", "gDisableWarningText", true, false); + UIWidgets::PaddedEnhancementCheckbox("Disable Hot/Underwater Warning Text", "gDisableTunicWarningText", true, false); UIWidgets::Tooltip("Disables warning text when you don't have on the Goron/Zora Tunic in Hot/Underwater conditions."); ImGui::EndMenu(); @@ -734,6 +831,18 @@ namespace GameMenuBar { ImGui::EndMenu(); } + UIWidgets::PaddedEnhancementCheckbox("Disable LOD", "gDisableLOD", true, false); + UIWidgets::Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance"); + if (UIWidgets::PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false)) { + if (CVarGetInteger("gDisableDrawDistance", 0) == 0) { + CVarSetInteger("gDisableKokiriDrawDistance", 0); + } + } + UIWidgets::Tooltip("Turns off the objects draw distance, making objects being visible from a longer range"); + if (CVarGetInteger("gDisableDrawDistance", 0) == 1) { + UIWidgets::PaddedEnhancementCheckbox("Kokiri Draw Distance", "gDisableKokiriDrawDistance", true, false); + UIWidgets::Tooltip("The Kokiri are mystical beings that fade into view when approached\nEnabling this will remove their draw distance"); + } UIWidgets::PaddedEnhancementCheckbox("N64 Mode", "gLowResMode", true, false); UIWidgets::Tooltip("Sets aspect ratio to 4:3 and lowers resolution to 240p, the N64's native resolution"); UIWidgets::PaddedEnhancementCheckbox("Glitch line-up tick", "gDrawLineupTick", true, false); @@ -823,7 +932,7 @@ namespace GameMenuBar { ImGui::EndMenu(); } - UIWidgets::PaddedSeparator(false, true); + UIWidgets::PaddedSeparator(); // Autosave enum value of 1 is the default in presets and the old checkbox "on" state for backwards compatibility UIWidgets::PaddedText("Autosave", false, true); @@ -831,7 +940,7 @@ namespace GameMenuBar { UIWidgets::Tooltip("Automatically save the game when changing locations and/or obtaining items\n" "Major items exclude rupees and health/magic/ammo refills (but include bombchus unless bombchu drops are enabled)"); - UIWidgets::Spacer(0); + UIWidgets::PaddedSeparator(true, true, 2.0f, 2.0f); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); @@ -868,119 +977,6 @@ namespace GameMenuBar { ImGui::PopStyleVar(3); ImGui::PopStyleColor(1); - EXPERIMENTAL(); - - { // FPS Slider - const int minFps = 20; - static int maxFps; - if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { - maxFps = 360; - } else { - maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate(); - } - int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); - #ifdef __WIIU__ - // only support divisors of 60 on the Wii U - if (currentFps > 60) { - currentFps = 60; - } - else { - currentFps = 60 / (60 / currentFps); - } - - int fpsSlider = 1; - if (currentFps == 20) { - ImGui::Text("Frame interpolation: Off"); - } - else { - ImGui::Text("Frame interpolation: %d FPS", currentFps); - if (currentFps == 30) { - fpsSlider = 2; - } - else { // currentFps == 60 - fpsSlider = 3; - } - } - if (CVarGetInteger("gMatchRefreshRate", 0)) { - UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } - - if (ImGui::Button(" - ##WiiUFPS")) { - fpsSlider--; - } - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - - ImGui::SliderInt("##WiiUFPSSlider", &fpsSlider, 1, 3, "", ImGuiSliderFlags_AlwaysClamp); - - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - if (ImGui::Button(" + ##WiiUFPS")) { - fpsSlider++; - } - - if (CVarGetInteger("gMatchRefreshRate", 0)) { - UIWidgets::ReEnableComponent(""); - } - if (fpsSlider > 3) { - fpsSlider = 3; - } - else if (fpsSlider < 1) { - fpsSlider = 1; - } - - if (fpsSlider == 1) { - currentFps = 20; - } - else if (fpsSlider == 2) { - currentFps = 30; - } - else if (fpsSlider == 3) { - currentFps = 60; - } - CVarSetInteger("gInterpolationFPS", currentFps); - SohImGui::RequestCvarSaveOnNextTick(); - #else - bool matchingRefreshRate = CVarGetInteger("gMatchRefreshRate", 0) && SohImGui::WindowBackend() != SohImGui::Backend::DX11; - UIWidgets::EnhancementSliderInt((currentFps == 20) ? "Frame interpolation: Off" : "Frame interpolation: %d FPS", - "##FPSInterpolation", "gInterpolationFPS", minFps, maxFps, "", 20, true, matchingRefreshRate); - #endif - UIWidgets::Tooltip("Interpolate extra frames to get smoother graphics\n" - "Set to match your monitor's refresh rate, or a divisor of it\n" - "A higher target FPS than your monitor's refresh rate will just waste resources, and might give a worse result.\n" - "For consistent input lag, set this value and your monitor's refresh rate to a multiple of 20\n" - "Ctrl+Click for keyboard input"); - } // END FPS Slider - - if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) { - ImGui::Dummy(ImVec2(0,0)); - if (ImGui::Button("Match Refresh Rate")) { - int hz = Ship::Window::GetInstance()->GetCurrentRefreshRate(); - if (hz >= 20 && hz <= 360) { - CVarSetInteger("gInterpolationFPS", hz); - SohImGui::RequestCvarSaveOnNextTick(); - } - } - } else { - UIWidgets::PaddedEnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate", true, false); - } - UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); - - UIWidgets::PaddedEnhancementCheckbox("Disable LOD", "gDisableLOD", true, false); - UIWidgets::Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance"); - if (UIWidgets::PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false)) { - if (CVarGetInteger("gDisableDrawDistance", 0) == 0) { - CVarSetInteger("gDisableKokiriDrawDistance", 0); - } - } - UIWidgets::Tooltip("Turns off the objects draw distance, making objects being visible from a longer range"); - if (CVarGetInteger("gDisableDrawDistance", 0) == 1) { - UIWidgets::PaddedEnhancementCheckbox("Kokiri Draw Distance", "gDisableKokiriDrawDistance", true, false); - UIWidgets::Tooltip("The Kokiri are mystical beings that fade into view when approached\nEnabling this will remove their draw distance"); - } - UIWidgets::PaddedEnhancementCheckbox("Skip Text", "gSkipText", true, false); - UIWidgets::Tooltip("Holding down B skips text"); - #ifdef __SWITCH__ UIWidgets::Spacer(0); ImGui::Text("Switch performance mode"); diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 9a3652f7b..d4a54cd34 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -102,9 +102,13 @@ namespace UIWidgets { } void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) { - if (padTop) Spacer(0); + if (padTop) { + Spacer(extraVerticalTopPadding); + } ImGui::Separator(); - if (padBottom) Spacer(0); + if (padBottom) { + Spacer(extraVerticalBottomPadding); + } } void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) { diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 5957b97ca..5bae84443 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -660,9 +660,9 @@ s32 func_8008F2F8(PlayState* play) { triggerEntry = &sTextTriggers[var]; if ((triggerEntry->flag != 0) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && - (((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON && CVarGetInteger("gSuperTunic", 0) == 0 && CVarGetInteger("gDisableWarningText", 0) == 0)) || + (((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON && CVarGetInteger("gSuperTunic", 0) == 0 && CVarGetInteger("gDisableTunicWarningText", 0) == 0)) || (((var == 1) || (var == 3)) && (this->currentBoots == PLAYER_BOOTS_IRON) && - (this->currentTunic != PLAYER_TUNIC_ZORA && CVarGetInteger("gSuperTunic", 0) == 0 && CVarGetInteger("gDisableWarningText", 0) == 0)))) { + (this->currentTunic != PLAYER_TUNIC_ZORA && CVarGetInteger("gSuperTunic", 0) == 0 && CVarGetInteger("gDisableTunicWarningText", 0) == 0)))) { Message_StartTextbox(play, triggerEntry->textId, NULL); gSaveContext.textTriggerFlags |= triggerEntry->flag; }