From 722dcb68e7b17c8b9f0c6d3ea77d8220812479dc Mon Sep 17 00:00:00 2001 From: cdozdil Date: Mon, 18 May 2026 00:46:09 +0300 Subject: [PATCH] Added background alpha --- OptiScaler.ini | 10 ++++++++-- OptiScaler/Config.cpp | 2 ++ OptiScaler/Config.h | 1 + OptiScaler/menu/menu_common.cpp | 30 +++++++++++++++++++++++------- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/OptiScaler.ini b/OptiScaler.ini index 77b894b2..81bdf67a 100644 --- a/OptiScaler.ini +++ b/OptiScaler.ini @@ -809,18 +809,24 @@ LightTheme=auto ; Accent color for the menu ; R/G/B float colors values of the accent color for the menu -; 0.0 to 1.0 - Default (auto) R: 0.00f, G: 0.40f, B: 0.77f (Blue) +; 0.0 to 1.0 - Default (auto) R: 0.0, G: 0.4, B: 0.77 (Blue) AccentColorR=auto AccentColorG=auto AccentColorB=auto ; Background color for the menu ; R/G/B float colors values of the accent color for the menu -; 0.0 to 1.0 - Default (auto) R: 0.0f, G: 0.0f, B: 0.0f (Black) +; 0.0 to 1.0 - Default (auto) R: 0.0, G: 0.0, B: 0.0 (Black) BGColorR=auto BGColorG=auto BGColorB=auto +; Background alpha for the menu +; 0 is transparent and 1 is opaque +; 0.0 to 1.0 - Default (auto) 0.99 +BGColorA=auto + + ; ------------------------------------------------------- diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index 024e5d63..1e8fc279 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -432,6 +432,7 @@ bool Config::Reload(std::filesystem::path iniPath) MenuBGColorR.set_from_config(readFloat("Menu", "BGColorR")); MenuBGColorG.set_from_config(readFloat("Menu", "BGColorG")); MenuBGColorB.set_from_config(readFloat("Menu", "BGColorB")); + MenuBGColorA.set_from_config(readFloat("Menu", "BGColorA")); } // Hooks @@ -1106,6 +1107,7 @@ bool Config::SaveIni() ini.SetValue("Menu", "BGColorR", GetFloatValue(Instance()->MenuBGColorR.value_for_config()).c_str()); ini.SetValue("Menu", "BGColorG", GetFloatValue(Instance()->MenuBGColorG.value_for_config()).c_str()); ini.SetValue("Menu", "BGColorB", GetFloatValue(Instance()->MenuBGColorB.value_for_config()).c_str()); + ini.SetValue("Menu", "BGColorA", GetFloatValue(Instance()->MenuBGColorA.value_for_config()).c_str()); } // Hooks diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 39a0ad34..963297c3 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -312,6 +312,7 @@ class Config CustomOptional MenuBGColorR { 0.0f }; CustomOptional MenuBGColorG { 0.0f }; CustomOptional MenuBGColorB { 0.0f }; + CustomOptional MenuBGColorA { 0.99f }; // Hooks CustomOptional HookOriginalNvngxOnly { false }; diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index 8f605735..80559fa5 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -1733,13 +1733,17 @@ static void ApplyThemeStyle() ImVec4* c = ImGui::GetStyle().Colors; + float minAlpha = Config::Instance()->MenuBGColorA.value_or_default() >= 0.5f + ? Config::Instance()->MenuBGColorA.value_or_default() + : 0.5f; + c[ImGuiCol_Text] = textPrimary; c[ImGuiCol_TextDisabled] = textDim; c[ImGuiCol_TextLink] = AccentReadable(); // MenuBGColor only. - c[ImGuiCol_WindowBg] = BgTint(bgDark, 1.00f); - c[ImGuiCol_ChildBg] = BgTint(bgMid, 1.10f); + c[ImGuiCol_WindowBg] = BgTint(bgDark, 1.00f, Config::Instance()->MenuBGColorA.value_or_default()); + c[ImGuiCol_ChildBg] = BgTint(bgMid, 1.10f, minAlpha + 0.1f); c[ImGuiCol_PopupBg] = lightTheme ? BgTint(bgLight, 0.90f) : BgTint(ImVec4(0.09f, 0.10f, 0.13f, 0.97f), 0.90f, 0.97f); c[ImGuiCol_MenuBarBg] = BgTint(bgDark, 0.85f); @@ -1749,7 +1753,7 @@ static void ApplyThemeStyle() c[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); // Neutral background, not MenuBGColor. - c[ImGuiCol_FrameBg] = BgTint(bgLight, 0.50f); + c[ImGuiCol_FrameBg] = BgTint(bgLight, 0.50f, minAlpha + 0.15f); c[ImGuiCol_FrameBgHovered] = SurfaceHover(); c[ImGuiCol_FrameBgActive] = SurfaceActive(); @@ -1757,7 +1761,7 @@ static void ApplyThemeStyle() c[ImGuiCol_TitleBgActive] = TitleActive(); c[ImGuiCol_TitleBgCollapsed] = ImVec4(bgTitle.x, bgTitle.y, bgTitle.z, 0.75f); - c[ImGuiCol_ScrollbarBg] = BgTint(bgDark, 0.60f); + c[ImGuiCol_ScrollbarBg] = BgTint(bgDark, 0.60f, minAlpha + 0.2f); c[ImGuiCol_ScrollbarGrab] = AccentSoft(); c[ImGuiCol_ScrollbarGrabHovered] = AccentMed(); c[ImGuiCol_ScrollbarGrabActive] = AccentStrong(); @@ -1798,10 +1802,10 @@ static void ApplyThemeStyle() c[ImGuiCol_PlotHistogram] = PlotAccent(0.85f); c[ImGuiCol_PlotHistogramHovered] = PlotAccentHovered(); - c[ImGuiCol_TableHeaderBg] = BgTint(bgMid, 0.80f); + c[ImGuiCol_TableHeaderBg] = BgTint(bgMid, 0.80f, minAlpha + 0.25f); c[ImGuiCol_TableBorderStrong] = borderCol; c[ImGuiCol_TableBorderLight] = lightTheme ? ImVec4(0.68f, 0.72f, 0.80f, 1.00f) : AccentSoft(); - c[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + c[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.0f); c[ImGuiCol_TableRowBgAlt] = lightTheme ? ImVec4(0.00f, 0.00f, 0.00f, 0.045f) : ImVec4(1.00f, 1.00f, 1.00f, 0.03f); c[ImGuiCol_TreeLines] = borderCol; @@ -5953,6 +5957,8 @@ bool MenuCommon::RenderMenu() ImGui::PopStyleColor(3); } + ImGui::SameLine(0.0f, 6.0f); + float accentColor[3] = { config->MenuAccentColorR.value_or_default(), config->MenuAccentColorG.value_or_default(), config->MenuAccentColorB.value_or_default() }; @@ -6141,11 +6147,21 @@ bool MenuCommon::RenderMenu() ImGui::Spacing(); + auto alpha = config->MenuBGColorA.value_or_default(); + if (ImGui::SliderFloat("Background Alpha", &alpha, 0.0f, 1.0f)) + { + config->MenuBGColorA = alpha; + ApplyThemeStyle(); + } + + ImGui::Spacing(); + if (ImGui::Button("Reset BG Colour")) { config->MenuBGColorR.reset(); config->MenuBGColorG.reset(); config->MenuBGColorB.reset(); + config->MenuBGColorA.reset(); ApplyThemeStyle(); } @@ -6650,7 +6666,7 @@ bool MenuCommon::RenderMenu() ImGui::SameLine(0.0f, 15.0f); - if (ImGui::Button("Save INI")) + if (ImGui::Button("Save Settings")) config->SaveIni(); ImGui::SameLine(0.0f, 6.0f);