Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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 GVARS_FILE "globals.xml"
11 
12 #ifndef BLAM
13 #define BLAM
14 #endif
15 
16 namespace Blam
17 {
23  namespace Globals
24  {
29  {
32  Ok,
36  };
37 
41  enum GvarType
42  {
44  Real,
46  Long,
49  Int,
52  };
53 
64  struct EngineGlobal
65  {
67  std::string name = "";
68  std::string info = "";
69  std::string value_raw = "";
70  bool read_only = false;
71 
73  // Additional value storage types, these are used in place of value_raw based on type. //
75 
76  bool boolean_value = false;
77  short short_value = 0;
78  long long_value = 0;
79  int int_value = 0;
80  float float_value = 0.0f;
81  BlamColor color_value = BlamColor(0, 0, 0);
82  };
83 
92  BLAM std::map<std::string, EngineGlobal>* GetGlobalsList();
93 
100 
108  BLAM std::string GetGvarTypeLabel(GvarType type);
109 
117  BLAM bool GlobalExists(std::string id);
118 
124  BLAM void RegisterGvar(EngineGlobal var);
125 
133  BLAM void RegisterGvar(std::string name, std::string value_raw, GvarType type);
134 
143  BLAM void RegisterGvar(std::string name, std::string value_raw, GvarType type, std::string info);
144 
152  BLAM EngineGlobal* GetGlobal(std::string name);
153 
162  BLAM GvarUpdateResult UpdateGlobalWrap(std::string name, std::string new_value);
163 
172  BLAM GvarUpdateResult UpdateGlobal(std::string name, std::string new_value);
173 
182  BLAM GvarUpdateResult UpdateGlobal(std::string name, bool new_value);
183 
192  BLAM GvarUpdateResult UpdateGlobal(std::string name, int new_value);
193 
202  BLAM GvarUpdateResult UpdateGlobal(std::string name, short new_value);
203 
212  BLAM GvarUpdateResult UpdateGlobal(std::string name, long new_value);
213 
222  BLAM GvarUpdateResult UpdateGlobal(std::string name, float new_value);
223 
232  BLAM GvarUpdateResult UpdateGlobal(std::string name, BlamColor new_value);
233 
241  BLAM bool* GetGlobalAsBoolean(std::string name);
242 
250  BLAM std::string* GetGlobalAsString(std::string name);
251 
259  BLAM short* GetGlobalAsShort(std::string name);
260 
268  BLAM long* GetGlobalAsLong(std::string name);
269 
277  BLAM int* GetGlobalAsInteger(std::string name);
278 
286  BLAM float* GetGlobalAsFloat(std::string name);
287 
295  BLAM BlamColor* GetGlobalAsColor(std::string name);
296  }
297 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:28
Blam::Globals::RegisterGvar
BLAM void RegisterGvar(EngineGlobal var)
Registers a new engine global.
Definition: globals.cpp:65
Blam::Globals::GetGlobal
BLAM EngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:193
Blam::Globals::GlobalExists
BLAM bool GlobalExists(std::string id)
Determines whether or not a global exists.
Definition: globals.cpp:27
Blam::Globals::EngineGlobal::float_value
float float_value
The float value of the global.
Definition: globals.h:80
Blam::Globals::EngineGlobal::info
std::string info
An optional description of the global.
Definition: globals.h:68
Blam::Globals::Int
@ Int
Represents an int.
Definition: globals.h:49
Blam::Globals::EngineGlobal::color_value
BlamColor color_value
The color value of the global.
Definition: globals.h:81
Blam::Globals::UnknownGlobal
@ UnknownGlobal
The specified global does not exist.
Definition: globals.h:31
Blam::Globals::Long
@ Long
Represents a long.
Definition: globals.h:46
Blam::Globals::GlobalIsProtected
@ GlobalIsProtected
The specified global is protected and cannot be modified during runtime.
Definition: globals.h:35
Blam::Globals::LoadGlobalsFromFile
BLAM bool LoadGlobalsFromFile()
Loads any globals from GVARS_FILE.
Definition: globals.cpp:206
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:407
Blam::Globals::InvalidArgs
@ InvalidArgs
The provided arguments were invalid.
Definition: globals.h:33
Blam::Globals::Real
@ Real
Same as Float.
Definition: globals.h:44
Blam::Globals::UpdateGlobalWrap
BLAM GvarUpdateResult UpdateGlobalWrap(std::string name, std::string new_value)
Updates a global's raw value.
Definition: globals.cpp:435
Blam::Globals::EngineGlobal::read_only
bool read_only
Whether or not the global is protected from modification.
Definition: globals.h:70
Blam::Globals::EngineGlobal::name
std::string name
The name of the global.
Definition: globals.h:67
Blam::Globals::GvarType
GvarType
Enumerator for the type of global variable.
Definition: globals.h:41
Blam::Globals::EngineGlobal::short_value
short short_value
The short value of the global.
Definition: globals.h:77
Blam::Globals::GetGlobalAsColor
BLAM BlamColor * GetGlobalAsColor(std::string name)
Retrieves a global's value as a BlamColor.
Definition: globals.cpp:419
Blam::Globals::String
@ String
Represents a std::string.
Definition: globals.h:48
Blam::Globals::EngineGlobal
Structure containing data for a game engine global.
Definition: globals.h:64
Blam::Globals::Float
@ Float
Represents a float.
Definition: globals.h:50
Blam::Globals::EngineGlobal::long_value
long long_value
The long value of the global.
Definition: globals.h:78
Blam::Globals::GvarUpdateResult
GvarUpdateResult
Enumerator for the result of a global update attempt.
Definition: globals.h:28
Blam::Globals::GetGlobalAsShort
BLAM short * GetGlobalAsShort(std::string name)
Retrieves a global's value as a short.
Definition: globals.cpp:371
Blam::Globals::InvalidType
@ InvalidType
The provided value was of an invalid type.
Definition: globals.h:30
Blam::Globals::Object
@ Object
Unknown. Referenced within the hs_doc from Halo 2 Sapien.
Definition: globals.h:47
Blam::Globals::Short
@ Short
Represents a short.
Definition: globals.h:45
Blam::Globals::EngineGlobal::int_value
int int_value
The int value of the global.
Definition: globals.h:79
Blam::Globals::GetGlobalsList
BLAM std::map< std::string, EngineGlobal > * GetGlobalsList()
Retrieves the list of loaded globals.
Definition: globals.cpp:22
Blam::Globals::OutOfBounds
@ OutOfBounds
The provided value was too small or too large for the globals' data type.
Definition: globals.h:34
Blam::Globals::GetGlobalAsLong
BLAM long * GetGlobalAsLong(std::string name)
Retrieves a global's value as a long.
Definition: globals.cpp:383
Blam::Globals::Color
@ Color
Represents a BlamColor. See #BlamColor for details.
Definition: globals.h:51
BLAM
#define BLAM
Definition: globals.h:13
Blam::Globals::Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:43
Blam::Globals::GetGlobalAsString
BLAM std::string * GetGlobalAsString(std::string name)
Retrieves a global's value as a string.
Definition: globals.cpp:359
Blam::Globals::EngineGlobal::value_raw
std::string value_raw
The raw value of the global as a string.
Definition: globals.h:69
Blam::Globals::EngineGlobal::type
GvarType type
The type of the global.
Definition: globals.h:66
Blam::Globals::Ok
@ Ok
The global was updated successfully.
Definition: globals.h:32
Blam::Globals::GetGlobalAsBoolean
BLAM bool * GetGlobalAsBoolean(std::string name)
Retrieves a global's value as a boolean.
Definition: globals.cpp:347
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::EngineGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: globals.h:76
Blam::Globals::UpdateGlobal
BLAM GvarUpdateResult UpdateGlobal(std::string name, std::string new_value)
Updates the value of a String global.
Definition: globals.cpp:578
Blam::Globals::GetGvarTypeLabel
BLAM std::string GetGvarTypeLabel(GvarType type)
Retrieves a string representation of a global's type, for use in UI.
Definition: globals.cpp:40
Blam::Globals::GetGlobalAsInteger
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:395