blocked non-country flags. closes #1721

This commit is contained in:
oy 2018-11-26 18:12:33 +01:00
parent 0db3f92fa8
commit 46b0f264cc
5 changed files with 24 additions and 7 deletions

View file

@ -22,19 +22,23 @@
}, },
{ {
"id": "XBZ", "id": "XBZ",
"code": 950 "code": 950,
"blocked": true
}, },
{ {
"id": "XCA", "id": "XCA",
"code": 951 "code": 951,
"blocked": true
}, },
{ {
"id": "XES", "id": "XES",
"code": 952 "code": 952,
"blovked": true
}, },
{ {
"id": "XGA", "id": "XGA",
"code": 953 "code": 953,
"blocked": true
}, },
{ {
"id": "default", "id": "default",

View file

@ -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); 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); 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); m_aCountryFlags.add_unsorted(CountryFlag);
// print message // print message
@ -134,6 +139,7 @@ void CCountryFlags::OnInit()
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "countryflags", "failed to load country flags. folder='countryflags/'"); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "countryflags", "failed to load country flags. folder='countryflags/'");
CCountryFlag DummyEntry; CCountryFlag DummyEntry;
DummyEntry.m_CountryCode = -1; DummyEntry.m_CountryCode = -1;
DummyEntry.m_Blocked = false;
mem_zero(DummyEntry.m_aCountryCodeString, sizeof(DummyEntry.m_aCountryCodeString)); mem_zero(DummyEntry.m_aCountryCodeString, sizeof(DummyEntry.m_aCountryCodeString));
m_aCountryFlags.add(DummyEntry); 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())]; 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); const CCountryFlag *pFlag = GetByCountryCode(CountryCode);
if(!AllowBlocked && pFlag->m_Blocked)
pFlag = GetByCountryCode(-1);
if(pFlag->m_Texture.IsValid()) if(pFlag->m_Texture.IsValid())
{ {
Graphics()->TextureSet(pFlag->m_Texture); Graphics()->TextureSet(pFlag->m_Texture);

View file

@ -13,6 +13,7 @@ public:
{ {
int m_CountryCode; int m_CountryCode;
char m_aCountryCodeString[8]; char m_aCountryCodeString[8];
bool m_Blocked;
IGraphics::CTextureHandle m_Texture; IGraphics::CTextureHandle m_Texture;
bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; } bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
@ -23,7 +24,7 @@ public:
int Num() const; int Num() const;
const CCountryFlag *GetByCountryCode(int CountryCode) const; const CCountryFlag *GetByCountryCode(int CountryCode) const;
const CCountryFlag *GetByIndex(int Index) 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: private:
enum enum

View file

@ -1999,6 +1999,8 @@ int CMenus::Render()
for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i) for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i)
{ {
const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i); const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i);
if(pEntry->m_Blocked)
continue;
if(pEntry->m_CountryCode == ActSelection) if(pEntry->m_CountryCode == ActSelection)
OldSelected = i; OldSelected = i;

View file

@ -745,7 +745,7 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header)
Rect.VMargin(6.0f, &Rect); Rect.VMargin(6.0f, &Rect);
Rect.HMargin(3.0f, &Rect); Rect.HMargin(3.0f, &Rect);
vec4 Color(1.0f, 1.0f, 1.0f, 1.0f); 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; Item.m_Rect.y += 2.0f;
if(s_SelectedLanguage != -1 && !str_comp(s_Languages[s_SelectedLanguage].m_Name, r.front().m_Name)) 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) for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i)
{ {
const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i); const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i);
if(pEntry->m_Blocked)
continue;
if(pEntry->m_CountryCode == g_Config.m_PlayerCountry) if(pEntry->m_CountryCode == g_Config.m_PlayerCountry)
OldSelected = i; OldSelected = i;