|
| void | add (std::string_view name, VarValue default_value, std::string_view description, VarFlags flags={}) |
| | Declares a variable, at its default.
|
| |
| template<std::same_as< bool > Bool> |
| void | add (std::string_view name, Bool default_value, std::string_view description, VarFlags flags={}) |
| | Declares a boolean variable.
|
| |
template<std::integral Integer>
requires (!std::same_as<Integer, bool>) |
| void | add (std::string_view name, Integer default_value, std::string_view description, VarFlags flags={}) |
| | Declares a variable from an integer, kept as a 64-bit integer.
|
| |
| void | add (std::string_view name, const char *default_value, std::string_view description, VarFlags flags={}) |
| | Declares a text variable from a C string.
|
| |
| bool | contains (std::string_view name) const |
| | Tells whether a variable is declared.
|
| |
| const VarInfo & | info (std::string_view name) const |
| | A variable, as declared, with its value now.
|
| |
| template<typename Value > |
| const Value & | get (std::string_view name) const |
| | Value of a variable, in its type.
|
| |
| std::string | text (std::string_view name) const |
| | Value of a variable as text, as set_text() reads it back.
|
| |
| VarResult | set (std::string_view name, VarValue value) |
| | Changes a variable, in its type; an integer sets a number too.
|
| |
| VarResult | set_text (std::string_view name, std::string_view text) |
| | Changes a variable from text, as a console or a command line gives it.
|
| |
| void | reset (std::string_view name) |
| | Puts a variable back at its default, whatever its flags.
|
| |
| void | reset_all () |
| | Puts every variable back at its default.
|
| |
| void | set_cheats (bool enabled) noexcept |
| | Turns cheats on or off; cheat variables keep their values.
|
| |
| bool | cheats () const noexcept |
| | Tells whether cheats are on.
|
| |
| std::vector< std::string_view > | names () const |
| | Names of the variables, in alphabetical order.
|
| |
| std::size_t | size () const noexcept |
| | Number of variables.
|
| |
The settings a console reads and changes by name while the game runs.
Each variable has a name (lower case letters, digits, _ and ., starting with a letter: r_vsync, net.rate), a type fixed when it is declared, a default, a description and flags. Values change in their own type, or from text as a console or a command line gives them (set_text()): 1, 0, true, false, on or off for a boolean, a whole number for an integer (an integer is a number too), any number, read the same in every locale, for a number, and the text itself for a text. A read-only variable keeps its default, and a cheat changes only while cheats are on. Not thread-safe: use it from the game thread.
variables.
add(
"player_speed", 300.0,
"Player speed, in pixels per second", {.cheat =
true});
variables.
set_text(
"player_speed",
"450");
const double speed = variables.
get<
double>(
"player_speed");
The settings a console reads and changes by name while the game runs.
Definition console_variables.hpp:80
const Value & get(std::string_view name) const
Value of a variable, in its type.
Definition console_variables.hpp:147
VarResult set_text(std::string_view name, std::string_view text)
Changes a variable from text, as a console or a command line gives it.
void add(std::string_view name, VarValue default_value, std::string_view description, VarFlags flags={})
Declares a variable, at its default.