diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/elrail.cpp | 5 | ||||
-rw-r--r-- | src/elrail_func.h | 2 | ||||
-rw-r--r-- | src/newgrf_config.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_config.h | 2 | ||||
-rw-r--r-- | src/rail_gui.cpp | 7 | ||||
-rw-r--r-- | src/rail_gui.h | 2 | ||||
-rw-r--r-- | src/settings.cpp | 282 | ||||
-rw-r--r-- | src/settings_internal.h | 50 | ||||
-rw-r--r-- | src/table/company_settings.ini | 30 | ||||
-rw-r--r-- | src/table/currency_settings.ini | 3 | ||||
-rw-r--r-- | src/table/gameopt_settings.ini | 13 | ||||
-rw-r--r-- | src/table/misc_settings.ini | 9 | ||||
-rw-r--r-- | src/table/settings.h.preamble | 44 | ||||
-rw-r--r-- | src/table/settings.ini | 219 | ||||
-rw-r--r-- | src/table/win32_settings.ini | 7 | ||||
-rw-r--r-- | src/table/window_settings.ini | 7 |
16 files changed, 272 insertions, 416 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp index 44481dd31..4959bb2cb 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -593,9 +593,9 @@ void DrawRailCatenary(const TileInfo *ti) DrawRailCatenaryRailway(ti); } -bool SettingsDisableElrail(int32 p1) +void SettingsDisableElrail(int32 new_value) { - bool disable = (p1 != 0); + bool disable = (new_value != 0); /* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; @@ -639,5 +639,4 @@ bool SettingsDisableElrail(int32 p1) * rails. It may have unintended consequences if that function is ever * extended, though. */ ReinitGuiAfterToggleElrail(disable); - return true; } diff --git a/src/elrail_func.h b/src/elrail_func.h index 043843724..bd301d6bb 100644 --- a/src/elrail_func.h +++ b/src/elrail_func.h @@ -36,6 +36,6 @@ void DrawRailCatenary(const TileInfo *ti); void DrawRailCatenaryOnTunnel(const TileInfo *ti); void DrawRailCatenaryOnBridge(const TileInfo *ti); -bool SettingsDisableElrail(int32 p1); ///< _settings_game.disable_elrail callback +void SettingsDisableElrail(int32 new_value); ///< _settings_game.disable_elrail callback #endif /* ELRAIL_FUNC_H */ diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index b92b297da..044d36193 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -282,15 +282,13 @@ void GRFParameterInfo::Finalize() /** * Update the palettes of the graphics from the config file. * Called when changing the default palette in advanced settings. - * @param p1 Unused. - * @return Always true. + * @param new_value Unused. */ -bool UpdateNewGRFConfigPalette(int32 p1) +void UpdateNewGRFConfigPalette(int32 new_value) { for (GRFConfig *c = _grfconfig_newgame; c != nullptr; c = c->next) c->SetSuitablePalette(); for (GRFConfig *c = _grfconfig_static; c != nullptr; c = c->next) c->SetSuitablePalette(); for (GRFConfig *c = _all_grfs; c != nullptr; c = c->next) c->SetSuitablePalette(); - return true; } /** diff --git a/src/newgrf_config.h b/src/newgrf_config.h index 1588f8c3a..3b3da962e 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -239,6 +239,6 @@ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFC GRFTextWrapper FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create); void UpdateNewGRFScanStatus(uint num, const char *name); -bool UpdateNewGRFConfigPalette(int32 p1 = 0); +void UpdateNewGRFConfigPalette(int32 new_value = 0); #endif /* NEWGRF_CONFIG_H */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index e7221d01c..86f718984 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -2130,10 +2130,9 @@ static void SetDefaultRailGui() /** * Updates the current signal variant used in the signal GUI * to the one adequate to current year. - * @param p needed to be called when a setting changes - * @return success, needed for settings + * @param new_value needed to be called when a setting changes */ -bool ResetSignalVariant(int32 p) +void ResetSignalVariant(int32 new_value) { SignalVariant new_variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); @@ -2145,8 +2144,6 @@ bool ResetSignalVariant(int32 p) } _cur_signal_variant = new_variant; } - - return true; } /** diff --git a/src/rail_gui.h b/src/rail_gui.h index 29a1b9b16..81fb8f627 100644 --- a/src/rail_gui.h +++ b/src/rail_gui.h @@ -15,7 +15,7 @@ struct Window *ShowBuildRailToolbar(RailType railtype); void ReinitGuiAfterToggleElrail(bool disable); -bool ResetSignalVariant(int32 = 0); +void ResetSignalVariant(int32 = 0); void InitializeRailGUI(); DropDownList GetRailTypeDropDownList(bool for_replacement = false, bool all_option = false); diff --git a/src/settings.cpp b/src/settings.cpp index f2980a363..0160f8e0e 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -807,99 +807,56 @@ const StringSettingDesc *SettingDesc::AsStringSetting() const /* Begin - Callback Functions for the various settings. */ /** Reposition the main toolbar as the setting changed. */ -static bool v_PositionMainToolbar(int32 p1) +static void v_PositionMainToolbar(int32 new_value) { if (_game_mode != GM_MENU) PositionMainToolbar(nullptr); - return true; } /** Reposition the statusbar as the setting changed. */ -static bool v_PositionStatusbar(int32 p1) +static void v_PositionStatusbar(int32 new_value) { if (_game_mode != GM_MENU) { PositionStatusbar(nullptr); PositionNewsMessage(nullptr); PositionNetworkChatWindow(nullptr); } - return true; -} - -static bool PopulationInLabelActive(int32 p1) -{ - UpdateAllTownVirtCoords(); - return true; -} - -static bool RedrawScreen(int32 p1) -{ - MarkWholeScreenDirty(); - return true; } /** * Redraw the smallmap after a colour scheme change. * @param p1 Callback parameter. - * @return Always true. */ -static bool RedrawSmallmap(int32 p1) +static void RedrawSmallmap(int32 new_value) { BuildLandLegend(); BuildOwnerLegend(); SetWindowClassesDirty(WC_SMALLMAP); - return true; } -static bool InvalidateDetailsWindow(int32 p1) -{ - SetWindowClassesDirty(WC_VEHICLE_DETAILS); - return true; -} - -static bool StationSpreadChanged(int32 p1) +static void StationSpreadChanged(int32 p1) { InvalidateWindowData(WC_SELECT_STATION, 0); InvalidateWindowData(WC_BUILD_STATION, 0); - return true; } -static bool InvalidateBuildIndustryWindow(int32 p1) +static void CloseSignalGUI(int32 new_value) { - InvalidateWindowData(WC_BUILD_INDUSTRY, 0); - return true; -} - -static bool CloseSignalGUI(int32 p1) -{ - if (p1 == 0) { + if (new_value == 0) { DeleteWindowByClass(WC_BUILD_SIGNAL); } - return true; -} - -static bool InvalidateTownViewWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_TOWN_VIEW, p1); - return true; } -static bool DeleteSelectStationWindow(int32 p1) -{ - DeleteWindowById(WC_SELECT_STATION, 0); - return true; -} - -static bool UpdateConsists(int32 p1) +static void UpdateConsists(int32 new_value) { for (Train *t : Train::Iterate()) { /* Update the consist of all trains so the maximum speed is set correctly. */ if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(CCF_TRACK); } InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); - return true; } -/* Check service intervals of vehicles, p1 is value of % or day based servicing */ -static bool CheckInterval(int32 p1) +/* Check service intervals of vehicles, newvalue is value of % or day based servicing */ +static void UpdateServiceInterval(int32 new_value) { bool update_vehicles; VehicleDefaultSettings *vds; @@ -911,7 +868,7 @@ static bool CheckInterval(int32 p1) update_vehicles = true; } - if (p1 != 0) { + if (new_value != 0) { vds->servint_trains = 50; vds->servint_roadveh = 50; vds->servint_aircraft = 50; @@ -928,66 +885,42 @@ static bool CheckInterval(int32 p1) for (Vehicle *v : Vehicle::Iterate()) { if (v->owner == _current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) { v->SetServiceInterval(CompanyServiceInterval(c, v->type)); - v->SetServiceIntervalIsPercent(p1 != 0); + v->SetServiceIntervalIsPercent(new_value != 0); } } } - InvalidateDetailsWindow(0); - - return true; + SetWindowClassesDirty(WC_VEHICLE_DETAILS); } -static bool UpdateInterval(VehicleType type, int32 p1) +static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value) { - bool update_vehicles; VehicleDefaultSettings *vds; if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) { vds = &_settings_client.company.vehicle; - update_vehicles = false; } else { vds = &Company::Get(_current_company)->settings.vehicle; - update_vehicles = true; } /* Test if the interval is valid */ - uint16 interval = GetServiceIntervalClamped(p1, vds->servint_ispercent); - if (interval != p1) return false; + int32 interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent); + return interval == new_value; +} - if (update_vehicles) { +static void UpdateServiceInterval(VehicleType type, int32 new_value) +{ + if (_game_mode != GM_MENU && Company::IsValidID(_current_company)) { for (Vehicle *v : Vehicle::Iterate()) { if (v->owner == _current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) { - v->SetServiceInterval(p1); + v->SetServiceInterval(new_value); } } } - InvalidateDetailsWindow(0); - - return true; -} - -static bool UpdateIntervalTrains(int32 p1) -{ - return UpdateInterval(VEH_TRAIN, p1); -} - -static bool UpdateIntervalRoadVeh(int32 p1) -{ - return UpdateInterval(VEH_ROAD, p1); -} - -static bool UpdateIntervalShips(int32 p1) -{ - return UpdateInterval(VEH_SHIP, p1); -} - -static bool UpdateIntervalAircraft(int32 p1) -{ - return UpdateInterval(VEH_AIRCRAFT, p1); + SetWindowClassesDirty(WC_VEHICLE_DETAILS); } -static bool TrainAccelerationModelChanged(int32 p1) +static void TrainAccelerationModelChanged(int32 new_value) { for (Train *t : Train::Iterate()) { if (t->IsFrontEngine()) { @@ -1000,30 +933,24 @@ static bool TrainAccelerationModelChanged(int32 p1) SetWindowClassesDirty(WC_ENGINE_PREVIEW); InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); SetWindowClassesDirty(WC_VEHICLE_DETAILS); - - return true; } /** * This function updates the train acceleration cache after a steepness change. - * @param p1 Callback parameter. - * @return Always true. + * @param new_value Unused new value of setting. */ -static bool TrainSlopeSteepnessChanged(int32 p1) +static void TrainSlopeSteepnessChanged(int32 new_value) { for (Train *t : Train::Iterate()) { if (t->IsFrontEngine()) t->CargoChanged(); } - - return true; } /** * This function updates realistic acceleration caches when the setting "Road vehicle acceleration model" is set. - * @param p1 Callback parameter - * @return Always true + * @param new_value Unused new value of setting. */ -static bool RoadVehAccelerationModelChanged(int32 p1) +static void RoadVehAccelerationModelChanged(int32 new_value) { if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) { for (RoadVehicle *rv : RoadVehicle::Iterate()) { @@ -1037,48 +964,29 @@ static bool RoadVehAccelerationModelChanged(int32 p1) SetWindowClassesDirty(WC_ENGINE_PREVIEW); InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); SetWindowClassesDirty(WC_VEHICLE_DETAILS); - - return true; } /** * This function updates the road vehicle acceleration cache after a steepness change. - * @param p1 Callback parameter. - * @return Always true. + * @param new_value Unused new value of setting. */ -static bool RoadVehSlopeSteepnessChanged(int32 p1) +static void RoadVehSlopeSteepnessChanged(int32 new_value) { for (RoadVehicle *rv : RoadVehicle::Iterate()) { if (rv->IsFrontEngine()) rv->CargoChanged(); } - - return true; -} - -static bool DragSignalsDensityChanged(int32) -{ - InvalidateWindowData(WC_BUILD_SIGNAL, 0); - - return true; } -static bool TownFoundingChanged(int32 p1) +static void TownFoundingChanged(int32 new_value) { if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) { DeleteWindowById(WC_FOUND_TOWN, 0); - return true; + } else { + InvalidateWindowData(WC_FOUND_TOWN, 0); } - InvalidateWindowData(WC_FOUND_TOWN, 0); - return true; -} - -static bool InvalidateVehTimetableWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); - return true; } -static bool ZoomMinMaxChanged(int32 p1) +static void ZoomMinMaxChanged(int32 new_value) { extern void ConstrainAllViewportsZoom(); ConstrainAllViewportsZoom(); @@ -1089,81 +997,32 @@ static bool ZoomMinMaxChanged(int32 p1) UpdateCursorSize(); LoadStringWidthTable(); } - return true; } -static bool SpriteZoomMinChanged(int32 p1) { +static void SpriteZoomMinChanged(int32 new_value) +{ GfxClearSpriteCache(); /* Force all sprites to redraw at the new chosen zoom level */ MarkWholeScreenDirty(); - return true; } /** * Update any possible saveload window and delete any newgrf dialogue as * its widget parts might change. Reinit all windows as it allows access to the * newgrf debug button. - * @param p1 unused. - * @return Always true. + * @param new_value unused. */ -static bool InvalidateNewGRFChangeWindows(int32 p1) +static void InvalidateNewGRFChangeWindows(int32 new_value) { InvalidateWindowClassesData(WC_SAVELOAD); DeleteWindowByClass(WC_GAME_OPTIONS); ReInitAllWindows(_gui_zoom_cfg); - return true; } -static bool InvalidateCompanyLiveryWindow(int32 p1) +static void InvalidateCompanyLiveryWindow(int32 new_value) { InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1); ResetVehicleColourMap(); - return RedrawScreen(p1); -} - -static bool InvalidateIndustryViewWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_INDUSTRY_VIEW); - return true; -} - -static bool InvalidateAISettingsWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_AI_SETTINGS); - return true; -} - -/** - * Update the town authority window after a town authority setting change. - * @param p1 Unused. - * @return Always true. - */ -static bool RedrawTownAuthority(int32 p1) -{ - SetWindowClassesDirty(WC_TOWN_AUTHORITY); - return true; -} - -/** - * Invalidate the company infrastructure details window after a infrastructure maintenance setting change. - * @param p1 Unused. - * @return Always true. - */ -static bool InvalidateCompanyInfrastructureWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE); - return true; -} - -/** - * Invalidate the company details window after the shares setting changed. - * @param p1 Unused. - * @return Always true. - */ -static bool InvalidateCompanyWindow(int32 p1) -{ - InvalidateWindowClassesData(WC_COMPANY); - return true; } /** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */ @@ -1176,7 +1035,7 @@ static void ValidateSettings() } } -static bool DifficultyNoiseChange(int32 i) +static void DifficultyNoiseChange(int32 new_value) { if (_game_mode == GM_NORMAL) { UpdateAirportsNoise(); @@ -1184,11 +1043,9 @@ static bool DifficultyNoiseChange(int32 i) InvalidateWindowClassesData(WC_TOWN_VIEW, 0); } } - - return true; } -static bool MaxNoAIsChange(int32 i) +static void MaxNoAIsChange(int32 new_value) { if (GetGameSettings().difficulty.max_no_competitors != 0 && AI::GetInfoList()->size() == 0 && @@ -1197,15 +1054,14 @@ static bool MaxNoAIsChange(int32 i) } InvalidateWindowClassesData(WC_GAME_OPTIONS, 0); - return true; } /** * Check whether the road side may be changed. - * @param p1 unused + * @param new_value unused * @return true if the road side may be changed. */ -static bool CheckRoadSide(int p1) +static bool CheckRoadSide(int32 &new_value) { extern bool RoadVehiclesAreBuilt(); return _game_mode == GM_MENU || !RoadVehiclesAreBuilt(); @@ -1225,10 +1081,10 @@ static size_t ConvertLandscape(const char *value) return OneOfManySettingDesc::ParseSingleValue(value, strlen(value), _old_landscape_values); } -static bool CheckFreeformEdges(int32 p1) +static bool CheckFreeformEdges(int32 &new_value) { if (_game_mode == GM_MENU) return true; - if (p1 != 0) { + if (new_value != 0) { for (Ship *s : Ship::Iterate()) { /* Check if there is a ship on the northern border. */ if (TileX(s->tile) == 0 || TileY(s->tile) == 0) { @@ -1243,8 +1099,6 @@ static bool CheckFreeformEdges(int32 p1) return false; } } - for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0)); - for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y)); } else { for (uint i = 0; i < MapMaxX(); i++) { if (TileHeight(TileXY(i, 1)) != 0) { @@ -1270,6 +1124,18 @@ static bool CheckFreeformEdges(int32 p1) return false; } } + } + return true; +} + +static void UpdateFreeformEdges(int32 new_value) +{ + if (_game_mode == GM_MENU) return; + + if (new_value != 0) { + for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0)); + for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y)); + } else { /* Make tiles at the border water again. */ for (uint i = 0; i < MapMaxX(); i++) { SetTileHeight(TileXY(i, 0), 0); @@ -1281,14 +1147,13 @@ static bool CheckFreeformEdges(int32 p1) } } MarkWholeScreenDirty(); - return true; } /** * Changing the setting "allow multiple NewGRF sets" is not allowed * if there are vehicles. */ -static bool ChangeDynamicEngines(int32 p1) +static bool CheckDynamicEngines(int32 &new_value) { if (_game_mode == GM_MENU) return true; @@ -1300,7 +1165,7 @@ static bool ChangeDynamicEngines(int32 p1) return true; } -static bool ChangeMaxHeightLevel(int32 p1) +static bool CheckMaxHeightLevel(int32 &new_value) { if (_game_mode == GM_NORMAL) return false; if (_game_mode != GM_EDITOR) return true; @@ -1308,39 +1173,33 @@ static bool ChangeMaxHeightLevel(int32 p1) /* Check if at least one mountain on the map is higher than the new value. * If yes, disallow the change. */ for (TileIndex t = 0; t < MapSize(); t++) { - if ((int32)TileHeight(t) > p1) { + if ((int32)TileHeight(t) > new_value) { ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR); /* Return old, unchanged value */ return false; } } - /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */ - InvalidateWindowClassesData(WC_SMALLMAP, 2); - return true; } -static bool StationCatchmentChanged(int32 p1) +static void StationCatchmentChanged(int32 new_value) { Station::RecomputeCatchmentForAll(); MarkWholeScreenDirty(); - return true; } -static bool MaxVehiclesChanged(int32 p1) +static void MaxVehiclesChanged(int32 new_value) { InvalidateWindowClassesData(WC_BUILD_TOOLBAR); MarkWholeScreenDirty(); - return true; } -static bool InvalidateShipPathCache(int32 p1) +static void InvalidateShipPathCache(int32 new_value) { for (Ship *s : Ship::Iterate()) { s->path.clear(); } - return true; } /** @@ -1354,12 +1213,6 @@ static bool ReplaceAsteriskWithEmptyPassword(std::string &newval) return true; } -static bool UpdateClientConfigValues(int32 p1) -{ - UpdateClientConfigValues(); - return true; -} - /** Update the game info, and send it to the clients when we are running as a server. */ static void UpdateClientConfigValues() { @@ -1838,17 +1691,12 @@ void DeleteGRFPresetFromConfig(const char *config_name) void IntSettingDesc::ChangeValue(const void *object, int32 newval) const { int32 oldval = this->Read(object); - - this->MakeValueValidAndWrite(object, newval); - newval = this->Read(object); - + this->MakeValueValid(newval); + if (this->pre_check != nullptr && !this->pre_check(newval)) return; if (oldval == newval) return; - if (this->proc != nullptr && !this->proc(newval)) { - /* The change was not allowed, so revert. */ - this->Write(object, oldval); - return; - } + this->Write(object, newval); + if (this->post_callback != nullptr) this->post_callback(newval); if (this->flags & SGF_NO_NETWORK) { GamelogStartAction(GLAT_SETTING); diff --git a/src/settings_internal.h b/src/settings_internal.h index 4a483cc0e..4de017837 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -64,8 +64,6 @@ enum SettingType { }; struct IniItem; -typedef bool OnChange(int32 var); ///< callback prototype on data modification -typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error /** Properties of config file settings. */ struct SettingDesc { @@ -125,11 +123,27 @@ struct SettingDesc { /** Base integer type, including boolean, settings. Only these are shown in the settings UI. */ struct IntSettingDesc : SettingDesc { + /** + * A check to be performed before the setting gets changed. The passed integer may be + * changed by the check if that is important, for example to remove some unwanted bit. + * The return value denotes whether the value, potentially after the changes, + * is allowed to be used/set in the configuration. + * @param value The prospective new value for the setting. + * @return True when the setting is accepted. + */ + typedef bool PreChangeCheck(int32 &value); + /** + * A callback to denote that a setting has been changed. + * @param The new value for the setting. + */ + typedef void PostChangeCallback(int32 value); + IntSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, int32 def, - int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val, - SettingCategory cat, OnChange *proc) : + 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), - str(str), str_help(str_help), str_val(str_val), cat(cat), proc(proc) {} + str(str), str_help(str_help), str_val(str_val), cat(cat), pre_check(pre_check), + post_callback(post_callback) {} virtual ~IntSettingDesc() {} int32 def; ///< default value given when none is present @@ -140,7 +154,8 @@ struct IntSettingDesc : SettingDesc { StringID str_help; ///< (Translated) string with help text; gui only. StringID str_val; ///< (Translated) first string describing the value. SettingCategory cat; ///< assigned categories of the setting - OnChange *proc; ///< callback procedure for when the value is changed + PreChangeCheck *pre_check; ///< Callback to check for the validity of the setting. + PostChangeCallback *post_callback; ///< Callback when the setting has been changed. /** * Check whether this setting is a boolean type setting. @@ -166,8 +181,10 @@ private: /** Boolean setting. */ struct BoolSettingDesc : IntSettingDesc { BoolSettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, bool def, - StringID str, StringID str_help, StringID str_val, SettingCategory cat, OnChange *proc) : - IntSettingDesc(save, name, flags, startup, def, 0, 1, 0, str, str_help, str_val, cat, proc) {} + 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, + pre_check, post_callback) {} virtual ~BoolSettingDesc() {} bool IsBoolSetting() const override { return true; } @@ -177,10 +194,14 @@ struct BoolSettingDesc : IntSettingDesc { /** One of many setting. */ struct OneOfManySettingDesc : IntSettingDesc { - OneOfManySettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, - int32 def, int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, OnChange *proc, - std::initializer_list<const char *> many, OnConvert *many_cnvt) : - IntSettingDesc(save, name, flags, startup, def, 0, max, 0, str, str_help, str_val, cat, proc), many_cnvt(many_cnvt) + typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error + + OneOfManySettingDesc(SaveLoad save, const char *name, SettingGuiFlag 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) : + IntSettingDesc(save, name, flags, startup, def, 0, max, 0, str, str_help, str_val, cat, + pre_check, post_callback), many_cnvt(many_cnvt) { for (auto one : many) this->many.push_back(one); } @@ -200,10 +221,11 @@ struct OneOfManySettingDesc : IntSettingDesc { /** Many of many setting. */ struct ManyOfManySettingDesc : OneOfManySettingDesc { ManyOfManySettingDesc(SaveLoad save, const char *name, SettingGuiFlag flags, bool startup, - int32 def, StringID str, StringID str_help, StringID str_val, SettingCategory cat, OnChange *proc, + 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) : OneOfManySettingDesc(save, name, flags, startup, def, (1 << many.size()) - 1, str, str_help, - str_val, cat, proc, many, many_cnvt) {} + str_val, cat, pre_check, post_callback, many, many_cnvt) {} virtual ~ManyOfManySettingDesc() {} size_t ParseValue(const char *str) const override; diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index eecebb40e..019c26dd9 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -5,19 +5,16 @@ ; [pre-amble] -static bool CheckInterval(int32 p1); -static bool InvalidateDetailsWindow(int32 p1); -static bool UpdateIntervalTrains(int32 p1); -static bool UpdateIntervalRoadVeh(int32 p1); -static bool UpdateIntervalShips(int32 p1); -static bool UpdateIntervalAircraft(int32 p1); +static void UpdateServiceInterval(int32 new_value); +static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value); +static void UpdateServiceInterval(VehicleType type, int32 new_value); static const SettingTable _company_settings{ [post-amble] }; [templates] -SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size"); @@ -29,7 +26,8 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr +pre_cb = nullptr +post_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION @@ -82,7 +80,7 @@ var = vehicle.servint_ispercent def = false str = STR_CONFIG_SETTING_SERVINT_ISPERCENT strhelp = STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT -proc = CheckInterval +post_cb = UpdateServiceInterval [SDT_VAR] base = CompanySettings @@ -95,7 +93,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_TRAINS strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalTrains +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_TRAIN, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); } [SDT_VAR] base = CompanySettings @@ -108,7 +107,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalRoadVeh +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_ROAD, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); } [SDT_VAR] base = CompanySettings @@ -121,7 +121,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_SHIPS strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalShips +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_SHIP, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); } [SDT_VAR] base = CompanySettings @@ -134,4 +135,5 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalAircraft +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_AIRCRAFT, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_AIRCRAFT, new_value); } diff --git a/src/table/currency_settings.ini b/src/table/currency_settings.ini index 0714b1b93..449bbee98 100644 --- a/src/table/currency_settings.ini +++ b/src/table/currency_settings.ini @@ -9,7 +9,7 @@ static const SettingTable _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, $extra, $startup), +SDT_VAR = SDT_VAR ($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] @@ -22,7 +22,6 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr pre_cb = nullptr post_cb = nullptr load = nullptr diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini index 56ac7d781..131833a41 100644 --- a/src/table/gameopt_settings.ini +++ b/src/table/gameopt_settings.ini @@ -37,12 +37,12 @@ static const SettingTable _gameopt_settings{ }; [templates] SDTG_LIST = SDTG_LIST($name, $type, $flags, $guiflags, $var, $def, $length, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDT_NULL = SDT_NULL( $length, $from, $to), -SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra, $startup), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $load, $cat, $extra, $startup), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -58,7 +58,8 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr +pre_cb = nullptr +post_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini index 952839daa..1b633a65a 100644 --- a/src/table/misc_settings.ini +++ b/src/table/misc_settings.ini @@ -22,11 +22,11 @@ static const SettingTable _misc_settings{ }; [templates] SDTG_LIST = SDTG_LIST($name, $type, $flags, $guiflags, $var, $def, $length, $from, $to, $cat, $extra, $startup), -SDTG_MMANY = SDTG_MMANY($name, $type, $flags, $guiflags, $var, $def, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTG_MMANY = SDTG_MMANY($name, $type, $flags, $guiflags, $var, $def, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDTG_SSTR = SDTG_SSTR($name, $type, $flags, $guiflags, $var, $def, 0, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), -SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -39,7 +39,6 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr pre_cb = nullptr post_cb = nullptr load = nullptr diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index f5f735244..3c8e6cb72 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -58,11 +58,11 @@ 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_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(Int, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, min, max, interval, str, strhelp, strval, cat, proc) +#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(Int, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback) -#define SDTG_BOOL(name, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(Bool, SLEG_GENERAL(SL_VAR, var, SLE_BOOL | flags, 1, from, to, extra), name, guiflags, startup, def, str, strhelp, strval, cat, proc) +#define SDTG_BOOL(name, flags, guiflags, var, def, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(Bool, SLEG_GENERAL(SL_VAR, var, SLE_BOOL | flags, 1, from, to, extra), name, guiflags, startup, def, str, strhelp, strval, cat, pre_check, post_callback) #define SDTG_LIST(name, type, flags, guiflags, var, def, length, from, to, cat, extra, startup)\ NSD(List, SLEG_GENERAL(SL_ARR, var, type | flags, length, from, to, extra), name, guiflags, startup, def) @@ -70,22 +70,22 @@ static size_t ConvertLandscape(const char *value); #define SDTG_SSTR(name, type, flags, guiflags, var, def, max_length, pre_check, post_callback, from, to, cat, extra, startup)\ NSD(String, SLEG_GENERAL(SL_STDSTR, var, type | flags, sizeof(var), from, to, extra), name, guiflags, startup, def, max_length, pre_check, post_callback) -#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(OneOfMany, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, max, str, strhelp, strval, cat, proc, full, nullptr) +#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(OneOfMany, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, max, str, strhelp, strval, cat, pre_check, post_callback, full, nullptr) -#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(ManyOfMany, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, str, strhelp, strval, cat, proc, full, nullptr) +#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(ManyOfMany, SLEG_GENERAL(SL_VAR, var, type | flags, 1, from, to, extra), name, guiflags, startup, def, str, strhelp, strval, cat, pre_check, post_callback, full, nullptr) #define SDTG_NULL(length, from, to)\ NSD(Null, SLEG_NULL(length, from, to)) /* Macros for various objects to go in the configuration file. * This section is for structures where their various members are saved */ -#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(Int, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, min, max, interval, str, strhelp, strval, cat, proc) +#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(Int, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback) -#define SDT_BOOL(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - NSD(Bool, SLE_GENERAL(SL_VAR, base, var, SLE_BOOL | flags, 1, from, to, extra), #var, guiflags, startup, def, str, strhelp, strval, cat, proc) +#define SDT_BOOL(base, var, flags, guiflags, def, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + NSD(Bool, SLE_GENERAL(SL_VAR, base, var, SLE_BOOL | flags, 1, from, to, extra), #var, guiflags, startup, def, str, strhelp, strval, cat, pre_check, post_callback) #define SDT_LIST(base, var, type, flags, guiflags, def, from, to, cat, extra, startup)\ NSD(List, SLE_GENERAL(SL_ARR, base, var, type | flags, lengthof(((base*)8)->var), from, to, extra), #var, guiflags, startup, def) @@ -93,21 +93,21 @@ static size_t ConvertLandscape(const char *value); #define SDT_SSTR(base, var, type, flags, guiflags, def, pre_check, post_callback, from, to, cat, extra, startup)\ NSD(String, SLE_GENERAL(SL_STDSTR, base, var, type | flags, sizeof(((base*)8)->var), from, to, extra), #var, guiflags, startup, def, 0, pre_check, post_callback) -#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, load, cat, extra, startup)\ - NSD(OneOfMany, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, max, str, strhelp, strval, cat, proc, full, load) +#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strhelp, strval, pre_check, post_callback, from, to, load, cat, extra, startup)\ + NSD(OneOfMany, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, max, str, strhelp, strval, cat, pre_check, post_callback, full, load) -#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc, strhelp, strval, from, to, cat, extra, startup)\ - NSD(ManyOfMany, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, str, strhelp, strval, cat, proc, full, nullptr) +#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, pre_check, post_callback, strhelp, strval, from, to, cat, extra, startup)\ + NSD(ManyOfMany, SLE_GENERAL(SL_VAR, base, var, type | flags, 1, from, to, extra), #var, guiflags, startup, def, str, strhelp, strval, cat, pre_check, post_callback, full, nullptr) #define SDT_NULL(length, from, to)\ NSD(Null, SLE_CONDNULL(length, from, to)) -#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - SDTG_VAR(#var, type, flags, guiflags, _settings_client.var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup) +#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + SDTG_VAR(#var, type, flags, guiflags, _settings_client.var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup) -#define SDTC_BOOL(var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - SDTG_BOOL(#var, flags, guiflags, _settings_client.var, def, str, strhelp, strval, proc, from, to, cat, extra, startup) +#define SDTC_BOOL(var, flags, guiflags, def, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + SDTG_BOOL(#var, flags, guiflags, _settings_client.var, def, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup) #define SDTC_LIST(var, type, flags, guiflags, def, from, to, cat, extra, startup)\ SDTG_LIST(#var, type, flags, guiflags, _settings_client.var, def, lengthof(_settings_client.var), from, to, cat, extra, startup) @@ -115,5 +115,5 @@ static size_t ConvertLandscape(const char *value); #define SDTC_SSTR(var, type, flags, guiflags, def, max_length, pre_check, post_callback, from, to, cat, extra, startup)\ SDTG_SSTR(#var, type, flags, guiflags, _settings_client.var, def, max_length, pre_check, post_callback, from, to, cat, extra, startup)\ -#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\ - SDTG_OMANY(#var, type, flags, guiflags, _settings_client.var, def, max, full, str, strhelp, strval, proc, from, to, cat, extra, startup) +#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup)\ + SDTG_OMANY(#var, type, flags, guiflags, _settings_client.var, def, max, full, str, strhelp, strval, pre_check, post_callback, from, to, cat, extra, startup) diff --git a/src/table/settings.ini b/src/table/settings.ini index 1de905c5b..2b6187087 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -6,46 +6,34 @@ [pre-amble] /* Begin - Callback Functions for the various settings */ -static bool v_PositionMainToolbar(int32 p1); -static bool v_PositionStatusbar(int32 p1); -static bool PopulationInLabelActive(int32 p1); -static bool RedrawScreen(int32 p1); -static bool RedrawSmallmap(int32 p1); -static bool StationSpreadChanged(int32 p1); -static bool InvalidateBuildIndustryWindow(int32 p1); -static bool CloseSignalGUI(int32 p1); -static bool InvalidateTownViewWindow(int32 p1); -static bool DeleteSelectStationWindow(int32 p1); -static bool UpdateConsists(int32 p1); -static bool TrainAccelerationModelChanged(int32 p1); -static bool RoadVehAccelerationModelChanged(int32 p1); -static bool TrainSlopeSteepnessChanged(int32 p1); -static bool RoadVehSlopeSteepnessChanged(int32 p1); -static bool DragSignalsDensityChanged(int32); -static bool TownFoundingChanged(int32 p1); -static bool DifficultyNoiseChange(int32 i); -static bool MaxNoAIsChange(int32 i); -static bool CheckRoadSide(int p1); -static bool ChangeMaxHeightLevel(int32 p1); -static bool CheckFreeformEdges(int32 p1); -static bool ChangeDynamicEngines(int32 p1); -static bool StationCatchmentChanged(int32 p1); -static bool InvalidateVehTimetableWindow(int32 p1); -static bool InvalidateCompanyLiveryWindow(int32 p1); -static bool InvalidateNewGRFChangeWindows(int32 p1); -static bool InvalidateIndustryViewWindow(int32 p1); -static bool InvalidateAISettingsWindow(int32 p1); -static bool RedrawTownAuthority(int32 p1); -static bool InvalidateCompanyInfrastructureWindow(int32 p1); -static bool InvalidateCompanyWindow(int32 p1); -static bool ZoomMinMaxChanged(int32 p1); -static bool SpriteZoomMinChanged(int32 p1); -static bool MaxVehiclesChanged(int32 p1); -static bool InvalidateShipPathCache(int32 p1); +static void v_PositionMainToolbar(int32 new_value); +static void v_PositionStatusbar(int32 new_value); +static void RedrawSmallmap(int32 new_value); +static void StationSpreadChanged(int32 new_value); +static void CloseSignalGUI(int32 new_value); +static void UpdateConsists(int32 new_value); +static void TrainAccelerationModelChanged(int32 new_value); +static void RoadVehAccelerationModelChanged(int32 new_value); +static void TrainSlopeSteepnessChanged(int32 new_value); +static void RoadVehSlopeSteepnessChanged(int32 new_value); +static void TownFoundingChanged(int32 new_value); +static void DifficultyNoiseChange(int32 new_value); +static void MaxNoAIsChange(int32 new_value); +static bool CheckRoadSide(int32 &new_value); +static bool CheckMaxHeightLevel(int32 &new_value); +static bool CheckFreeformEdges(int32 &new_value); +static void UpdateFreeformEdges(int32 new_value); +static bool CheckDynamicEngines(int32 &new_value); +static void StationCatchmentChanged(int32 new_value); +static void InvalidateCompanyLiveryWindow(int32 new_value); +static void InvalidateNewGRFChangeWindows(int32 new_value); +static void ZoomMinMaxChanged(int32 new_value); +static void SpriteZoomMinChanged(int32 new_value); +static void MaxVehiclesChanged(int32 new_value); +static void InvalidateShipPathCache(int32 new_value); static bool ReplaceAsteriskWithEmptyPassword(std::string &newval); static void UpdateClientConfigValues(); -static bool UpdateClientConfigValues(int32 p1); /* End - Callback Functions for the various settings */ @@ -62,18 +50,18 @@ const SettingTable _settings{ [post-amble] }; [templates] -SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDTC_LIST = SDTC_LIST( $var, $type, $flags, $guiflags, $def, $from, $to, $cat, $extra, $startup), -SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDTC_SSTR = SDTC_SSTR( $var, $type, $flags, $guiflags, $def, $length, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), -SDTC_VAR = SDTC_VAR( $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra, $startup), +SDTC_VAR = SDTC_VAR( $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $load, $cat, $extra, $startup), SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDT_NULL = SDT_NULL($length, $from, $to), [validation] @@ -91,7 +79,6 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr pre_cb = nullptr post_cb = nullptr load = nullptr @@ -114,7 +101,7 @@ def = 0 min = 0 max = MAX_COMPANIES - 1 interval = 1 -proc = MaxNoAIsChange +post_cb = MaxNoAIsChange cat = SC_BASIC [SDT_NULL] @@ -324,7 +311,7 @@ interval = 1 str = STR_CONFIG_SETTING_CITY_APPROVAL strhelp = STR_CONFIG_SETTING_CITY_APPROVAL_HELPTEXT strval = STR_CITY_APPROVAL_PERMISSIVE -proc = DifficultyNoiseChange +post_cb = DifficultyNoiseChange [SDTG_VAR] name = ""diff_level"" @@ -384,7 +371,7 @@ full = _roadsides str = STR_CONFIG_SETTING_ROAD_SIDE strhelp = STR_CONFIG_SETTING_ROAD_SIDE_HELPTEXT strval = STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT -proc = CheckRoadSide +pre_cb = CheckRoadSide cat = SC_BASIC ; Construction @@ -402,7 +389,8 @@ interval = 1 str = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT strhelp = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_HELPTEXT strval = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_VALUE -proc = ChangeMaxHeightLevel +pre_cb = CheckMaxHeightLevel +post_cb = [](auto) { InvalidateWindowClassesData(WC_SMALLMAP, 2); } cat = SC_ADVANCED [SDT_VAR] @@ -578,7 +566,7 @@ max = 2 str = STR_CONFIG_SETTING_SIGNALSIDE strhelp = STR_CONFIG_SETTING_SIGNALSIDE_HELPTEXT strval = STR_CONFIG_SETTING_SIGNALSIDE_LEFT -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC [SDT_BOOL] @@ -602,7 +590,7 @@ interval = 1 str = STR_CONFIG_SETTING_TOWN_LAYOUT strhelp = STR_CONFIG_SETTING_TOWN_LAYOUT_HELPTEXT strval = STR_CONFIG_SETTING_TOWN_LAYOUT_DEFAULT -proc = TownFoundingChanged +post_cb = TownFoundingChanged [SDT_BOOL] base = GameSettings @@ -626,7 +614,7 @@ interval = 1 str = STR_CONFIG_SETTING_TOWN_FOUNDING strhelp = STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT strval = STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN -proc = TownFoundingChanged +post_cb = TownFoundingChanged cat = SC_BASIC [SDT_BOOL] @@ -822,7 +810,7 @@ interval = 1 str = STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL strhelp = STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL_HELPTEXT strval = STR_CONFIG_SETTING_ORIGINAL -proc = TrainAccelerationModelChanged +post_cb = TrainAccelerationModelChanged [SDT_VAR] base = GameSettings @@ -837,7 +825,7 @@ interval = 1 str = STR_CONFIG_SETTING_ROAD_VEHICLE_ACCELERATION_MODEL strhelp = STR_CONFIG_SETTING_ROAD_VEHICLE_ACCELERATION_MODEL_HELPTEXT strval = STR_CONFIG_SETTING_ORIGINAL -proc = RoadVehAccelerationModelChanged +post_cb = RoadVehAccelerationModelChanged [SDT_VAR] base = GameSettings @@ -851,7 +839,7 @@ interval = 1 str = STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS strhelp = STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS_HELPTEXT strval = STR_CONFIG_SETTING_PERCENTAGE -proc = TrainSlopeSteepnessChanged +post_cb = TrainSlopeSteepnessChanged cat = SC_EXPERT [SDT_VAR] @@ -866,7 +854,7 @@ interval = 1 str = STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS strhelp = STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT strval = STR_CONFIG_SETTING_PERCENTAGE -proc = RoadVehSlopeSteepnessChanged +post_cb = RoadVehSlopeSteepnessChanged cat = SC_EXPERT [SDT_BOOL] @@ -875,7 +863,7 @@ var = pf.forbid_90_deg def = false str = STR_CONFIG_SETTING_FORBID_90_DEG strhelp = STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT -proc = InvalidateShipPathCache +post_cb = InvalidateShipPathCache cat = SC_EXPERT [SDT_VAR] @@ -998,7 +986,7 @@ interval = 1 str = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS strhelp = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_HELPTEXT strval = STR_CONFIG_SETTING_PATHFINDER_NPF -proc = InvalidateShipPathCache +post_cb = InvalidateShipPathCache cat = SC_EXPERT [SDT_BOOL] @@ -1019,7 +1007,7 @@ max = 5000 str = STR_CONFIG_SETTING_MAX_TRAINS strhelp = STR_CONFIG_SETTING_MAX_TRAINS_HELPTEXT strval = STR_JUST_COMMA -proc = MaxVehiclesChanged +post_cb = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -1032,7 +1020,7 @@ max = 5000 str = STR_CONFIG_SETTING_MAX_ROAD_VEHICLES strhelp = STR_CONFIG_SETTING_MAX_ROAD_VEHICLES_HELPTEXT strval = STR_JUST_COMMA -proc = MaxVehiclesChanged +post_cb = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -1045,7 +1033,7 @@ max = 5000 str = STR_CONFIG_SETTING_MAX_AIRCRAFT strhelp = STR_CONFIG_SETTING_MAX_AIRCRAFT_HELPTEXT strval = STR_JUST_COMMA -proc = MaxVehiclesChanged +post_cb = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -1058,7 +1046,7 @@ max = 5000 str = STR_CONFIG_SETTING_MAX_SHIPS strhelp = STR_CONFIG_SETTING_MAX_SHIPS_HELPTEXT strval = STR_JUST_COMMA -proc = MaxVehiclesChanged +post_cb = MaxVehiclesChanged cat = SC_BASIC [SDTG_BOOL] @@ -1122,7 +1110,7 @@ guiflags = SGF_NO_NETWORK def = true str = STR_CONFIG_SETTING_WAGONSPEEDLIMITS strhelp = STR_CONFIG_SETTING_WAGONSPEEDLIMITS_HELPTEXT -proc = UpdateConsists +post_cb = UpdateConsists [SDT_BOOL] base = GameSettings @@ -1132,7 +1120,7 @@ guiflags = SGF_NO_NETWORK def = false str = STR_CONFIG_SETTING_DISABLE_ELRAILS strhelp = STR_CONFIG_SETTING_DISABLE_ELRAILS_HELPTEXT -proc = SettingsDisableElrail +post_cb = SettingsDisableElrail cat = SC_EXPERT [SDT_VAR] @@ -1148,7 +1136,7 @@ interval = 1 str = STR_CONFIG_SETTING_FREIGHT_TRAINS strhelp = STR_CONFIG_SETTING_FREIGHT_TRAINS_HELPTEXT strval = STR_JUST_COMMA -proc = UpdateConsists +post_cb = UpdateConsists ; order.timetabling [SDT_NULL] @@ -1175,7 +1163,7 @@ var = vehicle.dynamic_engines from = SLV_95 guiflags = SGF_NO_NETWORK def = true -proc = ChangeDynamicEngines +pre_cb = CheckDynamicEngines cat = SC_EXPERT [SDT_VAR] @@ -1238,7 +1226,7 @@ max = 64 str = STR_CONFIG_SETTING_STATION_SPREAD strhelp = STR_CONFIG_SETTING_STATION_SPREAD_HELPTEXT strval = STR_CONFIG_SETTING_TILE_LENGTH -proc = StationSpreadChanged +post_cb = StationSpreadChanged cat = SC_BASIC [SDT_BOOL] @@ -1255,7 +1243,7 @@ var = station.modified_catchment def = true str = STR_CONFIG_SETTING_CATCHMENT strhelp = STR_CONFIG_SETTING_CATCHMENT_HELPTEXT -proc = StationCatchmentChanged +post_cb = StationCatchmentChanged cat = SC_EXPERT [SDT_BOOL] @@ -1265,7 +1253,7 @@ def = true from = SLV_SERVE_NEUTRAL_INDUSTRIES str = STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES strhelp = STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT -proc = StationCatchmentChanged +post_cb = StationCatchmentChanged [SDT_BOOL] base = GameSettings @@ -1308,7 +1296,7 @@ guiflags = SGF_NO_NETWORK def = false str = STR_CONFIG_SETTING_NOISE_LEVEL strhelp = STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT -proc = InvalidateTownViewWindow +post_cb = [](auto new_value) { InvalidateWindowClassesData(WC_TOWN_VIEW, new_value); } [SDT_BOOL] base = GameSettings @@ -1317,7 +1305,7 @@ from = SLV_106 def = true str = STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS strhelp = STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT -proc = DeleteSelectStationWindow +post_cb = [](auto) { DeleteWindowById(WC_SELECT_STATION, 0); } ## [SDT_BOOL] @@ -1340,7 +1328,7 @@ max = 2 str = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD strhelp = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_HELPTEXT strval = STR_CONFIG_SETTING_RAW_INDUSTRY_CONSTRUCTION_METHOD_NONE -proc = InvalidateBuildIndustryWindow +post_cb = [](auto) { InvalidateWindowData(WC_BUILD_INDUSTRY, 0); } cat = SC_BASIC [SDT_VAR] @@ -1373,7 +1361,7 @@ var = economy.bribe def = true str = STR_CONFIG_SETTING_BRIBE strhelp = STR_CONFIG_SETTING_BRIBE_HELPTEXT -proc = RedrawTownAuthority +post_cb = [](auto) { SetWindowClassesDirty(WC_TOWN_AUTHORITY); } cat = SC_BASIC [SDT_BOOL] @@ -1383,7 +1371,7 @@ from = SLV_79 def = true str = STR_CONFIG_SETTING_ALLOW_EXCLUSIVE strhelp = STR_CONFIG_SETTING_ALLOW_EXCLUSIVE_HELPTEXT -proc = RedrawTownAuthority +post_cb = [](auto) { SetWindowClassesDirty(WC_TOWN_AUTHORITY); } cat = SC_BASIC [SDT_BOOL] @@ -1393,7 +1381,7 @@ from = SLV_165 def = true str = STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS strhelp = STR_CONFIG_SETTING_ALLOW_FUND_BUILDINGS_HELPTEXT -proc = RedrawTownAuthority +post_cb = [](auto) { SetWindowClassesDirty(WC_TOWN_AUTHORITY); } cat = SC_BASIC [SDT_BOOL] @@ -1403,7 +1391,7 @@ from = SLV_160 def = true str = STR_CONFIG_SETTING_ALLOW_FUND_ROAD strhelp = STR_CONFIG_SETTING_ALLOW_FUND_ROAD_HELPTEXT -proc = RedrawTownAuthority +post_cb = [](auto) { SetWindowClassesDirty(WC_TOWN_AUTHORITY); } cat = SC_BASIC [SDT_BOOL] @@ -1505,7 +1493,7 @@ max = ET_END - 1 str = STR_CONFIG_SETTING_ECONOMY_TYPE strhelp = STR_CONFIG_SETTING_ECONOMY_TYPE_HELPTEXT strval = STR_CONFIG_SETTING_ECONOMY_TYPE_ORIGINAL -proc = InvalidateIndustryViewWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_INDUSTRY_VIEW); } cat = SC_BASIC [SDT_BOOL] @@ -1514,7 +1502,7 @@ var = economy.allow_shares def = false str = STR_CONFIG_SETTING_ALLOW_SHARES strhelp = STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT -proc = InvalidateCompanyWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_COMPANY); } [SDT_VAR] base = GameSettings @@ -1758,7 +1746,7 @@ from = SLV_166 def = false str = STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE strhelp = STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT -proc = InvalidateCompanyInfrastructureWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE); } cat = SC_BASIC ## @@ -2427,7 +2415,8 @@ base = GameSettings var = construction.freeform_edges from = SLV_111 def = true -proc = CheckFreeformEdges +pre_cb = CheckFreeformEdges +post_cb = UpdateFreeformEdges cat = SC_EXPERT [SDT_VAR] @@ -2528,7 +2517,7 @@ flags = SLF_NO_NETWORK_SYNC def = 0 max = CURRENCY_END - 1 full = _locale_currencies -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC [SDTG_OMANY] @@ -2541,7 +2530,7 @@ flags = SLF_NOT_IN_CONFIG def = 1 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC [SDT_OMANY] @@ -2554,7 +2543,7 @@ guiflags = SGF_MULTISTRING def = 1 max = 3 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT @@ -2570,7 +2559,7 @@ guiflags = SGF_MULTISTRING def = 1 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT @@ -2586,7 +2575,7 @@ guiflags = SGF_MULTISTRING def = 1 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_HELPTEXT @@ -2602,7 +2591,7 @@ guiflags = SGF_MULTISTRING def = 1 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_HELPTEXT @@ -2618,7 +2607,7 @@ guiflags = SGF_MULTISTRING def = 2 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_HELPTEXT @@ -2634,7 +2623,7 @@ guiflags = SGF_MULTISTRING def = 1 max = 2 full = _locale_units -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC str = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_HELPTEXT @@ -2811,7 +2800,7 @@ max = 2 str = STR_CONFIG_SETTING_TOOLBAR_POS strhelp = STR_CONFIG_SETTING_TOOLBAR_POS_HELPTEXT strval = STR_CONFIG_SETTING_HORIZONTAL_POS_LEFT -proc = v_PositionMainToolbar +post_cb = v_PositionMainToolbar cat = SC_BASIC [SDTC_VAR] @@ -2825,7 +2814,7 @@ max = 2 str = STR_CONFIG_SETTING_STATUSBAR_POS strhelp = STR_CONFIG_SETTING_STATUSBAR_POS_HELPTEXT strval = STR_CONFIG_SETTING_HORIZONTAL_POS_LEFT -proc = v_PositionStatusbar +post_cb = v_PositionStatusbar cat = SC_BASIC [SDTC_VAR] @@ -2866,7 +2855,7 @@ max = ZOOM_LVL_OUT_4X str = STR_CONFIG_SETTING_ZOOM_MIN strhelp = STR_CONFIG_SETTING_ZOOM_MIN_HELPTEXT strval = STR_CONFIG_SETTING_ZOOM_LVL_MIN -proc = ZoomMinMaxChanged +post_cb = ZoomMinMaxChanged startup = true [SDTC_VAR] @@ -2880,7 +2869,7 @@ max = ZOOM_LVL_MAX str = STR_CONFIG_SETTING_ZOOM_MAX strhelp = STR_CONFIG_SETTING_ZOOM_MAX_HELPTEXT strval = STR_CONFIG_SETTING_ZOOM_LVL_OUT_2X -proc = ZoomMinMaxChanged +post_cb = ZoomMinMaxChanged startup = true [SDTC_VAR] @@ -2894,7 +2883,7 @@ max = ZOOM_LVL_OUT_4X str = STR_CONFIG_SETTING_SPRITE_ZOOM_MIN strhelp = STR_CONFIG_SETTING_SPRITE_ZOOM_MIN_HELPTEXT strval = STR_CONFIG_SETTING_SPRITE_ZOOM_LVL_MIN -proc = SpriteZoomMinChanged +post_cb = SpriteZoomMinChanged [SDTC_BOOL] var = gui.population_in_label @@ -2902,7 +2891,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_POPULATION_IN_LABEL strhelp = STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT -proc = PopulationInLabelActive +post_cb = [](auto) { UpdateAllTownVirtCoords(); } [SDTC_BOOL] var = gui.link_terraform_toolbar @@ -2922,7 +2911,7 @@ max = 2 str = STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR strhelp = STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_HELPTEXT strval = STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_GREEN -proc = RedrawSmallmap +post_cb = RedrawSmallmap [SDTC_VAR] var = gui.liveries @@ -2935,7 +2924,7 @@ max = 2 str = STR_CONFIG_SETTING_LIVERIES strhelp = STR_CONFIG_SETTING_LIVERIES_HELPTEXT strval = STR_CONFIG_SETTING_LIVERIES_NONE -proc = InvalidateCompanyLiveryWindow +post_cb = InvalidateCompanyLiveryWindow [SDTC_VAR] var = gui.starting_colour @@ -3017,7 +3006,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false str = STR_CONFIG_SETTING_TIMETABLE_IN_TICKS strhelp = STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT -proc = InvalidateVehTimetableWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); } cat = SC_EXPERT [SDTC_BOOL] @@ -3026,7 +3015,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE strhelp = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT -proc = InvalidateVehTimetableWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); } [SDTC_BOOL] var = gui.quick_goto @@ -3047,7 +3036,7 @@ max = 2 str = STR_CONFIG_SETTING_LOADING_INDICATORS strhelp = STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT strval = STR_CONFIG_SETTING_COMPANIES_OFF -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC [SDTC_VAR] @@ -3069,7 +3058,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_ENABLE_SIGNAL_GUI strhelp = STR_CONFIG_SETTING_ENABLE_SIGNAL_GUI_HELPTEXT -proc = CloseSignalGUI +post_cb = CloseSignalGUI cat = SC_EXPERT [SDTC_VAR] @@ -3095,7 +3084,7 @@ max = 20 str = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY strhelp = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_HELPTEXT strval = STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_VALUE -proc = DragSignalsDensityChanged +post_cb = [](auto) { InvalidateWindowData(WC_BUILD_SIGNAL, 0); } cat = SC_BASIC [SDTC_BOOL] @@ -3117,7 +3106,7 @@ interval = 1 str = STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE strhelp = STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE_HELPTEXT strval = STR_JUST_INT -proc = ResetSignalVariant +post_cb = ResetSignalVariant [SDTC_BOOL] var = gui.vehicle_income_warn @@ -3213,7 +3202,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_SHOW_TRACK_RESERVATION strhelp = STR_CONFIG_SETTING_SHOW_TRACK_RESERVATION_HELPTEXT -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC [SDTC_VAR] @@ -3286,7 +3275,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_EXPENSES_LAYOUT strhelp = STR_CONFIG_SETTING_EXPENSES_LAYOUT_HELPTEXT -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } [SDTC_VAR] var = gui.station_gui_group_order @@ -3334,7 +3323,7 @@ max = 5 str = STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS strhelp = STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT strval = STR_JUST_COMMA -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } [SDTC_BOOL] var = gui.show_newgrf_name @@ -3342,7 +3331,7 @@ flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false str = STR_CONFIG_SETTING_SHOW_NEWGRF_NAME strhelp = STR_CONFIG_SETTING_SHOW_NEWGRF_NAME_HELPTEXT -proc = RedrawScreen +post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_ADVANCED ; For the dedicated build we'll enable dates in logs by default. @@ -3379,21 +3368,21 @@ cat = SC_EXPERT var = gui.newgrf_developer_tools flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false -proc = InvalidateNewGRFChangeWindows +post_cb = InvalidateNewGRFChangeWindows cat = SC_EXPERT [SDTC_BOOL] var = gui.ai_developer_tools flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false -proc = InvalidateAISettingsWindow +post_cb = [](auto) { InvalidateWindowClassesData(WC_AI_SETTINGS); } cat = SC_EXPERT [SDTC_BOOL] var = gui.scenario_developer flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC def = false -proc = InvalidateNewGRFChangeWindows +post_cb = InvalidateNewGRFChangeWindows [SDTC_BOOL] var = gui.newgrf_show_old_versions @@ -3409,7 +3398,7 @@ guiflags = SGF_MULTISTRING def = 1 min = 0 max = 1 -proc = UpdateNewGRFConfigPalette +post_cb = UpdateNewGRFConfigPalette cat = SC_EXPERT [SDTC_VAR] @@ -4029,7 +4018,7 @@ guiflags = SGF_NETWORK_ONLY def = 15 min = 1 max = MAX_COMPANIES -proc = UpdateClientConfigValues +post_cb = [](auto) { UpdateClientConfigValues(); } cat = SC_BASIC [SDTC_VAR] @@ -4040,7 +4029,7 @@ guiflags = SGF_NETWORK_ONLY def = 25 min = 2 max = MAX_CLIENTS -proc = UpdateClientConfigValues +post_cb = [](auto) { UpdateClientConfigValues(); } cat = SC_BASIC [SDTC_VAR] @@ -4051,7 +4040,7 @@ guiflags = SGF_NETWORK_ONLY def = 15 min = 0 max = MAX_CLIENTS -proc = UpdateClientConfigValues +post_cb = [](auto) { UpdateClientConfigValues(); } cat = SC_BASIC [SDTC_VAR] diff --git a/src/table/win32_settings.ini b/src/table/win32_settings.ini index 669474cc7..6b7d5276d 100644 --- a/src/table/win32_settings.ini +++ b/src/table/win32_settings.ini @@ -14,8 +14,8 @@ static const SettingTable _win32_settings{ }; #endif /* _WIN32 */ [templates] -SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -27,7 +27,8 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr +pre_cb = nullptr +post_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/window_settings.ini b/src/table/window_settings.ini index 5e11ea002..5334b0fc1 100644 --- a/src/table/window_settings.ini +++ b/src/table/window_settings.ini @@ -10,8 +10,8 @@ static const SettingTable _window_settings{ [post-amble] }; [templates] -SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size"); @@ -24,7 +24,8 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr +pre_cb = nullptr +post_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION |