diff options
author | rubidium <rubidium@openttd.org> | 2009-07-30 17:44:13 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-07-30 17:44:13 +0000 |
commit | 5592eb49556630e7277cabb68c9d7a185eebd7f6 (patch) | |
tree | c9bb9482ae91f9c80145c41001fec505fe812a7c /src/rail_gui.cpp | |
parent | 4a1f6547c678331f5e16b0c06c1e84eaa7d50db9 (diff) | |
download | openttd-5592eb49556630e7277cabb68c9d7a185eebd7f6.tar.xz |
(svn r16993) -Change: make the rail waypoint builder draggable
Diffstat (limited to 'src/rail_gui.cpp')
-rw-r--r-- | src/rail_gui.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index f8bdec455..ce33956be 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -150,8 +150,18 @@ static void PlaceRail_Waypoint(TileIndex tile) { if (_remove_button_clicked) { VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION); + return; + } + + TrackBits bits = IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_NORMAL ? GetTrackBits(tile) : TRACK_BIT_NONE; + Track track = RemoveFirstTrack(&bits); + if (bits == TRACK_BIT_NONE && IsDiagonalTrack(track)) { + /* Valid tile for waypoints */ + VpStartPlaceSizing(tile, track == TRACK_X ? VPM_FIX_X : VPM_FIX_Y, DDSP_BUILD_STATION); } else { - DoCommandP(tile, _cur_waypoint_type, 0, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT), CcPlaySound1E); + /* Tile where we can't build rail waypoints. This is always going to fail, + * but provides the user with a proper error message. */ + DoCommandP(tile, 0, 0, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); } } @@ -760,6 +770,13 @@ struct BuildRailToolbarWindow : Window { /* Waypoint */ if (_remove_button_clicked) { DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E); + } else { + TileArea ta(start_tile, end_tile); + uint32 p1 = _cur_railtype | (select_method == VPM_FIX_X ? AXIS_X : AXIS_Y) << 4 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24; + uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16; + + CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT), CcPlaySound1E, "" }; + ShowSelectStationIfNeeded(cmdcont, ta); } } break; |