Fix #10118: Cycle through current signal group, not just path signals (#11798)

This commit is contained in:
Tyler Trahan 2024-02-02 15:51:57 -05:00 committed by GitHub
parent 2e6c6b719f
commit 6f6f09910d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 10 deletions

View File

@ -1939,7 +1939,7 @@ STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE_HELPTEXT :Set the year wh
STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES :Cycle through signal types: {STRING2}
STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES_HELPTEXT :Select which signal types to cycle through when Ctrl+Clicking on a built signal with the signal tool
###length 2
STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS :Path signals only
STR_CONFIG_SETTING_CYCLE_SIGNAL_GROUP :Current group only
STR_CONFIG_SETTING_CYCLE_SIGNAL_ALL :All visible
STR_CONFIG_SETTING_SIGNAL_GUI_MODE :Show signal types: {STRING2}

View File

@ -241,16 +241,36 @@ static void GenericPlaceSignals(TileIndex tile)
Command<CMD_REMOVE_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track);
} else {
/* Which signals should we cycle through? */
SignalType cycle_start = _settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL && _settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL ? SIGTYPE_BLOCK : SIGTYPE_PBS;
bool tile_has_signal = IsValidTrack(track) && HasSignalOnTrack(tile, track);
SignalType cur_signal_on_tile = tile_has_signal ? GetSignalType(tile, track) : _cur_signal_type;
SignalType cycle_start;
SignalType cycle_end;
/* Start with the least restrictive case: the player wants to cycle through all signals they can see. */
if (_settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL) {
cycle_start = _settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL ? SIGTYPE_BLOCK : SIGTYPE_PBS;
cycle_end = SIGTYPE_LAST;
} else {
/* Only cycle through signals of the same group (block or path) as the current signal on the tile. */
if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
/* Block signals only. */
cycle_start = SIGTYPE_BLOCK;
cycle_end = SIGTYPE_LAST_NOPBS;
} else {
/* Path signals only. */
cycle_start = SIGTYPE_PBS;
cycle_end = SIGTYPE_LAST;
}
}
if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) {
/* signal GUI is used */
Command<CMD_BUILD_SINGLE_SIGNAL>::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0);
} else {
SignalVariant sigvar = TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
Command<CMD_BUILD_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
tile, track, _settings_client.gui.default_signal_type, 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, cycle_end, 0, 0);
}
}

View File

@ -27,8 +27,8 @@ enum SignalGUISettings : uint8_t {
/** Settings for which signals are cycled through by control-clicking on the signal with the signal tool. */
enum SignalCycleSettings : uint8_t {
SIGNAL_CYCLE_PATH = 0, ///< Cycle through path signals only.
SIGNAL_CYCLE_ALL = 1, ///< Cycle through all signals visible.
SIGNAL_CYCLE_GROUP = 0, ///< Cycle through current signal group (block or path) only.
SIGNAL_CYCLE_ALL = 1, ///< Cycle through all signals visible to the player.
};
#endif /* RAIL_GUI_H */

View File

@ -519,13 +519,13 @@ cat = SC_EXPERT
var = gui.cycle_signal_types
type = SLE_UINT8
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
def = 0
min = 0
max = 1
def = SIGNAL_CYCLE_GROUP
min = SIGNAL_CYCLE_GROUP
max = SIGNAL_CYCLE_ALL
interval = 1
str = STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES
strhelp = STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES_HELPTEXT
strval = STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS
strval = STR_CONFIG_SETTING_CYCLE_SIGNAL_GROUP
cat = SC_ADVANCED
[SDTC_VAR]