summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-01-13 17:28:11 +0000
committerfrosch <frosch@openttd.org>2009-01-13 17:28:11 +0000
commit7014833641e9115c49acc9bb0757c4128953ab8c (patch)
tree009a3f4774db0f9f731df2883270fc763bd1493c /src/station_gui.cpp
parent2ae730b220f1d35db9e0dafbebf611089bf2255f (diff)
downloadopenttd-7014833641e9115c49acc9bb0757c4128953ab8c.tar.xz
(svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 2902a8121..cdfc2b955 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -1206,17 +1206,26 @@ static const WindowDesc _select_station_desc = {
*/
static bool StationJoinerNeeded(CommandContainer cmd, int w, int h)
{
- if (CmdFailed(DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))))) return false;
-
/* Only show selection if distant join is enabled in the settings */
if (!_settings_game.station.distant_join_stations) return false;
- /* If a window is already opened, we always return true */
- if (FindWindowById(WC_SELECT_STATION, 0) != NULL) return true;
+ /* If a window is already opened and we didn't ctrl-click,
+ * return true (i.e. just flash the old window) */
+ Window *selection_window = FindWindowById(WC_SELECT_STATION, 0);
+ if (selection_window != NULL) {
+ if (!_ctrl_pressed) return true;
+
+ /* Abort current distant-join and start new one */
+ delete selection_window;
+ UpdateTileSelection();
+ }
/* only show the popup, if we press ctrl */
if (!_ctrl_pressed) return false;
+ /* Now check if we could build there */
+ if (CmdFailed(DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))))) return false;
+
/* First test for adjacent station */
FindStationsNearby(cmd.tile, w, h, false);
int neighbour_station_count = _stations_nearby_list.Length();