Merge pull request #7183 from Robyt3/Menus-Ingame-Browser-Refactoring

Minor refactoring of ingame server browser
This commit is contained in:
Dennis Felsing 2023-09-15 20:09:37 +00:00 committed by GitHub
commit 0f7d83e7f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -812,49 +812,45 @@ void CMenus::RenderServerControl(CUIRect MainView)
void CMenus::RenderInGameNetwork(CUIRect MainView)
{
CUIRect Box = MainView;
CUIRect Button;
int Page = g_Config.m_UiPage;
int NewPage = -1;
MainView.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 10.0f);
Box.HSplitTop(5.0f, &MainView, &MainView);
Box.HSplitTop(24.0f, &Box, &MainView);
CUIRect TabBar, Button;
MainView.HSplitTop(24.0f, &TabBar, &MainView);
Box.VSplitLeft(100.0f, &Button, &Box);
int NewPage = g_Config.m_UiPage;
TabBar.VSplitLeft(100.0f, &Button, &TabBar);
static CButtonContainer s_InternetButton;
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), Page == PAGE_INTERNET, &Button, 0))
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), g_Config.m_UiPage == PAGE_INTERNET, &Button, IGraphics::CORNER_NONE))
{
if(Page != PAGE_INTERNET)
if(g_Config.m_UiPage != PAGE_INTERNET)
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
NewPage = PAGE_INTERNET;
}
Box.VSplitLeft(80.0f, &Button, &Box);
TabBar.VSplitLeft(80.0f, &Button, &TabBar);
static CButtonContainer s_LanButton;
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), Page == PAGE_LAN, &Button, 0))
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), g_Config.m_UiPage == PAGE_LAN, &Button, IGraphics::CORNER_NONE))
{
if(Page != PAGE_LAN)
if(g_Config.m_UiPage != PAGE_LAN)
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
NewPage = PAGE_LAN;
}
Box.VSplitLeft(110.0f, &Button, &Box);
TabBar.VSplitLeft(110.0f, &Button, &TabBar);
static CButtonContainer s_FavoritesButton;
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), Page == PAGE_FAVORITES, &Button, 0))
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), g_Config.m_UiPage == PAGE_FAVORITES, &Button, IGraphics::CORNER_NONE))
{
if(Page != PAGE_FAVORITES)
if(g_Config.m_UiPage != PAGE_FAVORITES)
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
NewPage = PAGE_FAVORITES;
}
Box.VSplitLeft(110.0f, &Button, &Box);
TabBar.VSplitLeft(110.0f, &Button, &TabBar);
static CButtonContainer s_DDNetButton;
if(DoButton_MenuTab(&s_DDNetButton, "DDNet", Page == PAGE_DDNET, &Button, 0) || Page < PAGE_INTERNET || Page > PAGE_KOG)
if(DoButton_MenuTab(&s_DDNetButton, "DDNet", g_Config.m_UiPage == PAGE_DDNET, &Button, IGraphics::CORNER_NONE) || g_Config.m_UiPage < PAGE_INTERNET || g_Config.m_UiPage > PAGE_KOG)
{
if(Page != PAGE_DDNET)
if(g_Config.m_UiPage != PAGE_DDNET)
{
Client()->RequestDDNetInfo();
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
@ -862,11 +858,11 @@ void CMenus::RenderInGameNetwork(CUIRect MainView)
NewPage = PAGE_DDNET;
}
Box.VSplitLeft(110.0f, &Button, &Box);
TabBar.VSplitLeft(110.0f, &Button, &TabBar);
static CButtonContainer s_KoGButton;
if(DoButton_MenuTab(&s_KoGButton, "KoG", Page == PAGE_KOG, &Button, IGraphics::CORNER_BR))
if(DoButton_MenuTab(&s_KoGButton, "KoG", g_Config.m_UiPage == PAGE_KOG, &Button, IGraphics::CORNER_NONE))
{
if(Page != PAGE_KOG)
if(g_Config.m_UiPage != PAGE_KOG)
{
Client()->RequestDDNetInfo();
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
@ -874,7 +870,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView)
NewPage = PAGE_KOG;
}
if(NewPage != -1)
if(NewPage != g_Config.m_UiPage)
{
if(Client()->State() != IClient::STATE_OFFLINE)
SetMenuPage(NewPage);