1
0
Fork 0

Feature: Remember the last-used signal between games (#9792)

pull/9844/head
Tyler Trahan 2022-02-02 14:26:46 -07:00 committed by Patric Stout
parent 8639e222c8
commit 45a1036177
3 changed files with 16 additions and 3 deletions

View File

@ -250,7 +250,7 @@ static void GenericPlaceSignals(TileIndex tile)
} else {
SB(p1, 3, 1, _ctrl_pressed);
SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
SB(p1, 5, 3, SIGTYPE_PBS_ONEWAY);
SB(p1, 5, 3, _settings_client.gui.default_signal_type);
SB(p1, 8, 1, 0);
SB(p1, 9, 6, cycle_types);
}
@ -407,7 +407,7 @@ static void HandleAutoSignalPlacement()
SB(p2, 3, 1, 0);
SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
SB(p2, 6, 1, _ctrl_pressed);
SB(p2, 7, 3, SIGTYPE_PBS_ONEWAY);
SB(p2, 7, 3, _settings_client.gui.default_signal_type);
SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance);
}
@ -1797,6 +1797,9 @@ public:
_cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
_cur_signal_variant = widget >= WID_BS_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
/* Update default (last-used) signal type in config file. */
_settings_client.gui.default_signal_type = _cur_signal_type;
/* If 'remove' button of rail build toolbar is active, disable it. */
if (_remove_button_clicked) {
Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
@ -2204,7 +2207,7 @@ void InitializeRailGUI()
SetDefaultRailGui();
_convert_signal_button = false;
_cur_signal_type = SIGTYPE_PBS_ONEWAY;
_cur_signal_type = _settings_client.gui.default_signal_type;
ResetSignalVariant();
}

View File

@ -21,6 +21,7 @@
#include "zoom_type.h"
#include "openttd.h"
#include "rail_gui.h"
#include "signal_type.h"
/* Used to validate sizes of "max" value in settings. */
const size_t MAX_SLE_UINT8 = UINT8_MAX;
@ -146,6 +147,7 @@ struct GUISettings {
bool pause_on_newgame; ///< whether to start new games paused or not
SignalGUISettings signal_gui_mode; ///< select which signal types are shown in the signal GUI
SignalCycleSettings cycle_signal_types; ///< Which signal types to cycle with the build signal tool.
SignalType default_signal_type; ///< The default signal type, which is set automatically by the last signal used. Not available in Settings.
Year coloured_news_year; ///< when does newspaper become coloured?
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window

View File

@ -458,6 +458,14 @@ strval = STR_CONFIG_SETTING_SIGNAL_GUI_MODE_PATH
post_cb = [](auto) { CloseWindowByClass(WC_BUILD_SIGNAL); }
cat = SC_ADVANCED
[SDTC_VAR]
var = gui.default_signal_type
type = SLE_UINT8
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
def = 5
min = 0
max = 5
[SDTC_VAR]
var = gui.coloured_news_year
type = SLE_INT32