From 2974e5197e09af1dfd547b6ec50bbd5b6e21da94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 24 Jun 2024 21:22:06 +0200 Subject: [PATCH 1/2] Fix browser not refreshing if `ui_page` is changed in start menu When changing `ui_page` via the console while the start menu is active, the browser tab was not refreshed when clicking the Play-button, leading to the old server list being shown for the new browser tab. --- src/game/client/components/menus.cpp | 2 +- src/game/client/components/menus_start.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 42ffa4725..1dce1d64d 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -2354,7 +2354,7 @@ void CMenus::SetMenuPage(int NewPage) if(NewPage >= PAGE_INTERNET && NewPage <= PAGE_FAVORITE_COMMUNITY_5) { g_Config.m_UiPage = NewPage; - if(!m_ShowStart && OldPage != NewPage) + if(OldPage != NewPage) { RefreshBrowserTab(false); } diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index f32af9ff8..f04337ce3 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -285,8 +285,8 @@ void CMenus::RenderStartMenu(CUIRect MainView) if(NewPage != -1) { - m_MenuPage = NewPage; m_ShowStart = false; + SetMenuPage(NewPage); } } From 3947ba40b12b79fb93e9f7b6a5fde19a5f68b4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 24 Jun 2024 21:37:03 +0200 Subject: [PATCH 2/2] Refresh LAN tab after starting/stopping local server After starting/stopping the local server from the main menu, refresh the LAN tab on its next activation, so it immediately shows/hides the started/stopped server without needing a manual refresh. This is not a perfect solution, as the server would not show up when activating the LAN tab immediately after starting the server, because the server needs some time before it will respond to server info requests, but this works well enough unless the hotkeys are used. --- src/game/client/components/menus.cpp | 10 ++++++++-- src/game/client/components/menus.h | 1 + src/game/client/components/menus_start.cpp | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 1dce1d64d..0eb85a905 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -2354,9 +2354,15 @@ void CMenus::SetMenuPage(int NewPage) if(NewPage >= PAGE_INTERNET && NewPage <= PAGE_FAVORITE_COMMUNITY_5) { g_Config.m_UiPage = NewPage; - if(OldPage != NewPage) + bool ForceRefresh = false; + if(m_ForceRefreshLanPage) { - RefreshBrowserTab(false); + ForceRefresh = NewPage == PAGE_LAN; + m_ForceRefreshLanPage = false; + } + if(OldPage != NewPage || ForceRefresh) + { + RefreshBrowserTab(ForceRefresh); } } } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index dae2b20de..67cf1a408 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -170,6 +170,7 @@ protected: bool m_JoinTutorial = false; bool m_CreateDefaultFavoriteCommunities = false; + bool m_ForceRefreshLanPage = false; char m_aNextServer[256]; diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index f04337ce3..46875a33d 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -155,6 +155,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) if(str_find(aBuf, "/") == 0 || fs_is_file(aBuf)) { m_ServerProcess.m_Process = shell_execute(aBuf, EShellExecuteWindowState::BACKGROUND); + m_ForceRefreshLanPage = true; } else { @@ -297,6 +298,7 @@ void CMenus::KillServer() if(kill_process(m_ServerProcess.m_Process)) { m_ServerProcess.m_Process = INVALID_PROCESS; + m_ForceRefreshLanPage = true; } } }