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 <engine/shared/protocol.h>
8
9#include <game/client/component.h>
10
11#include <cstddef>
12#include <vector>
13
14class CCountryFlags : public CComponent
15{
16public:
17 class CCountryFlag
18 {
19 public:
20 /**
21 * Country code in ISO 3166-1 numeric.
22 */
23 int m_CountryCode;
24 char m_aCountryCodeString[8];
25 IGraphics::CTextureHandle m_Texture;
26
27 bool operator<(const CCountryFlag &Other) const;
28 };
29
30 int Sizeof() const override { return sizeof(*this); }
31 void OnInit() override;
32
33 size_t Num() const;
34 const CCountryFlag &GetByCountryCode(int CountryCode) const;
35 const CCountryFlag &GetByIndex(size_t Index) const;
36 void Render(const CCountryFlag &Flag, ColorRGBA Color, float x, float y, float w, float h);
37 void Render(int CountryCode, ColorRGBA Color, float x, float y, float w, float h);
38
39private:
40 std::vector<CCountryFlag> m_vCountryFlags;
41 size_t m_aCountryCodeToIndexTable[CountryCode::MAXIMUM - CountryCode::MINIMUM + 1];
42
43 int m_FlagsQuadContainerIndex;
44
45 static bool ValidateCountryCodeString(const char *pString);
46 void LoadCountryflagsIndexfile();
47};
48#endif
49