2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-02-23 01:48:53 +00:00
|
|
|
/** @file rail_gui.cpp File for dealing with rail construction user interface */
|
2005-08-03 11:08:13 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2005-02-13 11:18:02 +00:00
|
|
|
#include "table/sprites.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2005-07-22 07:02:20 +00:00
|
|
|
#include "functions.h"
|
2007-04-12 13:07:15 +00:00
|
|
|
#include "landscape.h"
|
2007-01-15 22:18:35 +00:00
|
|
|
#include "date.h"
|
2004-12-15 22:18:54 +00:00
|
|
|
#include "map.h"
|
2005-01-29 12:19:05 +00:00
|
|
|
#include "tile.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "window.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "gfx.h"
|
2004-11-05 23:12:33 +00:00
|
|
|
#include "sound.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "vehicle.h"
|
2004-11-14 11:04:59 +00:00
|
|
|
#include "station.h"
|
2005-03-24 17:03:37 +00:00
|
|
|
#include "waypoint.h"
|
2005-05-01 20:16:52 +00:00
|
|
|
#include "debug.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2006-05-07 11:40:53 +00:00
|
|
|
#include "newgrf_callbacks.h"
|
|
|
|
#include "newgrf_station.h"
|
2006-11-17 19:31:44 +00:00
|
|
|
#include "train.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-10-16 09:13:04 +00:00
|
|
|
static RailType _cur_railtype;
|
2004-08-09 17:04:08 +00:00
|
|
|
static bool _remove_button_clicked;
|
2006-03-08 06:55:33 +00:00
|
|
|
static DiagDirection _build_depot_direction;
|
2005-11-14 19:48:04 +00:00
|
|
|
static byte _waypoint_count = 1;
|
2004-11-14 13:07:07 +00:00
|
|
|
static byte _cur_waypoint_type;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-11-13 13:43:55 +00:00
|
|
|
static struct {
|
2004-08-09 17:04:08 +00:00
|
|
|
byte orientation;
|
|
|
|
byte numtracks;
|
|
|
|
byte platlength;
|
|
|
|
bool dragdrop;
|
2006-05-07 11:40:53 +00:00
|
|
|
|
|
|
|
bool newstations;
|
2007-01-10 18:56:51 +00:00
|
|
|
StationClassIDByte station_class;
|
2006-05-07 11:40:53 +00:00
|
|
|
byte station_type;
|
|
|
|
byte station_count;
|
2004-08-09 17:04:08 +00:00
|
|
|
} _railstation;
|
|
|
|
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void HandleStationPlacement(TileIndex start, TileIndex end);
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowBuildTrainDepotPicker();
|
|
|
|
static void ShowBuildWaypointPicker();
|
|
|
|
static void ShowStationBuilder();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcPlaySound1E(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_20_SPLAT_2, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GenericPlaceRail(TileIndex tile, int cmd)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
|
2004-09-11 09:55:19 +00:00
|
|
|
_remove_button_clicked ?
|
|
|
|
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER :
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER
|
2005-11-14 19:48:04 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_N(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5;
|
|
|
|
GenericPlaceRail(tile, cmd);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_NE(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_Y);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_E(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3;
|
|
|
|
GenericPlaceRail(tile, cmd);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_NW(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_X);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_AutoRail(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_RAILDIRS);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-05-09 08:17:33 +00:00
|
|
|
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
|
2006-03-19 13:48:08 +00:00
|
|
|
if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-09-11 09:55:19 +00:00
|
|
|
DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_AUTO | CMD_NO_WATER);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const uint16 _place_depot_extra[12] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
0x0604, 0x2102, 0x1202, 0x0505,
|
|
|
|
0x2400, 0x2801, 0x1800, 0x1401,
|
|
|
|
0x2203, 0x0904, 0x0A05, 0x1103,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2007-01-10 18:56:51 +00:00
|
|
|
DiagDirection dir = (DiagDirection)p2;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
|
2006-09-05 23:21:41 +00:00
|
|
|
tile += TileOffsByDiagDir(dir);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-16 11:24:58 +00:00
|
|
|
if (IsTileType(tile, MP_RAILWAY)) {
|
2004-08-09 17:04:08 +00:00
|
|
|
PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
|
|
|
|
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
|
|
|
|
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
|
|
|
|
}
|
2004-09-11 09:55:19 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_Depot(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot,
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT));
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_Waypoint(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (!_remove_button_clicked) {
|
2005-11-12 00:19:34 +00:00
|
|
|
DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT));
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2004-11-14 13:07:07 +00:00
|
|
|
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcStation(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);
|
2006-05-07 11:40:53 +00:00
|
|
|
/* Only close the station builder window if the default station is chosen. */
|
|
|
|
if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0) ResetObjectToPlace();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_Station(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-06-27 21:25:53 +00:00
|
|
|
if (_remove_button_clicked) {
|
2007-05-07 17:10:30 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RemoveFromStation);
|
2006-06-27 21:25:53 +00:00
|
|
|
} else if (_railstation.dragdrop) {
|
2004-08-09 17:04:08 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
|
|
|
|
VpSetPlaceSizingLimit(_patches.station_spread);
|
|
|
|
} else {
|
2006-05-07 11:40:53 +00:00
|
|
|
DoCommandP(tile,
|
|
|
|
_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16),
|
|
|
|
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GenericPlaceSignals(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-01-19 00:01:52 +00:00
|
|
|
byte trackstat;
|
2005-11-14 19:48:04 +00:00
|
|
|
uint i;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-09-05 16:15:22 +00:00
|
|
|
trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-01-19 00:01:52 +00:00
|
|
|
if (trackstat & TRACK_BIT_VERT) // N-S direction
|
|
|
|
trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-01-19 00:01:52 +00:00
|
|
|
if (trackstat & TRACK_BIT_HORZ) // E-W direction
|
|
|
|
trackstat = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// Lookup the bit index
|
|
|
|
i = 0;
|
2005-11-14 19:48:04 +00:00
|
|
|
if (trackstat != 0) {
|
|
|
|
for (; !(trackstat & 1); trackstat >>= 1) i++;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (!_remove_button_clicked) {
|
2007-01-19 17:44:11 +00:00
|
|
|
uint32 p1 = GB(i, 0, 3);
|
|
|
|
SB(p1, 3, 1, _ctrl_pressed);
|
|
|
|
SB(p1, 4, 1, _cur_year < _patches.semaphore_build_before);
|
2007-01-19 00:01:52 +00:00
|
|
|
|
|
|
|
DoCommandP(tile, p1, 0, CcPlaySound1E,
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
|
|
|
|
} else {
|
|
|
|
DoCommandP(tile, i, 0, CcPlaySound1E,
|
|
|
|
CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_Bridge(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcBuildRailTunnel(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_Tunnel(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel,
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void PlaceProc_BuyLand(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND));
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_ConvertRail(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceRail_AutoSignals(TileIndex tile)
|
2004-08-15 20:23:42 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
|
|
|
|
}
|
|
|
|
|
2006-11-22 16:08:01 +00:00
|
|
|
|
|
|
|
/** Enum referring to the widgets of the build rail toolbar */
|
|
|
|
enum {
|
|
|
|
RTW_CAPTION = 1,
|
|
|
|
RTW_BUILD_NS = 4,
|
|
|
|
RTW_BUILD_X = 5,
|
|
|
|
RTW_BUILD_EW = 6,
|
|
|
|
RTW_BUILD_Y = 7,
|
|
|
|
RTW_AUTORAIL = 8,
|
|
|
|
RTW_DEMOLISH = 9,
|
|
|
|
RTW_BUILD_DEPOT = 10,
|
|
|
|
RTW_BUILD_WAYPOINT = 11,
|
|
|
|
RTW_BUILD_STATION = 12,
|
|
|
|
RTW_BUILD_SIGNALS = 13,
|
|
|
|
RTW_BUILD_BRIDGE = 14,
|
|
|
|
RTW_BUILD_TUNNEL = 15,
|
|
|
|
RTW_REMOVE = 16,
|
|
|
|
RTW_CONVERT_RAIL = 17
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void BuildRailClick_N(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_NE(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_E(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_NW(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRailClick_AutoRail(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRailClick_Demolish(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Depot(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) {
|
2005-10-14 08:11:18 +00:00
|
|
|
ShowBuildTrainDepotPicker();
|
|
|
|
}
|
2004-12-12 17:42:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Waypoint(Window *w)
|
|
|
|
{
|
2005-11-12 00:19:34 +00:00
|
|
|
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
|
2006-11-22 16:08:01 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) &&
|
2005-11-14 19:48:04 +00:00
|
|
|
_waypoint_count > 1) {
|
2004-12-12 17:42:04 +00:00
|
|
|
ShowBuildWaypointPicker();
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Station(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:42 +00:00
|
|
|
static void BuildRailClick_AutoSignals(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Bridge(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Tunnel(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Remove(Window *w)
|
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
if (IsWindowWidgetDisabled(w, 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);
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2006-11-22 16:08:01 +00:00
|
|
|
ToggleWidgetLoweredState(w, RTW_REMOVE);
|
|
|
|
_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
|
2006-10-03 20:16:20 +00:00
|
|
|
SetSelectionRed(_remove_button_clicked);
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// handle station builder
|
2006-10-03 20:16:20 +00:00
|
|
|
if (_remove_button_clicked) {
|
|
|
|
SetTileSelectSize(1, 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRailClick_Convert(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-11-22 16:08:01 +00:00
|
|
|
HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void DoRailroadTrack(int mode)
|
|
|
|
{
|
2005-06-25 06:15:43 +00:00
|
|
|
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL,
|
2004-09-11 09:55:19 +00:00
|
|
|
_remove_button_clicked ?
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_REMOVE_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
|
2005-01-30 15:57:38 +00:00
|
|
|
CMD_BUILD_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
|
2004-08-09 17:04:08 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void HandleAutodirPlacement()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
TileHighlightData *thd = &_thd;
|
2005-01-30 15:57:38 +00:00
|
|
|
int trackstat = thd->drawstyle & 0xF; // 0..5
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-19 20:55:23 +00:00
|
|
|
if (thd->drawstyle & HT_RAIL) { // one tile case
|
2005-06-25 06:15:43 +00:00
|
|
|
GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat);
|
2005-01-30 15:57:38 +00:00
|
|
|
return;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2005-01-30 15:57:38 +00:00
|
|
|
|
|
|
|
DoRailroadTrack(trackstat);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void HandleAutoSignalPlacement()
|
2004-08-15 20:23:42 +00:00
|
|
|
{
|
|
|
|
TileHighlightData *thd = &_thd;
|
2007-01-19 17:44:11 +00:00
|
|
|
uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2005-01-23 20:40:49 +00:00
|
|
|
if (thd->drawstyle == HT_RECT) { // one tile case
|
2005-06-25 06:15:43 +00:00
|
|
|
GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
|
2005-01-23 20:40:49 +00:00
|
|
|
return;
|
2004-09-11 09:55:19 +00:00
|
|
|
}
|
2005-01-23 20:40:49 +00:00
|
|
|
|
2007-01-19 17:44:11 +00:00
|
|
|
SB(p2, 3, 1, _ctrl_pressed);
|
|
|
|
SB(p2, 4, 1, _cur_year < _patches.semaphore_build_before);
|
2007-01-19 00:01:52 +00:00
|
|
|
SB(p2, 24, 8, _patches.drag_signals_density);
|
2007-01-15 22:18:35 +00:00
|
|
|
|
2007-01-19 00:01:52 +00:00
|
|
|
/* _patches.drag_signals_density is given as a parameter such that each user
|
|
|
|
* in a network game can specify his/her own signal density */
|
2005-11-14 19:48:04 +00:00
|
|
|
DoCommandP(
|
2007-01-19 00:01:52 +00:00
|
|
|
TileVirtXY(thd->selstart.x, thd->selstart.y),
|
2005-11-14 19:48:04 +00:00
|
|
|
TileVirtXY(thd->selend.x, thd->selend.y),
|
2007-01-19 00:01:52 +00:00
|
|
|
p2,
|
2005-11-14 19:48:04 +00:00
|
|
|
CcPlaySound1E,
|
|
|
|
_remove_button_clicked ?
|
|
|
|
CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
|
|
|
|
CMD_BUILD_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)
|
|
|
|
);
|
2004-08-15 20:23:42 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static OnButtonClick * const _build_railroad_button_proc[] = {
|
|
|
|
BuildRailClick_N,
|
|
|
|
BuildRailClick_NE,
|
|
|
|
BuildRailClick_E,
|
|
|
|
BuildRailClick_NW,
|
2004-12-12 17:42:04 +00:00
|
|
|
BuildRailClick_AutoRail,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRailClick_Demolish,
|
|
|
|
BuildRailClick_Depot,
|
2004-12-12 17:42:04 +00:00
|
|
|
BuildRailClick_Waypoint,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRailClick_Station,
|
2004-08-15 20:23:42 +00:00
|
|
|
BuildRailClick_AutoSignals,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRailClick_Bridge,
|
|
|
|
BuildRailClick_Tunnel,
|
|
|
|
BuildRailClick_Remove,
|
2007-01-15 07:38:36 +00:00
|
|
|
BuildRailClick_Convert
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const uint16 _rail_keycodes[] = {
|
|
|
|
'1',
|
|
|
|
'2',
|
|
|
|
'3',
|
|
|
|
'4',
|
2004-12-12 17:42:04 +00:00
|
|
|
'5',
|
2004-08-09 17:04:08 +00:00
|
|
|
'6',
|
2004-12-12 17:42:04 +00:00
|
|
|
'7', // depot
|
|
|
|
'8', // waypoint
|
|
|
|
'9', // station
|
|
|
|
'S', // signals
|
|
|
|
'B', // bridge
|
|
|
|
'T', // tunnel
|
|
|
|
'R', // remove
|
|
|
|
'C', // convert rail
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-03 02:08:15 +00:00
|
|
|
static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget)
|
|
|
|
{
|
2006-10-05 01:43:49 +00:00
|
|
|
/* If it is the removal button that has been clicked, do nothing,
|
|
|
|
* as it is up to the other buttons to drive removal status */
|
2006-11-22 16:08:01 +00:00
|
|
|
if (clicked_widget == RTW_REMOVE) return;
|
2006-10-05 01:43:49 +00:00
|
|
|
|
2006-10-03 02:08:15 +00:00
|
|
|
switch (clicked_widget) {
|
2006-11-22 16:08:01 +00:00
|
|
|
case RTW_BUILD_NS:
|
|
|
|
case RTW_BUILD_X:
|
|
|
|
case RTW_BUILD_EW:
|
|
|
|
case RTW_BUILD_Y:
|
|
|
|
case RTW_AUTORAIL:
|
|
|
|
case RTW_BUILD_WAYPOINT:
|
|
|
|
case RTW_BUILD_STATION:
|
|
|
|
case RTW_BUILD_SIGNALS:
|
2006-10-05 01:43:49 +00:00
|
|
|
/* Removal button is enabled only if the rail/signal/waypoint/station
|
|
|
|
* button is still lowered. Once raised, it has to be disabled */
|
2006-11-22 16:08:01 +00:00
|
|
|
SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
|
2006-10-05 01:43:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* When any other buttons than rail/signal/waypoint/station, raise and
|
|
|
|
* disable the removal button*/
|
2006-11-22 16:08:01 +00:00
|
|
|
DisableWindowWidget(w, RTW_REMOVE);
|
|
|
|
RaiseWindowWidget(w, RTW_REMOVE);
|
2006-10-05 01:43:49 +00:00
|
|
|
break;
|
2006-10-03 02:08:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
2005-11-14 19:48:04 +00:00
|
|
|
switch (e->event) {
|
2006-11-22 16:08:01 +00:00
|
|
|
case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
|
2006-10-05 01:43:49 +00:00
|
|
|
|
2006-10-03 02:08:15 +00:00
|
|
|
case WE_PAINT: DrawWindowWidgets(w); break;
|
2006-10-05 01:43:49 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.click.widget >= 4) {
|
2004-08-09 17:04:08 +00:00
|
|
|
_remove_button_clicked = false;
|
2006-09-23 02:39:24 +00:00
|
|
|
_build_railroad_button_proc[e->we.click.widget - 4](w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2006-10-03 02:08:15 +00:00
|
|
|
UpdateRemoveWidgetStatus(w, e->we.click.widget);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
case WE_KEYPRESS: {
|
2005-11-14 19:48:04 +00:00
|
|
|
uint i;
|
2004-12-12 22:05:08 +00:00
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
for (i = 0; i != lengthof(_rail_keycodes); i++) {
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.keypress.keycode == _rail_keycodes[i]) {
|
|
|
|
e->we.keypress.cont = false;
|
2004-08-09 17:04:08 +00:00
|
|
|
_remove_button_clicked = false;
|
|
|
|
_build_railroad_button_proc[i](w);
|
2006-10-05 12:18:07 +00:00
|
|
|
UpdateRemoveWidgetStatus(w, i + 4);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
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:
|
2006-09-23 02:39:24 +00:00
|
|
|
_place_proc(e->we.place.tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case WE_PLACE_DRAG: {
|
2006-09-23 02:39:24 +00:00
|
|
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WE_PLACE_MOUSEUP:
|
2006-10-28 23:47:00 +00:00
|
|
|
if (e->we.place.pt.x != -1) {
|
2006-09-23 02:39:24 +00:00
|
|
|
TileIndex start_tile = e->we.place.starttile;
|
|
|
|
TileIndex end_tile = e->we.place.tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.place.userdata == VPM_X_OR_Y) {
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
|
2006-09-23 02:39:24 +00:00
|
|
|
} else if (e->we.place.userdata == VPM_RAILDIRS) {
|
2004-08-09 17:04:08 +00:00
|
|
|
bool old = _remove_button_clicked;
|
|
|
|
if (_ctrl_pressed) _remove_button_clicked = true;
|
|
|
|
HandleAutodirPlacement();
|
|
|
|
_remove_button_clicked = old;
|
2006-09-23 02:39:24 +00:00
|
|
|
} else if (e->we.place.userdata == VPM_SIGNALDIRS) {
|
2004-08-15 20:23:42 +00:00
|
|
|
HandleAutoSignalPlacement();
|
2006-09-23 02:39:24 +00:00
|
|
|
} else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) {
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
if (GUIPlaceProcDragXY(e)) break;
|
|
|
|
|
2007-05-07 17:10:30 +00:00
|
|
|
if ((e->we.place.userdata >> 4) == GUI_PlaceProc_RemoveFromStation >> 4) {
|
|
|
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) {
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
|
2007-05-07 17:10:30 +00:00
|
|
|
}
|
2006-09-23 02:39:24 +00:00
|
|
|
} else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) {
|
2004-08-09 17:04:08 +00:00
|
|
|
HandleStationPlacement(start_tile, end_tile);
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2006-09-23 02:39:24 +00:00
|
|
|
DoRailroadTrack(e->we.place.userdata & 1);
|
2006-06-27 21:25:53 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowButtons(w);
|
2006-11-22 16:08:01 +00:00
|
|
|
DisableWindowWidget(w, RTW_REMOVE);
|
|
|
|
InvalidateWidget(w, RTW_REMOVE);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
w = FindWindowById(WC_BUILD_STATION, 0);
|
2005-11-14 19:48:04 +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);
|
2005-11-14 19:48:04 +00:00
|
|
|
if (w != NULL) WP(w,def_d).close = true;
|
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
|
|
|
|
2006-04-10 07:15:58 +00:00
|
|
|
DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
2005-11-14 19:48:04 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2005-08-03 11:08:13 +00:00
|
|
|
static const Widget _build_rail_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2007-01-15 07:38:36 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 337, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 338, 349, 0, 13, 0x0, STR_STICKY_BUTTON},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_RAIL_NS, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_RAIL_NE, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_RAIL_EW, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_RAIL_NW, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_AUTORAIL, STR_BUILD_AUTORAIL_TIP},
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_DEPOT_RAIL, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_IMG_WAYPOINT, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 180, 221, 14, 35, SPR_IMG_RAIL_STATION, STR_101A_BUILD_RAILROAD_STATION},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 222, 243, 14, 35, SPR_IMG_RAIL_SIGNALS, STR_101B_BUILD_RAILROAD_SIGNALS},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 244, 285, 14, 35, SPR_IMG_BRIDGE, STR_101C_BUILD_RAILROAD_BRIDGE},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 286, 305, 14, 35, SPR_IMG_TUNNEL_RAIL, STR_101D_BUILD_RAILROAD_TUNNEL},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 306, 327, 14, 35, SPR_IMG_REMOVE, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_IMG_CONVERT_RAIL, STR_CONVERT_RAIL_TIP},
|
|
|
|
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-08-03 11:08:13 +00:00
|
|
|
static const WindowDesc _build_rail_desc = {
|
2007-01-15 07:38:36 +00:00
|
|
|
WDP_ALIGN_TBR, 22, 350, 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,
|
2005-08-03 11:08:13 +00:00
|
|
|
_build_rail_widgets,
|
2004-08-09 17:04:08 +00:00
|
|
|
BuildRailToolbWndProc
|
|
|
|
};
|
|
|
|
|
2005-08-03 11:08:13 +00:00
|
|
|
|
|
|
|
/** Configures the rail toolbar for railtype given
|
|
|
|
* @param railtype the railtype to display
|
|
|
|
* @param w the window to modify
|
|
|
|
*/
|
2006-07-26 03:33:12 +00:00
|
|
|
static void SetupRailToolbar(RailType railtype, Window *w)
|
2005-08-03 11:08:13 +00:00
|
|
|
{
|
|
|
|
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
|
|
|
|
|
|
|
|
assert(railtype < RAILTYPE_END);
|
2006-09-04 15:44:28 +00:00
|
|
|
w->widget[RTW_CAPTION].data = rti->strings.toolbar_caption;
|
|
|
|
w->widget[RTW_BUILD_NS].data = rti->gui_sprites.build_ns_rail;
|
|
|
|
w->widget[RTW_BUILD_X].data = rti->gui_sprites.build_x_rail;
|
|
|
|
w->widget[RTW_BUILD_EW].data = rti->gui_sprites.build_ew_rail;
|
|
|
|
w->widget[RTW_BUILD_Y].data = rti->gui_sprites.build_y_rail;
|
|
|
|
w->widget[RTW_AUTORAIL].data = rti->gui_sprites.auto_rail;
|
|
|
|
w->widget[RTW_BUILD_DEPOT].data = rti->gui_sprites.build_depot;
|
|
|
|
w->widget[RTW_CONVERT_RAIL].data = rti->gui_sprites.convert_rail;
|
|
|
|
w->widget[RTW_BUILD_TUNNEL].data = rti->gui_sprites.build_tunnel;
|
2005-08-03 11:08:13 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-10-16 09:13:04 +00:00
|
|
|
void ShowBuildRailToolbar(RailType railtype, int button)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
Window *w;
|
|
|
|
|
2006-10-31 21:15:56 +00:00
|
|
|
if (!IsValidPlayer(_current_player)) return;
|
2006-10-11 22:04:46 +00:00
|
|
|
if (!ValParamRailtype(railtype)) return;
|
2005-01-08 20:55:21 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// don't recreate the window if we're clicking on a button and the window exists.
|
|
|
|
if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
|
2004-09-11 09:55:19 +00:00
|
|
|
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
2005-10-16 09:13:04 +00:00
|
|
|
_cur_railtype = railtype;
|
2005-08-03 11:08:13 +00:00
|
|
|
w = AllocateWindowDesc(&_build_rail_desc);
|
2005-10-16 09:13:04 +00:00
|
|
|
SetupRailToolbar(railtype, w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-18 16:40:06 +00:00
|
|
|
_remove_button_clicked = false;
|
2006-10-05 23:38:40 +00:00
|
|
|
if (w != NULL && button >= 0) {
|
|
|
|
_build_railroad_button_proc[button](w);
|
|
|
|
UpdateRemoveWidgetStatus(w, button + 4);
|
|
|
|
}
|
2007-01-28 10:09:40 +00:00
|
|
|
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-11-17 18:03:33 +00:00
|
|
|
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
|
|
|
|
* --pasky */
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void HandleStationPlacement(TileIndex start, TileIndex end)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-07 17:02:43 +00:00
|
|
|
uint sx = TileX(start);
|
|
|
|
uint sy = TileY(start);
|
|
|
|
uint ex = TileX(end);
|
|
|
|
uint ey = TileY(end);
|
2004-08-09 17:04:08 +00:00
|
|
|
uint w,h;
|
|
|
|
|
2007-02-22 08:43:02 +00:00
|
|
|
if (sx > ex) Swap(sx, ex);
|
|
|
|
if (sy > ey) Swap(sy, ey);
|
2004-08-09 17:04:08 +00:00
|
|
|
w = ex - sx + 1;
|
|
|
|
h = ey - sy + 1;
|
2007-02-22 08:43:02 +00:00
|
|
|
if (!_railstation.orientation) Swap(w, h);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
DoCommandP(TileXY(sx, sy),
|
|
|
|
_railstation.orientation | (w << 8) | (h << 16),
|
|
|
|
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
|
|
|
|
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-11-07 15:25:07 +00:00
|
|
|
/* Check if the currently selected station size is allowed */
|
|
|
|
static void CheckSelectedSize(Window *w, const StationSpec *statspec)
|
|
|
|
{
|
|
|
|
if (statspec == NULL || _railstation.dragdrop) return;
|
|
|
|
|
|
|
|
if (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
|
|
RaiseWindowWidget(w, _railstation.numtracks + 4);
|
|
|
|
_railstation.numtracks = 1;
|
|
|
|
while (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
|
|
_railstation.numtracks++;
|
|
|
|
}
|
|
|
|
LowerWindowWidget(w, _railstation.numtracks + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
|
|
RaiseWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
_railstation.platlength = 1;
|
|
|
|
while (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
|
|
_railstation.platlength++;
|
|
|
|
}
|
|
|
|
LowerWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-09 13:26:15 +00:00
|
|
|
static void StationBuildWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
switch (e->event) {
|
2006-10-03 20:16:20 +00:00
|
|
|
case WE_CREATE:
|
|
|
|
LowerWindowWidget(w, _railstation.orientation + 3);
|
|
|
|
if (_railstation.dragdrop) {
|
|
|
|
LowerWindowWidget(w, 19);
|
|
|
|
} else {
|
|
|
|
LowerWindowWidget(w, _railstation.numtracks + 4);
|
|
|
|
LowerWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
}
|
2006-10-04 19:11:43 +00:00
|
|
|
SetWindowWidgetLoweredState(w, 20, !_station_show_coverage);
|
|
|
|
SetWindowWidgetLoweredState(w, 21, _station_show_coverage);
|
2006-10-03 20:16:20 +00:00
|
|
|
break;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT: {
|
2005-05-09 13:26:15 +00:00
|
|
|
int rad;
|
2004-08-09 17:04:08 +00:00
|
|
|
uint bits;
|
2006-05-07 11:40:53 +00:00
|
|
|
bool newstations = _railstation.newstations;
|
|
|
|
int y_offset;
|
2006-05-30 21:27:51 +00:00
|
|
|
DrawPixelInfo tmp_dpi, *old_dpi;
|
2007-01-03 23:53:23 +00:00
|
|
|
const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-05-09 13:26:15 +00:00
|
|
|
if (WP(w,def_d).close) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (_railstation.dragdrop) {
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
} else {
|
|
|
|
int x = _railstation.numtracks;
|
|
|
|
int y = _railstation.platlength;
|
2007-02-22 08:43:02 +00:00
|
|
|
if (_railstation.orientation == 0) Swap(x, y);
|
2006-02-01 07:36:15 +00:00
|
|
|
if (!_remove_button_clicked)
|
2004-08-09 17:04:08 +00:00
|
|
|
SetTileSelectSize(x, y);
|
|
|
|
}
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2005-01-10 22:36:11 +00:00
|
|
|
rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
|
2004-12-08 15:46:13 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_station_show_coverage)
|
2004-12-08 15:46:13 +00:00
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-01-03 23:53:23 +00:00
|
|
|
for (bits = 0; bits < 7; bits++) {
|
|
|
|
bool disable = bits >= _patches.station_spread;
|
|
|
|
if (statspec == NULL) {
|
|
|
|
SetWindowWidgetDisabledState(w, bits + 5, disable);
|
|
|
|
SetWindowWidgetDisabledState(w, bits + 12, disable);
|
|
|
|
} else {
|
|
|
|
SetWindowWidgetDisabledState(w, bits + 5, HASBIT(statspec->disallowed_platforms, bits) || disable);
|
|
|
|
SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths, bits) || disable);
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDParam(0, GetStationClassName(_railstation.station_class));
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
y_offset = newstations ? 90 : 0;
|
|
|
|
|
2006-05-30 21:27:51 +00:00
|
|
|
/* Set up a clipping area for the '/' station preview */
|
2006-08-28 07:33:51 +00:00
|
|
|
if (FillDrawPixelInfo(&tmp_dpi, 7, 26 + y_offset, 66, 48)) {
|
2006-05-30 21:27:51 +00:00
|
|
|
old_dpi = _cur_dpi;
|
|
|
|
_cur_dpi = &tmp_dpi;
|
|
|
|
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
|
|
|
|
StationPickerDrawSprite(32, 16, _cur_railtype, 2);
|
|
|
|
}
|
|
|
|
_cur_dpi = old_dpi;
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
2006-05-30 21:27:51 +00:00
|
|
|
|
|
|
|
/* Set up a clipping area for the '\' station preview */
|
2006-08-28 07:33:51 +00:00
|
|
|
if (FillDrawPixelInfo(&tmp_dpi, 75, 26 + y_offset, 66, 48)) {
|
2006-05-30 21:27:51 +00:00
|
|
|
old_dpi = _cur_dpi;
|
|
|
|
_cur_dpi = &tmp_dpi;
|
|
|
|
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
|
|
|
|
StationPickerDrawSprite(32, 16, _cur_railtype, 3);
|
|
|
|
}
|
|
|
|
_cur_dpi = old_dpi;
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, 0);
|
|
|
|
DrawStringCentered(74, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, 0);
|
|
|
|
DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, 0);
|
|
|
|
DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
|
|
|
|
|
|
|
|
DrawStationCoverageAreaText(2, 166 + y_offset, (uint)-1, rad);
|
|
|
|
|
|
|
|
if (newstations) {
|
2006-05-09 11:39:23 +00:00
|
|
|
uint16 i;
|
2006-05-07 11:40:53 +00:00
|
|
|
uint y = 35;
|
|
|
|
|
2006-05-27 16:12:16 +00:00
|
|
|
for (i = w->vscroll.pos; i < _railstation.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) {
|
2006-05-07 11:40:53 +00:00
|
|
|
const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
if (statspec != NULL && statspec->name != 0) {
|
|
|
|
if (HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) {
|
2007-01-14 19:57:49 +00:00
|
|
|
GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT));
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? 12 : 16, 118);
|
|
|
|
} else {
|
|
|
|
DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? 12 : 16, 118);
|
|
|
|
}
|
|
|
|
|
|
|
|
y += 14;
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
} break;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_CLICK: {
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2004-08-09 17:04:08 +00:00
|
|
|
case 3:
|
|
|
|
case 4:
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowWidget(w, _railstation.orientation + 3);
|
2006-09-23 02:39:24 +00:00
|
|
|
_railstation.orientation = e->we.click.widget - 3;
|
2006-10-03 20:16:20 +00:00
|
|
|
LowerWindowWidget(w, _railstation.orientation + 3);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
2007-03-03 20:43:50 +00:00
|
|
|
case 11: {
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowWidget(w, _railstation.numtracks + 4);
|
|
|
|
RaiseWindowWidget(w, 19);
|
2007-03-03 20:43:50 +00:00
|
|
|
|
2006-09-23 02:39:24 +00:00
|
|
|
_railstation.numtracks = (e->we.click.widget - 5) + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
_railstation.dragdrop = false;
|
2007-03-03 20:43:50 +00:00
|
|
|
|
|
|
|
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
|
|
|
|
if (statspec != NULL && HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
|
|
/* The previously selected number of platforms in invalid */
|
|
|
|
for (uint i = 0; i < 7; i++) {
|
|
|
|
if (!HASBIT(statspec->disallowed_lengths, i)) {
|
|
|
|
RaiseWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
_railstation.platlength = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-03 20:16:20 +00:00
|
|
|
LowerWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
LowerWindowWidget(w, _railstation.numtracks + 4);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2007-03-03 20:43:50 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
case 17:
|
2007-03-03 20:43:50 +00:00
|
|
|
case 18: {
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
RaiseWindowWidget(w, 19);
|
2007-03-03 20:43:50 +00:00
|
|
|
|
2006-09-23 02:39:24 +00:00
|
|
|
_railstation.platlength = (e->we.click.widget - 12) + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
_railstation.dragdrop = false;
|
2007-03-03 20:43:50 +00:00
|
|
|
|
|
|
|
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
|
|
|
|
if (statspec != NULL && HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
|
|
/* The previously selected number of tracks in invalid */
|
|
|
|
for (uint i = 0; i < 7; i++) {
|
|
|
|
if (!HASBIT(statspec->disallowed_platforms, i)) {
|
|
|
|
RaiseWindowWidget(w, _railstation.numtracks + 4);
|
|
|
|
_railstation.numtracks = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-03 20:16:20 +00:00
|
|
|
LowerWindowWidget(w, _railstation.platlength + 11);
|
|
|
|
LowerWindowWidget(w, _railstation.numtracks + 4);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2007-03-03 20:43:50 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
case 19:
|
|
|
|
_railstation.dragdrop ^= true;
|
2006-10-03 20:16:20 +00:00
|
|
|
ToggleWidgetLoweredState(w, 19);
|
2006-10-04 19:11:43 +00:00
|
|
|
SetWindowWidgetLoweredState(w, _railstation.numtracks + 4, !_railstation.dragdrop);
|
|
|
|
SetWindowWidgetLoweredState(w, _railstation.platlength + 11, !_railstation.dragdrop);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 20:
|
|
|
|
case 21:
|
2007-01-10 18:56:51 +00:00
|
|
|
_station_show_coverage = (e->we.click.widget != 20);
|
2006-10-04 19:11:43 +00:00
|
|
|
SetWindowWidgetLoweredState(w, 20, !_station_show_coverage);
|
|
|
|
SetWindowWidgetLoweredState(w, 21, _station_show_coverage);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2006-05-07 11:40:53 +00:00
|
|
|
|
2006-05-07 16:34:16 +00:00
|
|
|
case 22:
|
2006-05-07 11:40:53 +00:00
|
|
|
case 23:
|
|
|
|
ShowDropDownMenu(w, BuildStationClassDropdown(), _railstation.station_class, 23, 0, 1 << STAT_CLASS_WAYP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24: {
|
|
|
|
const StationSpec *statspec;
|
2006-09-23 02:39:24 +00:00
|
|
|
int y = (e->we.click.pt.y - 32) / 14;
|
2006-05-07 11:40:53 +00:00
|
|
|
|
|
|
|
if (y >= w->vscroll.cap) return;
|
|
|
|
y += w->vscroll.pos;
|
|
|
|
if (y >= _railstation.station_count) return;
|
|
|
|
|
|
|
|
/* Check station availability callback */
|
|
|
|
statspec = GetCustomStationSpec(_railstation.station_class, y);
|
|
|
|
if (statspec != NULL &&
|
|
|
|
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) &&
|
|
|
|
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
|
|
|
|
|
|
|
|
_railstation.station_type = y;
|
2006-11-07 15:25:07 +00:00
|
|
|
|
|
|
|
CheckSelectedSize(w, statspec);
|
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
} break;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
case WE_DROPDOWN_SELECT:
|
2006-09-23 02:39:24 +00:00
|
|
|
if (_railstation.station_class != e->we.dropdown.index) {
|
2007-01-10 18:56:51 +00:00
|
|
|
_railstation.station_class = (StationClassID)e->we.dropdown.index;
|
2006-05-07 11:40:53 +00:00
|
|
|
_railstation.station_type = 0;
|
|
|
|
_railstation.station_count = GetNumCustomStations(_railstation.station_class);
|
|
|
|
|
2006-11-07 15:25:07 +00:00
|
|
|
CheckSelectedSize(w, GetCustomStationSpec(_railstation.station_class, _railstation.station_type));
|
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
w->vscroll.count = _railstation.station_count;
|
|
|
|
w->vscroll.pos = _railstation.station_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
case WE_MOUSELOOP:
|
2004-08-09 17:04:08 +00:00
|
|
|
if (WP(w,def_d).close) {
|
|
|
|
DeleteWindow(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CheckRedrawStationCoverage(w);
|
2005-11-14 19:48:04 +00:00
|
|
|
break;
|
2005-01-20 10:31:59 +00:00
|
|
|
|
2005-01-20 08:36:15 +00:00
|
|
|
case WE_DESTROY:
|
2005-11-14 19:48:04 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _station_builder_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 199, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 87, 98, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 87, 98, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 112, 123, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 112, 123, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 152, 163, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 152, 163, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
static const Widget _newstation_builder_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2006-05-07 11:40:53 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 289, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 177, 188, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 177, 188, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 177, 188, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 177, 188, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 177, 188, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 177, 188, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 177, 188, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 202, 213, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 202, 213, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 202, 213, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 202, 213, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 202, 213, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 202, 213, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 202, 213, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 216, 227, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 242, 253, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 242, 253, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
2006-05-07 11:40:53 +00:00
|
|
|
|
|
|
|
/* newstations gui additions */
|
2006-10-24 16:27:18 +00:00
|
|
|
{ WWT_INSET, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, 14, 129, 139, 18, 27, STR_0225, STR_SELECT_STATION_CLASS_TIP},
|
|
|
|
{ WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP},
|
|
|
|
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
2006-05-07 11:40:53 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const WindowDesc _station_builder_desc = {
|
2006-11-10 19:24:14 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 148, 200,
|
|
|
|
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_station_builder_widgets,
|
|
|
|
StationBuildWndProc
|
|
|
|
};
|
|
|
|
|
2006-05-07 11:40:53 +00:00
|
|
|
static const WindowDesc _newstation_builder_desc = {
|
2006-11-10 19:24:14 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 148, 290,
|
|
|
|
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
2006-05-07 11:40:53 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_newstation_builder_widgets,
|
|
|
|
StationBuildWndProc
|
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowStationBuilder()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-05-07 11:40:53 +00:00
|
|
|
Window *w;
|
|
|
|
if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
|
|
|
|
w = AllocateWindowDesc(&_station_builder_desc);
|
|
|
|
_railstation.newstations = false;
|
|
|
|
} else {
|
|
|
|
w = AllocateWindowDesc(&_newstation_builder_desc);
|
|
|
|
_railstation.newstations = true;
|
|
|
|
_railstation.station_count = GetNumCustomStations(_railstation.station_class);
|
|
|
|
|
|
|
|
w->vscroll.count = _railstation.station_count;
|
|
|
|
w->vscroll.cap = 5;
|
|
|
|
w->vscroll.pos = clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildTrainDepotWndProc(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: LowerWindowWidget(w, _build_depot_direction + 3); break;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT: {
|
2005-10-16 09:13:04 +00:00
|
|
|
RailType r;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
|
|
r = _cur_railtype;
|
|
|
|
DrawTrainDepotSprite(70, 17, 0, r);
|
|
|
|
DrawTrainDepotSprite(70, 69, 1, r);
|
2005-11-14 19:48:04 +00:00
|
|
|
DrawTrainDepotSprite( 2, 69, 2, r);
|
|
|
|
DrawTrainDepotSprite( 2, 17, 3, r);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
|
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2005-11-14 19:48:04 +00:00
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowWidget(w, _build_depot_direction + 3);
|
2007-01-10 18:56:51 +00:00
|
|
|
_build_depot_direction = (DiagDirection)(e->we.click.widget - 3);
|
2006-10-03 20:16:20 +00:00
|
|
|
LowerWindowWidget(w, _build_depot_direction + 3);
|
2005-11-14 19:48:04 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
break;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP:
|
2005-11-14 19:48:04 +00:00
|
|
|
if (WP(w,def_d).close) DeleteWindow(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
2005-01-20 08:36:15 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
2005-11-14 19:48:04 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _build_depot_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_depot_desc = {
|
2006-11-10 19:24:14 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 140, 122,
|
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_depot_widgets,
|
|
|
|
BuildTrainDepotWndProc
|
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowBuildTrainDepotPicker()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_build_depot_desc);
|
|
|
|
}
|
|
|
|
|
2004-11-14 11:04:59 +00:00
|
|
|
|
2004-11-14 13:07:07 +00:00
|
|
|
static void BuildWaypointWndProc(Window *w, WindowEvent *e)
|
2004-11-14 11:04:59 +00:00
|
|
|
{
|
2005-05-01 20:16:52 +00:00
|
|
|
switch (e->event) {
|
2004-11-14 11:04:59 +00:00
|
|
|
case WE_PAINT: {
|
2005-11-14 19:48:04 +00:00
|
|
|
uint i;
|
|
|
|
|
2006-10-15 16:56:58 +00:00
|
|
|
for (i = 0; i < w->hscroll.cap; i++) {
|
|
|
|
SetWindowWidgetLoweredState(w, i + 3, (w->hscroll.pos + i) == _cur_waypoint_type);
|
|
|
|
}
|
|
|
|
|
2004-11-14 11:04:59 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2006-10-15 16:56:58 +00:00
|
|
|
for (i = 0; i < w->hscroll.cap; i++) {
|
|
|
|
if (w->hscroll.pos + i < w->hscroll.count) {
|
2006-05-07 11:40:53 +00:00
|
|
|
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, w->hscroll.pos + i);
|
|
|
|
|
2005-11-12 00:19:34 +00:00
|
|
|
DrawWaypointSprite(2 + i * 68, 25, w->hscroll.pos + i, _cur_railtype);
|
2006-05-07 11:40:53 +00:00
|
|
|
|
|
|
|
if (statspec != NULL &&
|
|
|
|
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) &&
|
|
|
|
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) {
|
2007-01-14 19:57:49 +00:00
|
|
|
GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, (1 << PALETTE_MODIFIER_GREYOUT));
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2005-11-12 08:51:46 +00:00
|
|
|
}
|
2004-11-14 11:04:59 +00:00
|
|
|
break;
|
2005-05-01 20:16:52 +00:00
|
|
|
}
|
2004-11-14 11:04:59 +00:00
|
|
|
case WE_CLICK: {
|
2006-09-23 02:39:24 +00:00
|
|
|
switch (e->we.click.widget) {
|
2006-05-07 11:40:53 +00:00
|
|
|
case 3: case 4: case 5: case 6: case 7: {
|
2006-09-23 02:39:24 +00:00
|
|
|
byte type = e->we.click.widget - 3 + w->hscroll.pos;
|
2006-05-07 11:40:53 +00:00
|
|
|
|
|
|
|
/* Check station availability callback */
|
|
|
|
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type);
|
|
|
|
if (statspec != NULL &&
|
|
|
|
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) &&
|
|
|
|
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
|
|
|
|
|
|
|
|
_cur_waypoint_type = type;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-11-14 11:04:59 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-07 11:40:53 +00:00
|
|
|
}
|
2004-11-14 11:04:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-01-03 19:45:18 +00:00
|
|
|
|
2004-11-14 11:04:59 +00:00
|
|
|
case WE_MOUSELOOP:
|
2005-11-14 19:48:04 +00:00
|
|
|
if (WP(w,def_d).close) DeleteWindow(w);
|
2005-05-01 20:16:52 +00:00
|
|
|
break;
|
2005-01-20 10:31:59 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
2005-11-14 19:48:04 +00:00
|
|
|
if (!WP(w,def_d).close) ResetObjectToPlace();
|
2005-01-20 10:31:59 +00:00
|
|
|
break;
|
2004-11-14 11:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-14 13:07:07 +00:00
|
|
|
static const Widget _build_waypoint_widgets[] = {
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 343, 0, 13, STR_WAYPOINT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 343, 14, 91, 0x0, 0},
|
2004-11-14 11:04:59 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 3, 68, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 71, 136, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 139, 204, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 207, 272, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 275, 340, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
2004-11-14 11:04:59 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
{ WWT_HSCROLLBAR, RESIZE_NONE, 7, 1, 343, 80, 91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
2004-11-14 22:30:46 +00:00
|
|
|
{ WIDGETS_END},
|
2004-11-14 11:04:59 +00:00
|
|
|
};
|
|
|
|
|
2004-11-14 13:07:07 +00:00
|
|
|
static const WindowDesc _build_waypoint_desc = {
|
2006-11-10 19:24:14 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 344, 92,
|
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2004-11-14 11:04:59 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
2004-11-14 13:07:07 +00:00
|
|
|
_build_waypoint_widgets,
|
|
|
|
BuildWaypointWndProc
|
2004-11-14 11:04:59 +00:00
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static void ShowBuildWaypointPicker()
|
2004-11-14 11:04:59 +00:00
|
|
|
{
|
2004-11-14 13:07:07 +00:00
|
|
|
Window *w = AllocateWindowDesc(&_build_waypoint_desc);
|
2004-11-14 20:02:43 +00:00
|
|
|
w->hscroll.cap = 5;
|
2005-11-12 00:19:34 +00:00
|
|
|
w->hscroll.count = _waypoint_count;
|
2004-11-14 11:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeRailGui()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-03-08 06:55:33 +00:00
|
|
|
_build_depot_direction = DIAGDIR_NW;
|
2004-08-09 17:04:08 +00:00
|
|
|
_railstation.numtracks = 1;
|
|
|
|
_railstation.platlength = 1;
|
|
|
|
_railstation.dragdrop = true;
|
|
|
|
}
|
2006-11-17 19:31:44 +00:00
|
|
|
|
|
|
|
void ReinitGuiAfterToggleElrail(bool disable)
|
|
|
|
{
|
|
|
|
extern RailType _last_built_railtype;
|
|
|
|
if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
|
|
|
|
Window *w;
|
|
|
|
_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
|
|
|
|
w = FindWindowById(WC_BUILD_TOOLBAR, 0);
|
|
|
|
if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
|
|
|
|
SetupRailToolbar(_cur_railtype, w);
|
|
|
|
SetWindowDirty(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|