2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-28 20:41:35 +00:00
|
|
|
/** @file road_gui.cpp */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#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"
|
|
|
|
#include "gfx_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2008-01-09 08:12:10 +00:00
|
|
|
#include "road_type.h"
|
2007-05-21 21:58:31 +00:00
|
|
|
#include "road_cmd.h"
|
|
|
|
#include "road_map.h"
|
2007-02-14 16:37:16 +00:00
|
|
|
#include "station_map.h"
|
2004-12-08 15:46:13 +00:00
|
|
|
#include "station.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "functions.h"
|
|
|
|
#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-01-12 14:10:35 +00:00
|
|
|
#include "player_func.h"
|
2008-01-13 14:37:30 +00:00
|
|
|
#include "settings_type.h"
|
2004-12-08 15:46:13 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/strings.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-05-25 23:21:32 +00:00
|
|
|
static void ShowRVStationPicker(RoadStop::Type rs);
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowRoadDepotPicker();
|
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
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(RoadFlags);
|
|
|
|
|
|
|
|
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
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-04 09:26:39 +00:00
|
|
|
if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Set the initial flags for the road constuction.
|
|
|
|
* The flags are:
|
2007-11-17 01:10:06 +00:00
|
|
|
* @li The direction is the X-dir
|
2007-10-22 19:11:50 +00:00
|
|
|
* @li The first tile has a partitial RoadBit (true or false)
|
|
|
|
*
|
|
|
|
* @param tile The start tile
|
|
|
|
*/
|
2007-11-17 01:10:06 +00:00
|
|
|
static void PlaceRoad_X_Dir(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-17 01:10:06 +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);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Set the initial flags for the road constuction.
|
|
|
|
* The flags are:
|
2007-11-17 01:10:06 +00:00
|
|
|
* @li The direction is the Y-dir
|
2007-10-22 19:11:50 +00:00
|
|
|
* @li The first tile has a partitial RoadBit (true or false)
|
|
|
|
*
|
|
|
|
* @param tile The start tile
|
|
|
|
*/
|
2007-11-17 01:10:06 +00:00
|
|
|
static void PlaceRoad_Y_Dir(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-17 01:10:06 +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);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Set the initial flags for the road constuction.
|
|
|
|
* The flags are:
|
|
|
|
* @li The direction is not set.
|
|
|
|
* @li The first tile has a partitial RoadBit (true or false)
|
|
|
|
*
|
|
|
|
* @param tile The start tile
|
|
|
|
*/
|
|
|
|
static void PlaceRoad_AutoRoad(TileIndex tile)
|
|
|
|
{
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_Bridge(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-23 13:52:10 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
} 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[] = {
|
|
|
|
{
|
|
|
|
STR_1804_CAN_T_BUILD_ROAD_HERE,
|
|
|
|
STR_1805_CAN_T_REMOVE_ROAD_FROM,
|
|
|
|
STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
|
2007-05-25 23:21:32 +00:00
|
|
|
{ STR_1808_CAN_T_BUILD_BUS_STATION, STR_1809_CAN_T_BUILD_TRUCK_STATION },
|
|
|
|
{ STR_CAN_T_REMOVE_BUS_STATION, STR_CAN_T_REMOVE_TRUCK_STATION },
|
|
|
|
{ STR_3042_BUS_STATION_ORIENTATION, STR_3043_TRUCK_STATION_ORIENT },
|
|
|
|
{ STR_3051_SELECT_BUS_STATION_ORIENTATION, STR_3052_SELECT_TRUCK_LOADING_BAY },
|
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
|
|
|
{
|
2008-01-27 17:32:12 +00:00
|
|
|
STR_CAN_T_BUILD_TRAMWAY_HERE,
|
|
|
|
STR_CAN_T_REMOVE_TRAMWAY_FROM,
|
|
|
|
STR_CAN_T_BUILD_TRAM_VEHICLE,
|
|
|
|
{ STR_CAN_T_BUILD_PASSENGER_TRAM_STATION, STR_CAN_T_BUILD_CARGO_TRAM_STATION },
|
|
|
|
{ STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION, STR_CAN_T_REMOVE_CARGO_TRAM_STATION },
|
|
|
|
{ STR_PASSENGER_TRAM_STATION_ORIENTATION, STR_CARGO_TRAM_STATION_ORIENT },
|
|
|
|
{ STR_SELECT_PASSENGER_TRAM_STATION_ORIENTATION, STR_SELECT_CARGO_TRAM_STATION_ORIENTATION },
|
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
|
|
|
};
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_Tunnel(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-03-06 13:29:27 +00:00
|
|
|
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-09-05 23:21:41 +00:00
|
|
|
tile += TileOffsByDiagDir(direction);
|
2004-08-10 14:50:42 +00:00
|
|
|
// if there is a roadpiece just outside of the station entrance, build a connecting route
|
2007-07-29 23:42:59 +00:00
|
|
|
if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
2007-05-21 21:58:31 +00:00
|
|
|
if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
|
|
|
|
DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2007-05-20 22:04:24 +00:00
|
|
|
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
2007-05-20 22:04:24 +00:00
|
|
|
BuildRoadOutsideStation(tile, dir);
|
2007-02-21 22:02:10 +00:00
|
|
|
/* For a drive-through road stop build connecting road for other entrance */
|
2007-11-19 21:02:30 +00:00
|
|
|
if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_Depot(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-02-14 16:37:16 +00:00
|
|
|
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
|
|
|
|
{
|
|
|
|
uint32 p1 = _road_station_picker_orientation;
|
|
|
|
|
|
|
|
if (p1 >= DIAGDIR_END) {
|
2007-11-20 13:35:54 +00:00
|
|
|
SetBit(p2, 1); // It's a drive-through stop
|
2007-02-14 16:37:16 +00:00
|
|
|
p1 -= DIAGDIR_END; // Adjust picker result to actual direction
|
|
|
|
}
|
|
|
|
DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
|
|
|
|
}
|
|
|
|
|
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) {
|
2007-05-24 08:36:11 +00:00
|
|
|
DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
|
2007-02-14 16:37:16 +00:00
|
|
|
} else {
|
2007-09-04 11:58:27 +00:00
|
|
|
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::BUS]));
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
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) {
|
2007-07-27 03:27:16 +00:00
|
|
|
DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::TRUCK]));
|
2007-02-14 16:37:16 +00:00
|
|
|
} else {
|
2007-09-04 11:58:27 +00:00
|
|
|
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRoad_DemolishArea(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-23 13:52:10 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Enum referring to the widgets of the build road toolbar */
|
|
|
|
enum RoadToolbarWidgets {
|
|
|
|
RTW_CLOSEBOX = 0,
|
|
|
|
RTW_CAPTION,
|
|
|
|
RTW_STICKY,
|
|
|
|
RTW_ROAD_X,
|
|
|
|
RTW_ROAD_Y,
|
2007-10-22 19:11:50 +00:00
|
|
|
RTW_AUTOROAD,
|
2007-10-14 20:24:42 +00:00
|
|
|
RTW_DEMOLISH,
|
|
|
|
RTW_DEPOT,
|
|
|
|
RTW_BUS_STATION,
|
|
|
|
RTW_TRUCK_STATION,
|
2007-11-18 13:55:23 +00:00
|
|
|
RTW_ONE_WAY,
|
2007-10-14 20:24:42 +00:00
|
|
|
RTW_BUILD_BRIDGE,
|
|
|
|
RTW_BUILD_TUNNEL,
|
|
|
|
RTW_REMOVE,
|
2006-11-22 16:08:01 +00:00
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Function that handles the click on the
|
|
|
|
* X road placement button.
|
|
|
|
*
|
|
|
|
* @param w The current window
|
|
|
|
*/
|
2007-11-17 01:10:06 +00:00
|
|
|
static void BuildRoadClick_X_Dir(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-17 01:10:06 +00:00
|
|
|
HandlePlacePushButton(w, RTW_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nwse, VHM_RECT, PlaceRoad_X_Dir);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Function that handles the click on the
|
|
|
|
* Y road placement button.
|
|
|
|
*
|
|
|
|
* @param w The current window
|
|
|
|
*/
|
2007-11-17 01:10:06 +00:00
|
|
|
static void BuildRoadClick_Y_Dir(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-17 01:10:06 +00:00
|
|
|
HandlePlacePushButton(w, RTW_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nesw, VHM_RECT, PlaceRoad_Y_Dir);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/**
|
|
|
|
* Function that handles the click on the
|
|
|
|
* autoroad placement button.
|
|
|
|
*
|
|
|
|
* @param w The current window
|
|
|
|
*/
|
|
|
|
static void BuildRoadClick_AutoRoad(Window *w)
|
|
|
|
{
|
2007-10-26 16:38:32 +00:00
|
|
|
HandlePlacePushButton(w, RTW_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, VHM_RECT, PlaceRoad_AutoRoad);
|
2007-10-22 19:11:50 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static void BuildRoadClick_Demolish(Window *w)
|
|
|
|
{
|
2007-10-26 16:38:32 +00:00
|
|
|
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceRoad_DemolishArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Depot(Window *w)
|
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2007-10-26 16:38:32 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_BusStation(Window *w)
|
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2007-10-26 16:38:32 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_TruckStation(Window *w)
|
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
|
2007-10-26 16:38:32 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 13:55:23 +00:00
|
|
|
/**
|
|
|
|
* Function that handles the click on the
|
|
|
|
* one way road button.
|
|
|
|
*
|
|
|
|
* @param w The current window
|
|
|
|
*/
|
|
|
|
static void BuildRoadClick_OneWay(Window *w)
|
|
|
|
{
|
2007-12-02 14:29:48 +00:00
|
|
|
if (w->IsWidgetDisabled(RTW_ONE_WAY)) return;
|
2007-11-18 13:55:23 +00:00
|
|
|
SetWindowDirty(w);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->ToggleWidgetLoweredState(RTW_ONE_WAY);
|
2007-11-18 14:39:43 +00:00
|
|
|
SetSelectionRed(false);
|
2007-11-18 13:55:23 +00:00
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void BuildRoadClick_Bridge(Window *w)
|
|
|
|
{
|
2007-10-26 16:38:32 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRoad_Bridge);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Tunnel(Window *w)
|
|
|
|
{
|
2007-10-26 16:38:32 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, VHM_SPECIAL, PlaceRoad_Tunnel);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRoadClick_Remove(Window *w)
|
|
|
|
{
|
2007-12-02 14:29:48 +00:00
|
|
|
if (w->IsWidgetDisabled(RTW_REMOVE)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->ToggleWidgetLoweredState(RTW_REMOVE);
|
|
|
|
SetSelectionRed(w->IsWidgetLowered(RTW_REMOVE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/** Array with the handlers of the button-clicks for the road-toolbar */
|
2005-11-14 19:48:04 +00:00
|
|
|
static OnButtonClick* const _build_road_button_proc[] = {
|
2007-11-17 01:10:06 +00:00
|
|
|
BuildRoadClick_X_Dir,
|
|
|
|
BuildRoadClick_Y_Dir,
|
2007-10-22 19:11:50 +00:00
|
|
|
BuildRoadClick_AutoRoad,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRoadClick_Demolish,
|
|
|
|
BuildRoadClick_Depot,
|
|
|
|
BuildRoadClick_BusStation,
|
|
|
|
BuildRoadClick_TruckStation,
|
2007-11-18 13:55:23 +00:00
|
|
|
BuildRoadClick_OneWay,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRoadClick_Bridge,
|
|
|
|
BuildRoadClick_Tunnel,
|
2007-01-15 07:38:36 +00:00
|
|
|
BuildRoadClick_Remove
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
/** Array with the keycode of the button-clicks for the road-toolbar */
|
2007-10-14 20:24:42 +00:00
|
|
|
static const uint16 _road_keycodes[] = {
|
|
|
|
'1',
|
|
|
|
'2',
|
|
|
|
'3',
|
|
|
|
'4',
|
|
|
|
'5',
|
|
|
|
'6',
|
2007-10-22 19:11:50 +00:00
|
|
|
'7',
|
2007-11-18 13:55:23 +00:00
|
|
|
'8',
|
2007-10-14 20:24:42 +00:00
|
|
|
'B',
|
|
|
|
'T',
|
|
|
|
'R',
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the remove button lowered state of the road toolbar
|
|
|
|
*
|
|
|
|
* @param w The toolbar window
|
|
|
|
* @param clicked_widget The widget which the player clicked just now
|
|
|
|
*/
|
2007-11-18 13:55:23 +00:00
|
|
|
static void UpdateOptionWidgetStatus(Window *w, int clicked_widget)
|
2007-10-14 20:24:42 +00:00
|
|
|
{
|
2007-11-18 13:55:23 +00:00
|
|
|
/* 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. */
|
2007-10-14 20:24:42 +00:00
|
|
|
switch (clicked_widget) {
|
|
|
|
case RTW_REMOVE:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->RaiseWidget(RTW_ONE_WAY);
|
2007-11-18 13:55:23 +00:00
|
|
|
break;
|
|
|
|
case RTW_ONE_WAY:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->RaiseWidget(RTW_REMOVE);
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
|
|
|
case RTW_BUS_STATION:
|
|
|
|
case RTW_TRUCK_STATION:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->DisableWidget(RTW_ONE_WAY);
|
|
|
|
w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget));
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
2007-11-18 13:55:23 +00:00
|
|
|
case RTW_ROAD_X:
|
|
|
|
case RTW_ROAD_Y:
|
|
|
|
case RTW_AUTOROAD:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsDisabledState(!w->IsWidgetLowered(clicked_widget),
|
2007-11-18 13:55:23 +00:00
|
|
|
RTW_REMOVE,
|
|
|
|
RTW_ONE_WAY,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
break;
|
2007-10-14 20:24:42 +00:00
|
|
|
default:
|
|
|
|
/* When any other buttons than road/station, raise and
|
|
|
|
* disable the removal button */
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsDisabledState(true,
|
2007-11-18 13:55:23 +00:00
|
|
|
RTW_REMOVE,
|
|
|
|
RTW_ONE_WAY,
|
|
|
|
WIDGET_LIST_END);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsLoweredState (false,
|
2007-11-18 13:55:23 +00:00
|
|
|
RTW_REMOVE,
|
|
|
|
RTW_ONE_WAY,
|
|
|
|
WIDGET_LIST_END);
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
|
2005-11-14 19:48:04 +00:00
|
|
|
{
|
|
|
|
switch (e->event) {
|
2007-11-18 13:55:23 +00:00
|
|
|
case WE_CREATE:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsDisabledState(true,
|
2007-11-18 13:55:23 +00:00
|
|
|
RTW_REMOVE,
|
|
|
|
RTW_ONE_WAY,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
break;
|
2006-11-16 18:41:57 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
|
2007-10-14 20:24:42 +00:00
|
|
|
RTW_DEPOT,
|
|
|
|
RTW_BUS_STATION,
|
|
|
|
RTW_TRUCK_STATION,
|
|
|
|
WIDGET_LIST_END);
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
break;
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
case WE_CLICK:
|
|
|
|
if (e->we.click.widget >= RTW_ROAD_X) {
|
|
|
|
_remove_button_clicked = false;
|
2007-11-18 13:55:23 +00:00
|
|
|
_one_way_button_clicked = false;
|
2007-10-14 20:24:42 +00:00
|
|
|
_build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w);
|
|
|
|
}
|
2007-11-18 13:55:23 +00:00
|
|
|
UpdateOptionWidgetStatus(w, e->we.click.widget);
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
case WE_KEYPRESS:
|
2007-10-14 20:24:42 +00:00
|
|
|
for (uint8 i = 0; i != lengthof(_road_keycodes); i++) {
|
|
|
|
if (e->we.keypress.keycode == _road_keycodes[i]) {
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
_remove_button_clicked = false;
|
2007-11-18 13:55:23 +00:00
|
|
|
_one_way_button_clicked = false;
|
2007-10-14 20:24:42 +00:00
|
|
|
_build_road_button_proc[i](w);
|
2007-11-18 13:55:23 +00:00
|
|
|
UpdateOptionWidgetStatus(w, i + RTW_ROAD_X);
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-12-22 00:18:40 +00:00
|
|
|
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_OBJ:
|
2007-12-02 14:29:48 +00:00
|
|
|
_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
|
|
|
|
_one_way_button_clicked = w->IsWidgetLowered(RTW_ONE_WAY);
|
2006-09-23 02:39:24 +00:00
|
|
|
_place_proc(e->we.place.tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2007-12-07 17:51:27 +00:00
|
|
|
w->RaiseButtons();
|
|
|
|
w->SetWidgetsDisabledState(true,
|
|
|
|
RTW_REMOVE,
|
|
|
|
RTW_ONE_WAY,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
w->InvalidateWidget(RTW_REMOVE);
|
|
|
|
w->InvalidateWidget(RTW_ONE_WAY);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
w = FindWindowById(WC_BUS_STATION, 0);
|
2007-04-18 22:10:36 +00:00
|
|
|
if (w != NULL) WP(w, def_d).close = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
w = FindWindowById(WC_TRUCK_STATION, 0);
|
2007-04-18 22:10:36 +00:00
|
|
|
if (w != NULL) WP(w, def_d).close = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
w = FindWindowById(WC_BUILD_DEPOT, 0);
|
2007-04-18 22:10:36 +00:00
|
|
|
if (w != NULL) WP(w, def_d).close = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
2007-05-23 12:45:56 +00:00
|
|
|
case WE_PLACE_DRAG:
|
2007-10-22 19:11:50 +00:00
|
|
|
/* 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. */
|
2007-05-23 13:52:10 +00:00
|
|
|
switch (e->we.place.select_proc) {
|
2007-11-17 01:10:06 +00:00
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
2007-10-22 19:11:50 +00:00
|
|
|
_place_road_flag &= ~RF_END_HALFROAD_X;
|
|
|
|
if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
|
|
|
|
break;
|
|
|
|
|
2007-11-17 01:10:06 +00:00
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
|
|
|
_place_road_flag &= ~RF_END_HALFROAD_Y;
|
|
|
|
if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
|
|
|
|
break;
|
|
|
|
|
2007-10-22 19:11:50 +00:00
|
|
|
case DDSP_PLACE_AUTOROAD:
|
|
|
|
_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
|
|
|
|
if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
|
|
|
|
if (e->we.place.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 &&
|
2007-11-18 20:10:07 +00:00
|
|
|
( (_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) ))) {
|
2007-10-22 19:11:50 +00:00
|
|
|
/* Set dir = X */
|
|
|
|
_place_road_flag &= ~RF_DIR_Y;
|
|
|
|
} else {
|
|
|
|
/* Set dir = Y */
|
|
|
|
_place_road_flag |= RF_DIR_Y;
|
|
|
|
}
|
|
|
|
|
2006-08-29 00:17:47 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-05-23 12:45:56 +00:00
|
|
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case WE_PLACE_MOUSEUP:
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.place.pt.x != -1) {
|
|
|
|
TileIndex start_tile = e->we.place.starttile;
|
|
|
|
TileIndex end_tile = e->we.place.tile;
|
2005-06-24 12:38:35 +00:00
|
|
|
|
2007-05-23 13:52:10 +00:00
|
|
|
switch (e->we.place.select_proc) {
|
|
|
|
case DDSP_BUILD_BRIDGE:
|
2007-05-23 12:45:56 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
|
|
|
|
break;
|
|
|
|
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
2007-05-23 12:45:56 +00:00
|
|
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
|
|
|
break;
|
|
|
|
|
2007-11-17 01:10:06 +00:00
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
2007-10-22 19:11:50 +00:00
|
|
|
case DDSP_PLACE_AUTOROAD:
|
|
|
|
/* Flag description:
|
|
|
|
* Use the first three bits (0x07) if dir == Y
|
|
|
|
* else use the last 2 bits (X dir has
|
|
|
|
* not the 3rd bit set) */
|
|
|
|
_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
|
|
|
|
|
2007-11-18 13:55:23 +00:00
|
|
|
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
|
2007-11-18 08:03:48 +00:00
|
|
|
(_ctrl_pressed || _remove_button_clicked) ?
|
2007-09-04 11:58:27 +00:00
|
|
|
CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
|
|
|
|
CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_PRESIZE: {
|
2006-09-23 02:39:24 +00:00
|
|
|
TileIndex tile = e->we.place.tile;
|
2005-06-24 12:38:35 +00:00
|
|
|
|
2007-05-24 09:24:46 +00:00
|
|
|
DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
2006-06-10 08:37:41 +00:00
|
|
|
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-11-09 07:25:55 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
|
|
|
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build road toolbar */
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _build_road_widgets[] = {
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // RTW_CLOSEBOX
|
2007-11-18 13:55:23 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 250, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // RTW_CAPTION
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 251, 262, 0, 13, 0x0, STR_STICKY_BUTTON}, // RTW_STICKY
|
2007-10-14 20:24:42 +00:00
|
|
|
|
2007-11-17 01:10:06 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_X_DIR, STR_180B_BUILD_ROAD_SECTION}, // RTW_ROAD_X
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_Y_DIR, STR_180B_BUILD_ROAD_SECTION}, // RTW_ROAD_Y
|
2007-10-22 19:11:50 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_AUTOROAD, STR_BUILD_AUTOROAD_TIP}, // RTW_AUTOROAD
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // RTW_DEMOLISH
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_ROAD_DEPOT, STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, // RTW_DEPOT
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_BUS_STATION, STR_180D_BUILD_BUS_STATION}, // RTW_BUS_STATION
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 132, 153, 14, 35, SPR_IMG_TRUCK_BAY, STR_180E_BUILD_TRUCK_LOADING_BAY}, // RTW_TRUCK_STATION
|
2007-11-18 13:55:23 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 154, 175, 14, 35, SPR_IMG_ROAD_ONE_WAY, STR_TOGGLE_ONE_WAY_ROAD}, // RTW_ONE_WAY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 176, 218, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, // RTW_BUILD_BRIDGE
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 219, 240, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL}, // RTW_BUILD_TUNNEL
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 241, 262, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, // RTW_REMOVE
|
2007-10-22 19:11:50 +00:00
|
|
|
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_road_desc = {
|
2007-11-18 13:55:23 +00:00
|
|
|
WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2004-12-22 00:18:40 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_road_widgets,
|
|
|
|
BuildRoadToolbWndProc
|
|
|
|
};
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build tram toolbar */
|
2007-05-25 22:07:40 +00:00
|
|
|
static const Widget _build_tramway_widgets[] = {
|
2008-01-27 17:32:12 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // RTW_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 228, 0, 13, STR_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // RTW_CAPTION
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 229, 240, 0, 13, 0x0, STR_STICKY_BUTTON}, // RTW_STICKY
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TRAMWAY_X_DIR, STR_BUILD_TRAMWAY_SECTION}, // RTW_ROAD_X
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TRAMWAY_Y_DIR, STR_BUILD_TRAMWAY_SECTION}, // RTW_ROAD_Y
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_AUTOTRAM, STR_BUILD_AUTOTRAM_TIP}, // RTW_AUTOROAD
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // RTW_DEMOLISH
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_ROAD_DEPOT, STR_BUILD_TRAM_VEHICLE_DEPOT}, // RTW_DEPOT
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_BUS_STATION, STR_BUILD_PASSENGER_TRAM_STATION}, // RTW_BUS_STATION
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 132, 153, 14, 35, SPR_IMG_TRUCK_BAY, STR_BUILD_CARGO_TRAM_STATION}, // RTW_TRUCK_STATION
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // RTW_ONE_WAY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 154, 196, 14, 35, SPR_IMG_BRIDGE, STR_BUILD_TRAMWAY_BRIDGE}, // RTW_BUILD_BRIDGE
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 197, 218, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_BUILD_TRAMWAY_TUNNEL}, // RTW_BUILD_TUNNEL
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 219, 240, 14, 35, SPR_IMG_REMOVE, STR_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS}, // RTW_REMOVE
|
2007-10-22 19:11:50 +00:00
|
|
|
|
2007-05-25 22:07:40 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_tramway_desc = {
|
2007-11-18 13:55:23 +00:00
|
|
|
WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
|
2007-05-25 22:07:40 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
|
|
|
_build_tramway_widgets,
|
|
|
|
BuildRoadToolbWndProc
|
|
|
|
};
|
|
|
|
|
2007-05-21 21:58:31 +00:00
|
|
|
void ShowBuildRoadToolbar(RoadType roadtype)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-31 21:15:56 +00:00
|
|
|
if (!IsValidPlayer(_current_player)) return;
|
2007-05-21 21:58:31 +00:00
|
|
|
_cur_roadtype = roadtype;
|
2006-10-31 21:15:56 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
2007-05-25 22:07:40 +00:00
|
|
|
Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
|
2007-01-28 10:09:40 +00:00
|
|
|
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build road toolbar in the scenario editor */
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _build_road_scen_widgets[] = {
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // RTW_CLOSEBOX
|
2007-11-18 13:55:23 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 184, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // RTW_CAPTION
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 185, 196, 0, 13, 0x0, STR_STICKY_BUTTON}, // RTW_STICKY
|
2007-10-14 20:24:42 +00:00
|
|
|
|
2007-11-17 01:10:06 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_X_DIR, STR_180B_BUILD_ROAD_SECTION}, // RTW_ROAD_X
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_Y_DIR, STR_180B_BUILD_ROAD_SECTION}, // RTW_ROAD_Y
|
2007-10-22 19:11:50 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_AUTOROAD, STR_BUILD_AUTOROAD_TIP}, // RTW_AUTOROAD
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // RTW_DEMOLISH
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // RTW_DEPOT
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // RTW_BUS_STATION
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // RTW_TRUCK_STATION
|
2007-11-18 13:55:23 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_ROAD_ONE_WAY, STR_TOGGLE_ONE_WAY_ROAD}, // RTW_ONE_WAY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, // RTW_BUILD_BRIDGE
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL}, // RTW_BUILD_TUNNEL
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, // RTW_REMOVE
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_road_scen_desc = {
|
2007-11-18 13:55:23 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SCEN_BUILD_ROAD, WC_NONE,
|
2004-12-23 11:36:22 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_road_scen_widgets,
|
|
|
|
BuildRoadToolbWndProc
|
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowBuildRoadScenToolbar()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-06-01 17:59:11 +00:00
|
|
|
_cur_roadtype = ROADTYPE_ROAD;
|
2004-08-09 17:04:08 +00:00
|
|
|
AllocateWindowDescFront(&_build_road_scen_desc, 0);
|
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Enum referring to the widgets of the build road depot window */
|
|
|
|
enum BuildRoadDepotWidgets {
|
|
|
|
BRDW_CLOSEBOX = 0,
|
|
|
|
BRDW_CAPTION,
|
|
|
|
BRDW_BACKGROUND,
|
|
|
|
BRDW_DEPOT_NE,
|
|
|
|
BRDW_DEPOT_SE,
|
|
|
|
BRDW_DEPOT_SW,
|
|
|
|
BRDW_DEPOT_NW,
|
|
|
|
};
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
|
2005-11-14 19:48:04 +00:00
|
|
|
{
|
|
|
|
switch (e->event) {
|
2007-12-02 14:29:48 +00:00
|
|
|
case WE_CREATE: w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE); break;
|
2006-10-03 20:16:20 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT:
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2007-05-21 21:58:31 +00:00
|
|
|
DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
|
|
|
|
DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
|
|
|
|
DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
|
|
|
|
DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2007-10-14 20:24:42 +00:00
|
|
|
case BRDW_DEPOT_NW:
|
|
|
|
case BRDW_DEPOT_NE:
|
|
|
|
case BRDW_DEPOT_SW:
|
|
|
|
case BRDW_DEPOT_SE:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
|
2007-10-14 20:24:42 +00:00
|
|
|
_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
|
2007-10-14 20:24:42 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2007-10-14 20:24:42 +00:00
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP:
|
2007-04-18 22:10:36 +00:00
|
|
|
if (WP(w, def_d).close) DeleteWindow(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
2005-01-20 08:36:15 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
2007-04-18 22:10:36 +00:00
|
|
|
if (!WP(w, def_d).close) ResetObjectToPlace();
|
2005-01-20 08:36:15 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build road depot window */
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _build_road_depot_widgets[] = {
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRDW_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRDW_CAPTION
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, // BRDW_BACKGROUND
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build tram depot window */
|
2007-05-25 22:07:40 +00:00
|
|
|
static const Widget _build_tram_depot_widgets[] = {
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRDW_CLOSEBOX
|
2008-01-27 17:32:12 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_TRAM_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRDW_CAPTION
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, // BRDW_BACKGROUND
|
2008-01-27 17:32:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
|
2007-05-25 22:07:40 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const WindowDesc _build_road_depot_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_road_depot_widgets,
|
|
|
|
BuildRoadDepotWndProc
|
|
|
|
};
|
|
|
|
|
2007-05-25 22:07:40 +00:00
|
|
|
static const WindowDesc _build_tram_depot_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
|
2007-05-25 22:07:40 +00:00
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_tram_depot_widgets,
|
|
|
|
BuildRoadDepotWndProc
|
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowRoadDepotPicker()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-25 22:07:40 +00:00
|
|
|
AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Enum referring to the widgets of the build road station window */
|
|
|
|
enum BuildRoadStationWidgets {
|
|
|
|
BRSW_CLOSEBOX = 0,
|
|
|
|
BRSW_CAPTION,
|
|
|
|
BRSW_BACKGROUND,
|
|
|
|
BRSW_STATION_NE,
|
|
|
|
BRSW_STATION_SE,
|
|
|
|
BRSW_STATION_SW,
|
|
|
|
BRSW_STATION_NW,
|
|
|
|
BRSW_STATION_X,
|
|
|
|
BRSW_STATION_Y,
|
|
|
|
BRSW_LT_OFF,
|
|
|
|
BRSW_LT_ON,
|
|
|
|
BRSW_INFO,
|
|
|
|
};
|
|
|
|
|
2005-01-12 00:50:08 +00:00
|
|
|
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
2006-02-01 07:36:15 +00:00
|
|
|
switch (e->event) {
|
2006-10-03 20:16:20 +00:00
|
|
|
case WE_CREATE:
|
2007-05-24 08:52:28 +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;
|
|
|
|
}
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
|
2007-10-14 20:24:42 +00:00
|
|
|
BRSW_STATION_NE,
|
|
|
|
BRSW_STATION_SE,
|
|
|
|
BRSW_STATION_SW,
|
|
|
|
BRSW_STATION_NW,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
|
2007-12-02 14:29:48 +00:00
|
|
|
w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
|
|
|
|
w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
|
2006-10-03 20:16:20 +00:00
|
|
|
break;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT: {
|
2007-04-18 22:10:36 +00:00
|
|
|
if (WP(w, def_d).close) return;
|
2005-01-12 00:50:08 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2005-01-12 00:50:08 +00:00
|
|
|
if (_station_show_coverage) {
|
|
|
|
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
|
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2005-01-12 00:50:08 +00:00
|
|
|
SetTileSelectSize(1, 1);
|
2006-06-27 21:25:53 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-07-16 23:55:22 +00:00
|
|
|
StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-12-31 11:13:51 +00:00
|
|
|
StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
|
|
|
|
StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
|
|
|
|
StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
|
|
|
|
StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
|
2007-02-14 16:37:16 +00:00
|
|
|
|
2007-12-31 11:13:51 +00:00
|
|
|
StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
|
|
|
|
StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
|
2007-02-14 16:37:16 +00:00
|
|
|
|
2008-01-27 11:01:10 +00:00
|
|
|
int text_end = DrawStationCoverageAreaText(2, 146,
|
2007-07-12 13:40:24 +00:00
|
|
|
(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
|
2008-01-27 11:01:10 +00:00
|
|
|
3) + 4;
|
|
|
|
if (text_end > w->widget[BRSW_BACKGROUND].bottom) {
|
|
|
|
SetWindowDirty(w);
|
|
|
|
ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case WE_CLICK: {
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2007-10-14 20:24:42 +00:00
|
|
|
case BRSW_STATION_NE:
|
|
|
|
case BRSW_STATION_SE:
|
|
|
|
case BRSW_STATION_SW:
|
|
|
|
case BRSW_STATION_NW:
|
|
|
|
case BRSW_STATION_X:
|
|
|
|
case BRSW_STATION_Y:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
|
2007-10-14 20:24:42 +00:00
|
|
|
_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
|
2007-10-14 20:24:42 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BRSW_LT_OFF:
|
|
|
|
case BRSW_LT_ON:
|
2007-12-02 14:29:48 +00:00
|
|
|
w->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
|
2007-10-14 20:24:42 +00:00
|
|
|
_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
|
2007-10-14 20:24:42 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
} break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP: {
|
2007-04-18 22:10:36 +00:00
|
|
|
if (WP(w, def_d).close) {
|
2004-08-09 17:04:08 +00:00
|
|
|
DeleteWindow(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckRedrawStationCoverage(w);
|
|
|
|
} break;
|
2005-01-23 13:09:35 +00:00
|
|
|
|
2005-01-20 08:36:15 +00:00
|
|
|
case WE_DESTROY:
|
2007-04-18 22:10:36 +00:00
|
|
|
if (!WP(w, def_d).close) ResetObjectToPlace();
|
2005-01-20 08:36:15 +00:00
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:24:42 +00:00
|
|
|
/** Widget definition of the build raod station window */
|
2007-05-25 23:21:32 +00:00
|
|
|
static const Widget _rv_station_picker_widgets[] = {
|
2007-10-14 20:24:42 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRSW_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRSW_CAPTION
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 206, 14, 176, 0x0, STR_NULL}, // BRSW_BACKGROUND
|
|
|
|
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_NULL}, // BRSW_STATION_NE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_NULL}, // BRSW_STATION_SE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_NULL}, // BRSW_STATION_SW
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_NULL}, // BRSW_STATION_NW
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_NULL}, // BRSW_STATION_X
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_NULL}, // BRSW_STATION_Y
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_LT_OFF
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BRSW_LT_ON
|
|
|
|
{ WWT_LABEL, RESIZE_NONE, 7, 0, 139, 120, 133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, // BRSW_INFO
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-05-25 23:21:32 +00:00
|
|
|
static const WindowDesc _rv_station_picker_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUS_STATION, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
2007-05-25 23:21:32 +00:00
|
|
|
_rv_station_picker_widgets,
|
2004-08-09 17:04:08 +00:00
|
|
|
RoadStationPickerWndProc
|
|
|
|
};
|
|
|
|
|
2007-05-25 23:21:32 +00:00
|
|
|
static void ShowRVStationPicker(RoadStop::Type rs)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-25 23:21:32 +00:00
|
|
|
Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
|
|
|
|
if (w == NULL) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-05-26 12:34:25 +00:00
|
|
|
w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
|
2007-10-14 20:24:42 +00:00
|
|
|
w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
|
|
|
|
for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[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
|
|
|
}
|