2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ttd.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"
|
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"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static uint _cur_railtype;
|
|
|
|
static bool _remove_button_clicked;
|
|
|
|
static byte _build_depot_direction;
|
2004-11-14 20:02:43 +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
|
|
|
|
|
|
|
struct {
|
|
|
|
byte orientation;
|
|
|
|
byte numtracks;
|
|
|
|
byte platlength;
|
|
|
|
bool dragdrop;
|
|
|
|
} _railstation;
|
|
|
|
|
|
|
|
|
|
|
|
static void HandleStationPlacement(uint start, uint end);
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowBuildTrainDepotPicker(void);
|
|
|
|
static void ShowBuildWaypointPicker(void);
|
|
|
|
static void ShowStationBuilder(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcPlaySound1E(bool success, uint 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
|
|
|
}
|
|
|
|
|
|
|
|
static void GenericPlaceRail(uint tile, int cmd)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_N(uint tile)
|
|
|
|
{
|
|
|
|
int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5;
|
|
|
|
GenericPlaceRail(tile, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_NE(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_E(uint tile)
|
|
|
|
{
|
|
|
|
int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3;
|
|
|
|
GenericPlaceRail(tile, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_NW(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_X);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_AutoRail(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_RAILDIRS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceExtraDepotRail(uint tile, uint16 extra)
|
|
|
|
{
|
|
|
|
byte b = _map5[tile];
|
|
|
|
|
|
|
|
if (b & 0xC0 || !(b & (extra >> 8)))
|
|
|
|
return;
|
|
|
|
|
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] = {
|
|
|
|
0x604, 0x2102, 0x1202, 0x505,
|
|
|
|
0x2400, 0x2801, 0x1800, 0x1401,
|
|
|
|
0x2203, 0x904, 0x0A05, 0x1103,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcRailDepot(bool success, uint tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
|
|
|
int dir = p2;
|
|
|
|
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
|
2005-01-05 13:32:03 +00:00
|
|
|
tile += TileOffsByDir(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
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_Depot(uint tile)
|
|
|
|
{
|
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));
|
|
|
|
}
|
|
|
|
|
2004-11-14 13:07:07 +00:00
|
|
|
static void PlaceRail_Waypoint(uint tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (!_remove_button_clicked) {
|
2005-05-09 16:37:40 +00:00
|
|
|
DoCommandP(tile, (_waypoint_count > 0) ? (0x100 + _cur_waypoint_type) : 0, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcStation(bool success, uint 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_Station(uint tile)
|
|
|
|
{
|
|
|
|
if(_remove_button_clicked)
|
|
|
|
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
|
|
|
|
else if (_railstation.dragdrop) {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
|
|
|
|
VpSetPlaceSizingLimit(_patches.station_spread);
|
|
|
|
} else {
|
2004-11-17 18:03:33 +00:00
|
|
|
// TODO: Custom station selector GUI. Now we just try using first custom station
|
|
|
|
// (and fall back to normal stations if it isn't available).
|
|
|
|
DoCommandP(tile, _railstation.orientation | (_railstation.numtracks<<8) | (_railstation.platlength<<16),_cur_railtype|1<<4, 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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:42 +00:00
|
|
|
static void GenericPlaceSignals(uint tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
uint trackstat;
|
|
|
|
int i;
|
|
|
|
|
2004-09-05 16:15:22 +00:00
|
|
|
trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-23 20:40:49 +00:00
|
|
|
if ((trackstat & 0x30)) // N-S direction
|
2004-08-09 17:04:08 +00:00
|
|
|
trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? 0x20 : 0x10;
|
|
|
|
|
2005-01-23 20:40:49 +00:00
|
|
|
if ((trackstat & 0x0C)) // E-W direction
|
2004-08-09 17:04:08 +00:00
|
|
|
trackstat = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? 4 : 8;
|
|
|
|
|
|
|
|
// Lookup the bit index
|
|
|
|
i = 0;
|
|
|
|
if (trackstat != 0) { while (!(trackstat & 1)) { i++; trackstat >>= 1; }}
|
|
|
|
|
|
|
|
if (!_remove_button_clicked) {
|
|
|
|
DoCommandP(tile, i + (_ctrl_pressed ? 8 : 0), 0, CcPlaySound1E,
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_Bridge(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void CcBuildRailTunnel(bool success, uint 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_Tunnel(uint tile)
|
|
|
|
{
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlaceProc_BuyLand(uint tile)
|
|
|
|
{
|
|
|
|
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PlaceRail_ConvertRail(uint tile)
|
|
|
|
{
|
(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
|
|
|
}
|
|
|
|
|
2004-08-15 20:23:42 +00:00
|
|
|
static void PlaceRail_AutoSignals(uint tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void BuildRailClick_N(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 4, _cur_railtype*4 + 0x4EF, 1, PlaceRail_N);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_NE(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 5, _cur_railtype*4 + 0x4F0, 1, PlaceRail_NE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_E(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 6, _cur_railtype*4 + 0x4F1, 1, PlaceRail_E);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_NW(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 7, _cur_railtype*4 + 0x4F2, 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
|
|
|
{
|
2005-01-19 20:55:23 +00:00
|
|
|
HandlePlacePushButton(w, 8, _cur_railtype + SPR_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
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const SpriteID _depot_cursors[] = {
|
|
|
|
0x510,
|
|
|
|
SPR_OPENTTD_BASE + 14,
|
|
|
|
SPR_OPENTTD_BASE + 15,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void BuildRailClick_Depot(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 10, _depot_cursors[_cur_railtype], 1, PlaceRail_Depot)) ShowBuildTrainDepotPicker();
|
2004-12-12 17:42:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Waypoint(Window *w)
|
|
|
|
{
|
|
|
|
_waypoint_count = GetCustomStationsCount(STAT_CLASS_WAYP);
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 11, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Waypoint)
|
2005-05-01 20:16:52 +00:00
|
|
|
&& _waypoint_count > 0)
|
2004-12-12 17:42:04 +00:00
|
|
|
ShowBuildWaypointPicker();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Station(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
if (HandlePlacePushButton(w, 12, 0x514, 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
|
|
|
{
|
2005-01-19 20:55:23 +00:00
|
|
|
HandlePlacePushButton(w, 13, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Bridge(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 14, 0xA21, 1, PlaceRail_Bridge);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Tunnel(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 15, 0x982 + _cur_railtype, 3, PlaceRail_Tunnel);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildRailClick_Remove(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
if (w->disabled_state & (1<<16))
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
SetWindowDirty(w);
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-12-22 00:18:40 +00:00
|
|
|
_thd.make_square_red = !!((w->click_state ^= (1 << 16)) & (1<<16));
|
2004-11-26 21:52:18 +00:00
|
|
|
MarkTileDirty(_thd.pos.x, _thd.pos.y);
|
2004-12-22 00:18:40 +00:00
|
|
|
_remove_button_clicked = (w->click_state & (1 << 16)) != 0;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// handle station builder
|
2004-12-22 00:18:40 +00:00
|
|
|
if( w->click_state & (1 << 16) )
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if(_remove_button_clicked)
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
else
|
|
|
|
BringWindowToFrontById(WC_BUILD_STATION, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRailClick_Convert(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 17, (SPR_OPENTTD_BASE + 26) + _cur_railtype * 2, 1, PlaceRail_ConvertRail);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildRailClick_Landscaping(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-12 17:42:04 +00:00
|
|
|
ShowTerraformToolbar();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void DoRailroadTrack(int mode)
|
|
|
|
{
|
2005-01-30 15:57:38 +00:00
|
|
|
DoCommandP(TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y), TILE_FROM_XY(_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
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void HandleAutodirPlacement(void)
|
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-01-30 15:57:38 +00:00
|
|
|
GenericPlaceRail(TILE_FROM_XY(thd->selend.x, thd->selend.y), trackstat);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-01-19 20:55:23 +00:00
|
|
|
static void HandleAutoSignalPlacement(void)
|
2004-08-15 20:23:42 +00:00
|
|
|
{
|
|
|
|
TileHighlightData *thd = &_thd;
|
2005-01-30 15:57:38 +00:00
|
|
|
byte trackstat = thd->drawstyle & 0xF; // 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
|
2004-08-15 20:23:42 +00:00
|
|
|
GenericPlaceSignals(TILE_FROM_XY(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
|
|
|
|
|
|
|
// _patches.drag_signals_density is given as a parameter such that each user in a network
|
|
|
|
// game can specify his/her own signal density
|
|
|
|
DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y),
|
2005-01-30 15:57:38 +00:00
|
|
|
(_ctrl_pressed ? 1 << 3 : 0) | (trackstat << 4) | (_patches.drag_signals_density << 24),
|
2005-01-23 20:40:49 +00:00
|
|
|
CcPlaySound1E,
|
2005-01-30 15:57:38 +00:00
|
|
|
(_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
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
BuildRailClick_Convert,
|
2004-12-12 17:42:04 +00:00
|
|
|
BuildRailClick_Landscaping,
|
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
|
|
|
|
'L', // landscaping
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
switch(e->event) {
|
|
|
|
case WE_PAINT:
|
2004-12-22 00:18:40 +00:00
|
|
|
w->disabled_state &= ~(1 << 16);
|
|
|
|
if (!(w->click_state & ((1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<11)|(1<<12)|(1<<13)))) {
|
|
|
|
w->disabled_state |= (1 << 16);
|
|
|
|
w->click_state &= ~(1<<16);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_CLICK:
|
2004-12-22 00:18:40 +00:00
|
|
|
if (e->click.widget >= 4) {
|
2004-08-09 17:04:08 +00:00
|
|
|
_remove_button_clicked = false;
|
2004-12-22 00:18:40 +00:00
|
|
|
_build_railroad_button_proc[e->click.widget - 4](w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_KEYPRESS: {
|
|
|
|
int i;
|
2004-12-12 22:05:08 +00:00
|
|
|
|
2004-12-22 00:18:40 +00:00
|
|
|
for(i=0; i!=lengthof(_rail_keycodes); i++) {
|
2004-08-09 17:04:08 +00:00
|
|
|
if (e->keypress.keycode == _rail_keycodes[i]) {
|
|
|
|
e->keypress.cont = false;
|
|
|
|
_remove_button_clicked = false;
|
|
|
|
_build_railroad_button_proc[i](w);
|
|
|
|
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:
|
|
|
|
_place_proc(e->place.tile);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case WE_PLACE_DRAG: {
|
|
|
|
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WE_PLACE_MOUSEUP:
|
|
|
|
if (e->click.pt.x != -1) {
|
(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
|
|
|
TileIndex start_tile = e->place.starttile;
|
|
|
|
TileIndex end_tile = e->place.tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (e->place.userdata == VPM_X_OR_Y) {
|
|
|
|
ResetObjectToPlace();
|
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
|
|
|
|
} else if (e->place.userdata == VPM_RAILDIRS) {
|
|
|
|
bool old = _remove_button_clicked;
|
|
|
|
if (_ctrl_pressed) _remove_button_clicked = true;
|
|
|
|
HandleAutodirPlacement();
|
|
|
|
_remove_button_clicked = old;
|
2004-08-15 20:23:42 +00:00
|
|
|
} else if (e->place.userdata == VPM_SIGNALDIRS) {
|
|
|
|
HandleAutoSignalPlacement();
|
(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
|
|
|
} else if ((e->place.userdata & 0xF) == VPM_X_AND_Y) {
|
|
|
|
if (GUIPlaceProcDragXY(e)) break;
|
|
|
|
|
2005-04-06 21:12:28 +00:00
|
|
|
if ((e->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));
|
2004-08-09 17:04:08 +00:00
|
|
|
} else if (e->place.userdata == VPM_X_AND_Y_LIMITED) {
|
|
|
|
HandleStationPlacement(start_tile, end_tile);
|
2005-01-30 15:57:38 +00:00
|
|
|
} else
|
|
|
|
DoRailroadTrack(e->place.userdata & 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2004-12-22 00:18:40 +00:00
|
|
|
UnclickWindowButtons(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
|
|
|
|
w = FindWindowById(WC_BUILD_STATION, 0);
|
|
|
|
if (w != NULL) WP(w,def_d).close=true;
|
|
|
|
w = FindWindowById(WC_BUILD_DEPOT, 0);
|
|
|
|
if (w != NULL) WP(w,def_d).close=true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_PRESIZE: {
|
|
|
|
uint tile = e->place.tile;
|
|
|
|
DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
|
|
|
VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static const Widget _build_railroad_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4E3, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4E4, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4E5, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4E6, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 0, STR_BUILD_AUTORAIL_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, 0x50E, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x97E, STR_101D_BUILD_RAILROAD_TUNNEL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 25, STR_CONVERT_RAIL_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_railroad_desc = {
|
2004-12-12 17:42:04 +00:00
|
|
|
640-372, 22, 372, 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_BUILD_TOOLBAR,0,
|
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_railroad_widgets,
|
|
|
|
BuildRailToolbWndProc
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Widget _build_monorail_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100B_MONORAIL_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4E7, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4E8, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4E9, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4EA, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 1, STR_BUILD_AUTORAIL_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_OPENTTD_BASE + 12, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x97F, STR_101D_BUILD_RAILROAD_TUNNEL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 27, STR_CONVERT_RAIL_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_monorail_desc = {
|
2004-12-12 17:42:04 +00:00
|
|
|
640-372, 22, 372, 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_BUILD_TOOLBAR,0,
|
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_monorail_widgets,
|
|
|
|
BuildRailToolbWndProc
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Widget _build_maglev_widgets[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100C_MAGLEV_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4EB, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4EC, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4EE, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4ED, STR_1018_BUILD_RAILROAD_TRACK},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 2, STR_BUILD_AUTORAIL_TIP},
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_OPENTTD_BASE + 13, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x980, STR_101D_BUILD_RAILROAD_TUNNEL},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 29, STR_CONVERT_RAIL_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
2004-12-12 17:42:04 +00:00
|
|
|
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_maglev_desc = {
|
2004-12-12 17:42:04 +00:00
|
|
|
640-372, 22, 372, 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
WC_BUILD_TOOLBAR,0,
|
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_maglev_widgets,
|
|
|
|
BuildRailToolbWndProc
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const WindowDesc * const _build_rr_desc[] = {
|
|
|
|
&_build_railroad_desc,
|
|
|
|
&_build_monorail_desc,
|
|
|
|
&_build_maglev_desc,
|
|
|
|
};
|
|
|
|
|
|
|
|
void ShowBuildRailToolbar(int index, int button)
|
|
|
|
{
|
|
|
|
Window *w;
|
|
|
|
|
2005-01-08 20:55:21 +00:00
|
|
|
if (_current_player == OWNER_SPECTATOR) return;
|
|
|
|
|
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);
|
2004-08-09 17:04:08 +00:00
|
|
|
_cur_railtype = (byte)index;
|
|
|
|
w = AllocateWindowDesc(_build_rr_desc[index]);
|
|
|
|
}
|
|
|
|
|
2004-09-18 16:40:06 +00:00
|
|
|
_remove_button_clicked = false;
|
2004-08-09 17:04:08 +00:00
|
|
|
if (w != NULL && button >= 0) _build_railroad_button_proc[button](w);
|
|
|
|
}
|
|
|
|
|
2004-11-17 18:03:33 +00:00
|
|
|
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
|
|
|
|
* --pasky */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void HandleStationPlacement(uint start, uint end)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
if (sx > ex) intswap(sx,ex);
|
|
|
|
if (sy > ey) intswap(sy,ey);
|
|
|
|
w = ex - sx + 1;
|
|
|
|
h = ey - sy + 1;
|
|
|
|
if (!_railstation.orientation) intswap(w,h);
|
|
|
|
|
2004-11-17 18:03:33 +00:00
|
|
|
// TODO: Custom station selector GUI. Now we just try using first custom station
|
|
|
|
// (and fall back to normal stations if it isn't available).
|
|
|
|
DoCommandP(TILE_XY(sx,sy), _railstation.orientation | (w<<8) | (h<<16),_cur_railtype|1<<4, 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-05-09 13:26:15 +00:00
|
|
|
static void StationBuildWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
switch (e->event) {
|
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;
|
|
|
|
|
2005-05-09 13:26:15 +00:00
|
|
|
if (WP(w,def_d).close) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
bits = (1<<3) << ( _railstation.orientation);
|
|
|
|
if (_railstation.dragdrop) {
|
|
|
|
bits |= (1<<19);
|
|
|
|
} else {
|
|
|
|
bits |= (1<<(5-1)) << (_railstation.numtracks);
|
|
|
|
bits |= (1<<(12-1)) << (_railstation.platlength);
|
|
|
|
}
|
|
|
|
bits |= (1<<20) << (_station_show_coverage);
|
|
|
|
w->click_state = bits;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_railstation.dragdrop) {
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
} else {
|
|
|
|
int x = _railstation.numtracks;
|
|
|
|
int y = _railstation.platlength;
|
|
|
|
if (_railstation.orientation == 0) intswap(x,y);
|
|
|
|
if(!_remove_button_clicked)
|
|
|
|
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
|
|
|
|
2005-05-09 13:26:15 +00:00
|
|
|
/* Update buttons for correct spread value */
|
|
|
|
w->disabled_state = 0;
|
|
|
|
for (bits = _patches.station_spread; bits < 7; bits++) {
|
|
|
|
SETBIT(w->disabled_state, bits + 5);
|
|
|
|
SETBIT(w->disabled_state, bits + 12);
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
StationPickerDrawSprite(39, 42, _cur_railtype, 2);
|
|
|
|
StationPickerDrawSprite(107, 42, _cur_railtype, 3);
|
|
|
|
|
|
|
|
DrawStringCentered(74, 15, STR_3002_ORIENTATION, 0);
|
|
|
|
DrawStringCentered(74, 76, STR_3003_NUMBER_OF_TRACKS, 0);
|
|
|
|
DrawStringCentered(74, 101, STR_3004_PLATFORM_LENGTH, 0);
|
|
|
|
DrawStringCentered(74, 141, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
|
|
|
|
|
2004-12-08 15:46:13 +00:00
|
|
|
DrawStationCoverageAreaText(2, 166, (uint)-1, rad);
|
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: {
|
2005-05-09 13:26:15 +00:00
|
|
|
switch (e->click.widget) {
|
2004-08-09 17:04:08 +00:00
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
_railstation.orientation = e->click.widget - 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:
|
|
|
|
case 11:
|
|
|
|
_railstation.numtracks = (e->click.widget - 5) + 1;
|
|
|
|
_railstation.dragdrop = false;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
case 17:
|
|
|
|
case 18:
|
|
|
|
_railstation.platlength = (e->click.widget - 12) + 1;
|
|
|
|
_railstation.dragdrop = false;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 19:
|
|
|
|
_railstation.dragdrop ^= true;
|
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:
|
|
|
|
_station_show_coverage = e->click.widget - 20;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP: {
|
|
|
|
if (WP(w,def_d).close) {
|
|
|
|
DeleteWindow(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CheckRedrawStationCoverage(w);
|
|
|
|
} break;
|
2005-01-20 10:31:59 +00:00
|
|
|
|
2005-01-20 08:36:15 +00:00
|
|
|
case WE_DESTROY:
|
2005-01-23 15:25:17 +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[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ 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_CLOSEBOX, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 97, 111, 87, 98, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 112, 126, 87, 98, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
|
|
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 97, 111, 112, 123, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 112, 126, 112, 123, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
|
|
|
|
|
|
//{ WWT_CLOSEBOX, RESIZE_NONE, 14, 14, 73, 137, 148, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
//{ WWT_CLOSEBOX, RESIZE_NONE, 14, 74, 133, 137, 148, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
|
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 14, 73, 152, 163, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
|
|
{ WWT_CLOSEBOX, 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
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _station_builder_desc = {
|
|
|
|
-1, -1, 148, 200,
|
|
|
|
WC_BUILD_STATION,WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_station_builder_widgets,
|
|
|
|
StationBuildWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowStationBuilder(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
AllocateWindowDesc(&_station_builder_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
switch(e->event) {
|
|
|
|
case WE_PAINT: {
|
|
|
|
int r;
|
|
|
|
|
|
|
|
w->click_state = (1 << 3) << _build_depot_direction;
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
|
|
r = _cur_railtype;
|
|
|
|
DrawTrainDepotSprite(70, 17, 0, r);
|
|
|
|
DrawTrainDepotSprite(70, 69, 1, r);
|
|
|
|
DrawTrainDepotSprite(2, 69, 2, r);
|
|
|
|
DrawTrainDepotSprite(2, 17, 3, r);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WE_CLICK: {
|
|
|
|
switch(e->click.widget) {
|
2005-01-23 15:25:17 +00:00
|
|
|
case 3: case 4: case 5: case 6:
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_depot_direction = e->click.widget - 3;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-08-09 17:04:08 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_MOUSELOOP:
|
|
|
|
if (WP(w,def_d).close)
|
|
|
|
DeleteWindow(w);
|
|
|
|
return;
|
2005-01-20 08:36:15 +00:00
|
|
|
|
|
|
|
case WE_DESTROY:
|
2005-01-23 15:25:17 +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[] = {
|
2005-01-03 19:45:18 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{ 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 = {
|
|
|
|
-1,-1, 140, 122,
|
|
|
|
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_depot_widgets,
|
|
|
|
BuildTrainDepotWndProc
|
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowBuildTrainDepotPicker(void)
|
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-05-01 20:16:52 +00:00
|
|
|
w->click_state = (1 << 3) << (_cur_waypoint_type - w->hscroll.pos);
|
2004-11-14 11:04:59 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2005-05-01 20:16:52 +00:00
|
|
|
if(w->hscroll.pos + 0 <= _waypoint_count) DrawWaypointSprite(2, 25, w->hscroll.pos + 0, _cur_railtype);
|
|
|
|
if(w->hscroll.pos + 1 <= _waypoint_count) DrawWaypointSprite(70, 25, w->hscroll.pos + 1, _cur_railtype);
|
|
|
|
if(w->hscroll.pos + 2 <= _waypoint_count) DrawWaypointSprite(138, 25, w->hscroll.pos + 2, _cur_railtype);
|
|
|
|
if(w->hscroll.pos + 3 <= _waypoint_count) DrawWaypointSprite(206, 25, w->hscroll.pos + 3, _cur_railtype);
|
|
|
|
if(w->hscroll.pos + 4 <= _waypoint_count) DrawWaypointSprite(274, 25, w->hscroll.pos + 4, _cur_railtype);
|
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: {
|
2005-05-01 20:16:52 +00:00
|
|
|
switch (e->click.widget) {
|
|
|
|
case 3: case 4: case 5: case 6: case 7:
|
|
|
|
_cur_waypoint_type = e->click.widget - 3 + w->hscroll.pos;
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2004-11-14 11:04:59 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-01-03 19:45:18 +00:00
|
|
|
|
2004-11-14 11:04:59 +00:00
|
|
|
case WE_MOUSELOOP:
|
|
|
|
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-05-01 20:16:52 +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[] = {
|
2005-01-03 19:45:18 +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
|
|
|
|
2005-01-03 19:45:18 +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
|
|
|
|
2005-01-04 21:45:38 +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 = {
|
2004-11-14 20:02:43 +00:00
|
|
|
-1,-1, 344, 92,
|
2004-11-14 11:04:59 +00:00
|
|
|
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
static void ShowBuildWaypointPicker(void)
|
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-05-01 20:16:52 +00:00
|
|
|
w->hscroll.count = _waypoint_count + 1;
|
2004-11-14 11:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void InitializeRailGui(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-09-11 09:55:19 +00:00
|
|
|
_build_depot_direction = 3;
|
2004-08-09 17:04:08 +00:00
|
|
|
_railstation.numtracks = 1;
|
|
|
|
_railstation.platlength = 1;
|
|
|
|
_railstation.dragdrop = true;
|
|
|
|
}
|