Feature: Remember the last-used signal between games
(cherry picked from commit a9de36ad23f30d125ed495f0bd84342b594d19df) See: https://github.com/OpenTTD/OpenTTD/pull/9792
This commit is contained in:

committed by
Jonathan G Rennison

parent
e5110bd7f6
commit
bec218069c
@@ -220,6 +220,13 @@ static void PlaceRail_Station(TileIndex tile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SignalType GetDefaultSignalType()
|
||||||
|
{
|
||||||
|
SignalType sigtype = _settings_client.gui.default_signal_type;
|
||||||
|
if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC && IsSignalTypeUnsuitableForRealisticBraking(sigtype)) return SIGTYPE_PBS_ONEWAY;
|
||||||
|
return sigtype;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
|
* Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
|
||||||
*
|
*
|
||||||
@@ -291,7 +298,7 @@ static void GenericPlaceSignals(TileIndex tile)
|
|||||||
} else {
|
} else {
|
||||||
SB(p1, 3, 1, _ctrl_pressed);
|
SB(p1, 3, 1, _ctrl_pressed);
|
||||||
SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
|
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, GetDefaultSignalType());
|
||||||
SB(p1, 8, 1, 0);
|
SB(p1, 8, 1, 0);
|
||||||
SB(p1, 9, 6, cycle_types);
|
SB(p1, 9, 6, cycle_types);
|
||||||
}
|
}
|
||||||
@@ -471,7 +478,7 @@ static void HandleAutoSignalPlacement()
|
|||||||
SB(p2, 3, 1, 0);
|
SB(p2, 3, 1, 0);
|
||||||
SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
|
SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
|
||||||
SB(p2, 6, 1, _ctrl_pressed);
|
SB(p2, 6, 1, _ctrl_pressed);
|
||||||
SB(p2, 7, 3, SIGTYPE_PBS_ONEWAY);
|
SB(p2, 7, 3, GetDefaultSignalType());
|
||||||
SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
|
SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
|
||||||
SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance);
|
SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance);
|
||||||
}
|
}
|
||||||
@@ -1977,6 +1984,9 @@ public:
|
|||||||
_cur_signal_type = TypeForClick(_cur_signal_button);
|
_cur_signal_type = TypeForClick(_cur_signal_button);
|
||||||
_cur_signal_variant = widget >= WID_BS_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
|
_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 = Clamp<SignalType>(_cur_signal_type, SIGTYPE_NORMAL, SIGTYPE_PBS_ONEWAY);
|
||||||
|
|
||||||
/* If 'remove' button of rail build toolbar is active, disable it. */
|
/* If 'remove' button of rail build toolbar is active, disable it. */
|
||||||
ClearRemoveState();
|
ClearRemoveState();
|
||||||
break;
|
break;
|
||||||
@@ -2457,7 +2467,7 @@ void InitializeRailGUI()
|
|||||||
_convert_signal_button = false;
|
_convert_signal_button = false;
|
||||||
_trace_restrict_button = false;
|
_trace_restrict_button = false;
|
||||||
_program_signal_button = false;
|
_program_signal_button = false;
|
||||||
_cur_signal_type = SIGTYPE_PBS_ONEWAY;
|
_cur_signal_type = GetDefaultSignalType();
|
||||||
_cur_signal_button =
|
_cur_signal_button =
|
||||||
_cur_signal_type == SIGTYPE_PROG ? 4 :
|
_cur_signal_type == SIGTYPE_PROG ? 4 :
|
||||||
_cur_signal_type == SIGTYPE_PBS ? 5 :
|
_cur_signal_type == SIGTYPE_PBS ? 5 :
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "rail_gui_type.h"
|
#include "rail_gui_type.h"
|
||||||
#include "station_type.h"
|
#include "station_type.h"
|
||||||
|
#include "signal_type.h"
|
||||||
|
|
||||||
/* Used to validate sizes of "max" value in settings. */
|
/* Used to validate sizes of "max" value in settings. */
|
||||||
const size_t MAX_SLE_UINT8 = UINT8_MAX;
|
const size_t MAX_SLE_UINT8 = UINT8_MAX;
|
||||||
@@ -192,6 +193,7 @@ struct GUISettings : public TimeSettings {
|
|||||||
bool pause_on_newgame; ///< whether to start new games paused or not
|
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
|
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.
|
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?
|
Year coloured_news_year; ///< when does newspaper become coloured?
|
||||||
bool override_time_settings; ///< Whether to override time display settings stored in savegame.
|
bool override_time_settings; ///< Whether to override time display settings stored in savegame.
|
||||||
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
||||||
|
@@ -4935,6 +4935,14 @@ strhelp = STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES_HELPTEXT
|
|||||||
strval = STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS
|
strval = STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS
|
||||||
cat = SC_ADVANCED
|
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]
|
[SDTC_VAR]
|
||||||
var = gui.drag_signals_density
|
var = gui.drag_signals_density
|
||||||
type = SLE_UINT8
|
type = SLE_UINT8
|
||||||
|
Reference in New Issue
Block a user