mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Fixed blocked flags causing the selected flag to not match the ListBox index
This commit is contained in:
parent
b9144fb5f1
commit
e6b91a97c2
|
@ -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())];
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue