diff options
author | frosch <frosch@openttd.org> | 2009-01-13 17:28:11 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-01-13 17:28:11 +0000 |
commit | 4780c732241b78be16df0cd493c79931c97344aa (patch) | |
tree | 009a3f4774db0f9f731df2883270fc763bd1493c | |
parent | e41655d67c2b1b6eb0f42466ed6723e7e1c32fd1 (diff) | |
download | openttd-4780c732241b78be16df0cd493c79931c97344aa.tar.xz |
(svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
-rw-r--r-- | src/station_gui.cpp | 17 | ||||
-rw-r--r-- | src/tilehighlight_func.h | 2 | ||||
-rw-r--r-- | src/viewport.cpp | 1 | ||||
-rw-r--r-- | src/window.cpp | 1 |
4 files changed, 15 insertions, 6 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(); diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h index 4a0f5bb0e..af57bcb29 100644 --- a/src/tilehighlight_func.h +++ b/src/tilehighlight_func.h @@ -24,6 +24,8 @@ void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDrag void VpSetPresizeRange(TileIndex from, TileIndex to); void VpSetPlaceSizingLimit(int limit); +void UpdateTileSelection(); + extern PlaceProc *_place_proc; extern TileHighlightData _thd; diff --git a/src/viewport.cpp b/src/viewport.cpp index 7029dc2da..57520bf54 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2116,7 +2116,6 @@ static HighLightStyle GetAutorailHT(int x, int y) * Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice, * Once for the old and once for the new selection. * _thd is TileHighlightData, found in viewport.h - * Called by MouseLoop() in windows.cpp */ void UpdateTileSelection() { diff --git a/src/window.cpp b/src/window.cpp index 32773982b..5ee2e1bf3 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1745,7 +1745,6 @@ enum MouseClick { TIME_BETWEEN_DOUBLE_CLICK = 500, ///< Time between 2 left clicks before it becoming a double click, in ms }; -extern void UpdateTileSelection(); extern bool VpHandlePlaceSizingDrag(); static void ScrollMainViewport(int x, int y) |