1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_COUNTRYFLAGS_H
4#define GAME_CLIENT_COMPONENTS_COUNTRYFLAGS_H
5
6#include <engine/graphics.h>
7#include <game/client/component.h>
8#include <vector>
9
10class CCountryFlags : public CComponent
11{
12public:
13 struct CCountryFlag
14 {
15 int m_CountryCode;
16 char m_aCountryCodeString[8];
17 IGraphics::CTextureHandle m_Texture;
18
19 bool operator<(const CCountryFlag &Other) const { return str_comp(a: m_aCountryCodeString, b: Other.m_aCountryCodeString) < 0; }
20 };
21
22 virtual int Sizeof() const override { return sizeof(*this); }
23 void OnInit() override;
24
25 size_t Num() const;
26 const CCountryFlag *GetByCountryCode(int CountryCode) const;
27 const CCountryFlag *GetByIndex(size_t Index) const;
28 void Render(const CCountryFlag *pFlag, ColorRGBA Color, float x, float y, float w, float h);
29 void Render(int CountryCode, ColorRGBA Color, float x, float y, float w, float h);
30
31private:
32 enum
33 {
34 CODE_LB = -1,
35 CODE_UB = 999,
36 CODE_RANGE = CODE_UB - CODE_LB + 1,
37 };
38 std::vector<CCountryFlag> m_vCountryFlags;
39 size_t m_aCodeIndexLUT[CODE_RANGE];
40
41 int m_FlagsQuadContainerIndex;
42
43 void LoadCountryflagsIndexfile();
44};
45#endif
46