From dbe8ef1fb7f47c2e6c6fd993cba7802f041db519 Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Mon, 3 Mar 2025 02:17:01 +0300 Subject: [PATCH 1/5] Fix slider fastIncrement conditions --- UnleashedRecomp/ui/options_menu.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 87134ddc..20b83e50 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1051,14 +1051,12 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf { float deltaTime = ImGui::GetIO().DeltaTime; - bool fastIncrement = (time - g_lastTappedTime) > 0.5; + bool fastIncrement = isSlider && (leftIsHeld || rightIsHeld) && (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; @@ -1074,7 +1072,6 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf decrement = leftIsHeld; increment = rightIsHeld; } - } do { From 890b557cb0fd5961c973a91b346f7eaff16ab8f4 Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Mon, 3 Mar 2025 02:21:06 +0300 Subject: [PATCH 2/5] 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; From d1e98f8091d5a8548628827f055dd3bf1ff1a669 Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Wed, 19 Mar 2025 23:14:32 +0300 Subject: [PATCH 3/5] Clamp deltaTime to a max value of 1/15f --- UnleashedRecomp/ui/options_menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 80737ff7..a6617d0e 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1050,7 +1050,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf } else if constexpr (std::is_same_v || std::is_same_v) { - float deltaTime = ImGui::GetIO().DeltaTime; + float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1f/15f); bool fastIncrement = isSlider && (leftIsHeld || rightIsHeld) && (time - g_lastTappedTime) > 0.5; bool isPlayIncrementSound = true; From 690b918be4ae2e973ae77b053d8dd9fc4057a6ca Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Sun, 23 Mar 2025 23:01:42 +0300 Subject: [PATCH 4/5] Compile fix --- UnleashedRecomp/ui/options_menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index a6617d0e..4df5b6e4 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1050,7 +1050,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf } else if constexpr (std::is_same_v || std::is_same_v) { - float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1f/15f); + float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1.0f/15.0f); bool fastIncrement = isSlider && (leftIsHeld || rightIsHeld) && (time - g_lastTappedTime) > 0.5; bool isPlayIncrementSound = true; From fcda5b313b6fe2b7b0b2d9eccaf857e9b7dbd5a2 Mon Sep 17 00:00:00 2001 From: Onaterdem Date: Sun, 23 Mar 2025 23:04:59 +0300 Subject: [PATCH 5/5] Spacing fix --- UnleashedRecomp/ui/options_menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 4df5b6e4..5ea2ce52 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1050,7 +1050,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf } else if constexpr (std::is_same_v || std::is_same_v) { - float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1.0f/15.0f); + float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1.0f / 15.0f); bool fastIncrement = isSlider && (leftIsHeld || rightIsHeld) && (time - g_lastTappedTime) > 0.5; bool isPlayIncrementSound = true;