#pragma once
#include "../sdk.hpp"
#include <map>
class CControl;
class CTab;
class CWindow;
class CGUI;
extern CGUI GUI;
extern bool menu_open;
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_Label1,
UIC_KeyBind,
UIC_ComboBox,
UIC_ItemSelector,
UIC_Button,
UIC_MultiBox,
UIC_GroupBox,
UIC_ListBox,
UIC_CheckBox1,
UIC_Slider2,
UIC_ColorSelector,
UIC_Label,
UIC_TextField,
UIC_dropdown
};
// 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();
POINT GetAbsolutePos1();
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 SetIcon(std::string icon);
void RegisterControl(CControl* control);
std::vector<CControl*> Controls;
private:
std::string Title;
std::string Icon;
CWindow* parent;
};
// Base class for a simple GUI window
class CWindow
{
public:
friend class CControl;
friend class CGUI;
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 GetClientAreaCheckBox();
RECT GetClientArea1();
RECT GetTabArea();
RECT GetDragArea();
CControl* FocusedControl;
bool m_bIsOpen = false;
private:
void DrawControls();
std::vector<CTab*> Tabs;
CTab* SelectedTab;
bool IsFocusingControl;
std::string Title;
int m_x;
int m_y;
int m_iWidth;
int m_iHeight;
};
namespace Globalss
{
extern float MenuAlpha2;
extern float MenuAlpha4;
extern float MenuAlpha6;
extern float MenuAlpha8;
extern float MenuAlpha10;
extern float MenuAlpha22;
extern float MenuAlpha12;
extern float MenuAlpha14;
extern float MenuAlpha16;
extern float MenuAlpha18;
extern float MenuAlpha20;
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();
std::vector<CWindow*> Windows;
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
// KeyBinds -> Windows Map
std::map<int, CWindow*> WindowBinds;
};