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.
This commit is contained in:
Robert Müller 2024-06-24 21:37:03 +02:00
parent 2974e5197e
commit 3947ba40b1
3 changed files with 11 additions and 2 deletions

View file

@ -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);
}
}
}

View file

@ -170,6 +170,7 @@ protected:
bool m_JoinTutorial = false;
bool m_CreateDefaultFavoriteCommunities = false;
bool m_ForceRefreshLanPage = false;
char m_aNextServer[256];

View file

@ -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;
}
}
}