2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file road_gui.cpp GUI for building roads. */
|
2007-03-28 20:41:35 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "station_gui.h"
|
2008-01-06 18:56:43 +00:00
|
|
|
#include "terraform_gui.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2007-05-21 21:58:31 +00:00
|
|
|
#include "road_cmd.h"
|
2009-01-31 20:16:06 +00:00
|
|
|
#include "station_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
2007-12-29 09:24:26 +00:00
|
|
|
#include "sound_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
2008-04-18 10:16:51 +00:00
|
|
|
#include "tunnelbridge.h"
|
2010-03-17 20:19:55 +00:00
|
|
|
#include "tunnelbridge_map.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_base.h"
|
2010-07-04 10:57:31 +00:00
|
|
|
#include "hotkeys.h"
|
2011-01-14 12:01:07 +00:00
|
|
|
#include "road_gui.h"
|
2004-12-08 15:46:13 +00:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/road_widget.h"
|
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowRVStationPicker(Window *parent, RoadStopType rs);
|
|
|
|
static void ShowRoadDepotPicker(Window *parent);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static bool _remove_button_clicked;
|
2007-11-18 13:55:23 +00:00
|
|
|
static bool _one_way_button_clicked;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Define the values of the RoadFlags
|
|
|
|
* @see CmdBuildLongRoad
|
|
|
|
*/
|
|
|
|
enum RoadFlags {
|
|
|
|
RF_NONE = 0x00,
|
2007-10-26 16:38:32 +00:00
|
|
|
RF_START_HALFROAD_Y = 0x01, // The start tile in Y-dir should have only a half road
|
|
|
|
RF_END_HALFROAD_Y = 0x02, // The end tile in Y-dir should have only a half road
|
2007-10-22 19:11:50 +00:00
|
|
|
RF_DIR_Y = 0x04, // The direction is Y-dir
|
|
|
|
RF_DIR_X = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
|
2007-10-26 16:38:32 +00:00
|
|
|
RF_START_HALFROAD_X = 0x08, // The start tile in X-dir should have only a half road
|
|
|
|
RF_END_HALFROAD_X = 0x10, // The end tile in X-dir should have only a half road
|
2007-10-22 19:11:50 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(RoadFlags)
|
2007-10-22 19:11:50 +00:00
|
|
|
|
|
|
|
static RoadFlags _place_road_flag;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-05-21 21:58:31 +00:00
|
|
|
static RoadType _cur_roadtype;
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
static DiagDirection _road_depot_orientation;
|
|
|
|
static DiagDirection _road_station_picker_orientation;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-01-11 18:46:09 +00:00
|
|
|
void CcPlaySound1D(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Succeeded()) SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
2010-12-20 19:24:27 +00:00
|
|
|
* Callback to start placing a bridge.
|
|
|
|
* @param tile Start tile of the bridge.
|
2007-10-22 19:11:50 +00:00
|
|
|
*/
|
2010-12-20 19:24:27 +00:00
|
|
|
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-03-17 20:19:55 +00:00
|
|
|
if (IsBridgeTile(tile)) {
|
|
|
|
TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
|
|
|
|
Point pt = {0, 0};
|
2010-12-20 19:24:27 +00:00
|
|
|
w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, tile, other_tile);
|
2010-03-17 20:19:55 +00:00
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 12:01:07 +00:00
|
|
|
/**
|
|
|
|
* Callback executed after a build road tunnel command has been called.
|
|
|
|
*
|
|
|
|
* @param result Whether the build succeeded.
|
|
|
|
* @param start_tile Starting tile of the tunnel.
|
|
|
|
* @param p1 bit 0-3 railtype or roadtypes
|
|
|
|
* bit 8-9 transport type
|
|
|
|
* @param p2 unused
|
|
|
|
*/
|
2011-01-14 12:46:05 +00:00
|
|
|
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Succeeded()) {
|
2011-01-14 12:01:07 +00:00
|
|
|
SndPlayTileFx(SND_20_SPLAT_2, start_tile);
|
2009-01-07 17:40:17 +00:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2011-01-14 12:01:07 +00:00
|
|
|
|
|
|
|
DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
|
|
|
|
ConnectRoadToStructure(start_tile, start_direction);
|
|
|
|
|
|
|
|
TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
|
|
|
|
DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
|
|
|
|
ConnectRoadToStructure(end_tile, end_direction);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
|
|
|
SetRedErrorSquare(_build_tunnel_endtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-24 08:36:11 +00:00
|
|
|
/** Structure holding information per roadtype for several functions */
|
|
|
|
struct RoadTypeInfo {
|
|
|
|
StringID err_build_road; ///< Building a normal piece of road
|
|
|
|
StringID err_remove_road; ///< Removing a normal piece of road
|
|
|
|
StringID err_depot; ///< Building a depot
|
|
|
|
StringID err_build_station[2]; ///< Building a bus or truck station
|
|
|
|
StringID err_remove_station[2]; ///< Removing of a bus or truck station
|
|
|
|
|
2007-05-25 23:21:32 +00:00
|
|
|
StringID picker_title[2]; ///< Title for the station picker for bus or truck stations
|
|
|
|
StringID picker_tooltip[2]; ///< Tooltip for the station picker for bus or truck stations
|
|
|
|
|
2007-05-24 08:36:11 +00:00
|
|
|
SpriteID cursor_nesw; ///< Cursor for building NE and SW bits
|
|
|
|
SpriteID cursor_nwse; ///< Cursor for building NW and SE bits
|
2007-10-22 19:11:50 +00:00
|
|
|
SpriteID cursor_autoroad; ///< Cursor for building autoroad
|
2007-05-24 08:36:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** What errors/cursors must be shown for several types of roads */
|
|
|
|
static const RoadTypeInfo _road_type_infos[] = {
|
|
|
|
{
|
2009-04-21 23:40:56 +00:00
|
|
|
STR_ERROR_CAN_T_BUILD_ROAD_HERE,
|
|
|
|
STR_ERROR_CAN_T_REMOVE_ROAD_FROM,
|
|
|
|
STR_ERROR_CAN_T_BUILD_ROAD_DEPOT,
|
|
|
|
{ STR_ERROR_CAN_T_BUILD_BUS_STATION, STR_ERROR_CAN_T_BUILD_TRUCK_STATION },
|
|
|
|
{ STR_ERROR_CAN_T_REMOVE_BUS_STATION, STR_ERROR_CAN_T_REMOVE_TRUCK_STATION },
|
|
|
|
{ STR_STATION_BUILD_BUS_ORIENTATION, STR_STATION_BUILD_TRUCK_ORIENTATION },
|
|
|
|
{ STR_STATION_BUILD_BUS_ORIENTATION_TOOLTIP, STR_STATION_BUILD_TRUCK_ORIENTATION_TOOLTIP },
|
2007-05-24 08:36:11 +00:00
|
|
|
|
|
|
|
SPR_CURSOR_ROAD_NESW,
|
|
|
|
SPR_CURSOR_ROAD_NWSE,
|
2007-10-22 19:11:50 +00:00
|
|
|
SPR_CURSOR_AUTOROAD,
|
2007-05-24 08:36:11 +00:00
|
|
|
},
|
2007-05-25 22:07:40 +00:00
|
|
|
{
|
2009-04-21 23:40:56 +00:00
|
|
|
STR_ERROR_CAN_T_BUILD_TRAMWAY_HERE,
|
|
|
|
STR_ERROR_CAN_T_REMOVE_TRAMWAY_FROM,
|
|
|
|
STR_ERROR_CAN_T_BUILD_TRAM_DEPOT,
|
|
|
|
{ STR_ERROR_CAN_T_BUILD_PASSENGER_TRAM_STATION, STR_ERROR_CAN_T_BUILD_CARGO_TRAM_STATION },
|
|
|
|
{ STR_ERROR_CAN_T_REMOVE_PASSENGER_TRAM_STATION, STR_ERROR_CAN_T_REMOVE_CARGO_TRAM_STATION },
|
|
|
|
{ STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION, STR_STATION_BUILD_CARGO_TRAM_ORIENTATION },
|
|
|
|
{ STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION_TOOLTIP, STR_STATION_BUILD_CARGO_TRAM_ORIENTATION_TOOLTIP },
|
2007-05-25 22:07:40 +00:00
|
|
|
|
|
|
|
SPR_CURSOR_TRAMWAY_NESW,
|
|
|
|
SPR_CURSOR_TRAMWAY_NWSE,
|
2007-10-22 19:11:50 +00:00
|
|
|
SPR_CURSOR_AUTOTRAM,
|
2007-05-25 22:07:40 +00:00
|
|
|
},
|
2007-05-24 08:36:11 +00:00
|
|
|
};
|
|
|
|
|
2011-01-14 11:55:40 +00:00
|
|
|
/**
|
|
|
|
* If required, connects a new structure to an existing road or tram by building the missing roadbit.
|
|
|
|
* @param tile Tile containing the structure to connect.
|
|
|
|
* @param direction Direction to check.
|
|
|
|
*/
|
|
|
|
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-09-05 23:21:41 +00:00
|
|
|
tile += TileOffsByDiagDir(direction);
|
2008-04-04 18:41:16 +00:00
|
|
|
/* if there is a roadpiece just outside of the station entrance, build a connecting route */
|
2008-02-14 15:59:16 +00:00
|
|
|
if (IsNormalRoadTile(tile)) {
|
2007-05-21 21:58:31 +00:00
|
|
|
if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
|
2008-12-28 14:37:19 +00:00
|
|
|
DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD);
|
2007-05-21 21:58:31 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-11 18:46:09 +00:00
|
|
|
void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Failed()) return;
|
|
|
|
|
|
|
|
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
|
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2011-01-14 11:55:40 +00:00
|
|
|
ConnectRoadToStructure(tile, dir);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Command callback for building road stops.
|
2010-02-24 21:45:23 +00:00
|
|
|
* @param result Result of the build road stop command.
|
2010-02-24 21:51:59 +00:00
|
|
|
* @param tile Start tile.
|
|
|
|
* @param p1 bit 0..7: Width of the road stop.
|
|
|
|
* bit 8..15: Length of the road stop.
|
2010-02-24 21:45:23 +00:00
|
|
|
* @param p2 bit 0: 0 For bus stops, 1 for truck stops.
|
|
|
|
* bit 1: 0 For normal stops, 1 for drive-through.
|
|
|
|
* bit 2..3: The roadtypes.
|
|
|
|
* bit 5: Allow stations directly adjacent to other stations.
|
|
|
|
* bit 6..7: Entrance direction (#DiagDirection).
|
|
|
|
* bit 16..31: Station ID to join (NEW_STATION if build new one).
|
|
|
|
* @see CmdBuildRoadStop
|
|
|
|
*/
|
|
|
|
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
if (result.Failed()) return;
|
|
|
|
|
|
|
|
DiagDirection dir = (DiagDirection)GB(p2, 6, 2);
|
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2010-02-24 21:51:59 +00:00
|
|
|
TileArea roadstop_area(tile, GB(p1, 0, 8), GB(p1, 8, 8));
|
|
|
|
TILE_AREA_LOOP(cur_tile, roadstop_area) {
|
2011-01-14 11:55:40 +00:00
|
|
|
ConnectRoadToStructure(cur_tile, dir);
|
2010-02-24 21:51:59 +00:00
|
|
|
/* For a drive-through road stop build connecting road for other entrance. */
|
2011-01-14 11:55:40 +00:00
|
|
|
if (HasBit(p2, 1)) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
|
2010-02-24 21:51:59 +00:00
|
|
|
}
|
2010-02-24 21:45:23 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 21:51:59 +00:00
|
|
|
/**
|
|
|
|
* Place a new road stop.
|
|
|
|
* @param start_tile First tile of the area.
|
|
|
|
* @param end_tile Last tile of the area.
|
|
|
|
* @param p2 bit 0: 0 For bus stops, 1 for truck stops.
|
|
|
|
* bit 2..3: The roadtypes.
|
|
|
|
* bit 5: Allow stations directly adjacent to other stations.
|
|
|
|
* @param cmd Command to use.
|
|
|
|
* @see CcRoadStop()
|
|
|
|
*/
|
|
|
|
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
|
2007-02-14 16:37:16 +00:00
|
|
|
{
|
2010-02-24 21:45:23 +00:00
|
|
|
uint8 ddir = _road_station_picker_orientation;
|
2009-01-08 16:35:45 +00:00
|
|
|
SB(p2, 16, 16, INVALID_STATION); // no station to join
|
2007-02-14 16:37:16 +00:00
|
|
|
|
2010-02-24 21:45:23 +00:00
|
|
|
if (ddir >= DIAGDIR_END) {
|
|
|
|
SetBit(p2, 1); // It's a drive-through stop.
|
|
|
|
ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2010-02-24 21:45:23 +00:00
|
|
|
p2 |= ddir << 6; // Set the DiagDirecion into p2 bits 6 and 7.
|
|
|
|
|
2010-02-24 21:51:59 +00:00
|
|
|
TileArea ta(start_tile, end_tile);
|
|
|
|
CommandContainer cmdcont = { ta.tile, ta.w | ta.h << 8, p2, cmd, CcRoadStop, "" };
|
|
|
|
ShowSelectStationIfNeeded(cmdcont, ta);
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 19:24:27 +00:00
|
|
|
/**
|
|
|
|
* Callback for placing a bus station.
|
|
|
|
* @param tile Position to place the station.
|
|
|
|
*/
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_BusStation(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-24 13:00:32 +00:00
|
|
|
if (_remove_button_clicked) {
|
2010-02-24 21:53:16 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_BUSSTOP);
|
2007-02-14 16:37:16 +00:00
|
|
|
} else {
|
2010-02-24 21:51:59 +00:00
|
|
|
if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
|
|
|
|
VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
|
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_BUSSTOP);
|
|
|
|
}
|
|
|
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 19:24:27 +00:00
|
|
|
/**
|
|
|
|
* Callback for placing a truck station.
|
|
|
|
* @param tile Position to place the station.
|
|
|
|
*/
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_TruckStation(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-24 13:00:32 +00:00
|
|
|
if (_remove_button_clicked) {
|
2010-02-24 21:53:16 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_TRUCKSTOP);
|
2007-02-14 16:37:16 +00:00
|
|
|
} else {
|
2010-02-24 21:51:59 +00:00
|
|
|
if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
|
|
|
|
VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
|
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
|
|
|
|
}
|
|
|
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Toogles state of the Remove button of Build road toolbar
|
2008-02-17 17:00:43 +00:00
|
|
|
* @param w window the button belongs to
|
|
|
|
*/
|
|
|
|
static void ToggleRoadButton_Remove(Window *w)
|
|
|
|
{
|
2011-12-16 18:52:15 +00:00
|
|
|
w->ToggleWidgetLoweredState(WID_ROT_REMOVE);
|
|
|
|
w->SetWidgetDirty(WID_ROT_REMOVE);
|
|
|
|
_remove_button_clicked = w->IsWidgetLowered(WID_ROT_REMOVE);
|
2008-02-17 17:00:43 +00:00
|
|
|
SetSelectionRed(_remove_button_clicked);
|
|
|
|
}
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Updates the Remove button because of Ctrl state change
|
2008-02-17 17:00:43 +00:00
|
|
|
* @param w window the button belongs to
|
|
|
|
* @return true iff the remove buton was changed
|
|
|
|
*/
|
|
|
|
static bool RoadToolbar_CtrlChanged(Window *w)
|
|
|
|
{
|
2011-12-16 18:52:15 +00:00
|
|
|
if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
|
2008-02-17 17:00:43 +00:00
|
|
|
|
|
|
|
/* allow ctrl to switch remove mode only for these widgets */
|
2011-12-16 18:52:15 +00:00
|
|
|
for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
|
2008-02-17 17:00:43 +00:00
|
|
|
if (w->IsWidgetLowered(i)) {
|
|
|
|
ToggleRoadButton_Remove(w);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-20 19:20:38 +00:00
|
|
|
/** Road toolbar window handler. */
|
2008-05-18 21:34:35 +00:00
|
|
|
struct BuildRoadToolbarWindow : Window {
|
2010-12-20 19:23:07 +00:00
|
|
|
int last_started_action; ///< Last started user action.
|
|
|
|
|
2009-08-29 21:33:50 +00:00
|
|
|
BuildRoadToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-18 21:34:35 +00:00
|
|
|
{
|
2009-08-29 21:33:50 +00:00
|
|
|
this->InitNested(desc, window_number);
|
2008-05-18 21:34:35 +00:00
|
|
|
this->SetWidgetsDisabledState(true,
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_REMOVE,
|
|
|
|
WID_ROT_ONE_WAY,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2008-05-18 21:34:35 +00:00
|
|
|
|
2010-09-28 21:58:06 +00:00
|
|
|
this->OnInvalidateData();
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = WIDGET_LIST_END;
|
2009-08-29 21:33:50 +00:00
|
|
|
|
2008-05-29 15:13:28 +00:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
2007-10-14 20:24:42 +00:00
|
|
|
}
|
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
~BuildRoadToolbarWindow()
|
|
|
|
{
|
2009-01-02 21:01:27 +00:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
2010-09-28 21:58:06 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2010-09-28 21:58:06 +00:00
|
|
|
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_DEPOT,
|
|
|
|
WID_ROT_BUS_STATION,
|
|
|
|
WID_ROT_TRUCK_STATION,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2010-09-28 21:58:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
/**
|
|
|
|
* Update the remove button lowered state of the road toolbar
|
|
|
|
*
|
2008-09-30 20:39:50 +00:00
|
|
|
* @param clicked_widget The widget which the client clicked just now
|
2008-05-18 21:34:35 +00:00
|
|
|
*/
|
|
|
|
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
|
|
|
|
{
|
|
|
|
/* The remove and the one way button state is driven
|
|
|
|
* by the other buttons so they don't act on themselfs.
|
|
|
|
* Both are only valid if they are able to apply as options. */
|
|
|
|
switch (clicked_widget) {
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_REMOVE:
|
|
|
|
this->RaiseWidget(WID_ROT_ONE_WAY);
|
|
|
|
this->SetWidgetDirty(WID_ROT_ONE_WAY);
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ONE_WAY:
|
|
|
|
this->RaiseWidget(WID_ROT_REMOVE);
|
|
|
|
this->SetWidgetDirty(WID_ROT_REMOVE);
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUS_STATION:
|
|
|
|
case WID_ROT_TRUCK_STATION:
|
|
|
|
this->DisableWidget(WID_ROT_ONE_WAY);
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ROAD_X:
|
|
|
|
case WID_ROT_ROAD_Y:
|
|
|
|
case WID_ROT_AUTOROAD:
|
2008-05-18 21:34:35 +00:00
|
|
|
this->SetWidgetsDisabledState(!this->IsWidgetLowered(clicked_widget),
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_REMOVE,
|
|
|
|
WID_ROT_ONE_WAY,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* When any other buttons than road/station, raise and
|
|
|
|
* disable the removal button */
|
|
|
|
this->SetWidgetsDisabledState(true,
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_REMOVE,
|
|
|
|
WID_ROT_ONE_WAY,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2009-08-29 21:33:50 +00:00
|
|
|
this->SetWidgetsLoweredState(false,
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_REMOVE,
|
|
|
|
WID_ROT_ONE_WAY,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 21:34:35 +00:00
|
|
|
{
|
2010-12-20 19:20:38 +00:00
|
|
|
_remove_button_clicked = false;
|
|
|
|
_one_way_button_clicked = false;
|
|
|
|
switch (widget) {
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ROAD_X:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nwse, HT_RECT);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ROAD_Y:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nesw, HT_RECT);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_AUTOROAD:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, HT_RECT);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_DEMOLISH:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_DEPOT:
|
2010-12-20 19:21:50 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2011-12-16 18:52:15 +00:00
|
|
|
if (HandlePlacePushButton(this, WID_ROT_DEPOT, SPR_CURSOR_ROAD_DEPOT, HT_RECT)) {
|
2010-12-20 19:23:07 +00:00
|
|
|
ShowRoadDepotPicker(this);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUS_STATION:
|
2010-12-20 19:21:50 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2011-12-16 18:52:15 +00:00
|
|
|
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
|
2010-12-20 19:23:07 +00:00
|
|
|
ShowRVStationPicker(this, ROADSTOP_BUS);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_TRUCK_STATION:
|
2010-12-20 19:21:50 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2011-12-16 18:52:15 +00:00
|
|
|
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
|
2010-12-20 19:23:07 +00:00
|
|
|
ShowRVStationPicker(this, ROADSTOP_TRUCK);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ONE_WAY:
|
|
|
|
if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
|
2010-12-20 19:21:50 +00:00
|
|
|
this->SetDirty();
|
2011-12-16 18:52:15 +00:00
|
|
|
this->ToggleWidgetLoweredState(WID_ROT_ONE_WAY);
|
2010-12-20 19:21:50 +00:00
|
|
|
SetSelectionRed(false);
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUILD_BRIDGE:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUILD_TUNNEL:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, HT_SPECIAL);
|
2010-12-20 19:23:07 +00:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_REMOVE:
|
|
|
|
if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
|
2010-12-20 19:21:50 +00:00
|
|
|
|
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
|
|
|
ToggleRoadButton_Remove(this);
|
|
|
|
SndPlayFx(SND_15_BEEP);
|
2010-12-20 19:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
|
|
|
|
if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
{
|
2010-07-04 10:57:31 +00:00
|
|
|
int num = CheckHotkeyMatch(roadtoolbar_hotkeys, keycode, this);
|
|
|
|
if (num == -1 || this->GetWidget<NWidgetBase>(num) == NULL) return ES_NOT_HANDLED;
|
|
|
|
this->OnClick(Point(), num, 1);
|
2009-04-26 10:21:50 +00:00
|
|
|
MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
|
2010-07-04 10:57:31 +00:00
|
|
|
return ES_HANDLED;
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
2011-12-16 18:52:15 +00:00
|
|
|
_remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE);
|
|
|
|
_one_way_button_clicked = this->IsWidgetLowered(WID_ROT_ONE_WAY);
|
2010-12-20 19:23:07 +00:00
|
|
|
switch (this->last_started_action) {
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ROAD_X:
|
2010-12-20 19:24:27 +00:00
|
|
|
_place_road_flag = RF_DIR_X;
|
|
|
|
if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_ROAD_Y:
|
2010-12-20 19:24:27 +00:00
|
|
|
_place_road_flag = RF_DIR_Y;
|
|
|
|
if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_Y_DIR);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_AUTOROAD:
|
2010-12-20 19:24:27 +00:00
|
|
|
_place_road_flag = RF_NONE;
|
|
|
|
if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
|
|
|
|
if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_DEMOLISH:
|
2010-12-20 19:23:07 +00:00
|
|
|
PlaceProc_DemolishArea(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_DEPOT:
|
2010-12-20 19:24:27 +00:00
|
|
|
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0,
|
|
|
|
CMD_BUILD_ROAD_DEPOT | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUS_STATION:
|
2010-12-20 19:23:07 +00:00
|
|
|
PlaceRoad_BusStation(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_TRUCK_STATION:
|
2010-12-20 19:23:07 +00:00
|
|
|
PlaceRoad_TruckStation(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUILD_BRIDGE:
|
2010-12-20 19:24:27 +00:00
|
|
|
PlaceRoad_Bridge(tile, this);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_ROT_BUILD_TUNNEL:
|
2010-12-20 19:24:27 +00:00
|
|
|
DoCommandP(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0,
|
|
|
|
CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
|
2010-12-20 19:23:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
|
|
|
this->RaiseButtons();
|
|
|
|
this->SetWidgetsDisabledState(true,
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_ROT_REMOVE,
|
|
|
|
WID_ROT_ONE_WAY,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2011-12-16 18:52:15 +00:00
|
|
|
this->SetWidgetDirty(WID_ROT_REMOVE);
|
|
|
|
this->SetWidgetDirty(WID_ROT_ONE_WAY);
|
2008-05-18 21:34:35 +00:00
|
|
|
|
2009-07-21 22:25:21 +00:00
|
|
|
DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
|
|
|
|
DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
|
|
|
|
DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
|
2009-02-08 16:00:57 +00:00
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
2009-07-21 22:25:21 +00:00
|
|
|
DeleteWindowByClass(WC_BUILD_BRIDGE);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
|
|
|
|
{
|
|
|
|
/* Here we update the end tile flags
|
|
|
|
* of the road placement actions.
|
|
|
|
* At first we reset the end halfroad
|
|
|
|
* bits and if needed we set them again. */
|
|
|
|
switch (select_proc) {
|
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
|
|
|
_place_road_flag &= ~RF_END_HALFROAD_X;
|
|
|
|
if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
|
|
|
_place_road_flag &= ~RF_END_HALFROAD_Y;
|
|
|
|
if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_PLACE_AUTOROAD:
|
|
|
|
_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
|
|
|
|
if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
|
|
|
|
if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
|
|
|
|
|
|
|
|
/* For autoroad we need to update the
|
|
|
|
* direction of the road */
|
|
|
|
if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
|
|
|
|
( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
|
|
|
|
(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
|
|
|
|
/* Set dir = X */
|
|
|
|
_place_road_flag &= ~RF_DIR_Y;
|
|
|
|
} else {
|
|
|
|
/* Set dir = Y */
|
|
|
|
_place_road_flag |= RF_DIR_Y;
|
2007-10-22 19:11:50 +00:00
|
|
|
}
|
2007-05-23 12:45:56 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
2007-05-23 12:45:56 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
|
|
|
|
{
|
|
|
|
if (pt.x != -1) {
|
|
|
|
switch (select_proc) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
case DDSP_BUILD_BRIDGE:
|
2009-01-07 17:40:17 +00:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2008-05-18 21:34:35 +00:00
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
|
2008-04-04 18:41:16 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
|
|
|
case DDSP_PLACE_AUTOROAD:
|
|
|
|
/* Flag description:
|
2009-03-14 18:16:29 +00:00
|
|
|
* Use the first three bits (0x07) if dir == Y
|
|
|
|
* else use the last 2 bits (X dir has
|
|
|
|
* not the 3rd bit set) */
|
2008-05-18 21:34:35 +00:00
|
|
|
_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
|
|
|
|
|
2010-01-14 23:05:07 +00:00
|
|
|
DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
|
2010-12-20 19:19:23 +00:00
|
|
|
_remove_button_clicked ?
|
|
|
|
CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
|
|
|
|
CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);
|
2008-05-18 21:34:35 +00:00
|
|
|
break;
|
2010-02-24 21:51:59 +00:00
|
|
|
|
|
|
|
case DDSP_BUILD_BUSSTOP:
|
|
|
|
PlaceRoadStop(start_tile, end_tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_BUILD_TRUCKSTOP:
|
|
|
|
PlaceRoadStop(start_tile, end_tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
|
|
|
|
break;
|
2010-02-24 21:53:16 +00:00
|
|
|
|
|
|
|
case DDSP_REMOVE_BUSSTOP: {
|
|
|
|
TileArea ta(start_tile, end_tile);
|
|
|
|
DoCommandP(ta.tile, ta.w | ta.h << 8, ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D);
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-02-24 21:53:16 +00:00
|
|
|
|
|
|
|
case DDSP_REMOVE_TRUCKSTOP: {
|
|
|
|
TileArea ta(start_tile, end_tile);
|
|
|
|
DoCommandP(ta.tile, ta.w | ta.h << 8, ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D);
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
}
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 07:25:55 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlacePresize(Point pt, TileIndex tile)
|
|
|
|
{
|
2010-04-14 20:28:37 +00:00
|
|
|
DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
2008-05-18 21:34:35 +00:00
|
|
|
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
|
|
|
}
|
2008-02-17 17:00:43 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual EventState OnCTRLStateChange()
|
|
|
|
{
|
|
|
|
if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
|
|
|
|
return ES_NOT_HANDLED;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2010-07-04 10:57:31 +00:00
|
|
|
|
|
|
|
static Hotkey<BuildRoadToolbarWindow> roadtoolbar_hotkeys[];
|
|
|
|
};
|
|
|
|
|
|
|
|
Hotkey<BuildRoadToolbarWindow> BuildRoadToolbarWindow::roadtoolbar_hotkeys[] = {
|
2011-12-16 18:52:15 +00:00
|
|
|
Hotkey<BuildRoadToolbarWindow>('1', "build_x", WID_ROT_ROAD_X),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('2', "build_y", WID_ROT_ROAD_Y),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('3', "autoroad", WID_ROT_AUTOROAD),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('4', "demolish", WID_ROT_DEMOLISH),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('5', "depot", WID_ROT_DEPOT),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('6', "bus_station", WID_ROT_BUS_STATION),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('7', "truck_station", WID_ROT_TRUCK_STATION),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('8', "oneway", WID_ROT_ONE_WAY),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('B', "bridge", WID_ROT_BUILD_BRIDGE),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('T', "tunnel", WID_ROT_BUILD_TUNNEL),
|
|
|
|
Hotkey<BuildRoadToolbarWindow>('R', "remove", WID_ROT_REMOVE),
|
2010-07-04 10:57:31 +00:00
|
|
|
HOTKEY_LIST_END(BuildRoadToolbarWindow)
|
2008-05-18 21:34:35 +00:00
|
|
|
};
|
2010-07-04 10:57:31 +00:00
|
|
|
Hotkey<BuildRoadToolbarWindow> *_roadtoolbar_hotkeys = BuildRoadToolbarWindow::roadtoolbar_hotkeys;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-03-26 18:55:42 +00:00
|
|
|
static const NWidgetPart _nested_build_road_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_ROAD_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _build_road_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_ALIGN_TOOLBAR, 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_build_road_widgets, lengthof(_nested_build_road_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-03-26 18:55:42 +00:00
|
|
|
static const NWidgetPart _nested_build_tramway_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_TRAM_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY), SetMinimalSize(0, 0),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _build_tramway_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_ALIGN_TOOLBAR, 0, 0,
|
2007-05-25 22:07:40 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2007-05-25 22:07:40 +00:00
|
|
|
|
2010-07-04 10:57:31 +00:00
|
|
|
/**
|
|
|
|
* Open the build road toolbar window
|
|
|
|
*
|
|
|
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
|
|
|
*
|
|
|
|
* @return newly opened road toolbar, or NULL if the toolbar could not be opened.
|
|
|
|
*/
|
|
|
|
Window *ShowBuildRoadToolbar(RoadType roadtype)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-07-04 10:57:31 +00:00
|
|
|
if (!Company::IsValidID(_local_company)) return NULL;
|
2007-05-21 21:58:31 +00:00
|
|
|
_cur_roadtype = roadtype;
|
2006-10-31 21:15:56 +00:00
|
|
|
|
2008-05-04 09:39:16 +00:00
|
|
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
2010-07-04 10:57:31 +00:00
|
|
|
return AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
EventState RoadToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|
|
|
{
|
|
|
|
extern RoadType _last_built_roadtype;
|
|
|
|
int num = CheckHotkeyMatch<BuildRoadToolbarWindow>(_roadtoolbar_hotkeys, keycode, NULL, true);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
Window *w = ShowBuildRoadToolbar(_last_built_roadtype);
|
|
|
|
if (w == NULL) return ES_NOT_HANDLED;
|
|
|
|
return w->OnKeyPress(key, keycode);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 18:55:42 +00:00
|
|
|
static const NWidgetPart _nested_build_road_scen_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_ROAD_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
|
2009-03-26 18:55:42 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _build_road_scen_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_AUTO, 0, 0,
|
2008-06-25 17:30:16 +00:00
|
|
|
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-05-01 19:51:52 +00:00
|
|
|
/**
|
|
|
|
* Show the road building toolbar in the scenario editor.
|
|
|
|
* @return The just opened toolbar.
|
|
|
|
*/
|
2010-07-04 10:57:31 +00:00
|
|
|
Window *ShowBuildRoadScenToolbar()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-06-01 17:59:11 +00:00
|
|
|
_cur_roadtype = ROADTYPE_ROAD;
|
2011-12-19 20:50:21 +00:00
|
|
|
return AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, TRANSPORT_ROAD);
|
2010-07-04 10:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EventState RoadToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
|
|
|
{
|
|
|
|
int num = CheckHotkeyMatch<BuildRoadToolbarWindow>(_roadtoolbar_hotkeys, keycode, NULL, true);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
Window *w = ShowBuildRoadScenToolbar();
|
|
|
|
if (w == NULL) return ES_NOT_HANDLED;
|
|
|
|
return w->OnKeyPress(key, keycode);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 17:37:44 +00:00
|
|
|
struct BuildRoadDepotWindow : public PickerWindowBase {
|
2009-08-29 21:33:50 +00:00
|
|
|
BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
|
2008-05-17 17:37:44 +00:00
|
|
|
{
|
2009-08-29 21:33:50 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
|
2008-05-17 17:37:44 +00:00
|
|
|
if ( _cur_roadtype == ROADTYPE_TRAM) {
|
2011-12-16 18:52:15 +00:00
|
|
|
this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
|
|
|
|
for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
2009-08-29 21:33:50 +00:00
|
|
|
|
|
|
|
this->FinishInitNested(desc, TRANSPORT_ROAD);
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2009-08-29 21:33:50 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
2011-12-16 18:52:15 +00:00
|
|
|
if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
DrawRoadDepotSprite(r.left - 1, r.top, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-17 17:37:44 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_BROD_DEPOT_NW:
|
|
|
|
case WID_BROD_DEPOT_NE:
|
|
|
|
case WID_BROD_DEPOT_SW:
|
|
|
|
case WID_BROD_DEPOT_SE:
|
|
|
|
this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
|
|
|
|
_road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
|
|
|
|
this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
|
2008-05-17 17:37:44 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-17 17:37:44 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-03-26 21:12:14 +00:00
|
|
|
static const NWidgetPart _nested_build_road_depot_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
2009-03-26 21:12:14 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
|
|
|
NWidget(NWID_HORIZONTAL_LTR),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
2009-03-26 21:12:14 +00:00
|
|
|
NWidget(NWID_VERTICAL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
|
|
|
|
NWidget(NWID_VERTICAL),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
|
2009-03-26 21:12:14 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _build_road_depot_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_AUTO, 0, 0,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2007-05-25 22:07:40 +00:00
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowRoadDepotPicker(Window *parent)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-24 11:19:30 +00:00
|
|
|
new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct BuildRoadStationWindow : public PickerWindowBase {
|
2009-08-29 22:24:29 +00:00
|
|
|
BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(parent)
|
2008-05-17 17:37:44 +00:00
|
|
|
{
|
2009-08-29 22:24:29 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
|
2008-05-17 17:37:44 +00:00
|
|
|
/* Trams don't have non-drivethrough stations */
|
|
|
|
if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
|
|
|
|
_road_station_picker_orientation = DIAGDIR_END;
|
|
|
|
}
|
|
|
|
this->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
|
2011-12-16 18:52:15 +00:00
|
|
|
WID_BROS_STATION_NE,
|
|
|
|
WID_BROS_STATION_SE,
|
|
|
|
WID_BROS_STATION_SW,
|
|
|
|
WID_BROS_STATION_NW,
|
2010-12-20 19:19:23 +00:00
|
|
|
WIDGET_LIST_END);
|
2008-05-17 17:37:44 +00:00
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = _road_type_infos[_cur_roadtype].picker_title[rs];
|
|
|
|
for (uint i = WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
|
2008-05-17 17:37:44 +00:00
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
|
|
|
|
this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
|
2009-08-29 22:24:29 +00:00
|
|
|
|
|
|
|
this->FinishInitNested(desc, TRANSPORT_ROAD);
|
|
|
|
|
|
|
|
this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-01-08 16:35:45 +00:00
|
|
|
virtual ~BuildRoadStationWindow()
|
|
|
|
{
|
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-17 17:37:44 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2009-07-10 21:59:07 +00:00
|
|
|
int rad = _settings_game.station.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
|
2009-01-04 11:11:11 +00:00
|
|
|
if (_settings_client.gui.station_show_coverage) {
|
2008-05-17 17:37:44 +00:00
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
|
|
|
} else {
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2009-08-29 22:24:29 +00:00
|
|
|
/* 'Accepts' and 'Supplies' texts. */
|
2009-07-10 22:03:09 +00:00
|
|
|
StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
|
2011-12-16 18:52:15 +00:00
|
|
|
int top = this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->pos_y + this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->current_y + WD_PAR_VSEP_NORMAL;
|
|
|
|
NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(WID_BROS_BACKGROUND);
|
2009-08-29 22:24:29 +00:00
|
|
|
int right = back_nwi->pos_x + back_nwi->current_x;
|
|
|
|
int bottom = back_nwi->pos_y + back_nwi->current_y;
|
|
|
|
top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL;
|
|
|
|
top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL;
|
|
|
|
/* Resize background if the text is not equally long as the window. */
|
|
|
|
if (top > bottom || (top < bottom && back_nwi->current_y > back_nwi->smallest_y)) {
|
|
|
|
ResizeWindow(this, 0, top - bottom);
|
2008-05-17 17:37:44 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2009-08-29 22:24:29 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
2011-12-16 18:52:15 +00:00
|
|
|
if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
|
2009-08-29 22:24:29 +00:00
|
|
|
|
|
|
|
StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
|
2011-12-16 18:52:15 +00:00
|
|
|
StationPickerDrawSprite(r.left + TILE_PIXELS, r.bottom - TILE_PIXELS, st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
|
2009-08-29 22:24:29 +00:00
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-17 17:37:44 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_BROS_STATION_NE:
|
|
|
|
case WID_BROS_STATION_SE:
|
|
|
|
case WID_BROS_STATION_SW:
|
|
|
|
case WID_BROS_STATION_NW:
|
|
|
|
case WID_BROS_STATION_X:
|
|
|
|
case WID_BROS_STATION_Y:
|
|
|
|
this->RaiseWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
|
|
|
|
_road_station_picker_orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
|
|
|
|
this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
|
2008-05-17 17:37:44 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
this->SetDirty();
|
2009-01-08 16:35:45 +00:00
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
2008-05-17 17:37:44 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:52:15 +00:00
|
|
|
case WID_BROS_LT_OFF:
|
|
|
|
case WID_BROS_LT_ON:
|
|
|
|
this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
|
|
|
|
_settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF);
|
|
|
|
this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
|
2008-05-17 17:37:44 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-04 18:41:16 +00:00
|
|
|
|
2008-05-17 17:37:44 +00:00
|
|
|
virtual void OnTick()
|
|
|
|
{
|
|
|
|
CheckRedrawStationCoverage(this);
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2008-05-17 17:37:44 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-05-03 13:53:34 +00:00
|
|
|
/** Widget definition of the build road station window */
|
2009-05-03 13:55:22 +00:00
|
|
|
static const NWidgetPart _nested_rv_station_picker_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
|
2009-05-03 13:55:22 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
2009-11-22 14:41:21 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), EndContainer(),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
|
2009-11-22 14:41:21 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), EndContainer(),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
|
2009-11-22 14:41:21 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
2009-11-22 14:41:21 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
|
2009-05-03 13:55:22 +00:00
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
|
2011-12-16 18:52:15 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
|
2009-05-03 13:55:22 +00:00
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
2009-08-30 08:10:00 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
|
2009-05-03 13:55:22 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _rv_station_picker_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_AUTO, 0, 0,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUS_STATION, WC_BUILD_TOOLBAR,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_rv_station_picker_widgets, lengthof(_nested_rv_station_picker_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowRVStationPicker(Window *parent, RoadStopType rs)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-24 11:19:30 +00:00
|
|
|
new BuildRoadStationWindow(&_rv_station_picker_desc, parent, rs);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeRoadGui()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-01-10 18:56:51 +00:00
|
|
|
_road_depot_orientation = DIAGDIR_NW;
|
|
|
|
_road_station_picker_orientation = DIAGDIR_NW;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|