-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.h
More file actions
271 lines (220 loc) · 3.93 KB
/
Copy pathGUI.h
File metadata and controls
271 lines (220 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#pragma once
#include "CommonIncludes.h"
#include <map>
class CControl;
class CTab;
class CWindow;
class CGUI;
extern CGUI GUI;
enum UIFlags
{
UI_None = 0x00,
UI_Drawable = 0x01,
UI_Clickable = 0x02,
UI_Focusable = 0x04,
UI_RenderFirst = 0x08,
UI_SaveFile = 0x10
};
enum UIControlTypes
{
UIC_CheckBox = 1,
UIC_Slider,
UIC_KeyBind,
UIC_ComboBox,
UIC_ItemSelector,
UIC_Button,
UIC_MultiBox,
UIC_GroupBox,
UIC_ListBox,
UIC_ColorSelector,
UIC_Label,
UIC_TextField
};
// Base class for GUI controls
class CControl
{
friend class CGUI;
friend class CTab;
friend class CWindow;
public:
void SetPosition(int x, int y);
void SetSize(int w, int h);
void GetSize(int &w, int &h);
void SetFileId(std::string fid);
int FileControlType;
int m_iWidth, m_iHeight;
POINT GetAbsolutePos();
bool Flag(int f);
int m_x, m_y;
CControl* parent_group;
int g_tab = 0;
bool should_function = true;
protected:
int m_Flags;
CWindow* parent;
std::string FileIdentifier;
virtual void Draw(bool) = 0;
virtual void OnUpdate() = 0;
virtual void OnClick() = 0;
};
// A GUI Control Container
class CTab
{
friend class CControl;
friend class CGUI;
friend class CWindow;
public:
void SetTitle(std::string name);
void RegisterControl(CControl* control);
std::vector<CControl*> Controls;
private:
std::string Title;
CWindow* parent;
};
// Base class for a simple GUI window
class CWindow
{
friend class CControl;
friend class CGUI;
public:
void SetPosition(int x, int y);
void SetSize(int w, int h);
void SetTitle(std::string title);
void Open();
void Close();
void Toggle();
bool isOpen();
int get_iWidth()
{
return m_iWidth;
}
int get_iHeight()
{
return m_iHeight;
}
int get_x()
{
return m_x;
}
int get_y()
{
return m_y;
}
CControl* GetFocus();
void RegisterTab(CTab* Tab);
RECT GetClientArea();
RECT GetClientArea1();
RECT GetTabArea();
RECT GetDragArea();
CControl* FocusedControl;
private:
void DrawControls();
bool m_bIsOpen = false;
std::vector<CTab*> Tabs;
CTab* SelectedTab;
bool IsFocusingControl;
std::string Title;
int m_x;
int m_y;
int m_iWidth;
int m_iHeight;
};
namespace Globals
{
extern float MenuAlpha2;
}
namespace Globals
{
extern float MenuAlpha4;
}
namespace Globals
{
extern float MenuAlpha6;
}
namespace Globals
{
extern float MenuAlpha8;
}
namespace Globals
{
extern float MenuAlpha10;
}
namespace Globals
{
extern float MenuAlpha22;
}
namespace Globals
{
extern float MenuAlpha12;
}
namespace Globals
{
extern float MenuAlpha14;
}
namespace Globals
{
extern float MenuAlpha16;
}
namespace Globals
{
extern float MenuAlpha18;
}
namespace Globals
{
extern float MenuAlpha20;
}
namespace Globals
{
extern float MenuAlpha24;
}
extern float MenuAlpha;
extern float MenuAlpha3;
extern float MenuAlpha5;
extern float MenuAlpha7;
extern float MenuAlpha9;
extern float MenuAlpha11;
extern float MenuAlpha17;
extern float MenuAlpha19;
extern float MenuAlpha21;
extern float MenuAlpha23;
// User interface manager
class CGUI
{
public:
CGUI();
// Draws all windows
void Draw();
// Handle all input etc
void Update();
// Draws a single window
bool DrawWindow(CWindow* window, int menu);
// Registers a window
void RegisterWindow(CWindow* window);
// Config saving/loading
void SaveWindowState(CWindow* window, std::string Filename);
void LoadWindowState(CWindow* window, std::string Filename);
// Window Binds
void BindWindow(unsigned char Key, CWindow* window);
// Input
bool GetKeyPress(unsigned int key);
bool GetKeyState(unsigned int key);
bool IsMouseInRegion(int x, int y, int x2, int y2);
bool IsMouseInRegion(RECT region);
POINT GetMouse();
private:
// Input
// keyboard
bool keys[256];
bool oldKeys[256];
// Mouse
POINT Mouse;
bool MenuOpen;
// Window Dragging
bool IsDraggingWindow;
CWindow* DraggingWindow;
int DragOffsetX; int DragOffsetY;
// Windows
std::vector<CWindow*> Windows;
// KeyBinds -> Windows Map
std::map<int, CWindow*> WindowBinds;
};