mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 13:27:58 +03:00
Fix Options Menu sliders being frame-dependent at lower framerates (#677)
* Fix slider fastIncrement conditions * Change options menu sliders' fastIncrement logic to use a persistent holdTime variable, rather than the current frame's deltaTime * Clamp deltaTime to a max value of 1/15f * Compile fix * Spacing fix
This commit is contained in:
parent
2f43b9a304
commit
2322b75e54
1 changed files with 22 additions and 18 deletions
|
@ -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;
|
||||
|
||||
|
@ -1050,21 +1051,24 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
|||
}
|
||||
else if constexpr (std::is_same_v<T, float> || std::is_same_v<T, int32_t>)
|
||||
{
|
||||
float deltaTime = ImGui::GetIO().DeltaTime;
|
||||
float deltaTime = std::fmin(ImGui::GetIO().DeltaTime, 1.0f / 15.0f);
|
||||
|
||||
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)
|
||||
g_fastIncrementHoldTime += deltaTime;
|
||||
else
|
||||
g_fastIncrementHoldTime = 0;
|
||||
|
||||
if (fastIncrement)
|
||||
{
|
||||
isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME;
|
||||
|
||||
if ((time - g_lastIncrementTime) < INCREMENT_TIME)
|
||||
if (g_fastIncrementHoldTime < INCREMENT_TIME)
|
||||
fastIncrement = false;
|
||||
else
|
||||
g_lastIncrementTime = time;
|
||||
|
@ -1075,7 +1079,6 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
|||
decrement = leftIsHeld;
|
||||
increment = rightIsHeld;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -1094,9 +1097,10 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* 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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue