From 0409577277c04a0f6a1f022c28745716b259b93c Mon Sep 17 00:00:00 2001 From: merni-ns <66267867+merni-ns@users.noreply.github.com> Date: Sun, 16 Jun 2024 02:44:29 +0530 Subject: [PATCH] Add: Setting to disable warning for old vehicles (#12714) --- src/lang/english.txt | 3 +++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/gui_settings.ini | 7 +++++++ src/vehicle.cpp | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index cbb10cf08b..d54f117745 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1488,6 +1488,9 @@ STR_CONFIG_SETTING_WARN_INCOME_LESS :Warn if a vehic STR_CONFIG_SETTING_WARN_INCOME_LESS_HELPTEXT :When enabled, a news message gets sent when a vehicle has not made any profit within a year STR_CONFIG_SETTING_WARN_INCOME_LESS_HELPTEXT_PERIOD :When enabled, a news message gets sent when a vehicle has not made any profit within a period +STR_CONFIG_SETTING_WARN_OLD_VEHICLE :Warn if a vehicle is getting old: {STRING2} +STR_CONFIG_SETTING_WARN_OLD_VEHICLE_HELPTEXT :When enabled, a news message gets sent when a vehicle is getting old + STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES :Vehicles never expire: {STRING2} STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT :When enabled, all vehicle models remain available forever after their introduction diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 64ab66b970..e87401ddfb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2074,6 +2074,7 @@ static SettingsContainer &GetSettingsTree() advisors->Add(new SettingEntry("gui.order_review_system")); advisors->Add(new SettingEntry("gui.vehicle_income_warn")); advisors->Add(new SettingEntry("gui.lost_vehicle_warn")); + advisors->Add(new SettingEntry("gui.old_vehicle_warn")); advisors->Add(new SettingEntry("gui.show_finances")); advisors->Add(new SettingEntry("news_display.economy")); advisors->Add(new SettingEntry("news_display.subsidies")); diff --git a/src/settings_type.h b/src/settings_type.h index 239a845a90..639d1d8060 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -132,6 +132,7 @@ struct GUISettings { bool lost_vehicle_warn; ///< if a vehicle can't find its destination, show a warning uint8_t order_review_system; ///< perform order reviews on vehicles bool vehicle_income_warn; ///< if a vehicle isn't generating income, show a warning + bool old_vehicle_warn; ///< if a vehicle is getting old, show a warning bool show_finances; ///< show finances at end of year bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames bool new_nonstop; ///< ttdpatch compatible nonstop handling diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 903a9532a1..ae01f9feb5 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -591,6 +591,13 @@ def = true str = STR_CONFIG_SETTING_WARN_LOST_VEHICLE strhelp = STR_CONFIG_SETTING_WARN_LOST_VEHICLE_HELPTEXT +[SDTC_BOOL] +var = gui.old_vehicle_warn +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_WARN_OLD_VEHICLE +strhelp = STR_CONFIG_SETTING_WARN_OLD_VEHICLE_HELPTEXT + [SDTC_BOOL] var = gui.new_nonstop flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d0a16880f6..5903ea259f 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1454,6 +1454,9 @@ void AgeVehicle(Vehicle *v) SetWindowDirty(WC_VEHICLE_DETAILS, v->index); + /* Don't warn if warnings are disabled */ + if (!_settings_client.gui.old_vehicle_warn) return; + /* Don't warn about vehicles which are non-primary (e.g., part of an articulated vehicle), don't belong to us, are crashed, or are stopped */ if (v->Previous() != nullptr || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0 || (v->vehstatus & VS_STOPPED) != 0) return;