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