Skip to content

Commit 33d0017

Browse files
committed
add cl_gametype_filter_list
1 parent 15ff072 commit 33d0017

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

src/engine/shared/config_variables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ MACRO_CONFIG_INT(ClScoreboardShorten, cl_scoreboard_shorten, 0, 0, 2, CFGFLAG_CL
758758
MACRO_CONFIG_INT(ClStatboardWeaponsStyle, cl_statboard_weapons_style, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Change the statboard weapons style to a bar")
759759
MACRO_CONFIG_INT(ClUpsidedownTees, cl_upsidedown_tees, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show tees upside down")
760760
MACRO_CONFIG_INT(ClMapChangeMessage, cl_map_change_message, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show map change echo message")
761+
MACRO_CONFIG_STR(ClGametypeFilterList, cl_gametype_filter_list, 128, "", CFGFLAG_CLIENT | CFGFLAG_SAVE, "Gametype buttons filter list")
761762

762763
// Client identify (from Kaizo Network)
763764
MACRO_CONFIG_INT(ClSendClientType, cl_send_client_type, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Let know other clients that we are DuckClient")

src/game/client/components/menus_browser.cpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,74 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
853853
View.HSplitTop(6.0f, nullptr, &View);
854854
CUIRect CommunityFilter;
855855
View.HSplitTop(19.0f + 4.0f * 17.0f + CScrollRegion::HEIGHT_MAGIC_FIX, &CommunityFilter, &View);
856-
View.HSplitTop(8.0f, nullptr, &View);
857856
RenderServerbrowserCommunitiesFilter(CommunityFilter);
858857
}
859858

859+
// Pointer31, gametype filter selector
860+
if (str_length(Config()->m_ClGametypeFilterList) && View.h > RowHeight) {
861+
View.HSplitTop(6.0f, nullptr, &View);
862+
CUIRect GametypeFilters; CUIRect GametypeFiltersHeader;
863+
View.HSplitBottom(8.0f, &GametypeFilters, &View);
864+
GametypeFilters.HSplitTop(20.0f, &GametypeFiltersHeader, &GametypeFilters);
865+
866+
GametypeFiltersHeader.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_T, 4.0f);
867+
Ui()->DoLabel(&GametypeFiltersHeader, Localize("Gametype Filters"), 12.0f, TEXTALIGN_MC);
868+
869+
GametypeFilters.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f);
870+
871+
static CButtonContainer s_Buttons[11]; // if it's 10 it'll cause issues if the country/type filter is enabled... for some reason. thus +1
872+
873+
if (!(GametypeFilters.h < RowHeight)) {
874+
bool isSelected = str_comp(Config()->m_BrFilterGametype, "") == 0;
875+
GametypeFilters.HSplitTop(RowHeight, &Button, &GametypeFilters);
876+
if(DoButton_CheckBox(&s_Buttons[10], "No filter", isSelected, &Button))
877+
{
878+
str_copy(Config()->m_BrFilterGametype, "");
879+
Client()->ServerBrowserUpdate();
880+
}
881+
}
882+
883+
const char *pGametypeList = Config()->m_ClGametypeFilterList;
884+
const char *pGametypeNext = pGametypeList;
885+
const char *pHead = pGametypeNext;
886+
pHead = str_skip_whitespaces_const(pHead);
887+
pGametypeNext = pHead;
888+
889+
for (int i = 0; i < 9; i++)
890+
{
891+
int Len = 0;
892+
while(*pHead && !str_isspace(*pHead))
893+
{
894+
pHead++; Len++;
895+
}
896+
897+
char aBuf[128]; char bBuf[128];
898+
str_copy(aBuf, pGametypeNext, Len+1);
899+
str_format(bBuf, sizeof(bBuf), "'%s'", aBuf);
900+
901+
if (GametypeFilters.h < RowHeight)
902+
break;
903+
904+
bool isSelected = str_comp(Config()->m_BrFilterGametype, aBuf) == 0;
905+
GametypeFilters.HSplitTop(RowHeight, &Button, &GametypeFilters);
906+
if(DoButton_CheckBox(&s_Buttons[i], bBuf, isSelected, &Button))
907+
{
908+
str_copy(Config()->m_BrFilterGametype, aBuf);
909+
Client()->ServerBrowserUpdate();
910+
}
911+
912+
if (!*pHead)
913+
break;
914+
915+
pHead = str_skip_whitespaces_const(pHead);
916+
917+
if (!*pHead)
918+
break;
919+
920+
pGametypeNext = pHead;
921+
}
922+
}
923+
860924
static CButtonContainer s_ResetButton;
861925
if(DoButton_Menu(&s_ResetButton, Localize("Reset filter"), 0, &ResetButton))
862926
{

0 commit comments

Comments
 (0)