mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
move refresh logic of browsertab into helper function
This commit is contained in:
parent
a5a191eb32
commit
43aae1bd82
|
@ -1298,6 +1298,7 @@ int CMenus::Render()
|
|||
s_Frame++;
|
||||
m_DoubleClickIndex = -1;
|
||||
|
||||
RefreshBrowserTab(g_Config.m_UiPage);
|
||||
if(g_Config.m_UiPage == PAGE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
else if(g_Config.m_UiPage == PAGE_LAN)
|
||||
|
@ -1783,24 +1784,7 @@ int CMenus::Render()
|
|||
{
|
||||
Client()->Disconnect();
|
||||
m_Popup = POPUP_NONE;
|
||||
if(g_Config.m_UiPage == PAGE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
else if(g_Config.m_UiPage == PAGE_LAN)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
else if(g_Config.m_UiPage == PAGE_FAVORITES)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
else if(g_Config.m_UiPage == PAGE_DDNET)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
||||
}
|
||||
else if(g_Config.m_UiPage == PAGE_KOG)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
|
||||
}
|
||||
RefreshBrowserTab(g_Config.m_UiPage);
|
||||
}
|
||||
|
||||
if(Client()->MapDownloadTotalsize() > 0)
|
||||
|
@ -2745,6 +2729,28 @@ void CMenus::SetMenuPage(int NewPage)
|
|||
g_Config.m_UiPage = NewPage;
|
||||
}
|
||||
|
||||
void CMenus::RefreshBrowserTab(int UiPage)
|
||||
{
|
||||
if(UiPage == PAGE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
else if(UiPage == PAGE_LAN)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
else if(UiPage == PAGE_FAVORITES)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
else if(UiPage == PAGE_DDNET)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
||||
}
|
||||
else if(UiPage == PAGE_KOG)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
|
||||
}
|
||||
}
|
||||
|
||||
bool CMenus::HandleListInputs(const CUIRect &View, float &ScrollValue, const float ScrollAmount, int *pScrollOffset, const float ElemHeight, int &SelectedIndex, const int NumElems)
|
||||
{
|
||||
if(NumElems == 0)
|
||||
|
|
|
@ -705,6 +705,7 @@ public:
|
|||
private:
|
||||
static int GhostlistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser);
|
||||
void SetMenuPage(int NewPage);
|
||||
void RefreshBrowserTab(int UiPage);
|
||||
bool HandleListInputs(const CUIRect &View, float &ScrollValue, float ScrollAmount, int *pScrollOffset, float ElemHeight, int &SelectedIndex, int NumElems);
|
||||
|
||||
// found in menus_ingame.cpp
|
||||
|
|
|
@ -631,25 +631,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
|
||||
if(DoButtonMenu(m_RefreshButton, &s_RefreshButton, Func, 0, &ButtonRefresh, true, false, IGraphics::CORNER_ALL) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()))
|
||||
{
|
||||
if(g_Config.m_UiPage == PAGE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
else if(g_Config.m_UiPage == PAGE_LAN)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
else if(g_Config.m_UiPage == PAGE_FAVORITES)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
else if(g_Config.m_UiPage == PAGE_DDNET)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
||||
}
|
||||
else if(g_Config.m_UiPage == PAGE_KOG)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
|
||||
}
|
||||
m_DoubleClickIndex = -1;
|
||||
RefreshBrowserTab(g_Config.m_UiPage);
|
||||
}
|
||||
|
||||
static int s_JoinButton = 0;
|
||||
|
|
|
@ -61,24 +61,7 @@ void CMenus::RenderGame(CUIRect MainView)
|
|||
else
|
||||
{
|
||||
Client()->Disconnect();
|
||||
if(g_Config.m_UiPage == PAGE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
else if(g_Config.m_UiPage == PAGE_LAN)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
else if(g_Config.m_UiPage == PAGE_FAVORITES)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
else if(g_Config.m_UiPage == PAGE_DDNET)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
||||
}
|
||||
else if(g_Config.m_UiPage == PAGE_KOG)
|
||||
{
|
||||
// start a new server list request
|
||||
Client()->RequestDDNetInfo();
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
|
||||
}
|
||||
RefreshBrowserTab(g_Config.m_UiPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue