Apply ImGui scaling when using presets (#5991)
* Apply ImGui scaling when using presets * Make ImGuiScale function do nothing if scale setting is unchanged
This commit is contained in:
@@ -129,6 +129,7 @@ void applyPreset(std::string presetName, std::vector<PresetSection> includeSecti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShipInit::InitAll();
|
ShipInit::InitAll();
|
||||||
|
OTRGlobals::Instance->ScaleImGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPresetSelector(std::vector<PresetSection> includeSections, std::string presetLoc, bool disabled) {
|
void DrawPresetSelector(std::vector<PresetSection> includeSections, std::string presetLoc, bool disabled) {
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B };
|
|||||||
Color_RGB8 goronColor = { 0x64, 0x14, 0x00 };
|
Color_RGB8 goronColor = { 0x64, 0x14, 0x00 };
|
||||||
Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
||||||
|
|
||||||
|
int32_t previousImGuiScaleIndex;
|
||||||
float previousImGuiScale;
|
float previousImGuiScale;
|
||||||
|
|
||||||
bool prevAltAssets = false;
|
bool prevAltAssets = false;
|
||||||
@@ -431,6 +432,7 @@ void OTRGlobals::Initialize() {
|
|||||||
|
|
||||||
hasMasterQuest = hasOriginal = false;
|
hasMasterQuest = hasOriginal = false;
|
||||||
|
|
||||||
|
previousImGuiScaleIndex = -1;
|
||||||
previousImGuiScale = defaultImGuiScale;
|
previousImGuiScale = defaultImGuiScale;
|
||||||
|
|
||||||
fontMonoSmall = CreateFontWithSize(14.0f, "fonts/Inconsolata-Regular.ttf");
|
fontMonoSmall = CreateFontWithSize(14.0f, "fonts/Inconsolata-Regular.ttf");
|
||||||
@@ -499,11 +501,17 @@ OTRGlobals::~OTRGlobals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OTRGlobals::ScaleImGui() {
|
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;
|
float newScale = scale / previousImGuiScale;
|
||||||
ImGui::GetStyle().ScaleAllSizes(newScale);
|
ImGui::GetStyle().ScaleAllSizes(newScale);
|
||||||
ImGui::GetIO().FontGlobalScale = scale;
|
ImGui::GetIO().FontGlobalScale = scale;
|
||||||
previousImGuiScale = scale;
|
previousImGuiScale = scale;
|
||||||
|
previousImGuiScaleIndex = imGuiScaleIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) {
|
ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user