1#ifndef GAME_CLIENT_COMPONENTS_MENU_BACKGROUND_H
2#define GAME_CLIENT_COMPONENTS_MENU_BACKGROUND_H
3
4#include <game/client/components/background.h>
5#include <game/client/components/camera.h>
6
7#include <array>
8#include <chrono>
9#include <string>
10#include <vector>
11
12// themes
13class CTheme
14{
15public:
16 CTheme(const char *pName, bool HasDay, bool HasNight) :
17 m_Name(pName), m_HasDay(HasDay), m_HasNight(HasNight) {}
18
19 std::string m_Name;
20 bool m_HasDay;
21 bool m_HasNight;
22 IGraphics::CTextureHandle m_IconTexture;
23 bool operator<(const CTheme &Other) const { return m_Name < Other.m_Name; }
24};
25
26class CMenuBackground : public CBackground
27{
28 std::chrono::nanoseconds m_ThemeScanStartTime{0};
29
30public:
31 enum
32 {
33 POS_START = 0,
34 POS_DEMOS,
35 POS_NEWS,
36 POS_SETTINGS_LANGUAGE,
37 POS_SETTINGS_GENERAL,
38 POS_SETTINGS_PLAYER,
39 POS_SETTINGS_TEE,
40 POS_SETTINGS_APPEARANCE,
41 POS_SETTINGS_CONTROLS,
42 POS_SETTINGS_GRAPHICS,
43 POS_SETTINGS_SOUND,
44 POS_SETTINGS_DDNET,
45 POS_SETTINGS_ASSETS,
46 POS_SETTINGS_RESERVED0,
47 POS_SETTINGS_RESERVED1,
48 POS_BROWSER_INTERNET,
49 POS_BROWSER_LAN,
50 POS_BROWSER_FAVORITES,
51 POS_BROWSER_CUSTOM0,
52 POS_BROWSER_CUSTOM1,
53 POS_BROWSER_CUSTOM2,
54 POS_BROWSER_CUSTOM3,
55 POS_BROWSER_CUSTOM4,
56 POS_RESERVED0,
57 POS_RESERVED1,
58 POS_RESERVED2,
59
60 NUM_POS,
61 };
62
63 enum
64 {
65 POS_BROWSER_CUSTOM_NUM = (POS_BROWSER_CUSTOM4 - POS_BROWSER_CUSTOM0) + 1,
66 POS_SETTINGS_RESERVED_NUM = (POS_SETTINGS_RESERVED1 - POS_SETTINGS_RESERVED0) + 1,
67 POS_RESERVED_NUM = (POS_RESERVED2 - POS_RESERVED0) + 1,
68 };
69
70 enum
71 {
72 PREDEFINED_THEMES_COUNT = 3,
73 };
74
75private:
76 CCamera m_Camera;
77
78 vec2 m_RotationCenter;
79 std::array<vec2, NUM_POS> m_aPositions;
80 int m_CurrentPosition;
81 vec2 m_CurrentDirection = vec2(1.0f, 0.0f);
82 vec2 m_AnimationStartPos;
83 bool m_ChangedPosition;
84 float m_MoveTime;
85
86 bool m_IsInit;
87 bool m_Loading;
88
89 void ResetPositions();
90
91 void LoadThemeIcon(CTheme &Theme);
92 static int ThemeScan(const char *pName, int IsDir, int DirType, void *pUser);
93
94 std::vector<CTheme> m_vThemes;
95
96public:
97 CMenuBackground();
98 int Sizeof() const override { return sizeof(*this); }
99
100 void OnInterfacesInit(CGameClient *pClient) override;
101 void OnInit() override;
102 void OnMapLoad() override;
103 void OnRender() override;
104
105 void LoadMenuBackground(bool HasDayHint = true, bool HasNightHint = true);
106
107 bool Render();
108 bool IsLoading() const { return m_Loading; }
109
110 class CCamera *GetCurCamera() override;
111
112 void ChangePosition(int PositionNumber);
113
114 std::vector<CTheme> &GetThemes();
115};
116
117std::array<vec2, CMenuBackground::NUM_POS> GenerateMenuBackgroundPositions();
118
119#endif
120