achievement_menu: replicate skills menu fast scrolling

This commit is contained in:
Hyper 2025-02-09 19:52:10 +00:00
parent d2e1a475f5
commit d8082985b1

View file

@ -608,7 +608,6 @@ static void DrawContentContainer()
auto time = ImGui::GetTime(); auto time = ImGui::GetTime();
auto fastScroll = (time - g_lastTappedTime) > 0.6; auto fastScroll = (time - g_lastTappedTime) > 0.6;
auto fastScrollSpeed = 1.0 / 3.5; auto fastScrollSpeed = 1.0 / 3.5;
auto fastScrollEncounteredEdge = false;
static auto fastScrollSpeedUp = false; static auto fastScrollSpeedUp = false;
if (scrollUp || scrollDown) if (scrollUp || scrollDown)
@ -632,33 +631,24 @@ static void DrawContentContainer()
scrollUp = upIsHeld; scrollUp = upIsHeld;
scrollDown = downIsHeld; scrollDown = downIsHeld;
fastScrollSpeedUp = true;
} }
} }
if (scrollUp) if (scrollUp)
{ {
--g_selectedRowIndex; --g_selectedRowIndex;
if (g_selectedRowIndex < 0) if (g_selectedRowIndex < 0)
{ g_selectedRowIndex = rowCount - 1;
g_selectedRowIndex = fastScroll ? 0 : rowCount - 1;
fastScrollEncounteredEdge = fastScroll;
fastScrollSpeedUp = false;
}
} }
else if (scrollDown) else if (scrollDown)
{ {
++g_selectedRowIndex; ++g_selectedRowIndex;
if (g_selectedRowIndex >= rowCount) if (g_selectedRowIndex >= rowCount)
{ g_selectedRowIndex = 0;
g_selectedRowIndex = fastScroll ? rowCount - 1 : 0;
fastScrollEncounteredEdge = fastScroll;
fastScrollSpeedUp = false;
}
} }
if ((scrollUp || scrollDown) && !fastScrollEncounteredEdge) if (scrollUp || scrollDown)
{ {
g_rowSelectionTime = time; g_rowSelectionTime = time;
Game_PlaySound("sys_actstg_pausecursor"); Game_PlaySound("sys_actstg_pausecursor");
@ -670,21 +660,11 @@ static void DrawContentContainer()
int visibleRowCount = int(floor((clipRectMax.y - clipRectMin.y) / itemHeight)); int visibleRowCount = int(floor((clipRectMax.y - clipRectMin.y) / itemHeight));
if (g_firstVisibleRowIndex > g_selectedRowIndex) if (g_firstVisibleRowIndex > g_selectedRowIndex)
{
g_firstVisibleRowIndex = g_selectedRowIndex; g_firstVisibleRowIndex = g_selectedRowIndex;
if (g_selectedRowIndex > 0)
fastScrollSpeedUp = true;
}
if (g_firstVisibleRowIndex + visibleRowCount - 1 < g_selectedRowIndex) if (g_firstVisibleRowIndex + visibleRowCount - 1 < g_selectedRowIndex)
{
g_firstVisibleRowIndex = std::max(0, g_selectedRowIndex - visibleRowCount + 1); g_firstVisibleRowIndex = std::max(0, g_selectedRowIndex - visibleRowCount + 1);
if (g_selectedRowIndex < rowCount - 1)
fastScrollSpeedUp = true;
}
// Pop clip rect from DrawContentContainer // Pop clip rect from DrawContentContainer
drawList->PopClipRect(); drawList->PopClipRect();