Changeset - r28646:f7d76fe6fd3a
[Not reviewed]
master
0 4 0
Tyler Trahan - 10 months ago 2024-02-02 20:51:57
tyler@tylertrahan.com
Fix #10118: Cycle through current signal group, not just path signals (#11798)
4 files changed with 30 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1939,7 +1939,7 @@ STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFOR
 
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}
src/rail_gui.cpp
Show inline comments
 
@@ -241,16 +241,36 @@ static void GenericPlaceSignals(TileInde
 
		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);
 

	
 
		}
 
	}
src/rail_gui.h
Show inline comments
 
@@ -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 */
src/table/settings/gui_settings.ini
Show inline comments
 
@@ -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]
0 comments (0 inline, 0 general)