diff options
| author | Jordan Longstaff <JordanLongstaff@users.noreply.github.com> | 2025-12-03 10:58:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-03 08:58:43 -0700 |
| commit | b649f5ed52ea4e824af2f05076b5d9ca697183af (patch) | |
| tree | fab9fedbe754b0bd75e22a0af1ebf46a543f7aec /soh | |
| parent | 17f7c3e8f5b1cc664efdd67d52e28326e607d0af (diff) | |
Apply ImGui scaling when using presets (#5991)
* Apply ImGui scaling when using presets
* Make ImGuiScale function do nothing if scale setting is unchanged
Diffstat (limited to 'soh')
| -rw-r--r-- | soh/soh/Enhancements/Presets/Presets.cpp | 1 | ||||
| -rw-r--r-- | soh/soh/OTRGlobals.cpp | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index 7671ee18e..c75303045 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -129,6 +129,7 @@ void applyPreset(std::string presetName, std::vector<PresetSection> includeSecti } } ShipInit::InitAll(); + OTRGlobals::Instance->ScaleImGui(); } void DrawPresetSelector(std::vector<PresetSection> includeSections, std::string presetLoc, bool disabled) { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 97d8454b5..2aadd55d2 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -152,6 +152,7 @@ Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B }; Color_RGB8 goronColor = { 0x64, 0x14, 0x00 }; Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; +int32_t previousImGuiScaleIndex; float previousImGuiScale; bool prevAltAssets = false; @@ -431,6 +432,7 @@ void OTRGlobals::Initialize() { hasMasterQuest = hasOriginal = false; + previousImGuiScaleIndex = -1; previousImGuiScale = defaultImGuiScale; fontMonoSmall = CreateFontWithSize(14.0f, "fonts/Inconsolata-Regular.ttf"); @@ -499,11 +501,17 @@ OTRGlobals::~OTRGlobals() { } void OTRGlobals::ScaleImGui() { - float scale = imguiScaleOptionToValue[CVarGetInteger(CVAR_SETTING("ImGuiScale"), defaultImGuiScale)]; + int32_t imGuiScaleIndex = CVarGetInteger(CVAR_SETTING("ImGuiScale"), defaultImGuiScale); + if (imGuiScaleIndex == previousImGuiScaleIndex) { + return; + } + + float scale = imguiScaleOptionToValue[imGuiScaleIndex]; float newScale = scale / previousImGuiScale; ImGui::GetStyle().ScaleAllSizes(newScale); ImGui::GetIO().FontGlobalScale = scale; previousImGuiScale = scale; + previousImGuiScaleIndex = imGuiScaleIndex; } ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) { |
