Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
globals.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <map>
5 #include <vector>
6 
7 #include <Strings/components/resources/color/BlamColor.h>
8 #include <Strings/components/utils/string/string.h>
9 
10 #define GLOBALS_FILE "globals.xml"
11 
12 #ifndef BLAM
13 #define BLAM
14 #endif
15 
20 {
21  InvalidType,
23  Ok,
24  InvalidArgs,
25  OutOfBounds,
27 };
28 
33 {
35  Real,
37  Long,
38  //Object, //!< Unknown. Referenced within the `hs_doc` from Halo 2 Sapien.
40  Int,
42 };
43 
55 {
57  std::string name = "";
58  std::string info = "";
59  std::string value_raw = "";
60  bool read_only = false;
61 
63  // Additional value storage types, these are used in place of value_raw based on type. //
65 
66  bool boolean_value = false;
67  short short_value = 0;
68  long long_value = 0;
69  int int_value = 0;
70  float float_value = 0.0f;
71  BlamColor color_value = BlamColor(0, 0, 0);
72 };
73 
77 namespace Blam::Globals
78 {
87  BLAM std::map<std::string, BlamEngineGlobal>* GetGlobalsList();
88 
95 
103  BLAM std::string GetGlobalTypeLabel(BlamGlobalType type);
104 
112  BLAM bool GlobalExists(std::string id);
113 
120 
128  BLAM void RegisterGlobal(std::string name, std::string value_raw, BlamGlobalType type);
129 
138  BLAM void RegisterGlobal(std::string name, std::string value_raw, BlamGlobalType type, std::string info);
139 
147  BLAM BlamEngineGlobal* GetGlobal(std::string name);
148 
157  BLAM BlamGlobalUpdateResult UpdateGlobalWrap(std::string name, std::string new_value);
158 
167  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, std::string new_value);
168 
177  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, bool new_value);
178 
187  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, int new_value);
188 
197  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, short new_value);
198 
207  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, long new_value);
208 
217  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, float new_value);
218 
227  BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, BlamColor new_value);
228 
236  BLAM bool* GetGlobalAsBoolean(std::string name);
237 
245  BLAM std::string* GetGlobalAsString(std::string name);
246 
254  BLAM short* GetGlobalAsShort(std::string name);
255 
263  BLAM long* GetGlobalAsLong(std::string name);
264 
272  BLAM int* GetGlobalAsInteger(std::string name);
273 
281  BLAM float* GetGlobalAsFloat(std::string name);
282 
290  BLAM BlamColor* GetGlobalAsColor(std::string name);
291 }
BlamGlobalType
BlamGlobalType
Enumerator for the type of global variable.
Definition: globals.h:32
Short
@ Short
!< Represents a float.
Definition: globals.h:36
BlamGlobalUpdateResult::OutOfBounds
@ OutOfBounds
The provided value was too small or too large for the globals' data type.
Blam::Globals::GlobalExists
BLAM bool GlobalExists(std::string id)
Determines whether or not a global exists.
Definition: globals.cpp:27
Blam::Globals::UpdateGlobal
BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, std::string new_value)
Updates the value of a String global.
Definition: globals.cpp:574
Real
@ Real
Definition: globals.h:35
BlamEngineGlobal::name
std::string name
The name of the global.
Definition: globals.h:57
Blam::Globals
Namespace containing functions relating to game engine globals.
Definition: globals.h:77
BlamGlobalUpdateResult::UnknownGlobal
@ UnknownGlobal
The specified global does not exist.
Blam::Globals::LoadGlobalsFromFile
BLAM bool LoadGlobalsFromFile()
Loads any globals from #GVARS_FILE.
Definition: globals.cpp:202
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:403
BlamGlobalUpdateResult::Ok
@ Ok
The global was updated successfully.
BlamEngineGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: globals.h:66
Int
@ Int
Represents an int.
Definition: globals.h:40
Blam::Globals::GetGlobalAsColor
BLAM BlamColor * GetGlobalAsColor(std::string name)
Retrieves a global's value as a BlamColor.
Definition: globals.cpp:415
BlamEngineGlobal::info
std::string info
An optional description of the global.
Definition: globals.h:58
BlamGlobalUpdateResult::InvalidArgs
@ InvalidArgs
The provided arguments were invalid.
BlamEngineGlobal::type
BlamGlobalType type
The type of the global.
Definition: globals.h:56
String
@ String
Represents a std::string.
Definition: globals.h:39
BlamEngineGlobal
Structure containing data for a game engine global.
Definition: globals.h:54
Blam::Globals::RegisterGlobal
BLAM void RegisterGlobal(BlamEngineGlobal var)
Registers a new engine global.
Definition: globals.cpp:61
Blam::Globals::GetGlobalAsShort
BLAM short * GetGlobalAsShort(std::string name)
Retrieves a global's value as a short.
Definition: globals.cpp:367
BlamGlobalUpdateResult
BlamGlobalUpdateResult
Enumerator for the result of a global update attempt.
Definition: globals.h:19
BlamEngineGlobal::short_value
short short_value
The short value of the global.
Definition: globals.h:67
BlamEngineGlobal::read_only
bool read_only
Whether or not the global is protected from modification.
Definition: globals.h:60
BlamGlobalUpdateResult::InvalidType
@ InvalidType
The provided value was of an invalid type.
Blam::Globals::GetGlobalTypeLabel
BLAM std::string GetGlobalTypeLabel(BlamGlobalType type)
Retrieves a string representation of a global's type, for use in UI.
Definition: globals.cpp:40
Blam::Globals::GetGlobal
BLAM BlamEngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:189
BlamEngineGlobal::color_value
BlamColor color_value
The color value of the global.
Definition: globals.h:71
Long
@ Long
Represents a long.
Definition: globals.h:37
Color
@ Color
Represents a BlamColor. See #BlamColor for details.
Definition: globals.h:41
Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:34
Blam::Globals::GetGlobalAsLong
BLAM long * GetGlobalAsLong(std::string name)
Retrieves a global's value as a long.
Definition: globals.cpp:379
BLAM
#define BLAM
Definition: globals.h:13
BlamEngineGlobal::int_value
int int_value
The int value of the global.
Definition: globals.h:69
Blam::Globals::GetGlobalAsString
BLAM std::string * GetGlobalAsString(std::string name)
Retrieves a global's value as a string.
Definition: globals.cpp:355
BlamGlobalUpdateResult::GlobalIsProtected
@ GlobalIsProtected
The specified global is protected and cannot be modified during runtime.
Blam::Globals::UpdateGlobalWrap
BLAM BlamGlobalUpdateResult UpdateGlobalWrap(std::string name, std::string new_value)
Updates a global's raw value.
Definition: globals.cpp:431
BlamEngineGlobal::float_value
float float_value
The float value of the global.
Definition: globals.h:70
BlamEngineGlobal::value_raw
std::string value_raw
The raw value of the global as a string.
Definition: globals.h:59
Blam::Globals::GetGlobalAsBoolean
BLAM bool * GetGlobalAsBoolean(std::string name)
Retrieves a global's value as a boolean.
Definition: globals.cpp:343
name
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font name
Definition: ARPHICPL.TXT:16
Blam::Globals::GetGlobalsList
BLAM std::map< std::string, BlamEngineGlobal > * GetGlobalsList()
Retrieves the list of loaded globals.
Definition: globals.cpp:22
BlamEngineGlobal::long_value
long long_value
The long value of the global.
Definition: globals.h:68
Blam::Globals::GetGlobalAsInteger
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:391