mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Improve usage of CCountryFlags::Render
function
Pass color by value instead of pointer to simplify usage. Add separate function that accepts a country flag directly instead of an index.
This commit is contained in:
parent
17c06423d2
commit
de44e59bef
|
@ -143,13 +143,17 @@ const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(size_t Index) const
|
|||
return &m_vCountryFlags[Index % m_vCountryFlags.size()];
|
||||
}
|
||||
|
||||
void CCountryFlags::Render(int CountryCode, const ColorRGBA *pColor, float x, float y, float w, float h)
|
||||
void CCountryFlags::Render(const CCountryFlag *pFlag, ColorRGBA Color, float x, float y, float w, float h)
|
||||
{
|
||||
const CCountryFlag *pFlag = GetByCountryCode(CountryCode);
|
||||
if(pFlag->m_Texture.IsValid())
|
||||
{
|
||||
Graphics()->TextureSet(pFlag->m_Texture);
|
||||
Graphics()->SetColor(*pColor);
|
||||
Graphics()->SetColor(Color);
|
||||
Graphics()->RenderQuadContainerEx(m_FlagsQuadContainerIndex, 0, -1, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
void CCountryFlags::Render(int CountryCode, ColorRGBA Color, float x, float y, float w, float h)
|
||||
{
|
||||
Render(GetByCountryCode(CountryCode), Color, x, y, w, h);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ public:
|
|||
size_t Num() const;
|
||||
const CCountryFlag *GetByCountryCode(int CountryCode) const;
|
||||
const CCountryFlag *GetByIndex(size_t Index) const;
|
||||
void Render(int CountryCode, const ColorRGBA *pColor, float x, float y, float w, float h);
|
||||
void Render(const CCountryFlag *pFlag, ColorRGBA Color, float x, float y, float w, float h);
|
||||
void Render(int CountryCode, ColorRGBA Color, float x, float y, float w, float h);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
|
|
@ -687,8 +687,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
|
|||
float OldWidth = Rect.w;
|
||||
Rect.w = Rect.h * 2;
|
||||
Rect.x += (OldWidth - Rect.w) / 2.0f;
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, UI()->MouseHovered(&Rect) ? 1.0f : g_Config.m_BrFilterCountry ? 0.9f : 0.5f);
|
||||
m_pClient->m_CountryFlags.Render(g_Config.m_BrFilterCountryIndex, &Color, Rect.x, Rect.y, Rect.w, Rect.h);
|
||||
m_pClient->m_CountryFlags.Render(g_Config.m_BrFilterCountryIndex, ColorRGBA(1.0f, 1.0f, 1.0f, UI()->MouseHovered(&Rect) ? 1.0f : g_Config.m_BrFilterCountry ? 0.9f : 0.5f), Rect.x, Rect.y, Rect.w, Rect.h);
|
||||
|
||||
if(UI()->DoButtonLogic(&g_Config.m_BrFilterCountryIndex, 0, &Rect))
|
||||
{
|
||||
|
@ -946,8 +945,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
|
|||
ServerBrowser()->Refresh(ServerBrowser()->GetCurrentType());
|
||||
}
|
||||
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, Active ? 1.0f : 0.2f);
|
||||
m_pClient->m_CountryFlags.Render(FlagID, &Color, Pos.x, Pos.y, FlagWidth, FlagHeight);
|
||||
m_pClient->m_CountryFlags.Render(FlagID, ColorRGBA(1.0f, 1.0f, 1.0f, Active ? 1.0f : 0.2f), Pos.x, Pos.y, FlagWidth, FlagHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1013,8 +1011,7 @@ CUI::EPopupMenuFunctionResult CMenus::PopupCountrySelection(void *pContext, CUIR
|
|||
const float OldWidth = FlagRect.w;
|
||||
FlagRect.w = FlagRect.h * 2.0f;
|
||||
FlagRect.x += (OldWidth - FlagRect.w) / 2.0f;
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
pMenus->m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
pMenus->m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
|
||||
pMenus->UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_MC);
|
||||
}
|
||||
|
@ -1284,10 +1281,8 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
|
|||
TextRender()->TextEx(&Cursor, pClan, -1);
|
||||
|
||||
// flag
|
||||
ColorRGBA FColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, &FColor, Flag.x,
|
||||
Flag.y + ((Flag.h - Flag.w / 2) / 2),
|
||||
Flag.w, Flag.w / 2);
|
||||
m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f),
|
||||
Flag.x, Flag.y + ((Flag.h - Flag.w / 2) / 2), Flag.w, Flag.w / 2);
|
||||
}
|
||||
|
||||
const int NewSelected = s_ListBox.DoEnd();
|
||||
|
|
|
@ -320,8 +320,7 @@ void CMenus::RenderPlayers(CUIRect MainView)
|
|||
Cursor.m_LineWidth = Button.w;
|
||||
TextRender()->TextEx(&Cursor, CurrentClient.m_aClan, -1);
|
||||
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, &Color,
|
||||
m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f),
|
||||
Button2.x, Button2.y + Button2.h / 2.0f - 0.75f * Button2.h / 2.0f, 1.5f * Button2.h, 0.75f * Button2.h);
|
||||
|
||||
// ignore chat button
|
||||
|
|
|
@ -390,8 +390,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
float OldWidth = FlagRect.w;
|
||||
FlagRect.w = FlagRect.h * 2;
|
||||
FlagRect.x += (OldWidth - FlagRect.w) / 2.0f;
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
|
||||
if(pEntry->m_Texture.IsValid())
|
||||
{
|
||||
|
@ -2071,8 +2070,7 @@ bool CMenus::RenderLanguageSelection(CUIRect MainView)
|
|||
Item.m_Rect.VSplitLeft(Item.m_Rect.h * 2.0f, &FlagRect, &Label);
|
||||
FlagRect.VMargin(6.0f, &FlagRect);
|
||||
FlagRect.HMargin(3.0f, &FlagRect);
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_pClient->m_CountryFlags.Render(Language.m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
m_pClient->m_CountryFlags.Render(Language.m_CountryCode, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
|
||||
|
||||
UI()->DoLabel(&Label, Language.m_Name.c_str(), 16.0f, TEXTALIGN_ML);
|
||||
}
|
||||
|
|
|
@ -485,8 +485,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// country flag
|
||||
ColorRGBA Color(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
m_pClient->m_CountryFlags.Render(m_pClient->m_aClients[pInfo->m_ClientID].m_Country, &Color,
|
||||
m_pClient->m_CountryFlags.Render(m_pClient->m_aClients[pInfo->m_ClientID].m_Country, ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f),
|
||||
CountryOffset, y + (Spacing + TeeSizeMod * 5.0f) / 2.0f, CountryLength, LineHeight - Spacing - TeeSizeMod * 5.0f);
|
||||
|
||||
// ping
|
||||
|
|
Loading…
Reference in a new issue