mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
blocked non-country flags. closes #1721
This commit is contained in:
parent
80400c396d
commit
2f588a158b
|
@ -22,19 +22,23 @@
|
|||
},
|
||||
{
|
||||
"id": "XBZ",
|
||||
"code": 950
|
||||
"code": 950,
|
||||
"blocked": true
|
||||
},
|
||||
{
|
||||
"id": "XCA",
|
||||
"code": 951
|
||||
"code": 951,
|
||||
"blocked": true
|
||||
},
|
||||
{
|
||||
"id": "XES",
|
||||
"code": 952
|
||||
"code": 952,
|
||||
"blovked": true
|
||||
},
|
||||
{
|
||||
"id": "XGA",
|
||||
"code": 953
|
||||
"code": 953,
|
||||
"blocked": true
|
||||
},
|
||||
{
|
||||
"id": "default",
|
||||
|
|
|
@ -88,6 +88,11 @@ void CCountryFlags::LoadCountryflagsIndexfile()
|
|||
CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
|
||||
mem_free(Info.m_pData);
|
||||
}
|
||||
// blocked?
|
||||
CountryFlag.m_Blocked = false;
|
||||
const json_value Check = rStart[i]["blocked"];
|
||||
if(Check.type == json_boolean && Check)
|
||||
CountryFlag.m_Blocked = true;
|
||||
m_aCountryFlags.add_unsorted(CountryFlag);
|
||||
|
||||
// print message
|
||||
|
@ -134,6 +139,7 @@ void CCountryFlags::OnInit()
|
|||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "countryflags", "failed to load country flags. folder='countryflags/'");
|
||||
CCountryFlag DummyEntry;
|
||||
DummyEntry.m_CountryCode = -1;
|
||||
DummyEntry.m_Blocked = false;
|
||||
mem_zero(DummyEntry.m_aCountryCodeString, sizeof(DummyEntry.m_aCountryCodeString));
|
||||
m_aCountryFlags.add(DummyEntry);
|
||||
}
|
||||
|
@ -154,9 +160,11 @@ const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index) const
|
|||
return &m_aCountryFlags[max(0, Index%m_aCountryFlags.size())];
|
||||
}
|
||||
|
||||
void CCountryFlags::Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h)
|
||||
void CCountryFlags::Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h, bool AllowBlocked)
|
||||
{
|
||||
const CCountryFlag *pFlag = GetByCountryCode(CountryCode);
|
||||
if(!AllowBlocked && pFlag->m_Blocked)
|
||||
pFlag = GetByCountryCode(-1);
|
||||
if(pFlag->m_Texture.IsValid())
|
||||
{
|
||||
Graphics()->TextureSet(pFlag->m_Texture);
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
{
|
||||
int m_CountryCode;
|
||||
char m_aCountryCodeString[8];
|
||||
bool m_Blocked;
|
||||
IGraphics::CTextureHandle m_Texture;
|
||||
|
||||
bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
|
||||
|
@ -23,7 +24,7 @@ public:
|
|||
int Num() const;
|
||||
const CCountryFlag *GetByCountryCode(int CountryCode) const;
|
||||
const CCountryFlag *GetByIndex(int Index) const;
|
||||
void Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h);
|
||||
void Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h, bool AllowBlocked=false);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
|
|
@ -1999,6 +1999,8 @@ int CMenus::Render()
|
|||
for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i)
|
||||
{
|
||||
const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i);
|
||||
if(pEntry->m_Blocked)
|
||||
continue;
|
||||
if(pEntry->m_CountryCode == ActSelection)
|
||||
OldSelected = i;
|
||||
|
||||
|
|
|
@ -745,7 +745,7 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header)
|
|||
Rect.VMargin(6.0f, &Rect);
|
||||
Rect.HMargin(3.0f, &Rect);
|
||||
vec4 Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_pClient->m_pCountryFlags->Render(r.front().m_CountryCode, &Color, Rect.x, Rect.y, Rect.w, Rect.h);
|
||||
m_pClient->m_pCountryFlags->Render(r.front().m_CountryCode, &Color, Rect.x, Rect.y, Rect.w, Rect.h, true);
|
||||
Item.m_Rect.y += 2.0f;
|
||||
if(s_SelectedLanguage != -1 && !str_comp(s_Languages[s_SelectedLanguage].m_Name, r.front().m_Name))
|
||||
{
|
||||
|
@ -1149,6 +1149,8 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i)
|
||||
{
|
||||
const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i);
|
||||
if(pEntry->m_Blocked)
|
||||
continue;
|
||||
if(pEntry->m_CountryCode == g_Config.m_PlayerCountry)
|
||||
OldSelected = i;
|
||||
|
||||
|
|
Loading…
Reference in a new issue