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