From 56875d65f761bc38ed4907a2986216b402d60507 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Sat, 1 May 2021 18:16:36 +0200 Subject: [PATCH] Fix serverlist scrolling --- src/client/component/server_list.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index dcf721c..d0f8f70 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -43,8 +43,8 @@ namespace server_list std::vector servers; size_t server_list_page = 0; - volatile bool update_server_list = false; + std::chrono::high_resolution_clock::time_point last_scroll{}; size_t get_page_count() { @@ -220,6 +220,11 @@ namespace server_list return game::Menu_IsMenuOpenAndVisible(0, "menu_systemlink_join"); } + bool is_scrolling_disabled() + { + return update_server_list || (std::chrono::high_resolution_clock::now() - last_scroll) < 500ms; + } + bool scroll_down() { if (!is_server_list_open()) @@ -227,8 +232,9 @@ namespace server_list return false; } - if (server_list_page + 1 < get_page_count()) + if (!is_scrolling_disabled() && server_list_page + 1 < get_page_count()) { + last_scroll = std::chrono::high_resolution_clock::now(); ++server_list_page; trigger_refresh(); } @@ -243,8 +249,9 @@ namespace server_list return false; } - if (server_list_page > 0) + if (!is_scrolling_disabled() && server_list_page > 0) { + last_scroll = std::chrono::high_resolution_clock::now(); --server_list_page; trigger_refresh(); }