diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 35d76533a..a9ca670d6 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -647,14 +647,14 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f); CUIRect Button, EditButtons; - 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) - || (UI()->MouseInside(&View) && Input()->KeyPress(KEY_MOUSE_1))) + if(UI()->DoButtonLogic(&m_lFilters[FilterIndex], "", 0, &View)) { Switch = true; // switch later, to make sure we haven't clicked one of the filter buttons (edit...) } - + Button.Margin(2.0f, &Button); + View.VSplitLeft(20.0f, &Button, &View); + DoIcon(IMAGE_MENUICONS, pFilter->Extended() ? SPRITE_MENU_EXPANDED : SPRITE_MENU_COLLAPSED, &Button); + // split buttons from label View.VSplitLeft(Spacing, 0, &View); View.VSplitRight((ButtonHeight+Spacing)*4.0f, &View, &EditButtons); @@ -1088,11 +1088,19 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) if(m_lFilters[i].Extended()) NumServers += m_lFilters[i].NumSortedServers(); + int SelectedIndex = m_SelectedServer.m_Index; + int SelectedFilter; + for(SelectedFilter = 0; SelectedFilter < m_lFilters.size(); SelectedFilter++) + if(m_lFilters[SelectedFilter].Extended()) + break; + if(SelectedFilter == m_lFilters.size()) // no selected filter found + SelectedFilter = -1; + int NumFilters = m_lFilters.size(); float ListHeight = NumServers * ms_ListheaderHeight; // add server list height ListHeight += NumFilters * SpacingH; // add filters ListHeight += (NumFilters) * ButtonHeight;// add filters spacing - if(!m_SidebarActive && m_SelectedServer.m_Index != -1) + if(!m_SidebarActive && m_SelectedServer.m_Index != -1 && SelectedFilter != -1) ListHeight += ms_ListheaderHeight*5; // float LineH = ms_aBrowserCols[0].m_Rect.h; @@ -1116,14 +1124,6 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) else ScrollNum = 0; - int SelectedIndex = m_SelectedServer.m_Index; - int SelectedFilter; - for(SelectedFilter = 0; SelectedFilter < m_lFilters.size(); SelectedFilter++) - if(m_lFilters[SelectedFilter].Extended()) - break; - if(SelectedFilter == m_lFilters.size()) // no selected filter found - SelectedFilter = 0; - if(SelectedFilter > -1) { int NewIndex = -1; diff --git a/src/game/client/components/menus_popups.cpp b/src/game/client/components/menus_popups.cpp index 7e6ea3bc7..f9f2134fb 100644 --- a/src/game/client/components/menus_popups.cpp +++ b/src/game/client/components/menus_popups.cpp @@ -91,10 +91,29 @@ void CMenus::DoPopupMenu() int CMenus::PopupFilter(CMenus *pMenus, CUIRect View) { - CUIRect ServerFilter = View, FilterHeader; + CUIRect ServerFilter = View, FilterHeader, Button, Icon;; const float FontSize = 10.0f; const float LineSize = 16.0f; + // new filter + ServerFilter.HSplitBottom(LineSize, &ServerFilter, &Button); + Button.VSplitLeft(60.0f, &Button, &Icon); + static char s_aFilterName[32] = { 0 }; + static float s_FilterOffset = 0.0f; + static int s_EditFilter = 0; + pMenus->DoEditBox(&s_EditFilter, &Button, s_aFilterName, sizeof(s_aFilterName), FontSize, &s_FilterOffset); + pMenus->RenderTools()->DrawUIRect(&Icon, vec4(1, 1, 1, 0.25f), CUI::CORNER_ALL, 5.0f); + Icon.VSplitLeft(20.0f, &Button, &Icon); + Icon.HMargin(2.0f, &Icon); + pMenus->UI()->DoLabelScaled(&Icon, Localize("New filter"), FontSize, CUI::ALIGN_LEFT); + static CButtonContainer s_AddFilter; + if(s_aFilterName[0] && pMenus->DoButton_SpriteCleanID(&s_AddFilter, IMAGE_FRIENDICONS, SPRITE_FRIEND_PLUS_A, &Button, true)) + { + CServerFilterInfo NewFilterInfo; + pMenus->m_lFilters.add(CBrowserFilter(CBrowserFilter::FILTER_CUSTOM, s_aFilterName, pMenus->ServerBrowser())); + s_aFilterName[0] = 0; + } + // slected filter CBrowserFilter *pFilter = 0; for(int i = 0; i < pMenus->m_lFilters.size(); ++i) @@ -118,7 +137,6 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View) pMenus->RenderTools()->DrawUIRect(&ServerFilter, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f); FilterHeader.HMargin(2.0f, &FilterHeader); pMenus->UI()->DoLabel(&FilterHeader, Localize("Server filter"), FontSize+2.0f, CUI::ALIGN_CENTER); - CUIRect Button, Icon; //ServerFilter.VSplitLeft(5.0f, 0, &ServerFilter); //ServerFilter.Margin(3.0f, &ServerFilter); @@ -348,25 +366,6 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View) pFilter->SetFilter(&FilterInfo); } - // new filter - ServerFilter.HSplitBottom(LineSize, &ServerFilter, &Button); - Button.VSplitLeft(60.0f, &Button, &Icon); - static char s_aFilterName[32] = {0}; - static float s_FilterOffset = 0.0f; - static int s_EditFilter = 0; - pMenus->DoEditBox(&s_EditFilter, &Button, s_aFilterName, sizeof(s_aFilterName), FontSize, &s_FilterOffset); - pMenus->RenderTools()->DrawUIRect(&Icon, vec4(1, 1, 1, 0.25f), CUI::CORNER_ALL, 5.0f); - Icon.VSplitLeft(20.0f, &Button, &Icon); - Icon.HMargin(2.0f, &Icon); - pMenus->UI()->DoLabelScaled(&Icon, Localize("New filter"), FontSize, CUI::ALIGN_LEFT); - static CButtonContainer s_AddFilter; - if(s_aFilterName[0] && pMenus->DoButton_SpriteCleanID(&s_AddFilter, IMAGE_FRIENDICONS, SPRITE_FRIEND_PLUS_A, &Button, true)) - { - CServerFilterInfo NewFilterInfo; - pMenus->m_lFilters.add(CBrowserFilter(CBrowserFilter::FILTER_CUSTOM, s_aFilterName, pMenus->ServerBrowser())); - s_aFilterName[0] = 0; - } - // reset filter ServerFilter.HSplitBottom(LineSize, &ServerFilter, 0); ServerFilter.HSplitBottom(LineSize, &ServerFilter, &Button);