 |
Blamite Game Engine - blam!
00272.10.26.20.0001.blamite
The core library for the Blamite Game Engine.
|
Go to the documentation of this file.
7 #include <Strings/components/utils/string/string.h>
9 #define GVARS_FILE "./globals.xml"
59 return std::string(std::to_string(
r) +
"," + std::to_string(
g) +
"," + std::to_string(
b) +
"," + std::to_string(
a));
120 std::string new_string = format;
122 new_string = BlamStrings::Utils::String::Replace(new_string,
"{r}", std::to_string(
r));
123 new_string = BlamStrings::Utils::String::Replace(new_string,
"{g}", std::to_string(
g));
124 new_string = BlamStrings::Utils::String::Replace(new_string,
"{b}", std::to_string(
b));
125 new_string = BlamStrings::Utils::String::Replace(new_string,
"{a}", std::to_string(
a));
127 double r_float = (double)
r / 255.0f;
128 double g_float = (double)
g / 255.0f;
129 double b_float = (double)
b / 255.0f;
130 double a_float = (double)
a / 255.0f;
132 new_string = BlamStrings::Utils::String::Replace(new_string,
"{r>f}", std::to_string(r_float));
133 new_string = BlamStrings::Utils::String::Replace(new_string,
"{g>f}", std::to_string(g_float));
134 new_string = BlamStrings::Utils::String::Replace(new_string,
"{b>f}", std::to_string(b_float));
135 new_string = BlamStrings::Utils::String::Replace(new_string,
"{a>f}", std::to_string(a_float));
147 return ToString(
"rgba({r},{g},{b},{a>f})");
161 std::vector<std::string> color_values = BlamStrings::Utils::String::Split(
string,
",");
163 if (color_values.size() == 3)
165 r = atoi(color_values.at(0).c_str());
166 g = atoi(color_values.at(1).c_str());
167 b = atoi(color_values.at(2).c_str());
172 else if (color_values.size() == 4)
174 r = atoi(color_values.at(0).c_str());
175 g = atoi(color_values.at(1).c_str());
176 b = atoi(color_values.at(2).c_str());
177 a = atoi(color_values.at(3).c_str());
Namespace surrounding all major engine components.
Definition: blam_api.h:18
BlamColor()
Definition: globals.h:28
BLAM void RegisterGvar(EngineGlobal var)
Registers a new engine global.
Definition: globals.cpp:65
BLAM EngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:193
BLAM bool GlobalExists(std::string id)
Determines whether or not a global exists.
Definition: globals.cpp:27
float float_value
The float value of the global.
Definition: globals.h:250
std::string info
An optional description of the global.
Definition: globals.h:238
@ Int
Represents an int.
Definition: globals.h:219
BlamColor color_value
The color value of the global.
Definition: globals.h:251
short g
The Green value of the color.
Definition: globals.h:24
@ UnknownGlobal
The specified global does not exist.
Definition: globals.h:201
@ Long
Represents a long.
Definition: globals.h:216
@ GlobalIsProtected
The specified global is protected and cannot be modified during runtime.
Definition: globals.h:205
BLAM bool LoadGlobalsFromFile()
Loads any globals from GVARS_FILE.
Definition: globals.cpp:206
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:399
@ InvalidArgs
The provided arguments were invalid.
Definition: globals.h:203
@ Real
Unknown. Referenced within the hs_doc from Halo 2 Sapien.
Definition: globals.h:214
BLAM GvarUpdateResult UpdateGlobalWrap(std::string name, std::string new_value)
Updates a global's raw value.
Definition: globals.cpp:427
bool read_only
Whether or not the global is protected from modification.
Definition: globals.h:240
std::string name
The name of the global.
Definition: globals.h:237
GvarType
Enumerator for the type of global variable.
Definition: globals.h:211
short short_value
The short value of the global.
Definition: globals.h:247
BLAM BlamColor * GetGlobalAsColor(std::string name)
Retrieves a global's value as a BlamColor.
Definition: globals.cpp:411
short a
The Alpha value of the color.
Definition: globals.h:26
@ String
Represents a std::string.
Definition: globals.h:218
short r
The Red value of the color.
Definition: globals.h:23
#define BLAM
Definition: globals.h:12
Structure containing data for a game engine global.
Definition: globals.h:234
@ Float
Represents a float.
Definition: globals.h:220
long long_value
The long value of the global.
Definition: globals.h:248
GvarUpdateResult
Enumerator for the result of a global update attempt.
Definition: globals.h:198
BLAM short * GetGlobalAsShort(std::string name)
Retrieves a global's value as a short.
Definition: globals.cpp:363
BlamColor(short _r, short _g, short _b)
Definition: globals.h:36
@ InvalidType
The provided value was of an invalid type.
Definition: globals.h:200
short b
The Blue value of the color.
Definition: globals.h:25
@ Object
Unknown. Referenced within the hs_doc from Halo 2 Sapien.
Definition: globals.h:217
@ Short
Represents a short.
Definition: globals.h:215
float GetBlueAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: globals.h:87
int int_value
The int value of the global.
Definition: globals.h:249
BLAM std::map< std::string, EngineGlobal > * GetGlobalsList()
Retrieves the list of loaded globals.
Definition: globals.cpp:22
@ OutOfBounds
The provided value was too small or too large for the globals' data type.
Definition: globals.h:204
BLAM long * GetGlobalAsLong(std::string name)
Retrieves a global's value as a long.
Definition: globals.cpp:375
@ Color
Represents a BlamColor. See BlamColor for details.
Definition: globals.h:221
float GetRedAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: globals.h:67
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:213
float GetGreenAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: globals.h:77
BLAM std::string * GetGlobalAsString(std::string name)
Retrieves a global's value as a string.
Definition: globals.cpp:351
std::string ToString()
Converts the color value to a string.
Definition: globals.h:57
std::string value_raw
The raw value of the global as a string.
Definition: globals.h:239
std::string ToStringForCSS()
Converts the color to a string that can be used with CSS.
Definition: globals.h:145
bool FromString(std::string string)
Attempts to set color information from a string.
Definition: globals.h:159
std::string ToString(std::string format)
Converts the color value to a string in the specified format.
Definition: globals.h:118
BlamColor(short _r, short _g, short _b, short _a)
Definition: globals.h:44
float GetAlphaAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: globals.h:97
Structure representing a color.
Definition: globals.h:20
GvarType type
The type of the global.
Definition: globals.h:236
@ Ok
The global was updated successfully.
Definition: globals.h:202
BLAM bool * GetGlobalAsBoolean(std::string name)
Retrieves a global's value as a boolean.
Definition: globals.cpp:339
bool boolean_value
The boolean value of the global.
Definition: globals.h:246
BLAM GvarUpdateResult UpdateGlobal(std::string name, std::string new_value)
Updates the value of a String global.
Definition: globals.cpp:570
BLAM std::string GetGvarTypeLabel(GvarType type)
Retrieves a string representation of a global's type, for use in UI.
Definition: globals.cpp:40
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:387