Codechange: Use EnumBitSet for ScriptConfigFlags. (#13669)

This commit is contained in:
Peter Nelson
2025-02-28 18:57:40 +00:00
committed by GitHub
parent e70f20a781
commit 94783fe2ed
7 changed files with 39 additions and 38 deletions

View File

@@ -17,15 +17,16 @@
/** Maximum of 10 digits for MIN / MAX_INT32, 1 for the sign and 1 for '\0'. */
static const int INT32_DIGITS_WITH_SIGN_AND_TERMINATION = 10 + 1 + 1;
/** Bitmask of flags for Script settings. */
enum ScriptConfigFlags : uint8_t {
SCRIPTCONFIG_NONE = 0x0, ///< No flags set.
/** Flags for Script settings. */
enum class ScriptConfigFlag : uint8_t {
// Unused flag 0x1.
SCRIPTCONFIG_BOOLEAN = 0x2, ///< This value is a boolean (either 0 (false) or 1 (true) ).
SCRIPTCONFIG_INGAME = 0x4, ///< This setting can be changed while the Script is running.
SCRIPTCONFIG_DEVELOPER = 0x8, ///< This setting will only be visible when the Script development tools are active.
Boolean = 1, ///< This value is a boolean (either 0 (false) or 1 (true) ).
InGame = 2, ///< This setting can be changed while the Script is running.
Developer = 3, ///< This setting will only be visible when the Script development tools are active.
};
using ScriptConfigFlags = EnumBitSet<ScriptConfigFlag, uint8_t>;
typedef std::map<int, std::string> LabelMapping; ///< Map-type used to map the setting numbers to labels.
/** Info about a single Script setting. */
@@ -36,7 +37,7 @@ struct ScriptConfigItem {
int max_value = 1; ///< The maximal value this configuration setting can have.
int default_value = 0; ///< The default value of this configuration setting.
int step_size = 1; ///< The step size in the gui.
ScriptConfigFlags flags = SCRIPTCONFIG_NONE; ///< Flags for the configuration setting.
ScriptConfigFlags flags{}; ///< Flags for the configuration setting.
LabelMapping labels; ///< Text labels for the integer values.
bool complete_labels = false; ///< True if all values have a label.