diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 53a10bb995a..ec95fd24e50 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -746,7 +746,7 @@ MACRO_CONFIG_INT(ClOldDoorLaser, cl_old_door_laser, 0, 0, 1, CFGFLAG_SAVE | CFGF MACRO_CONFIG_INT(ClOldFreezeLaser, cl_old_freeze_laser, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Use old freeze laser end") MACRO_CONFIG_INT(ClOldClientConsole, cl_old_client_console, 0, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Use old client console") MACRO_CONFIG_INT(ClBloodParticles, cl_blood_particles, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Add extra blood particles") -MACRO_CONFIG_INT(ClPosistionCommunityFilter, cl_position_community_filter, 0, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Where to place the community filter in the browser") +MACRO_CONFIG_INT(ClPosistionCommunityFilter, cl_position_community_filter, 0, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Where to place the community filter in the browser (0=top toolbox, 1=bottom filters panel, 2=hidden)") MACRO_CONFIG_INT(ClHideCountryTypeFilters, cl_hide_country_type_filters, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to hide the country/type filters in the browser") MACRO_CONFIG_INT(ClConfirmKillTime, cl_confirm_kill_time, 60, -1, 14400, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Confirmation message before killing self after game time (in seconds, -1 to turn off, 0 to always turn on)") MACRO_CONFIG_INT(ClDuckFilter, cl_duck_filter, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Replace all skins with a duck skin") diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 9b36b93a3ed..e9dd3d91fe0 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -856,68 +856,63 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) RenderServerbrowserCommunitiesFilter(CommunityFilter); } - // Pointer31, gametype filter selector - if (str_length(Config()->m_ClGametypeFilterList) && View.h > RowHeight) { + // gametype filter selector + static const int MAX_GAMETYPE_FILTERS = 15; + if(str_length(g_Config.m_ClGametypeFilterList) && View.h > RowHeight) + { View.HSplitTop(6.0f, nullptr, &View); - CUIRect GametypeFilters; CUIRect GametypeFiltersHeader; - View.HSplitBottom(8.0f, &GametypeFilters, &View); + CUIRect GametypeFilters; + CUIRect GametypeFiltersHeader; + View.HSplitTop(View.h, &GametypeFilters, &View); GametypeFilters.HSplitTop(20.0f, &GametypeFiltersHeader, &GametypeFilters); GametypeFiltersHeader.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_T, 4.0f); Ui()->DoLabel(&GametypeFiltersHeader, Localize("Gametype Filters"), 12.0f, TEXTALIGN_MC); GametypeFilters.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f); - - static CButtonContainer s_Buttons[16]; - if (!(GametypeFilters.h < RowHeight)) { - bool isSelected = str_comp(Config()->m_BrFilterGametype, "") == 0; + // MAX_GAMETYPE_FILTERS slots for gametype entries, +1 for the "No filter" button + static CButtonContainer s_Buttons[MAX_GAMETYPE_FILTERS + 1]; + + if(GametypeFilters.h >= RowHeight) + { + bool IsSelected = str_comp(g_Config.m_BrFilterGametype, "") == 0; GametypeFilters.HSplitTop(RowHeight, &Button, &GametypeFilters); - if(DoButton_CheckBox(&s_Buttons[15], "No filter", isSelected, &Button)) + if(DoButton_CheckBox(&s_Buttons[MAX_GAMETYPE_FILTERS], "No filter", IsSelected, &Button)) { - str_copy(Config()->m_BrFilterGametype, ""); + str_copy(g_Config.m_BrFilterGametype, ""); Client()->ServerBrowserUpdate(); } } - const char *pGametypeList = Config()->m_ClGametypeFilterList; - const char *pGametypeNext = pGametypeList; - const char *pHead = pGametypeNext; - pHead = str_skip_whitespaces_const(pHead); - pGametypeNext = pHead; - - for (int i = 0; i < 15; i++) + const char *pHead = str_skip_whitespaces_const(g_Config.m_ClGametypeFilterList); + for(int i = 0; i < MAX_GAMETYPE_FILTERS && *pHead; i++) { + const char *pToken = pHead; int Len = 0; while(*pHead && !str_isspace(*pHead)) { - pHead++; Len++; + pHead++; + Len++; } - char aBuf[128]; char bBuf[128]; - str_copy(aBuf, pGametypeNext, Len+1); + char aBuf[128]; + char bBuf[128]; + str_copy(aBuf, pToken, minimum(Len + 1, (int)sizeof(aBuf))); str_format(bBuf, sizeof(bBuf), "'%s'", aBuf); - if (GametypeFilters.h < RowHeight) + if(GametypeFilters.h < RowHeight) break; - bool isSelected = str_comp(Config()->m_BrFilterGametype, aBuf) == 0; + bool IsSelected = str_comp(g_Config.m_BrFilterGametype, aBuf) == 0; GametypeFilters.HSplitTop(RowHeight, &Button, &GametypeFilters); - if(DoButton_CheckBox(&s_Buttons[i], bBuf, isSelected, &Button)) + if(DoButton_CheckBox(&s_Buttons[i], bBuf, IsSelected, &Button)) { - str_copy(Config()->m_BrFilterGametype, aBuf); + str_copy(g_Config.m_BrFilterGametype, aBuf); Client()->ServerBrowserUpdate(); } - if (!*pHead) - break; - pHead = str_skip_whitespaces_const(pHead); - - if (!*pHead) - break; - - pGametypeNext = pHead; } }