From e8e63d412e313141cea6ba4a3b5764770443f796 Mon Sep 17 00:00:00 2001 From: Skrubby Skrub In A Shrub <87662196+SkrubbySkrubInAShrub@users.noreply.github.com> Date: Thu, 7 May 2026 18:08:13 +0200 Subject: [PATCH] chore: Slider consistency --- src/Features/Upscaling.cpp | 50 ++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/Features/Upscaling.cpp b/src/Features/Upscaling.cpp index e0fcbd015f..addc167f09 100644 --- a/src/Features/Upscaling.cpp +++ b/src/Features/Upscaling.cpp @@ -196,11 +196,11 @@ void Upscaling::DrawSettings() else currentUpscaleMode = &settings.upscaleMethodNoDLSS; - // Slider for method selection - // Clamp the index used to read from the built label vector to avoid OOB if the stored value is stale - uint32_t modeLabelIndex = std::min(*currentUpscaleMode, static_cast(upscaleModes.size() - 1)); - std::string currentLabel = upscaleModes[modeLabelIndex]; - ImGui::SliderInt("Method", (int*)currentUpscaleMode, 0, availableModes, currentLabel.c_str()); + // Dropdown for method selection + std::vector modeLabels; + for (uint32_t i = 0; i <= availableModes; ++i) + modeLabels.push_back(upscaleModes[i].c_str()); + ImGui::Combo("Method", (int*)currentUpscaleMode, modeLabels.data(), (int)modeLabels.size()); *currentUpscaleMode = std::min(availableModes, *currentUpscaleMode); @@ -312,22 +312,24 @@ void Upscaling::DrawSettings() ImGui::PopStyleColor(); } - std::string enabledLabel = "Enabled"; - const char* toggleModes[] = { "Disabled", "Enabled" }; - const char* toggleModesFG[] = { "Disabled", enabledLabel.c_str() }; - - ImGui::SliderInt("Frame Generation", (int*)&settings.frameGenerationMode, 0, 1, toggleModesFG[settings.frameGenerationMode]); + bool fgEnabled = settings.frameGenerationMode != 0; + if (ImGui::Checkbox("Frame Generation", &fgEnabled)) + settings.frameGenerationMode = fgEnabled ? 1 : 0; if (!frameGenerationDx12PathActive) ImGui::BeginDisabled(); - ImGui::SliderInt("Frame Limit (Variable Refresh Rate)", (int*)&settings.frameLimitMode, 0, 1, std::format("{}", toggleModes[settings.frameLimitMode]).c_str()); + bool flEnabled = settings.frameLimitMode != 0; + if (ImGui::Checkbox("Frame Limit (Variable Refresh Rate)", &flEnabled)) + settings.frameLimitMode = flEnabled ? 1 : 0; if (!frameGenerationDx12PathActive) ImGui::EndDisabled(); ImGui::TextWrapped("Allows frame generation to function on low refresh rate monitors. Detected: %.2f Hz", refreshRate); - ImGui::SliderInt("Force Enable Frame Generation", (int*)&settings.frameGenerationForceEnable, 0, 1, std::format("{}", toggleModes[settings.frameGenerationForceEnable]).c_str()); + bool fgForce = settings.frameGenerationForceEnable != 0; + if (ImGui::Checkbox("Force Enable Frame Generation", &fgForce)) + settings.frameGenerationForceEnable = fgForce ? 1 : 0; ImGui::Checkbox("Frame Generation in Menus", &settings.frameGenerationAllowInMenus); if (auto _tt = Util::HoverTooltipWrapper()) { @@ -344,8 +346,6 @@ void Upscaling::DrawSettings() const bool reflexAvailable = streamline.initialized && streamline.featureReflex; const bool reflexControlsAvailable = reflexAvailable && !reflexBlockedByFrameGeneration; const bool markerOptimizationAvailable = reflexControlsAvailable && streamline.featurePCL; - const char* toggleModes[] = { "Disabled", "Enabled" }; - if (reflexBlockedByFrameGeneration) { ImGui::TextDisabled("Reflex is unavailable while the DX12 frame-generation swapchain is active."); } @@ -357,38 +357,29 @@ void Upscaling::DrawSettings() if (!reflexControlsAvailable) ImGui::BeginDisabled(); - int lowLatencyMode = settings.reflexLowLatencyMode ? 1 : 0; - ImGui::SliderInt("Low Latency Mode", &lowLatencyMode, 0, 1, toggleModes[lowLatencyMode]); + ImGui::Checkbox("Low Latency Mode", &settings.reflexLowLatencyMode); if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::TextUnformatted("Cuts input delay by syncing CPU work closer to the GPU."); ImGui::TextUnformatted("Can reduce max FPS a little, but usually feels more responsive."); } - settings.reflexLowLatencyMode = lowLatencyMode > 0; if (!settings.reflexLowLatencyMode) ImGui::BeginDisabled(); - int lowLatencyBoost = settings.reflexLowLatencyBoost ? 1 : 0; - ImGui::SliderInt("Low Latency Boost", &lowLatencyBoost, 0, 1, toggleModes[lowLatencyBoost]); + ImGui::Checkbox("Low Latency Boost", &settings.reflexLowLatencyBoost); if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::TextUnformatted("Keeps GPU clocks higher to avoid latency spikes at low GPU load."); ImGui::TextUnformatted("Useful if frametime jumps; costs extra power and heat."); } - settings.reflexLowLatencyBoost = lowLatencyBoost > 0; - - if (!settings.reflexLowLatencyMode) - ImGui::EndDisabled(); if (!markerOptimizationAvailable) ImGui::BeginDisabled(); - int markersToOptimize = settings.reflexUseMarkersToOptimize ? 1 : 0; - ImGui::SliderInt("Use Markers To Optimize", &markersToOptimize, 0, 1, toggleModes[markersToOptimize]); + ImGui::Checkbox("Use Markers To Optimize", &settings.reflexUseMarkersToOptimize); if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::TextUnformatted("Uses frame markers for tighter Reflex timing."); ImGui::TextUnformatted("Try On first; turn Off if it causes stutter on your setup."); } - settings.reflexUseMarkersToOptimize = markersToOptimize > 0; if (!markerOptimizationAvailable) ImGui::EndDisabled(); @@ -397,13 +388,14 @@ void Upscaling::DrawSettings() ImGui::TextDisabled("Marker optimization unavailable (PCL not loaded)."); } - int useFPSLimit = settings.reflexUseFPSLimit ? 1 : 0; - ImGui::SliderInt("Use FPS Limit", &useFPSLimit, 0, 1, toggleModes[useFPSLimit]); + ImGui::Checkbox("Use FPS Limit", &settings.reflexUseFPSLimit); if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::TextUnformatted("Uses Reflex's internal FPS cap for steadier frametimes."); ImGui::TextUnformatted("Can lower latency versus uncapped rendering."); } - settings.reflexUseFPSLimit = useFPSLimit > 0; + + if (!settings.reflexLowLatencyMode) + ImGui::EndDisabled(); if (!settings.reflexUseFPSLimit) ImGui::BeginDisabled();