Skip to content

Commit

Permalink
Feature: Add config option to set default company secondary colour fo…
Browse files Browse the repository at this point in the history
…r new games

This does duplicate translation strings for the colours
  • Loading branch information
Henry Wilson authored and rubidium42 committed Jul 26, 2023
1 parent 5653a94 commit a9c65a6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/openttd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<CMD_SET_COMPANY_COLOUR>::Post(LS_DEFAULT, false, (Colours)_settings_client.gui.starting_colour_secondary);
}

OnStartGame(false);

InitializeRailGUI();
Expand Down
1 change: 1 addition & 0 deletions src/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
1 change: 1 addition & 0 deletions src/settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/table/settings/gui_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9c65a6

Please sign in to comment.