|
@@ -5,34 +5,37 @@
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
/** @file settings_internal.h Functions and types used internally for the settings configurations. */
|
|
|
|
|
|
#ifndef SETTINGS_INTERNAL_H
|
|
|
#define SETTINGS_INTERNAL_H
|
|
|
|
|
|
#include "saveload/saveload.h"
|
|
|
|
|
|
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).
|
|
|
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).
|
|
|
SF_NOT_IN_SAVE = 1 << 10, ///< Do not save with savegame, basically client-based.
|
|
|
SF_NOT_IN_CONFIG = 1 << 11, ///< Do not save to config file.
|
|
|
SF_NO_NETWORK_SYNC = 1 << 12, ///< Do not synchronize over network (but it is saved if SF_NOT_IN_SAVE is not set).
|
|
|
};
|
|
|
DECLARE_ENUM_AS_BIT_SET(SettingFlag)
|
|
|
|
|
|
/**
|
|
|
* A SettingCategory defines a grouping of the settings.
|
|
|
* The group #SC_BASIC is intended for settings which also a novice player would like to change and is able to understand.
|
|
|
* The group #SC_ADVANCED is intended for settings which an experienced player would like to use. This is the case for most settings.
|
|
|
* Finally #SC_EXPERT settings only few people want to see in rare cases.
|
|
|
* The grouping is meant to be inclusive, i.e. all settings in #SC_BASIC also will be included
|
|
|
* in the set of settings in #SC_ADVANCED. The group #SC_EXPERT contains all settings.
|
|
|
*/
|
|
|
enum SettingCategory {
|
|
@@ -279,25 +282,25 @@ struct ListSettingDesc : SettingDesc {
|
|
|
virtual ~ListSettingDesc() {}
|
|
|
|
|
|
const char *def; ///< default value given when none is present
|
|
|
|
|
|
void FormatValue(char *buf, const char *last, const void *object) const override;
|
|
|
void ParseValue(const IniItem *item, void *object) const override;
|
|
|
bool IsSameValue(const IniItem *item, void *object) const override;
|
|
|
};
|
|
|
|
|
|
/** Placeholder for settings that have been removed, but might still linger in the savegame. */
|
|
|
struct NullSettingDesc : SettingDesc {
|
|
|
NullSettingDesc(SaveLoad save) :
|
|
|
SettingDesc(save, "", SF_NONE, false) {}
|
|
|
SettingDesc(save, "", SF_NOT_IN_CONFIG, false) {}
|
|
|
virtual ~NullSettingDesc() {}
|
|
|
|
|
|
void FormatValue(char *buf, const char *last, const void *object) const override { NOT_REACHED(); }
|
|
|
void ParseValue(const IniItem *item, void *object) const override { NOT_REACHED(); }
|
|
|
bool IsSameValue(const IniItem *item, void *object) const override { NOT_REACHED(); }
|
|
|
};
|
|
|
|
|
|
typedef std::initializer_list<std::unique_ptr<const SettingDesc>> SettingTable;
|
|
|
|
|
|
const SettingDesc *GetSettingFromName(const char *name);
|
|
|
void GetSettingSaveLoadByPrefix(const char *prefix, std::vector<SaveLoad> &saveloads);
|
|
|
bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame = false);
|