diff --git a/src/Menu.cpp b/src/Menu.cpp index a1618fc69a..3b68a16546 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -134,6 +134,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( UseMonochromeLogo, ShowFooter, CenterHeader, + DisableClearCacheButton, TooltipHoverDelay, BackgroundBlurEnabled, ScrollbarOpacity, diff --git a/src/Menu.h b/src/Menu.h index 869d93788e..5f3922cf09 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -242,14 +242,15 @@ class Menu return roles; }(); - bool UseSimplePalette = false; // DEPRECATED: No longer affects behavior. UI now shows both Simple and Advanced controls. - bool ShowActionIcons = true; // whether to show action buttons as icons - bool UseMonochromeIcons = false; // whether to use monochrome (white) action icons with text color tinting - bool UseMonochromeLogo = false; // whether to use monochrome CS logo - bool ShowFooter = true; // whether to show the footer with game version/GPU info - bool CenterHeader = false; // whether to center the header title and logo - float TooltipHoverDelay = 0.5f; // tooltip hover delay in seconds - bool BackgroundBlurEnabled = false; // enable background blur effect + bool UseSimplePalette = false; // DEPRECATED: No longer affects behavior. UI now shows both Simple and Advanced controls. + bool ShowActionIcons = true; // whether to show action buttons as icons + bool UseMonochromeIcons = false; // whether to use monochrome (white) action icons with text color tinting + bool UseMonochromeLogo = false; // whether to use monochrome CS logo + bool ShowFooter = true; // whether to show the footer with game version/GPU info + bool CenterHeader = false; // whether to center the header title and logo + bool DisableClearCacheButton = false; // disable the Clear Shader Cache button in the menu header + float TooltipHoverDelay = 0.5f; // tooltip hover delay in seconds + bool BackgroundBlurEnabled = false; // enable background blur effect // Scrollbar opacity settings struct ScrollbarOpacitySettings { diff --git a/src/Menu/MenuHeaderRenderer.cpp b/src/Menu/MenuHeaderRenderer.cpp index dff99024ff..fab9c00817 100644 --- a/src/Menu/MenuHeaderRenderer.cpp +++ b/src/Menu/MenuHeaderRenderer.cpp @@ -206,10 +206,19 @@ void MenuHeaderRenderer::RenderHeader(bool isDocked, bool showLogo, bool canShow // Clear Shader Cache Button ImGui::TableNextColumn(); - if (ImGui::Button("Clear Shader Cache", { -1, 0 })) { - shaderCache->Clear(); - if (shaderCache->IsDiskCache()) { - shaderCache->DeleteDiskCache(); + { + bool isDisabled = globals::menu->GetSettings().Theme.DisableClearCacheButton; + if (isDisabled) { + ImGui::BeginDisabled(); + } + if (ImGui::Button("Clear Shader Cache", { -1, 0 })) { + shaderCache->Clear(); + if (shaderCache->IsDiskCache()) { + shaderCache->DeleteDiskCache(); + } + } + if (isDisabled) { + ImGui::EndDisabled(); } } if (auto _tt = Util::HoverTooltipWrapper()) { @@ -292,19 +301,22 @@ std::vector MenuHeaderRenderer::BuildActionIcons } if (uiIcons.clearCache.texture) { auto shaderCache = globals::shaderCache; + bool isDisabled = globals::menu->GetSettings().Theme.DisableClearCacheButton; actionIcons.push_back({ uiIcons.clearCache.texture, - "Clear Shader Cache\n\n" - "Clears the shader cache and disk cache (if enabled).\n" - "The Shader Cache is the collection of compiled shaders which replace\n" - "the vanilla shaders at runtime. The Disk Cache is a collection of\n" - "compiled shaders on disk. Clearing will mean that shaders are\n" - "recompiled only when the game re-encounters them.", + isDisabled ? "Clear Shader Cache (Disabled)" : + "Clear Shader Cache\n\n" + "Clears the shader cache and disk cache (if enabled).\n" + "The Shader Cache is the collection of compiled shaders which replace\n" + "the vanilla shaders at runtime. The Disk Cache is a collection of\n" + "compiled shaders on disk. Clearing will mean that shaders are\n" + "recompiled only when the game re-encounters them.", [shaderCache]() { shaderCache->Clear(); if (shaderCache->IsDiskCache()) { shaderCache->DeleteDiskCache(); } - } }); + }, + isDisabled }); } return actionIcons; @@ -365,25 +377,31 @@ void MenuHeaderRenderer::RenderDockedIcons(const std::vector& action // Draw icon with hover effect, using reduced area to minimize padding ImU32 tintColor; if (globals::menu->GetSettings().Theme.UseMonochromeIcons) { - // Use theme text color for monochrome icons ImVec4 textColor = globals::menu->GetSettings().Theme.Palette.Text; - if (!isHovered) { - textColor.w *= 0.85f; // Slightly reduce alpha when not hovered + if (it->disabled) { + textColor.w *= 0.35f; + } else if (!isHovered) { + textColor.w *= 0.85f; } tintColor = ImGui::GetColorU32(textColor); } else { - // Use white/gray tint for colored icons - tintColor = isHovered ? IM_COL32(255, 255, 255, 255) : IM_COL32(220, 220, 220, 220); + if (it->disabled) { + tintColor = IM_COL32(128, 128, 128, 90); + } else { + tintColor = isHovered ? IM_COL32(255, 255, 255, 255) : IM_COL32(220, 220, 220, 220); + } } fgDrawList->AddImage(it->texture, iconMin, iconMax, ImVec2(0, 0), ImVec2(1, 1), tintColor); } // Handle interaction if (isHovered) { - // Draw subtle background for hovered icon using interaction area - fgDrawList->AddRectFilled(interactionMin, interactionMax, IM_COL32(255, 255, 255, 40)); + // Draw subtle background for hovered icon using interaction area (only if not disabled) + if (!it->disabled) { + fgDrawList->AddRectFilled(interactionMin, interactionMax, IM_COL32(255, 255, 255, 40)); + } - if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { + if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !it->disabled) { it->callback(); } @@ -429,6 +447,11 @@ void MenuHeaderRenderer::RenderUndockedIcons(const std::vector& acti std::string buttonId = std::format("##ActionBtn{}", i); + // Disable interaction for disabled icons + if (icon.disabled) { + ImGui::BeginDisabled(); + } + // Use ImageButton with reduced image size to minimize padding if (ImGui::ImageButton(buttonId.c_str(), icon.texture, imageSize, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), tintColor)) { icon.callback(); @@ -437,6 +460,10 @@ void MenuHeaderRenderer::RenderUndockedIcons(const std::vector& acti ImGui::Text("%s", icon.tooltip); } + if (icon.disabled) { + ImGui::EndDisabled(); + } + // Add SameLine except for the last button if (i < actionIcons.size() - 1) { ImGui::SameLine(); diff --git a/src/Menu/MenuHeaderRenderer.h b/src/Menu/MenuHeaderRenderer.h index dafd6f1dc7..a0e7714e3d 100644 --- a/src/Menu/MenuHeaderRenderer.h +++ b/src/Menu/MenuHeaderRenderer.h @@ -10,6 +10,7 @@ class MenuHeaderRenderer ID3D11ShaderResourceView* texture; const char* tooltip; std::function callback; + bool disabled = false; }; static void RenderHeader(bool isDocked, bool showLogo, bool canShowIcons, float uiScale, const Menu::UIIcons& uiIcons); diff --git a/src/Menu/SettingsTabRenderer.cpp b/src/Menu/SettingsTabRenderer.cpp index 43849cbdc3..41c26931ea 100644 --- a/src/Menu/SettingsTabRenderer.cpp +++ b/src/Menu/SettingsTabRenderer.cpp @@ -315,6 +315,21 @@ void SettingsTabRenderer::RenderInterfaceTab() RenderColorsTab(); ImGui::EndTabBar(); } + + // Additional Interface Settings (outside of sub-tabs) + ImGui::Spacing(); + SeparatorTextWithFont("Header Buttons", Menu::FontRole::Subheading); + + bool disableClearCache = globals::menu->GetSettings().Theme.DisableClearCacheButton; + if (ImGui::Checkbox("Disable Clear Shader Cache Button", &disableClearCache)) { + globals::menu->GetSettings().Theme.DisableClearCacheButton = disableClearCache; + } + if (auto _tt = Util::HoverTooltipWrapper()) { + ImGui::Text( + "Disables the Clear Shader Cache button in the menu header.\n" + "The button will appear greyed out and non-functional."); + } + ImGui::EndTabItem(); } }