mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Merge pull request #8898 from KebsCS/pr-country-filters
Change country and types filter behavior
This commit is contained in:
commit
e0a95d14a6
|
@ -27,9 +27,6 @@
|
|||
#include <engine/http.h>
|
||||
#include <engine/storage.h>
|
||||
|
||||
static constexpr const char *COMMUNITY_COUNTRY_NONE = "none";
|
||||
static constexpr const char *COMMUNITY_TYPE_NONE = "None";
|
||||
|
||||
class CSortWrap
|
||||
{
|
||||
typedef bool (CServerBrowser::*SortFunc)(int, int) const;
|
||||
|
|
|
@ -309,6 +309,9 @@ public:
|
|||
|
||||
static constexpr const char *COMMUNITY_DDNET = "ddnet";
|
||||
static constexpr const char *COMMUNITY_NONE = "none";
|
||||
|
||||
static constexpr const char *COMMUNITY_COUNTRY_NONE = "none";
|
||||
static constexpr const char *COMMUNITY_TYPE_NONE = "None";
|
||||
/**
|
||||
* Special community value for country/type filters that
|
||||
* affect all communities.
|
||||
|
|
|
@ -869,11 +869,14 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View,
|
|||
{
|
||||
if(Click == 1)
|
||||
{
|
||||
// Left click: when all are active, only activate one
|
||||
// Left click: when all are active, only activate one and none
|
||||
for(int j = 0; j < MaxItems; ++j)
|
||||
{
|
||||
if(j != ItemIndex)
|
||||
Filter.Add(GetItemName(j));
|
||||
if(const char *pItemName = GetItemName(j);
|
||||
j != ItemIndex &&
|
||||
!((&Filter == &ServerBrowser()->CountriesFilter() && str_comp(pItemName, IServerBrowser::COMMUNITY_COUNTRY_NONE) == 0) ||
|
||||
(&Filter == &ServerBrowser()->TypesFilter() && str_comp(pItemName, IServerBrowser::COMMUNITY_TYPE_NONE) == 0)))
|
||||
Filter.Add(pItemName);
|
||||
}
|
||||
}
|
||||
else if(Click == 2)
|
||||
|
@ -890,7 +893,10 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View,
|
|||
bool AllFilteredExceptUs = true;
|
||||
for(int j = 0; j < MaxItems; ++j)
|
||||
{
|
||||
if(j != ItemIndex && !Filter.Filtered(GetItemName(j)))
|
||||
if(const char *pItemName = GetItemName(j);
|
||||
j != ItemIndex && !Filter.Filtered(pItemName) &&
|
||||
!((&Filter == &ServerBrowser()->CountriesFilter() && str_comp(pItemName, IServerBrowser::COMMUNITY_COUNTRY_NONE) == 0) ||
|
||||
(&Filter == &ServerBrowser()->TypesFilter() && str_comp(pItemName, IServerBrowser::COMMUNITY_TYPE_NONE) == 0)))
|
||||
{
|
||||
AllFilteredExceptUs = false;
|
||||
break;
|
||||
|
@ -898,7 +904,7 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View,
|
|||
}
|
||||
// When last one is removed, re-enable all currently selectable items.
|
||||
// Don't use Clear, to avoid enabling also currently unselectable items.
|
||||
if(AllFilteredExceptUs)
|
||||
if(AllFilteredExceptUs && Active)
|
||||
{
|
||||
for(int j = 0; j < MaxItems; ++j)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue