From e268371faea5323f17d84ce8401ab5adb6c3dfb9 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 25 Nov 2015 10:19:05 +0100 Subject: [PATCH] just extend one filter in the server browser --- src/game/client/components/menus.cpp | 2 ++ src/game/client/components/menus_browser.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 9611ac150..b7d9704f0 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -2256,6 +2256,8 @@ void CMenus::OnConsoleInit() m_lFilters.add(CBrowserFilter(CBrowserFilter::FILTER_STANDARD, Localize("Teeworlds"), ServerBrowser(), IServerBrowser::FILTER_COMPAT_VERSION|IServerBrowser::FILTER_PURE|IServerBrowser::FILTER_PURE_MAP|IServerBrowser::FILTER_PING, 999, -1, "", "")); m_lFilters.add(CBrowserFilter(CBrowserFilter::FILTER_FAVORITES, Localize("Favorites"), ServerBrowser(), IServerBrowser::FILTER_FAVORITE|IServerBrowser::FILTER_PING, 999, -1, "", "")); m_lFilters.add(CBrowserFilter(CBrowserFilter::FILTER_ALL, Localize("All"), ServerBrowser(), IServerBrowser::FILTER_PING, 999, -1, "", "")); + + m_lFilters[0].Switch(); } void CMenus::OnStateChange(int NewState, int OldState) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 2ce48bc39..6b6dba4ab 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -34,7 +34,7 @@ CMenus::CColumn CMenus::ms_aCols[] = { CMenus::CBrowserFilter::CBrowserFilter(int Custom, const char* pName, IServerBrowser *pServerBrowser, int Filter, int Ping, int Country, const char* pGametype, const char* pServerAddress) : m_pServerBrowser(pServerBrowser) { - m_Extended = true; + m_Extended = false; m_Custom = Custom; str_copy(m_aName, pName, sizeof(m_aName)); //Todo: fix Filter @@ -442,7 +442,19 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) View.VSplitLeft(20.0f, &Button, &View); Button.Margin(2.0f, &Button); if(DoButton_SpriteClean(IMAGE_MENUICONS, pFilter->Extended() ? SPRITE_MENU_EXPANDED : SPRITE_MENU_COLLAPSED, &Button)) + { pFilter->Switch(); + + // retract the other filters + if(pFilter->Extended()) + { + for(int i = 0; i < m_lFilters.size(); ++i) + { + if(i != FilterIndex && m_lFilters[i].Extended()) + m_lFilters[i].Switch(); + } + } + } // split buttons from label View.VSplitLeft(Spacing, 0, &View);