Codechange: split off the settings saveload code from the main settings handling logic

This commit is contained in:
Rubidium
2021-07-05 20:14:28 +02:00
committed by rubidium42
parent 25ca6a75bc
commit 7e7a4aad72
4 changed files with 204 additions and 183 deletions

View File

@@ -302,6 +302,16 @@ struct NullSettingDesc : SettingDesc {
typedef std::variant<IntSettingDesc, BoolSettingDesc, OneOfManySettingDesc, ManyOfManySettingDesc, StringSettingDesc, ListSettingDesc, NullSettingDesc> SettingVariant;
/**
* Helper to convert the type of the iterated settings description to a pointer to it.
* @param desc The type of the iterator of the value in SettingTable.
* @return The actual pointer to SettingDesc.
*/
static constexpr const SettingDesc *GetSettingDesc(const SettingVariant &desc)
{
return std::visit([](auto&& arg) -> const SettingDesc * { return &arg; }, desc);
}
const SettingDesc *GetSettingFromName(const std::string_view name);
void GetSettingSaveLoadByPrefix(const std::string_view prefix, std::vector<SaveLoad> &saveloads);
bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame = false);