From d297c07edbd2a28da3670e8e8a5e4faead8c47c2 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:27:40 +0000 Subject: [PATCH] options_menu: only fast increment for float/int sliders --- UnleashedRecomp/ui/options_menu.cpp | 47 +++++++++++++++-------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 95247d9..eb8ac15 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -685,28 +685,6 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf bool decrement = leftTapped; bool increment = rightTapped; - bool fastIncrement = (time - g_lastTappedTime) > 0.5; - constexpr double INCREMENT_TIME = 1.0 / 120.0; - - constexpr double INCREMENT_SOUND_TIME = 1.0 / 7.5; - bool isPlayIncrementSound = true; - - if (fastIncrement) - { - isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME; - - if ((time - g_lastIncrementTime) < INCREMENT_TIME) - fastIncrement = false; - else - g_lastIncrementTime = time; - } - - if (fastIncrement) - { - decrement = leftIsHeld; - increment = rightIsHeld; - } - g_leftWasHeld = leftIsHeld; g_rightWasHeld = rightIsHeld; @@ -738,6 +716,31 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf { float deltaTime = ImGui::GetIO().DeltaTime; + bool fastIncrement = (time - g_lastTappedTime) > 0.5; + bool isPlayIncrementSound = true; + + constexpr double INCREMENT_TIME = 1.0 / 120.0; + constexpr double INCREMENT_SOUND_TIME = 1.0 / 7.5; + + if (isSlider) + { + if (fastIncrement) + { + isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME; + + if ((time - g_lastIncrementTime) < INCREMENT_TIME) + fastIncrement = false; + else + g_lastIncrementTime = time; + } + + if (fastIncrement) + { + decrement = leftIsHeld; + increment = rightIsHeld; + } + } + do { if constexpr (std::is_integral_v)