tonti666

Untitled

Sep 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. /*
  2. Rest In Peace ApocalypseCheats
  3. */
  4.  
  5. #pragma once
  6.  
  7. #pragma once
  8.  
  9. #define UI_CURSORSIZE 18
  10. #define UI_CURSORFILL Color(255,255,255)
  11. #define UI_CURSOROUTLINE Color(20,20,20,140)
  12.  
  13. #define UI_WIN_TOPHEIGHT 12
  14. #define UI_WIN_TITLEHEIGHT 12
  15.  
  16. #define UI_TAB_WIDTH 230
  17. #define UI_TAB_HEIGHT 26
  18.  
  19. #define UI_WIN_CLOSE_X 80
  20. #define UI_WIN_CLOSE_Y 80
  21.  
  22. #define UI_CHK_SIZE 80
  23.  
  24. #define COL_WHITE Color(255, 255, 255)
  25. #define UI_COL_MAIN Color(27, 206, 94, 255)
  26. #define UI_COL_MAINDARK Color(113, 236, 159, 255)
  27. #define UI_COL_FADEMAIN Color(27, 206, 94, 40)
  28. #define UI_COL_SHADOW Color(101, 101, 101, 255)
  29. #define UI_COL_CLIENTBACK Color(238, 238, 238, 255)
  30. #define UI_COL_TABSEPERATOR Color(229, 229, 229, 255)
  31. #define UI_COL_TABTEXT Color(145, 145, 145, 255)
  32. #define UI_COL_GROUPOUTLINE Color(222, 222, 222, 255)
  33.  
  34. #include "CommonIncludes.h"
  35.  
  36. #include <map>
  37.  
  38. class CControl;
  39. class CTab;
  40. class CWindow;
  41. class CGUI;
  42.  
  43. extern CGUI GUI;
  44.  
  45. enum UIFlags
  46. {
  47. UI_None = 0x00,
  48. UI_Drawable = 0x01,
  49. UI_Clickable = 0x02,
  50. UI_Focusable = 0x04,
  51. UI_RenderFirst = 0x08,
  52. UI_SaveFile = 0x10
  53. };
  54.  
  55. enum UIControlTypes
  56. {
  57. UIC_CheckBox = 1,
  58. UIC_Slider,
  59. UIC_KeyBind,
  60. UIC_ComboBox
  61. };
  62.  
  63. // Base class for GUI controls
  64. class CControl
  65. {
  66. friend class CGUI;
  67. friend class CTab;
  68. friend class CWindow;
  69. public:
  70. void SetPosition(int x, int y);
  71. void SetSize(int w, int h);
  72. void GetSize(int &w, int &h);
  73. void SetFileId(std::string fid);
  74.  
  75. bool Flag(int f);
  76. protected:
  77. int m_x, m_y;
  78. int m_iWidth, m_iHeight;
  79. int m_Flags;
  80. CWindow* parent;
  81.  
  82. std::string FileIdentifier;
  83. int FileControlType;
  84.  
  85. virtual void Draw(bool) = 0;
  86. virtual void OnUpdate() = 0;
  87. virtual void OnClick() = 0;
  88.  
  89. POINT GetAbsolutePos();
  90. };
  91.  
  92. // A GUI Control Container
  93. class CTab
  94. {
  95. friend class CControl;
  96. friend class CGUI;
  97. friend class CWindow;
  98. public:
  99. void SetTitle(std::string name);
  100. void RegisterControl(CControl* control);
  101. private:
  102. std::string Title;
  103. std::vector<CControl*> Controls;
  104. CWindow* parent;
  105. };
  106.  
  107. // Base class for a simple GUI window
  108. class CWindow
  109. {
  110. friend class CControl;
  111. friend class CGUI;
  112. public:
  113. void SetPosition(int x, int y);
  114. void SetSize(int w, int h);
  115. void SetTitle(std::string title);
  116. void Open();
  117. void Close();
  118. void Toggle();
  119. CControl* GetFocus();
  120.  
  121. void RegisterTab(CTab* Tab);
  122.  
  123. RECT GetClientArea();
  124. RECT GetTabArea();
  125.  
  126. private:
  127. void DrawControls();
  128.  
  129. bool m_bIsOpen;
  130.  
  131. bool m_HasTabs;
  132.  
  133. std::vector<CTab*> Tabs;
  134. CTab* SelectedTab;
  135.  
  136. bool IsFocusingControl;
  137. CControl* FocusedControl;
  138.  
  139. std::string Title;
  140. int m_x;
  141. int m_y;
  142. int m_iWidth;
  143. int m_iHeight;
  144.  
  145. };
  146.  
  147. // User interface manager
  148. class CGUI
  149. {
  150. public:
  151. CGUI();
  152.  
  153. // Draws all windows
  154. void Draw();
  155.  
  156. // Handle all input etc
  157. void Update();
  158.  
  159. // Draws a single window
  160. bool DrawWindow(CWindow* window);
  161.  
  162. // Registers a window
  163. void RegisterWindow(CWindow* window);
  164.  
  165. // Config saving/loading
  166. void SaveWindowState(CWindow* window, std::string Filename);
  167. void LoadWindowState(std::string Filename, CWindow * window);
  168. void LoadWindowState(CWindow* window, std::string Filename);
  169.  
  170. // Window Binds
  171. void BindWindow(unsigned char Key, CWindow* window);
  172.  
  173. // Input
  174. bool GetKeyPress(unsigned int key);
  175. bool GetKeyState(unsigned int key);
  176. bool IsMouseInRegion(int y, int x2, int y2, int x);
  177. bool IsMouseInRegion(RECT region);
  178. POINT GetMouse();
  179.  
  180. private:
  181. // Input
  182. // keyboard
  183. bool keys[256];
  184. bool oldKeys[256];
  185. // Mouse
  186. POINT Mouse;
  187. bool MenuOpen;
  188.  
  189. // Window Dragging
  190. bool IsDraggingWindow;
  191. CWindow* DraggingWindow;
  192. int DragOffsetX; int DragOffsetY;
  193.  
  194. // Windows
  195. std::vector<CWindow*> Windows;
  196.  
  197. // KeyBinds -> Windows Map
  198. std::map<int, CWindow*> WindowBinds;
  199.  
  200. };
  201. namespace Globals
  202. {
  203. extern float MenuAlpha2;
  204. }
Add Comment
Please, Sign In to add comment