From a9c65a69d081aa0c11981c0ad87832e8b40745e2 Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Sat, 24 Jun 2023 21:50:04 +0100 Subject: [PATCH] Feature: Add config option to set default company secondary colour for new games This does duplicate translation strings for the colours --- src/lang/english.txt | 23 +++++++++++++++++++++++ src/openttd.cpp | 6 ++++++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/gui_settings.ini | 11 +++++++++++ 5 files changed, 42 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index ef21c75a14..d339bef374 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -190,6 +190,26 @@ STR_COLOUR_GREY :Grey STR_COLOUR_WHITE :White STR_COLOUR_RANDOM :Random +###length 17 +STR_COLOUR_SECONDARY_DARK_BLUE :Dark Blue +STR_COLOUR_SECONDARY_PALE_GREEN :Pale Green +STR_COLOUR_SECONDARY_SECONDARY_PINK :Pink +STR_COLOUR_SECONDARY_YELLOW :Yellow +STR_COLOUR_SECONDARY_RED :Red +STR_COLOUR_SECONDARY_LIGHT_BLUE :Light Blue +STR_COLOUR_SECONDARY_GREEN :Green +STR_COLOUR_SECONDARY_DARK_GREEN :Dark Green +STR_COLOUR_SECONDARY_BLUE :Blue +STR_COLOUR_SECONDARY_CREAM :Cream +STR_COLOUR_SECONDARY_MAUVE :Mauve +STR_COLOUR_SECONDARY_PURPLE :Purple +STR_COLOUR_SECONDARY_ORANGE :Orange +STR_COLOUR_SECONDARY_BROWN :Brown +STR_COLOUR_SECONDARY_GREY :Grey +STR_COLOUR_SECONDARY_WHITE :White +STR_COLOUR_SECONDARY_SAME_AS_PRIMARY :Same As Primary + + # Units used in OpenTTD STR_UNITS_VELOCITY_IMPERIAL :{DECIMAL}{NBSP}mph STR_UNITS_VELOCITY_METRIC :{DECIMAL}{NBSP}km/h @@ -1418,6 +1438,9 @@ STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :When enabled, i STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR :Starting company colour: {STRING2} STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT :Choose starting colour for the company +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY :Starting company secondary colour: {STRING2} +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY_HELPTEXT :Choose starting secondary colour for the company, if using a NewGRF that enables it. + STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Airports never expire: {STRING2} STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Enabling this setting makes each airport type stay available forever after its introduction diff --git a/src/openttd.cpp b/src/openttd.cpp index 92aa82b63a..bb54a7168a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -22,6 +22,7 @@ #include "base_media_base.h" #include "saveload/saveload.h" +#include "company_cmd.h" #include "company_func.h" #include "command_func.h" #include "news_func.h" @@ -861,12 +862,17 @@ static void MakeNewGameDone() /* Overwrite color from settings if needed * COLOUR_END corresponds to Random colour */ + if (_settings_client.gui.starting_colour != COLOUR_END) { c->colour = _settings_client.gui.starting_colour; ResetCompanyLivery(c); _company_colours[c->index] = (Colours)c->colour; } + if (_settings_client.gui.starting_colour_secondary != COLOUR_END && HasBit(_loaded_newgrf_features.used_liveries, LS_DEFAULT)) { + Command::Post(LS_DEFAULT, false, (Colours)_settings_client.gui.starting_colour_secondary); + } + OnStartGame(false); InitializeRailGUI(); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index d9b5e204e8..a34651397c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1860,6 +1860,7 @@ static SettingsContainer &GetSettingsTree() company->Add(new SettingEntry("gui.new_nonstop")); company->Add(new SettingEntry("gui.stop_location")); company->Add(new SettingEntry("gui.starting_colour")); + company->Add(new SettingEntry("gui.starting_colour_secondary")); company->Add(new SettingEntry("company.engine_renew")); company->Add(new SettingEntry("company.engine_renew_months")); company->Add(new SettingEntry("company.engine_renew_money")); diff --git a/src/settings_type.h b/src/settings_type.h index 123638939f..d31381bbe2 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -186,6 +186,7 @@ struct GUISettings { uint8_t graph_line_thickness; ///< the thickness of the lines in the various graph guis uint8_t osk_activation; ///< Mouse gesture to trigger the OSK. byte starting_colour; ///< default color scheme for the company to start a new game with + byte starting_colour_secondary; ///< default secondary color scheme for the company to start a new game with bool show_newgrf_name; ///< Show the name of the NewGRF in the build vehicle window bool show_cargo_in_vehicle_lists; ///< Show the cargoes the vehicles can carry in the list windows bool auto_remove_signals; ///< automatically remove signals when in the way during rail construction diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 2d8128aa7c..6780ae01fa 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -352,6 +352,17 @@ str = STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR strhelp = STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT strval = STR_COLOUR_DARK_BLUE +[SDTC_VAR] +var = gui.starting_colour_secondary +type = SLE_UINT8 +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN +def = COLOUR_END +min = 0 +max = COLOUR_END +str = STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY +strhelp = STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY_HELPTEXT +strval = STR_COLOUR_SECONDARY_DARK_BLUE + [SDTC_BOOL] var = gui.auto_remove_signals flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC