-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI.h
206 lines (167 loc) · 4.08 KB
/
GUI.h
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
/*
source by ibanned / xtk
*/
#pragma once
#include "CommonIncludes.h"
#include <map>
#define UI_CURSORSIZE 12
#define UI_CURSORFILL Color(255,255,255)
#define UI_CURSOROUTLINE Color(20,20,20,140)
#define UI_WIN_TOPHEIGHT 26
#define UI_WIN_TITLEHEIGHT 32
#define UI_TAB_WIDTH 125
#define UI_TAB_HEIGHT 150
#define UI_WIN_CLOSE_X 20
#define UI_WIN_CLOSE_Y 6
#define UI_CHK_SIZE 16
#define UI_COL_TEST Color(255, 0, 255, 255) //pink
#define UI_COL_TEST2 Color(105, 5, 153) //lila
#define UI_COL_TEXT3 Color(255, 0, 0, 255) //rot
#define UI_FILLER Color(0, 0, 0, 0) //nix
#define COL_WHITE Color(255, 255, 255) //weiß
#define UI_COL_MAIN Color(19, 19, 21, 255) //blau
#define UI_COL_MAINDARK Color(28, 136, 0, 255) //Grün
#define UI_COL_FADEMAIN Color(28, 136, 0, 255) // grün
#define UI_COL_SHADOW Color(0, 0, 0, 255) // schwarz / schwarz transparent
#define UI_COL_CLIENTBACK Color(30, 30, 30, 255) //schwarz
#define UI_COL_TABSEPERATOR Color(132, 132, 132, 200) //Transparent
#define UI_COL_TABTEXT Color(145, 145, 145, 255) //hellgrau
#define UI_COL_GROUPOUTLINE Color(19, 19, 21, 255) //gräulich
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_Seperate,
UIC_Slider,
UIC_Slider2,
UIC_Slider3,
UIC_Slider4,
UIC_KeyBind,
UIC_ComboBox,
UIC_ItemSelector,
UIC_Button
};
// 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;
bool Flag(int f);
protected:
int m_x, m_y;
int m_iWidth, m_iHeight;
int m_Flags;
CWindow* parent;
std::string FileIdentifier;
virtual void Draw(bool) = 0;
virtual void OnUpdate() = 0;
virtual void OnClick() = 0;
POINT GetAbsolutePos();
};
// 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);
private:
std::string Title;
std::vector<CControl*> Controls;
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();
bool isOpen();
void Toggle();
CControl* GetFocus();
void RegisterTab(CTab* Tab);
RECT GetClientArea();
RECT GetTabArea();
RECT GetClientArea1();
private:
void DrawControls();
bool m_bIsOpen;
std::vector<CTab*> Tabs;
CTab* SelectedTab;
bool IsFocusingControl;
CControl* FocusedControl;
std::string Title;
int m_x;
int m_y;
int m_iWidth;
int m_iHeight;
};
extern float MenuAlpha;
// 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);
// 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;
};