-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📚 Added scripting doc for console + cvars
- Loading branch information
Showing
3 changed files
with
69 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
/** | ||
* @brief Types and special attributes of cvars. | ||
* @note Default cvar type is string - To create a string cvar, enter '0' as flags. | ||
*/ | ||
enum CVarFlags | ||
{ | ||
CVAR_TYPE_BOOL = BITMASK(1), | ||
CVAR_TYPE_INT = BITMASK(2), | ||
CVAR_TYPE_FLOAT = BITMASK(3), | ||
CVAR_ARCHIVE = BITMASK(4), //!< Will be written to RoR.cfg | ||
CVAR_NO_LOG = BITMASK(5) //!< Will not be written to RoR.log | ||
}; | ||
|
||
/** | ||
* @brief A console variable, usually defined in RoR.cfg but also created by users or scripts. | ||
*/ | ||
class CVarClass | ||
{ | ||
public: | ||
|
||
/** | ||
* @brief Get the value converted to string, works with any CVAR_TYPE. | ||
*/ | ||
std::string const& getStr() const { return m_value_str; } | ||
|
||
float getFloat() const { return m_value_num; } | ||
|
||
int getInt() const { return (int)m_value_num; } | ||
|
||
bool getBool() const { return (bool)m_value_num; } | ||
|
||
std::string const& getName() const { return m_name; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
|
||
/** | ||
* @brief A class that gives you access to console variables (cvars), usually defined in RoR.cfg file. | ||
* @note This object is created automatically as global variable `console`. | ||
*/ | ||
class ConsoleClass | ||
{ | ||
public: | ||
/** | ||
* @brief Add CVar and parse default value if specified | ||
*/ | ||
CVar* cVarCreate(std::string const& name, std::string const& long_name, | ||
int flags, std::string const& val = std::string()); | ||
|
||
/** | ||
* Parse value by cvar type | ||
*/ | ||
void cVarAssign(CVar* cvar, std::string const& value); | ||
|
||
/** | ||
* Find cvar by short/long name | ||
*/ | ||
CVar* cVarFind(std::string const& input_name); | ||
|
||
/** | ||
* Set existing cvar by short/long name. Return the modified cvar (or NULL if not found) | ||
*/ | ||
CVar* cVarSet(std::string const& input_name, std::string const& input_val); | ||
|
||
/** | ||
* Get cvar by short/long name, or create new one using input as short name. | ||
*/ | ||
CVar* cVarGet(std::string const& input_name, int flags); | ||
}; |
This file was deleted.
Oops, something went wrong.