Skip to content

Commit

Permalink
Add an option to disable 'Communities' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Oct 2, 2024
1 parent c2b551d commit 672fd26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/engine/client/serverbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,9 @@ const std::vector<CCommunity> &CServerBrowser::Communities() const

const CCommunity *CServerBrowser::Community(const char *pCommunityId) const
{
if(g_Config.m_ClEnableCommunities == 0)
return nullptr;

const auto Community = std::find_if(Communities().begin(), Communities().end(), [pCommunityId](const auto &Elem) {
return str_comp(Elem.Id(), pCommunityId) == 0;
});
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/infc_config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#endif

MACRO_CONFIG_INT(ClEnableCommunities, cl_enable_communities, 1, 1, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable the Communities browser feature")
MACRO_CONFIG_STR(ClAssetInfclass, cl_asset_infclass, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for infclass")
MACRO_CONFIG_STR(ClInfcUpdatesUrl, cl_infc_updates_url, 256, "https://infclass.github.io/files", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The client updates URL")
MACRO_CONFIG_INT(ClInfStatusSize, infc_status_size, 16, 4, 64, CFGFLAG_SAVE | CFGFLAG_CLIENT, "The size of infclass status icons")
Expand Down
14 changes: 12 additions & 2 deletions src/game/client/components/menus_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
int m_Direction;
float m_Width;
CUIRect m_Rect;
bool m_Visible{true};
};

enum
Expand Down Expand Up @@ -154,14 +155,20 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
{COL_PING, IServerBrowser::SORT_PING, Localizable("Ping"), 1, 40.0f, {0}},
};

s_aCols[COL_FLAG_OFFICIAL + 1].m_Visible = g_Config.m_ClEnableCommunities == 0;
s_aCols[COL_COMMUNITY + 1].m_Visible = g_Config.m_ClEnableCommunities;

const int NumCols = std::size(s_aCols);

// do layout
for(int i = 0; i < NumCols; i++)
{
if(s_aCols[i].m_Direction == -1)
{
Headers.VSplitLeft(s_aCols[i].m_Width, &s_aCols[i].m_Rect, &Headers);
if(s_aCols[i].m_Visible)
{
Headers.VSplitLeft(s_aCols[i].m_Width, &s_aCols[i].m_Rect, &Headers);
}

if(i + 1 < NumCols)
{
Expand Down Expand Up @@ -310,6 +317,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
char aTemp[64];
for(const auto &Col : s_aCols)
{
if(!Col.m_Visible)
continue;

CUIRect Button;
Button.x = Col.m_Rect.x;
Button.y = ListItem.m_Rect.y;
Expand Down Expand Up @@ -1800,7 +1810,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
MainView.VSplitRight(205.0f, &ServerList, &ToolBox);
ServerList.VSplitRight(5.0f, &ServerList, nullptr);

if((g_Config.m_UiPage == PAGE_INTERNET || g_Config.m_UiPage == PAGE_FAVORITES) && !ServerBrowser()->Communities().empty())
if(g_Config.m_ClEnableCommunities && (g_Config.m_UiPage == PAGE_INTERNET || g_Config.m_UiPage == PAGE_FAVORITES) && !ServerBrowser()->Communities().empty())
{
CUIRect CommunityFilter;
ToolBox.HSplitTop(19.0f + 4.0f * 17.0f + CScrollRegion::HEIGHT_MAGIC_FIX, &CommunityFilter, &ToolBox);
Expand Down

0 comments on commit 672fd26

Please sign in to comment.