From ef65f6ad7dbbd2425ef83f8ac6efba042d5427d4 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 26 Feb 2025 23:31:04 +0300 Subject: [PATCH] Added HQ font option for menu (Default true) --- OptiScaler.ini | 5 +++++ OptiScaler/Config.cpp | 2 ++ OptiScaler/Config.h | 1 + OptiScaler/menu/menu_base.cpp | 5 ++++- OptiScaler/menu/menu_common.cpp | 35 ++++++++++++++++++++++----------- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/OptiScaler.ini b/OptiScaler.ini index 7fe7ab84..2785e531 100644 --- a/OptiScaler.ini +++ b/OptiScaler.ini @@ -351,6 +351,11 @@ ShortcutKey=auto ; true or false - Default (auto) is false ExtendedLimits=auto +; Use high quality font for menu +; Might use less VRAM +; true or false - Default (auto) is true +UseHQFont=auto + ; Enables Fps overlay ; true or false - Default (auto) is false ShowFps=auto diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index dc420c4a..43ef1fc5 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -213,6 +213,7 @@ bool Config::Reload(std::filesystem::path iniPath) ShortcutKey.set_from_config(readInt("Menu", "ShortcutKey")); ExtendedLimits.set_from_config(readBool("Menu", "ExtendedLimits")); ShowFps.set_from_config(readBool("Menu", "ShowFps")); + UseHQFont.set_from_config(readBool("Menu", "UseHQFont")); if (auto setting = readInt("Menu", "FpsOverlayPos"); setting.has_value()) FpsOverlayPos.set_from_config(std::clamp(setting.value(), 0, 3)); @@ -643,6 +644,7 @@ bool Config::SaveIni() ini.SetValue("Menu", "ShortcutKey", GetIntValue(Instance()->ShortcutKey.value_for_config()).c_str()); ini.SetValue("Menu", "ExtendedLimits", GetBoolValue(Instance()->ExtendedLimits.value_for_config()).c_str()); ini.SetValue("Menu", "ShowFps", GetBoolValue(Instance()->ShowFps.value_for_config()).c_str()); + ini.SetValue("Menu", "UseHQFont", GetBoolValue(Instance()->UseHQFont.value_for_config()).c_str()); ini.SetValue("Menu", "FpsOverlayPos", GetIntValue(Instance()->FpsOverlayPos.value_for_config()).c_str()); ini.SetValue("Menu", "FpsOverlayType", GetIntValue(Instance()->FpsOverlayType.value_for_config()).c_str()); ini.SetValue("Menu", "FpsOverlayHorizontal", GetBoolValue(Instance()->FpsOverlayHorizontal.value_for_config()).c_str()); diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index f8adb7bb..44c58429 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -191,6 +191,7 @@ public: CustomOptional FpsCycleShortcutKey{ VK_NEXT }; CustomOptional FpsOverlayHorizontal{ false }; CustomOptional FpsOverlayAlpha{ 0.4f }; + CustomOptional UseHQFont{ true }; // Hooks CustomOptional HookOriginalNvngxOnly{ false }; diff --git a/OptiScaler/menu/menu_base.cpp b/OptiScaler/menu/menu_base.cpp index cafa5aa1..e8b32e89 100644 --- a/OptiScaler/menu/menu_base.cpp +++ b/OptiScaler/menu/menu_base.cpp @@ -2,6 +2,7 @@ #include "imgui/imgui.h" #include "imgui/misc/freetype/imgui_freetype.h" #include "menu_base.h" +#include // TODO: maybe a vector of fonts? void MenuBase::LoadCustomFonts(ImGuiIO& io, float menuScale) @@ -40,7 +41,9 @@ void MenuBase::UpdateFonts(ImGuiIO& io, float rasterizerDensity) if (lastDensity != rasterizerDensity || io.Fonts->Fonts.empty()) { - LoadCustomFonts(io, rasterizerDensity); + if (Config::Instance()->UseHQFont.value_or_default()) + LoadCustomFonts(io, rasterizerDensity); + lastDensity = rasterizerDensity; } } \ No newline at end of file diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index d1badc98..ddfb3334 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -696,7 +696,7 @@ void MenuCommon::AddDLSSRenderPreset(std::string name, CustomOptionalIsInited()) { ImGui::Spacing(); - ImGui::PushFont(MenuBase::scaledFont); + + if (Config::Instance()->UseHQFont.value_or_default()) + ImGui::PushFont(MenuBase::scaledFont); + else + ImGui::SetWindowFontScale(Config::Instance()->MenuScale.value_or(1.0) * 3.0); if (State::Instance().nvngxExists || State::Instance().libxessExists) { ImGui::Spacing(); + ImGui::Text("Please select %s%s%s%s%s as upscaler\nfrom game options and enter the game\nto enable upscaler settings.\n", State::Instance().fsrHooks ? "FSR" : "", State::Instance().fsrHooks && (State::Instance().nvngxExists || State::Instance().isRunningOnNvidia) ? " or " : "", @@ -1210,7 +1215,10 @@ bool MenuCommon::RenderMenu() State::Instance().libxessExists ? "XeSS" : ""); - ImGui::PopFont(); + if (Config::Instance()->UseHQFont.value_or_default()) + ImGui::PopFont(); + else + ImGui::SetWindowFontScale(Config::Instance()->MenuScale.value_or(1.0)); ImGui::Spacing(); ImGui::Text("nvngx.dll: %sExist", State::Instance().nvngxExists || State::Instance().isRunningOnNvidia ? "" : "Not "); @@ -1224,7 +1232,10 @@ bool MenuCommon::RenderMenu() ImGui::Text("Can't find nvngx.dll and libxess.dll and FSR inputs\nUpscaling support will NOT work."); ImGui::Spacing(); - ImGui::PopFont(); + if (Config::Instance()->UseHQFont.value_or_default()) + ImGui::PopFont(); + else + ImGui::SetWindowFontScale(Config::Instance()->MenuScale.value_or(1.0)); } } @@ -1317,17 +1328,17 @@ bool MenuCommon::RenderMenu() } // Nukem's FG mod requirements - if (State::Instance().api == DX11) + if (State::Instance().api == DX11) { disabledMask[2] = true; fgDesc[2] = "Unsupported API"; } - else if (State::Instance().isWorkingAsNvngx) + else if (State::Instance().isWorkingAsNvngx) { disabledMask[2] = true; fgDesc[2] = "Unsupported Opti working mode"; } - else if (!State::Instance().NukemsFilesAvailable) + else if (!State::Instance().NukemsFilesAvailable) { disabledMask[2] = true; fgDesc[2] = "Missing the dlssg_to_fsr3_amd_is_better.dll file"; @@ -2011,9 +2022,9 @@ bool MenuCommon::RenderMenu() if (overridden) { ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Presets are overridden externally"); ShowHelpMarker("This usually happens due to using tools\n" - "such as Nvidia App or Nvidia Inspector"); + "such as Nvidia App or Nvidia Inspector"); ImGui::Text("Selecting setting below will disable that external override\n" - "but you need to Save INI and restart the game"); + "but you need to Save INI and restart the game"); ImGui::Spacing(); } @@ -2021,7 +2032,7 @@ bool MenuCommon::RenderMenu() if (bool pOverride = Config::Instance()->RenderPresetOverride.value_or_default(); ImGui::Checkbox("Render Presets Override", &pOverride)) Config::Instance()->RenderPresetOverride = pOverride; ShowHelpMarker("Each render preset has it strengths and weaknesses\n" - "Override to potentially improve image quality"); + "Override to potentially improve image quality"); ImGui::BeginDisabled(!Config::Instance()->RenderPresetOverride.value_or_default() || overridden); @@ -2058,8 +2069,8 @@ bool MenuCommon::RenderMenu() Config::Instance()->UseGenericAppIdWithDlss = appIdOverride; ShowHelpMarker("Use generic appid with NGX\n" - "Fixes OptiScaler preset override not working with certain games\n" - "Requires a game restart."); + "Fixes OptiScaler preset override not working with certain games\n" + "Requires a game restart."); ImGui::BeginDisabled(!Config::Instance()->RenderPresetOverride.value_or_default() || overridden); ImGui::Spacing();