Cavestory Mod API
GuiStyles.h
Go to the documentation of this file.
1 /*
2  Cavestory Multiplayer API
3  Copyright (C) 2021 Johnny Ledger
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
26 #ifndef CAVESTORY_MOD_API_H_
27 #error "Please include CavestoryModAPI.h before including sub-classes."
28 #endif
29 
30 #include <CSMAPI_begincode.h>
31 #pragma once
32 
33 #include <Mod/SortedBinList.h>
34 
35 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
36 
39 enum GuiStyleVarType : unsigned char
40 {
43 
46 
49 
52 
54  GSVT_RECT = 4,
55 
57  GSVT_POINT = 5
58 };
59 
60 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
61 
65 {
66  unsigned char r;
67  unsigned char g;
68  unsigned char b;
69  unsigned char a;
70 };
71 
75 {
76  int x;
77  int y;
78  int w;
79  int h;
80 };
81 
85 {
86  int x;
87  int y;
88 };
89 
90 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
91 
95 {
96 public: // Variables
97 
101 
105 
108  union
109  {
110  GuiStyleColor color;
111  GuiStylePoint point;
112  GuiStyleRect rect;
113  char* string;
114  int integer;
116 
117 public: // Constructor
118 
122 
126 
130 
131 public: // Operators
132 
135  inline bool operator< (const GuiStyleVariable& other) const { return m_NameHash < other.m_NameHash; }
136 
139  inline bool operator<=(const GuiStyleVariable& other) const { return m_NameHash <= other.m_NameHash; }
140 
143  inline bool operator> (const GuiStyleVariable& other) const { return m_NameHash > other.m_NameHash; }
144 
147  inline bool operator>=(const GuiStyleVariable& other) const { return m_NameHash >= other.m_NameHash; }
148 
151  inline bool operator!=(const GuiStyleVariable& other) const { return m_NameHash != other.m_NameHash; }
152 
155  inline bool operator==(const GuiStyleVariable& other) const { return m_NameHash == other.m_NameHash; }
156 };
157 
158 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
159 
162 {
163 private: // Variables
164 
167  DynamicSortedBinList<GuiStyleVariable*, 1, true> m_VarList;
168 
169 public:
170 
174 
178 
179 public: // Variable methods
180 
187  const char* GetStringVar(const char* pValueName, const char* pDefaultValue = "");
188 
195  int GetIntVar(const char* pValueName, int iDefaultValue = 0);
196 
204  GUI_COLOR GetColorVar(const char* pValueName, GUI_COLOR pDefaultValue = GUI_COLOR(0, 0, 0, 0), bool bForceOpqaue = false);
205 
212  GUI_RECT GetRectVar(const char* pValueName, GUI_RECT pDefaultValue = GUI_RECT(0, 0, 0, 0));
213 
220  GUI_POINT GetPointVar(const char* pValueName, GUI_POINT pDefaultValue = GUI_POINT(0, 0));
221 
222 public: // Manipulation
223 
226  void Reset();
227 
231  int LoadStyles(const char* pFileName);
232 };
233 
234 extern GuiStyleManager gGuiStyleMgr;
235 extern GuiStyleManager gGuiStyle_Locale;
236 #include <CSMAPI_endcode.h>
GuiStyleVarType
The variable type for a GuiStyleVariable.
Definition: GuiStyles.h:40
@ GSVT_COLOR
Color variable.
Definition: GuiStyles.h:45
@ GSVT_INTEGER
Integer variable.
Definition: GuiStyles.h:51
@ GSVT_POINT
Point variable.
Definition: GuiStyles.h:57
@ GSVT_STRING
String variable.
Definition: GuiStyles.h:48
@ GSVT_UNDEFINED
Undefined.
Definition: GuiStyles.h:42
@ GSVT_RECT
Rect variable.
Definition: GuiStyles.h:54
Definition: GuiStyles.h:162
int LoadStyles(const char *pFileName)
Load the currently loaded mod's GuiStyle.cfg file.
GUI_COLOR GetColorVar(const char *pValueName, GUI_COLOR pDefaultValue=GUI_COLOR(0, 0, 0, 0), bool bForceOpqaue=false)
Get the integer value of a variable.
const char * GetStringVar(const char *pValueName, const char *pDefaultValue="")
Get the string value of a variable.
GuiStyleManager()
Default constructor.
~GuiStyleManager()
Deconstructor.
int GetIntVar(const char *pValueName, int iDefaultValue=0)
Get the integer value of a variable.
GUI_POINT GetPointVar(const char *pValueName, GUI_POINT pDefaultValue=GUI_POINT(0, 0))
Get the point value of a variable.
void Reset()
Reset the manager.
GUI_RECT GetRectVar(const char *pValueName, GUI_RECT pDefaultValue=GUI_RECT(0, 0, 0, 0))
Get the rect value of a variable.
A sortable client class, to be used with SortedBinList.
Definition: GuiStyles.h:95
union GuiStyleVariable::@19 m_Values
The value for this variable.
GuiStyleVariable()
Main constructor.
GuiStyleVarType m_Type
The type of variable this is.
Definition: GuiStyles.h:104
~GuiStyleVariable()
Deconstructor.
GuiStyleVariable(int key)
Constructor.
int m_NameHash
The key.
Definition: GuiStyles.h:100
Manages colors.
Definition: CSMAPI_types.h:497
Manages points.
Definition: CSMAPI_types.h:546
Definition: CSMAPI_types.h:842
GuiStyles' color struct.
Definition: GuiStyles.h:65
GuiStyles' point struct.
Definition: GuiStyles.h:85
GuiStyles' rect struct.
Definition: GuiStyles.h:75