-
-
Notifications
You must be signed in to change notification settings - Fork 454
/
Copy pathCGUI_Impl.h
361 lines (308 loc) · 14.2 KB
/
CGUI_Impl.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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: gui/CGUI_Impl.h
* PURPOSE: Graphical User Interface module class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/
class CGUI_Impl;
#pragma once
#include <gui/CGUI.h>
#include <list>
#include <windows.h>
#define CGUI_CHAR_SIZE 6
class CGUIElement;
class CGUIElement_Impl;
class CGUIButton;
class CGUICheckBox;
class CGUIEdit;
class CGUIEvent;
class CGUIFont;
class CGUIFont_Impl;
class CGUIGridList;
class CGUILabel;
class CGUIMemo;
class CGUIMessageBox;
class CGUIProgressBar;
class CGUIRadioButton;
class CGUIStaticImage;
class CGUIScrollBar;
class CGUIScrollPane;
class CGUIComboBox;
class CGUITexture;
class CGUIWindow;
class CGUITab;
class CGUITabPanel;
struct IDirect3DDevice9;
namespace CEGUI
{
class FontManager;
class ImagesetManager;
class Renderer;
class System;
class SchemeManager;
class WindowManager;
class Image;
class EventArgs;
class GUISheet;
typedef GUISheet DefaultWindow;
} // namespace CEGUI
class CGUI_Impl : public CGUI, public CGUITabList
{
public:
CGUI_Impl(IDirect3DDevice9* pDevice);
~CGUI_Impl();
void SetSkin(const char* szName);
void SetBidiEnabled(bool bEnabled);
void Draw();
void Invalidate();
void Restore();
void DrawMouseCursor();
void ProcessMouseInput(CGUIMouseInput eMouseInput, unsigned long ulX = 0, unsigned long ulY = 0, CGUIMouseButton eMouseButton = NoButton);
void ProcessKeyboardInput(unsigned long ulKey, bool bIsDown);
void ProcessCharacter(unsigned long ulCharacter);
//
bool GetGUIInputEnabled();
void SetGUIInputMode(eInputMode a_eMode);
eInputMode GetGUIInputMode();
static CEGUI::String GetUTFString(const char* szInput);
static CEGUI::String GetUTFString(const std::string& strInput);
static CEGUI::String GetUTFString(const CEGUI::String& strInput); // Not defined
//
CGUIMessageBox* CreateMessageBox(const char* szTitle, const char* szMessage, unsigned int uiFlags);
CGUIButton* CreateButton(CGUIElement* pParent = NULL, const char* szCaption = "");
CGUIButton* CreateButton(CGUITab* pParent = NULL, const char* szCaption = "");
CGUICheckBox* CreateCheckBox(CGUIElement* pParent = NULL, const char* szCaption = "", bool bChecked = false);
CGUICheckBox* CreateCheckBox(CGUITab* pParent = NULL, const char* szCaption = "", bool bChecked = false);
CGUIRadioButton* CreateRadioButton(CGUIElement* pParent = NULL, const char* szCaption = "");
CGUIRadioButton* CreateRadioButton(CGUITab* pParent = NULL, const char* szCaption = "");
CGUIEdit* CreateEdit(CGUIElement* pParent = NULL, const char* szText = "");
CGUIEdit* CreateEdit(CGUITab* pParent = NULL, const char* szText = "");
CGUIGridList* CreateGridList(CGUIElement* pParent = NULL, bool bFrame = true);
CGUIGridList* CreateGridList(CGUITab* pParent = NULL, bool bFrame = true);
CGUILabel* CreateLabel(CGUIElement* pParent, const char* szCaption = "");
CGUILabel* CreateLabel(CGUITab* pParent, const char* szCaption = "");
CGUILabel* CreateLabel(const char* szCaption = "");
CGUIProgressBar* CreateProgressBar(CGUIElement* pParent);
CGUIProgressBar* CreateProgressBar(CGUITab* pParent);
CGUIMemo* CreateMemo(CGUIElement* pParent = NULL, const char* szText = "");
CGUIMemo* CreateMemo(CGUITab* pParent = NULL, const char* szText = "");
CGUIStaticImage* CreateStaticImage(CGUIElement* pParent);
CGUIStaticImage* CreateStaticImage(CGUITab* pParent);
CGUIStaticImage* CreateStaticImage(CGUIGridList* pParent);
CGUIStaticImage* CreateStaticImage();
CGUITabPanel* CreateTabPanel(CGUIElement* pParent);
CGUITabPanel* CreateTabPanel(CGUITab* pParent);
CGUITabPanel* CreateTabPanel();
CGUIScrollPane* CreateScrollPane(CGUIElement* pParent);
CGUIScrollPane* CreateScrollPane(CGUITab* pParent);
CGUIScrollPane* CreateScrollPane();
CGUIScrollBar* CreateScrollBar(bool bHorizontal, CGUIElement* pParent = NULL);
CGUIScrollBar* CreateScrollBar(bool bHorizontal, CGUITab* pParent = NULL);
CGUIComboBox* CreateComboBox(CGUIElement* pParent = NULL, const char* szCaption = "");
CGUIComboBox* CreateComboBox(CGUIComboBox* pParent = NULL, const char* szCaption = "");
CGUIWebBrowser* CreateWebBrowser(CGUIElement* pParent = nullptr);
CGUIWebBrowser* CreateWebBrowser(CGUITab* pParent = nullptr);
CGUIWindow* CreateWnd(CGUIElement* pParent = NULL, const char* szCaption = "");
//
CGUITexture* CreateTexture();
CGUIFont* CreateFnt(const char* szFontName, const char* szFontFile, unsigned int uSize = 8, unsigned int uFlags = 0, bool bAutoScale = false);
void SetCursorEnabled(bool bEnabled);
bool IsCursorEnabled();
void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) override;
void SetCurrentServerCursorAlpha(float fAlpha) override;
float GetCurrentServerCursorAlpha();
void SetCursorColor(float r, float g, float b, float alpha) noexcept override;
void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept override;
void ResetMenuCursorColor() noexcept override;
void RestoreCurrentServerCursorColor() noexcept override;
void ResetCursorColorVariables() noexcept override;
eCursorType GetCursorType();
void AddChild(CGUIElement_Impl* pChild);
CEGUI::FontManager* GetFontManager();
CEGUI::ImagesetManager* GetImageSetManager();
CEGUI::Renderer* GetRenderer();
CEGUI::System* GetGUISystem();
CEGUI::SchemeManager* GetSchemeManager();
CEGUI::WindowManager* GetWindowManager();
void GetUniqueName(char* pBuf);
CEGUI::Window* GetMasterWindow(CEGUI::Window* Window);
CVector2D GetResolution();
void SetResolution(float fWidth, float fHeight);
CGUIFont* GetDefaultFont();
CGUIFont* GetSmallFont();
CGUIFont* GetBoldFont();
CGUIFont* GetClearFont();
CGUIFont* GetSAHeaderFont();
CGUIFont* GetSAGothicFont();
CGUIFont* GetSansFont();
bool IsFontPresent(const char* szFont) { return m_pFontManager->isFontPresent(szFont); }
float GetTextExtent(const char* szText, const char* szFont = "default-normal");
float GetMaxTextExtent(SString strFont, SString arg, ...);
const SString& GetGuiWorkingDirectory() const;
void SetDefaultGuiWorkingDirectory(const SString& strDir);
void PushGuiWorkingDirectory(const SString& strDir);
void PopGuiWorkingDirectory(const SString& strDirCheck = "");
void SetCharacterKeyHandler(eInputChannel channel, const GUI_CALLBACK_KEY& Callback)
{
CHECK_CHANNEL(channel);
m_CharacterKeyHandlers[channel] = Callback;
}
void SetKeyDownHandler(eInputChannel channel, const GUI_CALLBACK_KEY& Callback)
{
CHECK_CHANNEL(channel);
m_KeyDownHandlers[channel] = Callback;
}
void SetMouseClickHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseClickHandlers[channel] = Callback;
}
void SetMouseDoubleClickHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseDoubleClickHandlers[channel] = Callback;
}
void SetMouseButtonDownHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseButtonDownHandlers[channel] = Callback;
}
void SetMouseButtonUpHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseButtonUpHandlers[channel] = Callback;
}
void SetMouseMoveHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseMoveHandlers[channel] = Callback;
}
void SetMouseEnterHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseEnterHandlers[channel] = Callback;
}
void SetMouseLeaveHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseLeaveHandlers[channel] = Callback;
}
void SetMouseWheelHandler(eInputChannel channel, const GUI_CALLBACK_MOUSE& Callback)
{
CHECK_CHANNEL(channel);
m_MouseWheelHandlers[channel] = Callback;
}
void SetMovedHandler(eInputChannel channel, const GUI_CALLBACK& Callback)
{
CHECK_CHANNEL(channel);
m_MovedHandlers[channel] = Callback;
}
void SetSizedHandler(eInputChannel channel, const GUI_CALLBACK& Callback)
{
CHECK_CHANNEL(channel);
m_SizedHandlers[channel] = Callback;
}
void SetFocusGainedHandler(eInputChannel channel, const GUI_CALLBACK_FOCUS& Callback)
{
CHECK_CHANNEL(channel);
m_FocusGainedHandlers[channel] = Callback;
}
void SetFocusLostHandler(eInputChannel channel, const GUI_CALLBACK_FOCUS& Callback)
{
CHECK_CHANNEL(channel);
m_FocusLostHandlers[channel] = Callback;
}
void SelectInputHandlers(eInputChannel channel)
{
CHECK_CHANNEL(channel);
m_Channel = channel;
}
void ClearInputHandlers(eInputChannel channel);
void ClearSystemKeys();
bool Event_CharacterKey(const CEGUI::EventArgs& e);
bool Event_KeyDown(const CEGUI::EventArgs& e);
bool Event_MouseClick(const CEGUI::EventArgs& e);
bool Event_MouseDoubleClick(const CEGUI::EventArgs& e);
bool Event_MouseButtonDown(const CEGUI::EventArgs& e);
bool Event_MouseButtonUp(const CEGUI::EventArgs& e);
bool Event_MouseWheel(const CEGUI::EventArgs& e);
bool Event_MouseMove(const CEGUI::EventArgs& e);
bool Event_MouseEnter(const CEGUI::EventArgs& e);
bool Event_MouseLeave(const CEGUI::EventArgs& e);
bool Event_Moved(const CEGUI::EventArgs& e);
bool Event_Sized(const CEGUI::EventArgs& e);
bool Event_RedrawRequested(const CEGUI::EventArgs& e);
bool Event_FocusGained(const CEGUI::EventArgs& e);
bool Event_FocusLost(const CEGUI::EventArgs& e);
void AddToRedrawQueue(CGUIElement* pWindow);
void RemoveFromRedrawQueue(CGUIElement* pWindow);
void CleanDeadPool();
CGUIWindow* LoadLayout(CGUIElement* pParent, const SString& strFilename);
bool LoadImageset(const SString& strFilename);
private:
CGUIButton* _CreateButton(CGUIElement_Impl* pParent = NULL, const char* szCaption = "");
CGUICheckBox* _CreateCheckBox(CGUIElement_Impl* pParent = NULL, const char* szCaption = "", bool bChecked = false);
CGUIRadioButton* _CreateRadioButton(CGUIElement_Impl* pParent = NULL, const char* szCaption = "");
CGUIEdit* _CreateEdit(CGUIElement_Impl* pParent = NULL, const char* szText = "");
CGUIGridList* _CreateGridList(CGUIElement_Impl* pParent = NULL, bool bFrame = true);
CGUILabel* _CreateLabel(CGUIElement_Impl* pParent = NULL, const char* szCaption = "");
CGUIProgressBar* _CreateProgressBar(CGUIElement_Impl* pParent = NULL);
CGUIMemo* _CreateMemo(CGUIElement_Impl* pParent = NULL, const char* szText = "");
CGUIStaticImage* _CreateStaticImage(CGUIElement_Impl* pParent = NULL);
CGUITabPanel* _CreateTabPanel(CGUIElement_Impl* pParent = NULL);
CGUIScrollPane* _CreateScrollPane(CGUIElement_Impl* pParent = NULL);
CGUIScrollBar* _CreateScrollBar(bool bHorizontal, CGUIElement_Impl* pParent = NULL);
CGUIComboBox* _CreateComboBox(CGUIElement_Impl* pParent = NULL, const char* szCaption = "");
CGUIWebBrowser* _CreateWebBrowser(CGUIElement_Impl* pParent = nullptr);
void SubscribeToMouseEvents();
CGUIFont* CreateFntFromWinFont(const char* szFontName, const char* szFontWinReg, const char* szFontWinFile, unsigned int uSize = 8, unsigned int uFlags = 0,
bool bAutoScale = false);
void ApplyGuiWorkingDirectory();
IDirect3DDevice9* m_pDevice;
CEGUI::Renderer* m_pRenderer;
CEGUI::System* m_pSystem;
CEGUI::FontManager* m_pFontManager;
CEGUI::ImagesetManager* m_pImageSetManager;
CEGUI::SchemeManager* m_pSchemeManager;
CEGUI::WindowManager* m_pWindowManager;
CEGUI::DefaultWindow* m_pTop;
const CEGUI::Image* m_pCursor;
float CurrentServerCursorAlpha = {255.0f};
float CurrentServerCursorRed = {255.0f};
float CurrentServerCursorGreen = {255.0f};
float CurrentServerCursorBlue = {255.0f};
CGUIFont_Impl* m_pDefaultFont;
CGUIFont_Impl* m_pSmallFont;
CGUIFont_Impl* m_pBoldFont;
CGUIFont_Impl* m_pClearFont;
CGUIFont_Impl* m_pSAHeaderFont;
CGUIFont_Impl* m_pSAGothicFont;
CGUIFont_Impl* m_pSansFont;
CGUIFont_Impl* m_pUniFont;
std::list<CGUIElement*> m_RedrawQueue;
unsigned long m_ulPreviousUnique;
eInputMode m_eInputMode;
GUI_CALLBACK_KEY m_CharacterKeyHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_KEY m_KeyDownHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseClickHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseDoubleClickHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseButtonDownHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseButtonUpHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseMoveHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseEnterHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseLeaveHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_MOUSE m_MouseWheelHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK m_MovedHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK m_SizedHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_FOCUS m_FocusGainedHandlers[INPUT_CHANNEL_COUNT];
GUI_CALLBACK_FOCUS m_FocusLostHandlers[INPUT_CHANNEL_COUNT];
eInputChannel m_Channel;
std::list<SString> m_GuiWorkingDirectoryStack;
bool m_HasSchemeLoaded;
SString m_CurrentSchemeName;
CElapsedTime m_RenderOkTimer;
};