diff options
author | Patric Stout <truebrain@openttd.org> | 2021-06-03 21:18:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 21:18:29 +0200 |
commit | feb2ddbefa5f6f702b996b00dfd92db53a52d174 (patch) | |
tree | 857856c235701578fe44dc862c0b60fd415761bc /src/settings_internal.h | |
parent | 28e90769f74e55ea7c8f75146d5b33e0aa777da8 (diff) | |
download | openttd-feb2ddbefa5f6f702b996b00dfd92db53a52d174.tar.xz |
Codechange: rename SettingGuiFlag to SettingFlag (#9332)
It is a lovely organicly grown enum, where it started off with
GUI-only flags, and after that a few flags got added that can be
considered GUI-only (the GUI disables/enables based on them), to
only have flags added that has nothing to do with the GUI.
So be less confusing, and rename them to what they do.
Additionally, I took this opportunity to rename 0ISDISABLED to
reflect what it really does.
Diffstat (limited to 'src/settings_internal.h')
-rw-r--r-- | src/settings_internal.h | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/settings_internal.h b/src/settings_internal.h index 632d4081d..351c66ea3 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -12,21 +12,20 @@ #include "saveload/saveload.h" -enum SettingGuiFlag : uint16 { - /* 2 bytes allocated for a maximum of 16 flags. */ - SGF_NONE = 0, - SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled - SGF_DISPLAY_ABS = 1 << 1, ///< display absolute value of the setting - SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer) - SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games - SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate - SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game - SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game - SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set) - SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct) - SGF_SCENEDIT_ONLY = 1 << 9, ///< this setting can only be changed in the scenario editor +enum SettingFlag : uint16 { + SF_NONE = 0, + SF_GUI_0_IS_SPECIAL = 1 << 0, ///< A value of zero is possible and has a custom string (the one after "strval"). + SF_GUI_NEGATIVE_IS_SPECIAL = 1 << 1, ///< A negative value has another string (the one after "strval"). + SF_GUI_DROPDOWN = 1 << 2, ///< The value represents a limited number of string-options (internally integer) presented as dropdown. + SF_GUI_CURRENCY = 1 << 3, ///< The number represents money, so when reading value multiply by exchange rate. + SF_NETWORK_ONLY = 1 << 4, ///< This setting only applies to network games. + SF_NO_NETWORK = 1 << 5, ///< This setting does not apply to network games; it may not be changed during the game. + SF_NEWGAME_ONLY = 1 << 6, ///< This setting cannot be changed in a game. + SF_SCENEDIT_TOO = 1 << 7, ///< This setting can be changed in the scenario editor (only makes sense when SF_NEWGAME_ONLY is set). + SF_SCENEDIT_ONLY = 1 << 8, ///< This setting can only be changed in the scenario editor. + SF_PER_COMPANY = 1 << 9, ///< This setting can be different for each company (saved in company struct). }; -DECLARE_ENUM_AS_BIT_SET(SettingGuiFlag) +DECLARE_ENUM_AS_BIT_SET(SettingFlag) /** * A SettingCategory defines a grouping of the settings. @@ -67,14 +66,14 @@ struct IniItem; /** Properties of config file settings. */ struct SettingDesc { - SettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup) : + SettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup) : name(name), flags(flags), startup(startup), save(save) {} virtual ~SettingDesc() {} - const char *name; ///< name of the setting. Used in configuration file and for console - SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.) - bool startup; ///< setting has to be loaded directly at startup? - SaveLoad save; ///< Internal structure (going to savegame, parts to config) + const char *name; ///< Name of the setting. Used in configuration file and for console. + SettingFlag flags; ///< Handles how a setting would show up in the GUI (text/currency, etc.). + bool startup; ///< Setting has to be loaded directly at startup?. + SaveLoad save; ///< Internal structure (going to savegame, parts to config). bool IsEditable(bool do_command = false) const; SettingType GetType() const; @@ -138,7 +137,7 @@ struct IntSettingDesc : SettingDesc { */ typedef void PostChangeCallback(int32 value); - IntSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, int32 def, + IntSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, int32 def, int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback) : SettingDesc(save, name, flags, startup), def(def), min(min), max(max), interval(interval), @@ -180,7 +179,7 @@ private: /** Boolean setting. */ struct BoolSettingDesc : IntSettingDesc { - BoolSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, bool def, + BoolSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, bool def, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback) : IntSettingDesc(save, name, flags, startup, def, 0, 1, 0, str, str_help, str_val, cat, @@ -196,7 +195,7 @@ struct BoolSettingDesc : IntSettingDesc { struct OneOfManySettingDesc : IntSettingDesc { typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error - OneOfManySettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, int32 def, + OneOfManySettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, int32 def, int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, std::initializer_list<const char *> many, OnConvert *many_cnvt) : @@ -220,7 +219,7 @@ struct OneOfManySettingDesc : IntSettingDesc { /** Many of many setting. */ struct ManyOfManySettingDesc : OneOfManySettingDesc { - ManyOfManySettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, + ManyOfManySettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, int32 def, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, std::initializer_list<const char *> many, OnConvert *many_cnvt) : @@ -249,7 +248,7 @@ struct StringSettingDesc : SettingDesc { */ typedef void PostChangeCallback(const std::string &value); - StringSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, const char *def, + StringSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, const char *def, uint32 max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) : SettingDesc(save, name, flags, startup), def(def == nullptr ? "" : def), max_length(max_length), pre_check(pre_check), post_callback(post_callback) {} @@ -275,7 +274,7 @@ private: /** List/array settings. */ struct ListSettingDesc : SettingDesc { - ListSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, const char *def) : + ListSettingDesc(SaveLoad save, const char *name, SettingFlag flags, bool startup, const char *def) : SettingDesc(save, name, flags, startup), def(def) {} virtual ~ListSettingDesc() {} @@ -289,7 +288,7 @@ struct ListSettingDesc : SettingDesc { /** Placeholder for settings that have been removed, but might still linger in the savegame. */ struct NullSettingDesc : SettingDesc { NullSettingDesc(SaveLoad save) : - SettingDesc(save, "", SGF_NONE, false) {} + SettingDesc(save, "", SF_NONE, false) {} virtual ~NullSettingDesc() {} void FormatValue(char *buf, const char *last, const void *object) const override { NOT_REACHED(); } |