From 890b557cb0fd5961c973a91b346f7eaff16ab8f4 Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Mon, 3 Mar 2025 02:21:06 +0300 Subject: [PATCH] Change options menu sliders' fastIncrement logic to use a persistent holdTime variable, rather than the current frame's deltaTime --- UnleashedRecomp/ui/options_menu.cpp | 37 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 20b83e50..324228f4 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -80,6 +80,7 @@ static double g_lockedOnTime; static double g_lastTappedTime; static double g_lastIncrementTime; static double g_lastIncrementSoundTime; +static double g_fastIncrementHoldTime; static constexpr size_t GRID_SIZE = 9; @@ -1057,21 +1058,26 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf constexpr double INCREMENT_TIME = 1.0 / 120.0; constexpr double INCREMENT_SOUND_TIME = 1.0 / 7.5; - if (fastIncrement) - { - isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME; + if (fastIncrement) + g_fastIncrementHoldTime += deltaTime; + else + g_fastIncrementHoldTime = 0; - if ((time - g_lastIncrementTime) < INCREMENT_TIME) - fastIncrement = false; - else - g_lastIncrementTime = time; - } + if (fastIncrement) + { + isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME; - if (fastIncrement) - { - decrement = leftIsHeld; - increment = rightIsHeld; - } + if (g_fastIncrementHoldTime < INCREMENT_TIME) + fastIncrement = false; + else + g_lastIncrementTime = time; + } + + if (fastIncrement) + { + decrement = leftIsHeld; + increment = rightIsHeld; + } do { @@ -1090,9 +1096,10 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf config->Value += 0.01f; } - deltaTime -= INCREMENT_TIME; + if (fastIncrement) + g_fastIncrementHoldTime -= INCREMENT_TIME; } - while (fastIncrement && deltaTime > 0.0f); + while (fastIncrement && g_fastIncrementHoldTime >= INCREMENT_TIME); bool isConfigValueInBounds = config->Value >= valueMin && config->Value <= valueMax;