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