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 <base/str.h>
7
8#include <engine/graphics.h>
9
10#include <game/client/component.h>
11
12#include <vector>
13
14class CCountryFlags : public CComponent
15{
16public:
17 struct CCountryFlag
18 {
19 int m_CountryCode;
20 char m_aCountryCodeString[8];
21 IGraphics::CTextureHandle m_Texture;
22
23 bool operator<(const CCountryFlag &Other) const { return str_comp(a: m_aCountryCodeString, b: Other.m_aCountryCodeString) < 0; }
24 };
25
26 int Sizeof() const override { return sizeof(*this); }
27 void OnInit() override;
28
29 size_t Num() const;
30 const CCountryFlag &GetByCountryCode(int CountryCode) const;
31 const CCountryFlag &GetByIndex(size_t Index) const;
32 void Render(const CCountryFlag &Flag, ColorRGBA Color, float x, float y, float w, float h);
33 void Render(int CountryCode, ColorRGBA Color, float x, float y, float w, float h);
34
35private:
36 enum
37 {
38 CODE_LB = -1,
39 CODE_UB = 999,
40 CODE_RANGE = CODE_UB - CODE_LB + 1,
41 };
42 std::vector<CCountryFlag> m_vCountryFlags;
43 size_t m_aCodeIndexLUT[CODE_RANGE];
44
45 int m_FlagsQuadContainerIndex;
46
47 void LoadCountryflagsIndexfile();
48};
49#endif
50