Skip to content

Commit

Permalink
Feature: Set default company secondary colour for new games
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Wilson committed Jun 24, 2023
1 parent 71f241f commit 6fce419
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,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

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 @@ -871,12 +872,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, 0, (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 @@ -1853,6 +1853,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 @@ -179,6 +179,7 @@ struct GUISettings {
uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis
uint8 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 @@ -348,6 +348,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_DARK_BLUE

[SDTC_BOOL]
var = gui.auto_remove_signals
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
Expand Down

0 comments on commit 6fce419

Please sign in to comment.