From 6fcb1569898758a53919a0f7c613db209d96170d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 17 Sep 2015 20:11:30 +0100 Subject: [PATCH 1/3] Add generic mechanism to cross-ref settings at load time. This is useful for loading settings from legacy/special versions, where the corresponding setting is somewhere else and/or a PATX setting, with duplicating all the info. (cherry picked from commit b5c453b21eaa9c9bff76bfb2e950d05ef7987ed7) --- src/settings.cpp | 46 ++++++++++++++++++++++++++++++----- src/settings_internal.h | 3 ++- src/table/settings.h.preamble | 15 +++++++----- src/table/settings.ini | 2 ++ 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 183c9f4dd8..1c60215960 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2045,24 +2045,27 @@ bool SetSettingValue(uint index, const char *value, bool force_newgame) /** * Given a name of setting, return a setting description of it. - * @param name Name of the setting to return a setting description of - * @param i Pointer to an integer that will contain the index of the setting after the call, if it is successful. + * @param name Name of the setting to return a setting description of + * @param i Pointer to an integer that will contain the index of the setting after the call, if it is successful. + * @param ignore_version Return a setting even if it not valid for the current savegame version * @return Pointer to the setting description of setting \a name if it can be found, * \c NULL indicates failure to obtain the description */ -const SettingDesc *GetSettingFromName(const char *name, uint *i) +const SettingDesc *GetSettingFromName(const char *name, uint *i, bool ignore_version) { const SettingDesc *sd; /* First check all full names */ for (*i = 0, sd = _settings; sd->save.cmd != SL_END; sd++, (*i)++) { - if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; + if (sd->desc.name == NULL) continue; + if (!ignore_version && !SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; if (strcmp(sd->desc.name, name) == 0) return sd; } /* Then check the shortcut variant of the name. */ for (*i = 0, sd = _settings; sd->save.cmd != SL_END; sd++, (*i)++) { - if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; + if (sd->desc.name == NULL) continue; + if (!ignore_version && !SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; const char *short_name = strchr(sd->desc.name, '.'); if (short_name != NULL) { short_name++; @@ -2073,7 +2076,8 @@ const SettingDesc *GetSettingFromName(const char *name, uint *i) if (strncmp(name, "company.", 8) == 0) name += 8; /* And finally the company-based settings */ for (*i = 0, sd = _company_settings; sd->save.cmd != SL_END; sd++, (*i)++) { - if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; + if (sd->desc.name == NULL) continue; + if (!ignore_version && !SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; if (strcmp(sd->desc.name, name) == 0) return sd; } @@ -2185,6 +2189,29 @@ void IConsoleListSettings(const char *prefilter) IConsolePrintF(CC_WARNING, "Use 'setting' command to change a value"); } +/** + * Load handler for settings, which don't go in the PATX chunk, and which are a cross-reference to another setting + * @param osd SettingDesc struct containing all information + * @param object can be either NULL in which case we load global variables or + * a pointer to a struct which is getting saved + */ +static void LoadSettingsXref(const SettingDesc *osd, void *object) { + DEBUG(sl, 3, "PATS chunk: Loading xref setting: '%s'", osd->xref); + uint index = 0; + const SettingDesc *setting_xref = GetSettingFromName(osd->xref, &index, true); + assert(setting_xref != NULL); + + // Generate a new SaveLoad from the xref target using the version params from the source + SaveLoad sld = setting_xref->save; + sld.version_from = osd->save.version_from; + sld.version_to = osd->save.version_to; + sld.ext_feature_test = osd->save.ext_feature_test; + void *ptr = GetVariableAddress(object, &sld); + + if (!SlObjectMember(ptr, &sld)) return; + if (IsNumericType(sld.conv)) Write_ValidateSetting(ptr, setting_xref, ReadValue(ptr, sld.conv)); +} + /** * Save and load handler for settings, except for those which go in the PATX chunk * @param osd SettingDesc struct containing all information @@ -2193,9 +2220,15 @@ void IConsoleListSettings(const char *prefilter) */ static void LoadSettings(const SettingDesc *osd, void *object) { + extern uint16 _sl_version; + for (; osd->save.cmd != SL_END; osd++) { if (osd->patx_name != NULL) continue; const SaveLoad *sld = &osd->save; + if (osd->xref != NULL) { + if (sld->ext_feature_test.IsFeaturePresent(_sl_version, sld->version_from, sld->version_to)) LoadSettingsXref(osd, object); + continue; + } void *ptr = GetVariableAddress(object, sld); if (!SlObjectMember(ptr, sld)) continue; @@ -2217,6 +2250,7 @@ static void SaveSettings(const SettingDesc *sd, void *object) size_t length = 0; for (i = sd; i->save.cmd != SL_END; i++) { if (i->patx_name != NULL) continue; + if (i->xref != NULL) continue; length += SlCalcObjMemberLength(object, &i->save); } SlSetLength(length); diff --git a/src/settings_internal.h b/src/settings_internal.h index e356e7e5e6..2f0021392f 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -112,6 +112,7 @@ struct SettingDesc { SettingDescBase desc; ///< Settings structure (going to configuration file) SaveLoad save; ///< Internal structure (going to savegame, parts to config) const char *patx_name; ///< Name to save/load setting from in PATX chunk, if NULL save/load from PATS chunk as normal + const char *xref; ///< Name of SettingDesc to use instead of the contents of this one, useful for loading legacy savegames, if NULL save/load as normal bool IsEditable(bool do_command = false) const; SettingType GetType() const; @@ -126,7 +127,7 @@ struct SettingDesc { * offset in a certain struct */ typedef SettingDesc SettingDescGlobVarList; -const SettingDesc *GetSettingFromName(const char *name, uint *i); +const SettingDesc *GetSettingFromName(const char *name, uint *i, bool ignore_version = false); bool SetSettingValue(uint index, int32 value, bool force_newgame = false); bool SetSettingValue(uint index, const char *value, bool force_newgame = false); void SetCompanySetting(uint index, int32 value); diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index ed67d43c30..9e78a500ff 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -62,7 +62,7 @@ static size_t ConvertLandscape(const char *value); /* Macros for various objects to go in the configuration file. * This section is for global variables */ #define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ - {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, NULL, cat), SLEG_GENERAL_X(sle_cmd, var, type | flags, length, from, to, extver), patxname} + {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, NULL, cat), SLEG_GENERAL_X(sle_cmd, var, type | flags, length, from, to, extver), patxname, NULL} #define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname) @@ -83,14 +83,14 @@ static size_t ConvertLandscape(const char *value); SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strhelp, strval, proc, from, to, cat, extver, patxname) #define SDTG_NULL(length, from, to, extver)\ - {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_NULL_X(length, from, to, extver), NULL} + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_NULL_X(length, from, to, extver), NULL, NULL} -#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_END(), NULL} +#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_END(), NULL, NULL} /* Macros for various objects to go in the configuration file. * This section is for structures where their various members are saved */ #define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extver, patxname)\ - {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat), SLE_GENERAL_X(sle_cmd, base, var, type | flags, length, from, to, extver), patxname} + {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat), SLE_GENERAL_X(sle_cmd, base, var, type | flags, length, from, to, extver), patxname, NULL} #define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname) @@ -114,7 +114,7 @@ static size_t ConvertLandscape(const char *value); SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname) #define SDT_NULL(length, from, to, extver)\ - {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(length, from, to, extver), NULL} + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(length, from, to, extver), NULL, NULL} #define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ @@ -132,5 +132,8 @@ static size_t ConvertLandscape(const char *value); #define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, from, to, cat, extver, patxname) -#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_END(), NULL} +#define SDT_XREF(from, to, extver, xref)\ + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(0, from, to, extver), NULL, xref} + +#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_END(), NULL, NULL} diff --git a/src/table/settings.ini b/src/table/settings.ini index 8d7826d7c7..e223ff1a7c 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -77,6 +77,7 @@ SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDT_NULL = SDT_NULL($length, $from, $to, $extver), +SDT_XREF = SDT_XREF( $from, $to, $extver, $xref), SDT_END = SDT_END() [defaults] @@ -93,6 +94,7 @@ to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() patxname = NULL +xref = From 46050820c5cfc602bd8bc7475a366ce53d29d54c Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 31 Aug 2015 09:58:10 +0100 Subject: [PATCH 2/3] Fix missing template definition in company_settings. (cherry picked from commit 6e505ceab154bc961b34152d8928b1adaae662d9) --- src/table/company_settings.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index 8296890a74..ba3148e568 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -20,6 +20,7 @@ static const SettingDesc _company_settings[] = { [templates] SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), +SDT_NULL = SDT_NULL($length, $from, $to, $extver), SDT_END = SDT_END() [defaults] From a3d15858263a78a828a3aa0664b033d9949d01aa Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 20 Aug 2017 01:39:49 +0100 Subject: [PATCH 3/3] Add settings callback field to re-order setting options in GUI --- src/settings_gui.cpp | 4 +++- src/settings_internal.h | 2 ++ src/table/company_settings.ini | 3 ++- src/table/currency_settings.ini | 3 ++- src/table/gameopt_settings.ini | 5 +++-- src/table/misc_settings.ini | 3 ++- src/table/settings.h.preamble | 36 +++++++++++++++++++-------------- src/table/settings.ini | 11 +++++++--- src/table/win32_settings.ini | 2 +- src/table/window_settings.ini | 3 ++- 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 0420ba15b3..b0dabeb41d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2092,7 +2092,9 @@ struct GameSettingsWindow : Window { DropDownList *list = new DropDownList(); for (int i = sdb->min; i <= (int)sdb->max; i++) { - *list->Append() = new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false); + int val = sd->orderproc ? sd->orderproc(i - sdb->min) : i; + assert_msg(val >= sdb->min && val <= (int)sdb->max, "min: %d, max: %d, val: %d", sdb->min, sdb->max, val); + *list->Append() = new DropDownListStringItem(sdb->str_val + val - sdb->min, val, false); } ShowDropDownListAt(this, list, value, -1, wi_rect, COLOUR_ORANGE, true); diff --git a/src/settings_internal.h b/src/settings_internal.h index 2f0021392f..4838bef805 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -89,6 +89,7 @@ enum SettingType { typedef bool OnChange(int32 var); ///< callback prototype on data modification typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error +typedef int OnGuiOrder(uint nth); ///< callback prototype for GUI ordering /** Properties of config file settings. */ struct SettingDescBase { @@ -113,6 +114,7 @@ struct SettingDesc { SaveLoad save; ///< Internal structure (going to savegame, parts to config) const char *patx_name; ///< Name to save/load setting from in PATX chunk, if NULL save/load from PATS chunk as normal const char *xref; ///< Name of SettingDesc to use instead of the contents of this one, useful for loading legacy savegames, if NULL save/load as normal + OnGuiOrder *orderproc; ///< Callback procedure for GUI re-ordering bool IsEditable(bool do_command = false) const; SettingType GetType() const; diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index ba3148e568..92d8b30ae8 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -19,7 +19,7 @@ static const SettingDesc _company_settings[] = { }; [templates] SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname, $orderproc), SDT_NULL = SDT_NULL($length, $from, $to, $extver), SDT_END = SDT_END() @@ -37,6 +37,7 @@ to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() patxname = NULL +orderproc = NULL diff --git a/src/table/currency_settings.ini b/src/table/currency_settings.ini index 6a8665379a..94e568f7b2 100644 --- a/src/table/currency_settings.ini +++ b/src/table/currency_settings.ini @@ -11,7 +11,7 @@ static const SettingDesc _currency_settings[] = { [post-amble] }; [templates] -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDT_CHR = SDT_CHR($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDT_END = SDT_END() @@ -29,6 +29,7 @@ from = 0 to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() +orderproc = NULL diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini index a5bc766ecb..798a6c9083 100644 --- a/src/table/gameopt_settings.ini +++ b/src/table/gameopt_settings.ini @@ -42,12 +42,12 @@ static const SettingDesc _gameopt_settings[] = { }; [templates] SDTG_GENERAL = SDTG_GENERAL($name, $sdt_cmd, $sle_cmd, $type, $flags, $guiflags, $var, $length, $def, $min, $max, $interval, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDT_NULL = SDT_NULL($length, $from, $to, $extver), SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extver, NULL), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDT_END = SDT_END() [defaults] @@ -63,6 +63,7 @@ from = 0 to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() +orderproc = NULL diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini index 06bae18013..401d952bab 100644 --- a/src/table/misc_settings.ini +++ b/src/table/misc_settings.ini @@ -20,7 +20,7 @@ SDTG_MMANY = SDTG_MMANY($name, $type, $flags, $guiflags, $var, $def, SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDTG_STR = SDTG_STR($name, $type, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDTG_END = SDTG_END() [defaults] @@ -36,6 +36,7 @@ from = 0 to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() +orderproc = NULL diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index 9e78a500ff..8e53410de6 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -61,11 +61,14 @@ static size_t ConvertLandscape(const char *value); /* Macros for various objects to go in the configuration file. * This section is for global variables */ -#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ - {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, NULL, cat), SLEG_GENERAL_X(sle_cmd, var, type | flags, length, from, to, extver), patxname, NULL} +#define SDTG_GENERAL2(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc)\ + {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, NULL, cat), SLEG_GENERAL_X(sle_cmd, var, type | flags, length, from, to, extver), patxname, NULL, orderproc} -#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ - SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname) +#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ + SDTG_GENERAL2(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extver, patxname, NULL) + +#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc)\ + SDTG_GENERAL2(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc) #define SDTG_BOOL(name, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname) @@ -83,17 +86,20 @@ static size_t ConvertLandscape(const char *value); SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strhelp, strval, proc, from, to, cat, extver, patxname) #define SDTG_NULL(length, from, to, extver)\ - {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_NULL_X(length, from, to, extver), NULL, NULL} + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_NULL_X(length, from, to, extver), NULL, NULL, NULL} -#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_END(), NULL, NULL} +#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLEG_END(), NULL, NULL, NULL} /* Macros for various objects to go in the configuration file. * This section is for structures where their various members are saved */ -#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extver, patxname)\ - {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat), SLE_GENERAL_X(sle_cmd, base, var, type | flags, length, from, to, extver), patxname, NULL} +#define SDT_GENERAL2(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extver, patxname, orderproc)\ + {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat), SLE_GENERAL_X(sle_cmd, base, var, type | flags, length, from, to, extver), patxname, NULL, orderproc} -#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ - SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname) +#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extver, patxname)\ + SDT_GENERAL2(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extver, patxname, NULL) + +#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc)\ + SDT_GENERAL2(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname, orderproc) #define SDT_BOOL(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, NULL, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname) @@ -114,11 +120,11 @@ static size_t ConvertLandscape(const char *value); SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, strhelp, strval, proc, NULL, from, to, cat, extver, patxname) #define SDT_NULL(length, from, to, extver)\ - {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(length, from, to, extver), NULL, NULL} + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(length, from, to, extver), NULL, NULL, NULL} -#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ - SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname) +#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc)\ + SDTG_GENERAL2(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname, orderproc) #define SDTC_BOOL(var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extver, patxname)\ SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, NULL, str, strhelp, strval, proc, from, to, cat, extver, patxname) @@ -133,7 +139,7 @@ static size_t ConvertLandscape(const char *value); SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, from, to, cat, extver, patxname) #define SDT_XREF(from, to, extver, xref)\ - {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(0, from, to, extver), NULL, xref} + {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_CONDNULL_X(0, from, to, extver), NULL, xref, NULL} -#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_END(), NULL, NULL} +#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, STR_NULL, NULL, NULL, SC_NONE}, SLE_END(), NULL, NULL, NULL} diff --git a/src/table/settings.ini b/src/table/settings.ini index e223ff1a7c..459ae21888 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -51,6 +51,10 @@ static bool UpdateClientConfigValues(int32 p1); #endif /* ENABLE_NETWORK */ /* End - Callback Functions for the various settings */ +/* Begin - GUI order callbacks */ + +/* End - GUI order callbacks */ + /* Some settings do not need to be synchronised when playing in multiplayer. * These include for example the GUI settings and will not be saved with the * savegame. @@ -65,17 +69,17 @@ const SettingDesc _settings[] = { }; [templates] SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname, $orderproc), SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDTC_LIST = SDTC_LIST( $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDTC_STR = SDTC_STR( $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), -SDTC_VAR = SDTC_VAR( $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), +SDTC_VAR = SDTC_VAR( $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname, $orderproc), SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extver, $patxname), SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, $patxname, $orderproc), SDT_NULL = SDT_NULL($length, $from, $to, $extver), SDT_XREF = SDT_XREF( $from, $to, $extver, $xref), SDT_END = SDT_END() @@ -95,6 +99,7 @@ cat = SC_ADVANCED extver = SlXvFeatureTest() patxname = NULL xref = +orderproc = NULL diff --git a/src/table/win32_settings.ini b/src/table/win32_settings.ini index a22e1a54e7..9c576c6b8e 100644 --- a/src/table/win32_settings.ini +++ b/src/table/win32_settings.ini @@ -18,7 +18,7 @@ static const SettingDescGlobVarList _win32_settings[] = { #endif /* WIN32 */ [templates] SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDTG_END = SDTG_END() [defaults] diff --git a/src/table/window_settings.ini b/src/table/window_settings.ini index a7b1742040..f2e8f0111e 100644 --- a/src/table/window_settings.ini +++ b/src/table/window_settings.ini @@ -13,7 +13,7 @@ static const SettingDesc _window_settings[] = { }; [templates] SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extver, NULL, $orderproc), SDT_END = SDT_END() [defaults] @@ -30,6 +30,7 @@ from = 0 to = SL_MAX_VERSION cat = SC_ADVANCED extver = SlXvFeatureTest() +orderproc = NULL