From 185d106d34d41eb71fd7f78f132f319c60a0872d Mon Sep 17 00:00:00 2001 From: tritonas00 Date: Sat, 9 Apr 2022 00:44:05 +0300 Subject: [PATCH] mp selector: replaced refreshing message with spinner --- .../main/gui/panels/GUI_MultiplayerSelector.cpp | 16 ++++++++++++++-- source/main/gui/panels/GUI_MultiplayerSelector.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/main/gui/panels/GUI_MultiplayerSelector.cpp b/source/main/gui/panels/GUI_MultiplayerSelector.cpp index 88d03c82f4..b37c57ac92 100644 --- a/source/main/gui/panels/GUI_MultiplayerSelector.cpp +++ b/source/main/gui/panels/GUI_MultiplayerSelector.cpp @@ -230,6 +230,8 @@ void MultiplayerSelector::DrawDirectTab() void MultiplayerSelector::DrawServerlistTab() { + GUIManager::GuiTheme const& theme = App::GetGuiManager()->GetTheme(); + const char* draw_label_text = nullptr; ImVec4 draw_label_color; @@ -252,6 +254,14 @@ void MultiplayerSelector::DrawServerlistTab() draw_label_color = m_serverlist_msg_color; } + if (m_show_spinner) + { + float spinner_size = 25.f; + ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.f) - spinner_size); + ImGui::SetCursorPosY((ImGui::GetWindowSize().y / 2.f) - spinner_size); + LoadingIndicatorCircle("spinner", spinner_size, theme.value_blue_text_color, theme.value_blue_text_color, 10, 10); + } + // DRAW SERVERLIST TABLE if (m_draw_table) { @@ -355,11 +365,11 @@ void MultiplayerSelector::DrawServerlistTab() void MultiplayerSelector::StartAsyncRefresh() { #if defined(USE_CURL) + m_show_spinner = true; m_draw_table = false; m_serverlist_data.clear(); m_selected_item = -1; - m_serverlist_msg = _LC("MultiplayerSelector", "... refreshing ..."); - m_serverlist_msg_color = App::GetGuiManager()->GetTheme().in_progress_text_color; + m_serverlist_msg = ""; std::packaged_task task(FetchServerlist); std::thread(std::move(task), App::mp_api_url->getStr()).detach(); // launch on a thread #endif // defined(USE_CURL) @@ -381,6 +391,7 @@ void MultiplayerSelector::SetVisible(bool visible) void MultiplayerSelector::DisplayRefreshFailed(std::string const& msg) { + m_show_spinner = false; m_serverlist_msg = msg; m_serverlist_msg_color = App::GetGuiManager()->GetTheme().error_text_color; m_draw_table = false; @@ -388,6 +399,7 @@ void MultiplayerSelector::DisplayRefreshFailed(std::string const& msg) void MultiplayerSelector::UpdateServerlist(MpServerInfoVec* data) { + m_show_spinner = false; m_serverlist_data = *data; m_draw_table = true; if (m_serverlist_data.empty()) diff --git a/source/main/gui/panels/GUI_MultiplayerSelector.h b/source/main/gui/panels/GUI_MultiplayerSelector.h index 53cb371d25..03a0c983e7 100644 --- a/source/main/gui/panels/GUI_MultiplayerSelector.h +++ b/source/main/gui/panels/GUI_MultiplayerSelector.h @@ -84,6 +84,7 @@ class MultiplayerSelector Str<1000> m_password_buf; Str<1000> m_server_host_buf; Ogre::TexturePtr m_lock_icon; + bool m_show_spinner = false; }; } // namespace GUI