diff --git a/doc/angelscript/CVarClass.h b/doc/angelscript/CVarClass.h new file mode 100644 index 0000000000..88cec7eb47 --- /dev/null +++ b/doc/angelscript/CVarClass.h @@ -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; } +}; diff --git a/doc/angelscript/ConsoleClass.h b/doc/angelscript/ConsoleClass.h new file mode 100644 index 0000000000..f52bbe754f --- /dev/null +++ b/doc/angelscript/ConsoleClass.h @@ -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); +}; diff --git a/doc/angelscript/SettingsClass.h b/doc/angelscript/SettingsClass.h deleted file mode 100644 index 4327fac3f7..0000000000 --- a/doc/angelscript/SettingsClass.h +++ /dev/null @@ -1,24 +0,0 @@ - - -/** - * @brief A class that gives you access to the RoR.cfg file. - * @note The settings object is already created for you, you don't need to create it yourself. - * E.g.: you can get a setting using settings.getSetting("Nickname"); - */ -class SettingsClass -{ -public: - /** - * Gets a setting from the RoR.cfg file. - * @param key the name of the setting - * @return The current value of the setting - */ - string getSetting(string key); - - /** - * Sets a setting in the RoR.cfg file. - * @param key the name of the setting - * @param value The new value for the setting - */ - void setSetting(string key, string value); -};