mirror of https://github.com/OpenTTD/OpenTTD
Feature: Remember the last-used signal between games (#9792)
parent
25ae42ae8a
commit
7f0efbe00e
|
@ -250,7 +250,7 @@ static void GenericPlaceSignals(TileIndex tile)
|
||||||
} else {
|
} else {
|
||||||
SignalVariant sigvar = _cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
|
SignalVariant sigvar = _cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
|
||||||
Command<CMD_BUILD_SIGNALS>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
|
Command<CMD_BUILD_SIGNALS>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
|
||||||
tile, track, SIGTYPE_PBS_ONEWAY, sigvar, false, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
|
tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ static void HandleAutoSignalPlacement()
|
||||||
TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed);
|
TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed);
|
||||||
} else {
|
} else {
|
||||||
bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr;
|
bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr;
|
||||||
SignalType sigtype = sig_gui ? _cur_signal_type : SIGTYPE_PBS_ONEWAY;
|
SignalType sigtype = sig_gui ? _cur_signal_type : _settings_client.gui.default_signal_type;
|
||||||
SignalVariant sigvar = sig_gui ? _cur_signal_variant : (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
|
SignalVariant sigvar = sig_gui ? _cur_signal_variant : (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
|
||||||
Command<CMD_BUILD_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
|
Command<CMD_BUILD_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
|
||||||
TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, _ctrl_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density);
|
TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, _ctrl_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density);
|
||||||
|
@ -1793,6 +1793,9 @@ public:
|
||||||
_cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
|
_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;
|
_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 of rail build toolbar is active, disable it. */
|
||||||
if (_remove_button_clicked) {
|
if (_remove_button_clicked) {
|
||||||
Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
|
Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
|
||||||
|
@ -2200,7 +2203,7 @@ void InitializeRailGUI()
|
||||||
SetDefaultRailGui();
|
SetDefaultRailGui();
|
||||||
|
|
||||||
_convert_signal_button = false;
|
_convert_signal_button = false;
|
||||||
_cur_signal_type = SIGTYPE_PBS_ONEWAY;
|
_cur_signal_type = _settings_client.gui.default_signal_type;
|
||||||
ResetSignalVariant();
|
ResetSignalVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "zoom_type.h"
|
#include "zoom_type.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "rail_gui.h"
|
#include "rail_gui.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;
|
||||||
|
@ -146,6 +147,7 @@ struct GUISettings {
|
||||||
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 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
|
||||||
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
||||||
|
|
|
@ -458,6 +458,14 @@ strval = STR_CONFIG_SETTING_SIGNAL_GUI_MODE_PATH
|
||||||
post_cb = [](auto) { CloseWindowByClass(WC_BUILD_SIGNAL); }
|
post_cb = [](auto) { CloseWindowByClass(WC_BUILD_SIGNAL); }
|
||||||
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.coloured_news_year
|
var = gui.coloured_news_year
|
||||||
type = SLE_INT32
|
type = SLE_INT32
|
||||||
|
|
Loading…
Reference in New Issue