Fixed blocked flags causing the selected flag to not match the ListBox index

This commit is contained in:
Jordy Ruiz 2018-12-09 14:29:54 +01:00
parent b9144fb5f1
commit e6b91a97c2
3 changed files with 10 additions and 5 deletions

View file

@ -155,8 +155,15 @@ const CCountryFlags::CCountryFlag *CCountryFlags::GetByCountryCode(int CountryCo
return GetByIndex(m_CodeIndexLUT[max(0, (CountryCode-CODE_LB)%CODE_RANGE)]);
}
const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index) const
const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index, bool SkipBlocked) const
{
if(SkipBlocked)
{
for(int i = 0; i < m_aCountryFlags.size(); i++)
if(!m_aCountryFlags[i].m_Blocked)
if(!Index--)
return &m_aCountryFlags[i];
}
return &m_aCountryFlags[max(0, Index%m_aCountryFlags.size())];
}

View file

@ -23,7 +23,7 @@ public:
int Num() const;
const CCountryFlag *GetByCountryCode(int CountryCode) const;
const CCountryFlag *GetByIndex(int Index) const;
const CCountryFlag *GetByIndex(int Index, bool SkipBlocked = false) const;
void Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h, bool AllowBlocked=false);
private:

View file

@ -1202,9 +1202,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
const int NewSelected = UiDoListboxEnd(&s_ListBoxState, 0);
if(OldSelected != NewSelected)
{
g_Config.m_PlayerCountry = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode;
}
g_Config.m_PlayerCountry = m_pClient->m_pCountryFlags->GetByIndex(NewSelected, true)->m_CountryCode;
}
void CMenus::RenderSettingsTeeBasic(CUIRect MainView)