annotate rail_gui.c @ 1058:26e926ec95fd draft

(svn r1559) Use IsTileType() instead of bit shifting and comparisons
author tron <tron@openttd.org>
date Tue, 18 Jan 2005 17:19:34 +0000
parents 3edb35954288
children 7d686f5c831a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1 #include "stdafx.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
2 #include "ttd.h"
507
9dcc34b8887e (svn r815) Include strings.h only in the files which need it.
tron <tron@openttd.org>
parents: 449
diff changeset
3 #include "table/strings.h"
679
21e658645b32 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron <tron@openttd.org>
parents: 651
diff changeset
4 #include "map.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
5 #include "window.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
6 #include "gui.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
7 #include "viewport.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
8 #include "gfx.h"
337
c88b35750799 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron <tron@openttd.org>
parents: 288
diff changeset
9 #include "sound.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
10 #include "command.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
11 #include "vehicle.h"
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
12 #include "station.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
13
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
14 static uint _cur_railtype;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
15 static bool _remove_button_clicked;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
16 static byte _build_depot_direction;
411
27a4386a1082 (svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik <dominik@openttd.org>
parents: 410
diff changeset
17 static byte _waypoint_count=1;
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
18 static byte _cur_waypoint_type;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
19
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
20 struct {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
21 byte orientation;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
22 byte numtracks;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
23 byte platlength;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
24 bool dragdrop;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
25 } _railstation;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
26
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
27
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
28 static void HandleStationPlacement(uint start, uint end);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
29 static void ShowBuildTrainDepotPicker();
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
30 static void ShowBuildWaypointPicker();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
31 static void ShowStationBuilder();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
32
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
33 typedef void OnButtonClick(Window *w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
34
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
35 void CcPlaySound1E(bool success, uint tile, uint32 p1, uint32 p2)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
36 {
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
37 if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
38 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
39
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
40 static void GenericPlaceRail(uint tile, int cmd)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
41 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
42 DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
43 _remove_button_clicked ?
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
44 CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER :
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
45 CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
46 );
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
47 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
48
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
49 static void PlaceRail_N(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
50 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
51 int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
52 GenericPlaceRail(tile, cmd);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
53 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
54
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
55 static void PlaceRail_NE(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
56 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
57 VpStartPlaceSizing(tile, VPM_FIX_Y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
58 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
59
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
60 static void PlaceRail_E(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
61 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
62 int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
63 GenericPlaceRail(tile, cmd);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
64 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
65
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
66 static void PlaceRail_NW(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
67 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
68 VpStartPlaceSizing(tile, VPM_FIX_X);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
69 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
70
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
71 static void PlaceRail_AutoRail(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
72 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
73 VpStartPlaceSizing(tile, VPM_RAILDIRS);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
74 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
75
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
76 static void PlaceExtraDepotRail(uint tile, uint16 extra)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
77 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
78 byte b = _map5[tile];
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
79
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
80 if (b & 0xC0 || !(b & (extra >> 8)))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
81 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
82
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
83 DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_AUTO | CMD_NO_WATER);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
84 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
85
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
86 static const uint16 _place_depot_extra[12] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
87 0x604, 0x2102, 0x1202, 0x505,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
88 0x2400, 0x2801, 0x1800, 0x1401,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
89 0x2203, 0x904, 0x0A05, 0x1103,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
90 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
91
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
92
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
93 void CcRailDepot(bool success, uint tile, uint32 p1, uint32 p2)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
94 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
95 if (success) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
96 int dir = p2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
97
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
98 SndPlayTileFx(SND_20_SPLAT_2, tile);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
99 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
100
900
767fb627c5c7 (svn r1386) Move TileIndexDiff to map.h
tron <tron@openttd.org>
parents: 896
diff changeset
101 tile += TileOffsByDir(dir);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
102
1035
3edb35954288 (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron <tron@openttd.org>
parents: 980
diff changeset
103 if (IsTileType(tile, MP_RAILWAY)) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
104 PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
105 PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
106 PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
107 }
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
108 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
109 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
110
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
111 static void PlaceRail_Depot(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
112 {
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
113 DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
114 CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
115 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
116
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
117 static void PlaceRail_Waypoint(uint tile)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
118 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
119 if (!_remove_button_clicked) {
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
120 DoCommandP(tile, _waypoint_count > 0 ? (0x100 + _cur_waypoint_type) : 0, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT));
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
121 } else {
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
122 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
123 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
124 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
125
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
126 void CcStation(bool success, uint tile, uint32 p1, uint32 p2)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
127 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
128 if (success) {
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
129 SndPlayTileFx(SND_20_SPLAT_2, tile);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
130 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
131 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
132 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
133
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
134 static void PlaceRail_Station(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
135 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
136 if(_remove_button_clicked)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
137 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
138 else if (_railstation.dragdrop) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
139 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
140 VpSetPlaceSizingLimit(_patches.station_spread);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
141 } else {
449
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
142 // TODO: Custom station selector GUI. Now we just try using first custom station
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
143 // (and fall back to normal stations if it isn't available).
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
144 DoCommandP(tile, _railstation.orientation | (_railstation.numtracks<<8) | (_railstation.platlength<<16),_cur_railtype|1<<4, CcStation,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
145 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
146 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
147 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
148
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
149 static void GenericPlaceSignals(uint tile)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
150 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
151 uint trackstat;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
152 int i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
153
159
a4e15430335b (svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents: 59
diff changeset
154 trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
155
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
156 if ((trackstat & 0x30) == 0x30) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
157 trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? 0x20 : 0x10;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
158 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
159
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
160 if ((trackstat & 0x0C) == 0x0C) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
161 trackstat = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? 4 : 8;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
162 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
163
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
164 // Lookup the bit index
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
165 i = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
166 if (trackstat != 0) { while (!(trackstat & 1)) { i++; trackstat >>= 1; }}
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
167
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
168 if (!_remove_button_clicked) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
169 DoCommandP(tile, i + (_ctrl_pressed ? 8 : 0), 0, CcPlaySound1E,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
170 CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
171 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
172 DoCommandP(tile, i, 0, CcPlaySound1E,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
173 CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
174 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
175 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
176
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
177 static void PlaceRail_Bridge(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
178 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
179 VpStartPlaceSizing(tile, VPM_X_OR_Y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
180 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
181
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
182 void CcBuildRailTunnel(bool success, uint tile, uint32 p1, uint32 p2)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
183 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
184 if (success) {
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
185 SndPlayTileFx(SND_20_SPLAT_2, tile);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
186 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
187 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
188 SetRedErrorSquare(_build_tunnel_endtile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
189 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
190 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
191
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
192 static void PlaceRail_Tunnel(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
193 {
543
0bade3c3b8ba (svn r942) -Merged branch/network back into the trunk
truelight <truelight@openttd.org>
parents: 541
diff changeset
194 DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
195 CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
196 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
197
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
198 void PlaceProc_BuyLand(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
199 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
200 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
201 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
202
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
203 static void PlaceRail_ConvertRail(uint tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
204 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
205 VpStartPlaceSizing(tile, VPM_X_AND_Y | (1<<4));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
206 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
207
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
208 static void PlaceRail_AutoSignals(uint tile)
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
209 {
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
210 VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
211 }
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
212
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
213 static void BuildRailClick_N(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
214 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
215 HandlePlacePushButton(w, 4, _cur_railtype*4 + 0x4EF, 1, PlaceRail_N);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
216 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
217
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
218 static void BuildRailClick_NE(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
219 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
220 HandlePlacePushButton(w, 5, _cur_railtype*4 + 0x4F0, 1, PlaceRail_NE);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
221 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
222
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
223 static void BuildRailClick_E(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
224 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
225 HandlePlacePushButton(w, 6, _cur_railtype*4 + 0x4F1, 1, PlaceRail_E);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
226 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
227
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
228 static void BuildRailClick_NW(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
229 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
230 HandlePlacePushButton(w, 7, _cur_railtype*4 + 0x4F2, 1, PlaceRail_NW);
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
231 }
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
232
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
233 static void BuildRailClick_AutoRail(Window *w)
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
234 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
235 HandlePlacePushButton(w, 8, _cur_railtype + SPR_OPENTTD_BASE + 4, 1, PlaceRail_AutoRail);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
236 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
237
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
238 static void BuildRailClick_Demolish(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
239 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
240 HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
241 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
242
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
243 static const SpriteID _depot_cursors[] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
244 0x510,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
245 SPR_OPENTTD_BASE + 14,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
246 SPR_OPENTTD_BASE + 15,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
247 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
248
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
249 static void BuildRailClick_Depot(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
250 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
251 if (HandlePlacePushButton(w, 10, _depot_cursors[_cur_railtype], 1, PlaceRail_Depot)) ShowBuildTrainDepotPicker();
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
252 }
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
253
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
254 static void BuildRailClick_Waypoint(Window *w)
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
255 {
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
256 _waypoint_count = GetCustomStationsCount(STAT_CLASS_WAYP);
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
257 if (HandlePlacePushButton(w, 11, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Waypoint)
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
258 && _waypoint_count > 1)
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
259 ShowBuildWaypointPicker();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
260 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
261
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
262 static void BuildRailClick_Station(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
263 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
264 if (HandlePlacePushButton(w, 12, 0x514, 1, PlaceRail_Station)) ShowStationBuilder();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
265 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
266
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
267 static void BuildRailClick_AutoSignals(Window *w)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
268 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
269 HandlePlacePushButton(w, 13, ANIMCURSOR_BUILDSIGNALS , 1, PlaceRail_AutoSignals);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
270 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
271
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
272 static void BuildRailClick_Bridge(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
273 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
274 HandlePlacePushButton(w, 14, 0xA21, 1, PlaceRail_Bridge);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
275 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
276
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
277 static void BuildRailClick_Tunnel(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
278 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
279 HandlePlacePushButton(w, 15, 0x982 + _cur_railtype, 3, PlaceRail_Tunnel);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
280 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
281
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
282 static void BuildRailClick_Remove(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
283 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
284 if (w->disabled_state & (1<<16))
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
285 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
286 SetWindowDirty(w);
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
287 SndPlayFx(SND_15_BEEP);
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
288
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
289 _thd.make_square_red = !!((w->click_state ^= (1 << 16)) & (1<<16));
514
b4053d4c56d4 (svn r829) Fix small glitch: Immediately redraw the tile selection square when using the hotkey to toggle removal
tron <tron@openttd.org>
parents: 507
diff changeset
290 MarkTileDirty(_thd.pos.x, _thd.pos.y);
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
291 _remove_button_clicked = (w->click_state & (1 << 16)) != 0;
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
292
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
293 // handle station builder
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
294 if( w->click_state & (1 << 16) )
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
295 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
296 if(_remove_button_clicked)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
297 SetTileSelectSize(1, 1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
298 else
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
299 BringWindowToFrontById(WC_BUILD_STATION, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
300 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
301 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
302
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
303 static void BuildRailClick_Convert(Window *w)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
304 {
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
305 HandlePlacePushButton(w, 17, (SPR_OPENTTD_BASE + 26) + _cur_railtype * 2, 1, PlaceRail_ConvertRail);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
306 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
307
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
308 static void BuildRailClick_Landscaping(Window *w)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
309 {
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
310 ShowTerraformToolbar();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
311 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
312
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
313
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
314 static void DoRailroadTrack(int mode)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
315 {
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
316 DoCommandP(TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y), PACK_POINT(_thd.selend.x, _thd.selend.y), (mode << 4) | _cur_railtype, NULL,
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
317 _remove_button_clicked ?
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
318 CMD_REMOVE_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
319 CMD_BUILD_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
320 );
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
321 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
322
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
323 typedef struct {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
324 byte bit, a,b, mouse;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
325 } BestFitStruct;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
326
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
327 #define M(d,m) (d << 6) | (m)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
328 static const BestFitStruct _bestfit[] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
329 // both edges have rail
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
330 {2, M(0, 1+8), M(3, 2+8), 0}, // upper track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
331 {3, M(2, 1+4), M(1, 2+4), 0}, // lower track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
332
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
333 {4, M(2, 1+32), M(3, 2+32), 1<<2}, // left track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
334 {5, M(0, 1+16), M(1, 2+16), 1<<3}, // right track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
335
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
336 {0, M(0,1+8+16), M(2,1+4+32), 0}, // diag1 track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
337 {1, M(3,2+8+32), M(1,2+4+16), 0}, // diag2 track
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
338
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
339 // one edge with rail
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
340 {0, M(0,1), 0, 0}, // diag1 track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
341 {0, M(2,1), 0, 0}, // diag1 track
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
342
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
343 {1, M(1,2), 0, 0}, // diag2 track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
344 {1, M(3,2), 0, 0}, // diag2 track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
345
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
346 {2, M(0,8), 0, 1<<0}, // upper track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
347 {2, M(3,8), 0, 1<<0}, // upper track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
348
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
349 {3, M(1,4), 0, 1<<1}, // lower track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
350 {3, M(2,4), 0, 1<<1}, // lower track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
351
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
352 {4, M(2,32), 0, 1<<2}, // left track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
353 {4, M(3,32), 0, 1<<2}, // left track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
354
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
355 {5, M(0,16), 0, 1<<3}, // right track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
356 {5, M(1,16), 0, 1<<3}, // right track
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
357
179
4b8dffdbf81f (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater <darkvater@openttd.org>
parents: 176
diff changeset
358 {0xff, 0, 0, 0},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
359 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
360 #undef M
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
361
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
362 static int GetBestArea(int x, int y)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
363 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
364 int r = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
365 if (x + y > 0x10) r += 2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
366 else if (x + y == 0x10) return -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
367 if (y - x > 0) r += 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
368 else if (y - x == 0) return -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
369 return r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
370 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
371
410
e165d1275350 (svn r607) -Patch: [ 985102 ] static cleanup
tron <tron@openttd.org>
parents: 409
diff changeset
372 static int GetBestFit1x1(int x, int y)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
373 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
374 byte m[5];
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
375 const BestFitStruct *bfs;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
376 byte mouse;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
377 uint tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
378 int best;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
379 int i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
380
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
381 // determine the mouse regions
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
382 mouse = ((x & 0xF) + (y & 0xF) < 0x10 ? 1 << 0 : 1 << 1) +
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
383 ((x & 0xF) > (y & 0xF) ? 1 << 2 : 1 << 3);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
384
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
385 // get the rail in each direction
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
386 tile = TILE_FROM_XY(x,y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
387 for(i=0; i!=5; i++) {
909
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
388 static const TileIndexDiffC _tile_inc[] = {
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
389 {-1 , 0 },
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
390 { 0 - -1, 1 - 0},
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
391 { 1 - 0, 0 - 1},
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
392 { 0 - 1, -1 - 0},
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
393 { 0 - 0, 0 - -1}
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
394 };
909
5213ce35d930 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron <tron@openttd.org>
parents: 900
diff changeset
395 tile += ToTileIndexDiff(_tile_inc[i]);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
396 m[i] = 0;
1035
3edb35954288 (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron <tron@openttd.org>
parents: 980
diff changeset
397 if (IsTileType(tile, MP_RAILWAY) && _map5[tile] < 0x80)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
398 m[i] = _map5[tile]&0x3F;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
399
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
400 // handle tracks under bridge
1035
3edb35954288 (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron <tron@openttd.org>
parents: 980
diff changeset
401 if(IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile]&0xF8)==0xE0)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
402 m[i] = (byte) !(_map5[tile]&0x01) + 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
403
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
404 if (_remove_button_clicked) m[i] ^= 0x3F;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
405 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
406
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
407 // check "mouse gesture"?
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
408 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
409 int a1,a2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
410 if ((a1 = GetBestArea(x & 0xF, y & 0xF)) != -1 && (a2 = GetBestArea(_tile_fract_coords.x, _tile_fract_coords.y)) != -1 && a1 != a2) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
411 static const byte _get_dir_by_areas[4][4] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
412 {0,2,4,1},
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
413 {2,0,0,5},
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
414 {4,0,0,3},
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
415 {1,5,3,0},
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
416 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
417 i = _get_dir_by_areas[a2][a1];
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
418 if (!HASBIT(m[4], i))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
419 return i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
420 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
421 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
422 // check each bestfit struct
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
423 for(bfs = _bestfit, best=-1; bfs->bit != 0xFF; bfs++) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
424 if ((bfs->a & m[bfs->a >> 6]) && (!bfs->b || bfs->b & m[bfs->b >> 6]) && !HASBIT(m[4], bfs->bit)) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
425 if ( (byte)(~mouse & bfs->mouse) == 0)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
426 return bfs->bit;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
427 if (best != -1)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
428 return best;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
429 best = bfs->bit;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
430 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
431 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
432
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
433 return best;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
434 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
435
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
436 static void SwapSelection()
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
437 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
438 TileHighlightData *thd = &_thd;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
439 Point pt = thd->selstart;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
440 thd->selstart.x = thd->selend.x & ~0xF;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
441 thd->selstart.y = thd->selend.y & ~0xF;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
442 thd->selend = pt;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
443 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
444
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
445 static bool Check2x1AutoRail(int mode)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
446 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
447 TileHighlightData *thd = &_thd;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
448 int fxpy = _tile_fract_coords.x + _tile_fract_coords.y;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
449 int sxpy = (thd->selend.x & 0xF) + (thd->selend.y & 0xF);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
450 int fxmy = _tile_fract_coords.x - _tile_fract_coords.y;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
451 int sxmy = (thd->selend.x & 0xF) - (thd->selend.y & 0xF);
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
452
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
453 switch(mode) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
454 case 0:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
455 if (fxpy >= 20 && sxpy <= 12) { SwapSelection(); DoRailroadTrack(0); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
456 if (fxmy < -3 && sxmy > 3) { DoRailroadTrack(0); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
457 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
458
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
459 case 1:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
460 if (fxmy > 3 && sxmy < -3) { SwapSelection(); DoRailroadTrack(0); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
461 if (fxpy <= 12 && sxpy >= 20) { DoRailroadTrack(0); return true; }
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
462 break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
463
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
464 case 2:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
465 if (fxmy > 3 && sxmy < -3) { DoRailroadTrack(3); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
466 if (fxpy >= 20 && sxpy <= 12) { SwapSelection(); DoRailroadTrack(0); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
467 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
468
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
469 case 3:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
470 if (fxmy < -3 && sxmy > 3) { SwapSelection(); DoRailroadTrack(3); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
471 if (fxpy <= 12 && sxpy >= 20) { DoRailroadTrack(0); return true; }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
472 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
473 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
474
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
475 return false;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
476 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
477
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
478
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
479 static void HandleAutodirPlacement()
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
480 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
481 TileHighlightData *thd = &_thd;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
482 int bit;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
483
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
484 if (thd->drawstyle == HT_RECT) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
485 int dx = thd->selstart.x - (thd->selend.x&~0xF);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
486 int dy = thd->selstart.y - (thd->selend.y&~0xF);
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
487
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
488 if (dx == 0 && dy == 0 ) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
489 // 1x1 tile
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
490 bit = GetBestFit1x1(thd->selend.x, thd->selend.y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
491 if (bit == -1) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
492 GenericPlaceRail(TILE_FROM_XY(thd->selend.x, thd->selend.y), bit);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
493 } else if (dx == 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
494 if (dy == -16) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
495 if (Check2x1AutoRail(0)) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
496 } else if (dy == 16) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
497 if (Check2x1AutoRail(1)) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
498 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
499 // same x coordinate
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
500 DoRailroadTrack(VPM_FIX_X);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
501 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
502 // same y coordinate
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
503 // check it's it -16 or 16, then we must check if it should be normal tiles or special tiles.
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
504 if (dx == -16) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
505 if (Check2x1AutoRail(2)) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
506 } else if (dx == 16) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
507 if (Check2x1AutoRail(3)) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
508 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
509 DoRailroadTrack(VPM_FIX_Y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
510 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
511 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
512 DoRailroadTrack(thd->drawstyle & 1 ? 0 : 3);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
513 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
514 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
515
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
516 static void HandleAutoSignalPlacement()
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
517 {
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
518 TileHighlightData *thd = &_thd;
59
120fb6c1877b (svn r60) -Fix: signal_density is given as a parameter to autosignal. This means all players can define it for themselves.
darkvater <darkvater@openttd.org>
parents: 58
diff changeset
519 int mode = 0;
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
520 uint trackstat = 0;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
521
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
522 int dx = thd->selstart.x - (thd->selend.x&~0xF);
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
523 int dy = thd->selstart.y - (thd->selend.y&~0xF);
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
524
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
525 if (dx == 0 && dy == 0 ) // 1x1 tile signals
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
526 GenericPlaceSignals(TILE_FROM_XY(thd->selend.x, thd->selend.y));
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
527 else { // signals have been dragged
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
528 if (thd->drawstyle == HT_RECT) { // X,Y direction
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
529 if (dx == 0)
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
530 mode = VPM_FIX_X;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
531 else if (dy == 0)
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
532 mode = VPM_FIX_Y;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
533
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
534 trackstat = 0xC0;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
535 } else { // W-E or N-S direction
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
536 mode = thd->drawstyle & 1 ? 0 : 3;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
537
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
538 if (dx == dy || abs(dx - dy) == 16) // North<->South track |
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
539 trackstat = (thd->drawstyle & 1) ? 0x20 : 0x10;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
540 else if (dx == -dy || abs(dx + dy) == 16) // East<->West track --
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
541 trackstat = (thd->drawstyle & 1) ? 4 : 8;
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
542 }
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
543
59
120fb6c1877b (svn r60) -Fix: signal_density is given as a parameter to autosignal. This means all players can define it for themselves.
darkvater <darkvater@openttd.org>
parents: 58
diff changeset
544 /* _patches.drag_signals_density is given as a parameter such that each user in a network
120fb6c1877b (svn r60) -Fix: signal_density is given as a parameter to autosignal. This means all players can define it for themselves.
darkvater <darkvater@openttd.org>
parents: 58
diff changeset
545 * game can specify his/her own signal density */
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
546 DoCommandP(TILE_FROM_XY(thd->selstart.x, thd->selstart.y), TILE_FROM_XY(thd->selend.x, thd->selend.y),
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
547 (mode << 4) | (_remove_button_clicked + (_ctrl_pressed ? 8 : 0)) | (trackstat << 8) | (_patches.drag_signals_density << 24),
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
548 CcPlaySound1E,
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
549 (_remove_button_clicked ? CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
550 CMD_BUILD_MANY_SIGNALS | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) ) );
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
551 }
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
552 }
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
553
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
554 static OnButtonClick * const _build_railroad_button_proc[] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
555 BuildRailClick_N,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
556 BuildRailClick_NE,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
557 BuildRailClick_E,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
558 BuildRailClick_NW,
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
559 BuildRailClick_AutoRail,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
560 BuildRailClick_Demolish,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
561 BuildRailClick_Depot,
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
562 BuildRailClick_Waypoint,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
563 BuildRailClick_Station,
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
564 BuildRailClick_AutoSignals,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
565 BuildRailClick_Bridge,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
566 BuildRailClick_Tunnel,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
567 BuildRailClick_Remove,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
568 BuildRailClick_Convert,
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
569 BuildRailClick_Landscaping,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
570 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
571
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
572 static const uint16 _rail_keycodes[] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
573 '1',
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
574 '2',
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
575 '3',
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
576 '4',
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
577 '5',
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
578 '6',
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
579 '7', // depot
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
580 '8', // waypoint
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
581 '9', // station
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
582 'S', // signals
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
583 'B', // bridge
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
584 'T', // tunnel
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
585 'R', // remove
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
586 'C', // convert rail
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
587 'L', // landscaping
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
588 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
589
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
590
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
591
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
592
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
593 static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
594 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
595 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
596 case WE_PAINT:
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
597 w->disabled_state &= ~(1 << 16);
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
598 if (!(w->click_state & ((1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<11)|(1<<12)|(1<<13)))) {
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
599 w->disabled_state |= (1 << 16);
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
600 w->click_state &= ~(1<<16);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
601 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
602 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
603 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
604
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
605 case WE_CLICK:
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
606 if (e->click.widget >= 4) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
607 _remove_button_clicked = false;
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
608 _build_railroad_button_proc[e->click.widget - 4](w);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
609 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
610 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
611
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
612 case WE_KEYPRESS: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
613 int i;
616
1d833077cb3e (svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik <dominik@openttd.org>
parents: 606
diff changeset
614
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
615 for(i=0; i!=lengthof(_rail_keycodes); i++) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
616 if (e->keypress.keycode == _rail_keycodes[i]) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
617 e->keypress.cont = false;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
618 _remove_button_clicked = false;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
619 _build_railroad_button_proc[i](w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
620 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
621 }
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
622 }
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
623 MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
624 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
625 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
626
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
627 case WE_PLACE_OBJ:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
628 _place_proc(e->place.tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
629 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
630
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
631 case WE_PLACE_DRAG: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
632 VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
633 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
634 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
635
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
636 case WE_PLACE_MOUSEUP:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
637 if (e->click.pt.x != -1) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
638 uint start_tile = e->place.starttile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
639 uint end_tile = e->place.tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
640
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
641 if (e->place.userdata == VPM_X_OR_Y) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
642 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
643 ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
644 } else if (e->place.userdata == VPM_RAILDIRS) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
645 bool old = _remove_button_clicked;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
646 if (_ctrl_pressed) _remove_button_clicked = true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
647 HandleAutodirPlacement();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
648 _remove_button_clicked = old;
58
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
649 } else if (e->place.userdata == VPM_SIGNALDIRS) {
9c9aa1db223f (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater <darkvater@openttd.org>
parents: 0
diff changeset
650 HandleAutoSignalPlacement();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
651 } else if (e->place.userdata == VPM_X_AND_Y) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
652 DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
653 } else if (e->place.userdata == (VPM_X_AND_Y | (1<<4))) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
654 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
655 } else if (e->place.userdata == (VPM_X_AND_Y | (2<<4))) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
656 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
657 } else if (e->place.userdata == VPM_X_AND_Y_LIMITED) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
658 HandleStationPlacement(start_tile, end_tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
659 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
660 DoRailroadTrack(e->place.userdata);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
661 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
662 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
663 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
664
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
665 case WE_ABORT_PLACE_OBJ:
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
666 UnclickWindowButtons(w);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
667 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
668
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
669 w = FindWindowById(WC_BUILD_STATION, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
670 if (w != NULL) WP(w,def_d).close=true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
671 w = FindWindowById(WC_BUILD_DEPOT, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
672 if (w != NULL) WP(w,def_d).close=true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
673 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
674
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
675 case WE_PLACE_PRESIZE: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
676 uint tile = e->place.tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
677 DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
678 VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
679 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
680 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
681 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
682
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
683
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
684 static const Widget _build_railroad_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
685 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
686 { WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
687 { WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
688
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
689 { WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
690
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
691 { WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4E3, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
692 { WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4E4, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
693 { WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4E5, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
694 { WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4E6, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
695 { WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 0, STR_BUILD_AUTORAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
696
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
697 { WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
698 { WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, 0x50E, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
699 { WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
700
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
701 { WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
702 { WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
703 { WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
704 { WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x97E, STR_101D_BUILD_RAILROAD_TUNNEL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
705 { WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
706 { WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 25, STR_CONVERT_RAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
707
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
708 { WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
709
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 159
diff changeset
710 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
711 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
712
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
713 static const WindowDesc _build_railroad_desc = {
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
714 640-372, 22, 372, 36,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
715 WC_BUILD_TOOLBAR,0,
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
716 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
717 _build_railroad_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
718 BuildRailToolbWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
719 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
720
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
721 static const Widget _build_monorail_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
722 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
723 { WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100B_MONORAIL_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
724 { WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
725
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
726 { WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
727
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
728 { WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4E7, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
729 { WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4E8, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
730 { WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4E9, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
731 { WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4EA, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
732 { WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 1, STR_BUILD_AUTORAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
733
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
734 { WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
735 { WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_OPENTTD_BASE + 12, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
736 { WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
737
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
738 { WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
739 { WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
740 { WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
741 { WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x97F, STR_101D_BUILD_RAILROAD_TUNNEL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
742 { WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
743 { WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 27, STR_CONVERT_RAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
744
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
745 { WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
746
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 159
diff changeset
747 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
748 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
749
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
750 static const WindowDesc _build_monorail_desc = {
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
751 640-372, 22, 372, 36,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
752 WC_BUILD_TOOLBAR,0,
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
753 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
754 _build_monorail_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
755 BuildRailToolbWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
756 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
757
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
758 static const Widget _build_maglev_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
759 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
760 { WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100C_MAGLEV_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
761 { WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
762
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
763 { WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
764
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
765 { WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4EB, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
766 { WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4EC, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
767 { WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4EE, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
768 { WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4ED, STR_1018_BUILD_RAILROAD_TRACK},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
769 { WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_OPENTTD_BASE + 2, STR_BUILD_AUTORAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
770
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
771 { WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
772 { WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_OPENTTD_BASE + 13, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
773 { WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_OPENTTD_BASE + 3, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
774
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
775 { WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
776 { WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
777 { WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
778 { WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, 0x980, STR_101D_BUILD_RAILROAD_TUNNEL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
779 { WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
780 { WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_OPENTTD_BASE + 29, STR_CONVERT_RAIL_TIP},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
781
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
782 { WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
783
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 159
diff changeset
784 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
785 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
786
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
787 static const WindowDesc _build_maglev_desc = {
606
fb4543338eed (svn r1030) Some toolbar icons are arranged differently:
dominik <dominik@openttd.org>
parents: 568
diff changeset
788 640-372, 22, 372, 36,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
789 WC_BUILD_TOOLBAR,0,
756
5c6aff6e4615 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater <darkvater@openttd.org>
parents: 679
diff changeset
790 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
791 _build_maglev_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
792 BuildRailToolbWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
793 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
794
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
795
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
796 static const WindowDesc * const _build_rr_desc[] = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
797 &_build_railroad_desc,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
798 &_build_monorail_desc,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
799 &_build_maglev_desc,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
800 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
801
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
802 void ShowBuildRailToolbar(int index, int button)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
803 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
804 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
805
946
45abacd24857 (svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik <dominik@openttd.org>
parents: 926
diff changeset
806 if (_current_player == OWNER_SPECTATOR) return;
45abacd24857 (svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik <dominik@openttd.org>
parents: 926
diff changeset
807
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
808 // don't recreate the window if we're clicking on a button and the window exists.
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
809 if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
810 DeleteWindowById(WC_BUILD_TOOLBAR, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
811 _cur_railtype = (byte)index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
812 w = AllocateWindowDesc(_build_rr_desc[index]);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
813 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
814
288
367bd0555126 (svn r294) -Fix: autorail always builds rail, instead of occasional rail removal (on pressing hotkey after pressing 'bulldozer')
darkvater <darkvater@openttd.org>
parents: 201
diff changeset
815 _remove_button_clicked = false;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
816 if (w != NULL && button >= 0) _build_railroad_button_proc[button](w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
817 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
818
449
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
819 /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
820 * --pasky */
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
821
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
822 static void HandleStationPlacement(uint start, uint end)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
823 {
926
b1ef952b19f8 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron <tron@openttd.org>
parents: 909
diff changeset
824 uint sx = TileX(start);
b1ef952b19f8 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron <tron@openttd.org>
parents: 909
diff changeset
825 uint sy = TileY(start);
b1ef952b19f8 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron <tron@openttd.org>
parents: 909
diff changeset
826 uint ex = TileX(end);
b1ef952b19f8 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron <tron@openttd.org>
parents: 909
diff changeset
827 uint ey = TileY(end);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
828 uint w,h;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
829
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
830 if (sx > ex) intswap(sx,ex);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
831 if (sy > ey) intswap(sy,ey);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
832 w = ex - sx + 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
833 h = ey - sy + 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
834 if (!_railstation.orientation) intswap(w,h);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
835
449
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
836 // TODO: Custom station selector GUI. Now we just try using first custom station
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
837 // (and fall back to normal stations if it isn't available).
bdc8bc713a3d (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron <tron@openttd.org>
parents: 438
diff changeset
838 DoCommandP(TILE_XY(sx,sy), _railstation.orientation | (w<<8) | (h<<16),_cur_railtype|1<<4, CcStation,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
839 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
840 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
841
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
842 static void StationBuildWndProc(Window *w, WindowEvent *e) {
568
150bd25be338 (svn r979) Allow more realistically sized catchment areas
Celestar <Celestar@openttd.org>
parents: 543
diff changeset
843 int rad;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
844 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
845 case WE_PAINT: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
846 uint bits;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
847
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
848 if (WP(w,def_d).close)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
849 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
850
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
851 bits = (1<<3) << ( _railstation.orientation);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
852 if (_railstation.dragdrop) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
853 bits |= (1<<19);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
854 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
855 bits |= (1<<(5-1)) << (_railstation.numtracks);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
856 bits |= (1<<(12-1)) << (_railstation.platlength);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
857 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
858 bits |= (1<<20) << (_station_show_coverage);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
859 w->click_state = bits;
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
860
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
861 if (_railstation.dragdrop) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
862 SetTileSelectSize(1, 1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
863 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
864 int x = _railstation.numtracks;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
865 int y = _railstation.platlength;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
866 if (_railstation.orientation == 0) intswap(x,y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
867 if(!_remove_button_clicked)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
868 SetTileSelectSize(x, y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
869 }
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
870
980
1a9f6dbbaaf9 (svn r1476) -Fix: [1099209] Catchment area with drag&drop stations (Celestar)
darkvater <darkvater@openttd.org>
parents: 946
diff changeset
871 rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
568
150bd25be338 (svn r979) Allow more realistically sized catchment areas
Celestar <Celestar@openttd.org>
parents: 543
diff changeset
872
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
873 if (_station_show_coverage)
568
150bd25be338 (svn r979) Allow more realistically sized catchment areas
Celestar <Celestar@openttd.org>
parents: 543
diff changeset
874 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
875
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
876 DrawWindowWidgets(w);
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
877
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
878 StationPickerDrawSprite(39, 42, _cur_railtype, 2);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
879 StationPickerDrawSprite(107, 42, _cur_railtype, 3);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
880
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
881 DrawStringCentered(74, 15, STR_3002_ORIENTATION, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
882 DrawStringCentered(74, 76, STR_3003_NUMBER_OF_TRACKS, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
883 DrawStringCentered(74, 101, STR_3004_PLATFORM_LENGTH, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
884 DrawStringCentered(74, 141, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
885
568
150bd25be338 (svn r979) Allow more realistically sized catchment areas
Celestar <Celestar@openttd.org>
parents: 543
diff changeset
886 DrawStationCoverageAreaText(2, 166, (uint)-1, rad);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
887 } break;
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
888
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
889 case WE_CLICK: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
890 switch(e->click.widget) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
891 case 0:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
892 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
893 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
894 case 3:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
895 case 4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
896 _railstation.orientation = e->click.widget - 3;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
897 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
898 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
899 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
900
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
901 case 5:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
902 case 6:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
903 case 7:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
904 case 8:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
905 case 9:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
906 case 10:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
907 case 11:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
908 _railstation.numtracks = (e->click.widget - 5) + 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
909 _railstation.dragdrop = false;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
910 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
911 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
912 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
913
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
914 case 12:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
915 case 13:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
916 case 14:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
917 case 15:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
918 case 16:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
919 case 17:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
920 case 18:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
921 _railstation.platlength = (e->click.widget - 12) + 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
922 _railstation.dragdrop = false;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
923 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
924 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
925 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
926
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
927 case 19:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
928 _railstation.dragdrop ^= true;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
929 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
930 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
931 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
932
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
933 case 20:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
934 case 21:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
935 _station_show_coverage = e->click.widget - 20;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
936 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
937 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
938 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
939 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
940 } break;
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
941
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
942 case WE_MOUSELOOP: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
943 if (WP(w,def_d).close) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
944 DeleteWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
945 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
946 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
947 CheckRedrawStationCoverage(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
948 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
949 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
950 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
951
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
952 static const Widget _station_builder_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
953 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
954 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
955 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 199, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
956 { WWT_PANEL, RESIZE_NONE, 14, 7, 72, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
957 { WWT_PANEL, RESIZE_NONE, 14, 75, 140, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
958
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
959 { WWT_CLOSEBOX, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
960 { WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
961 { WWT_CLOSEBOX, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
962 { WWT_CLOSEBOX, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
963 { WWT_CLOSEBOX, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
964 { WWT_CLOSEBOX, RESIZE_NONE, 14, 97, 111, 87, 98, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
965 { WWT_CLOSEBOX, RESIZE_NONE, 14, 112, 126, 87, 98, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
966
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
967 { WWT_CLOSEBOX, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
968 { WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
969 { WWT_CLOSEBOX, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
970 { WWT_CLOSEBOX, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
971 { WWT_CLOSEBOX, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
972 { WWT_CLOSEBOX, RESIZE_NONE, 14, 97, 111, 112, 123, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
973 { WWT_CLOSEBOX, RESIZE_NONE, 14, 112, 126, 112, 123, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
974
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
975 //{ WWT_CLOSEBOX, RESIZE_NONE, 14, 14, 73, 137, 148, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
976 //{ WWT_CLOSEBOX, RESIZE_NONE, 14, 74, 133, 137, 148, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
977 { WWT_CLOSEBOX, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
978 { WWT_CLOSEBOX, RESIZE_NONE, 14, 14, 73, 152, 163, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
979 { WWT_CLOSEBOX, RESIZE_NONE, 14, 74, 133, 152, 163, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 159
diff changeset
980 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
981 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
982
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
983 static const WindowDesc _station_builder_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
984 -1, -1, 148, 200,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
985 WC_BUILD_STATION,WC_BUILD_TOOLBAR,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
986 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
987 _station_builder_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
988 StationBuildWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
989 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
990
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
991 static void ShowStationBuilder()
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
992 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
993 AllocateWindowDesc(&_station_builder_desc);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
994 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
995
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
996 static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
997 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
998 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
999 case WE_PAINT: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1000 int r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1001
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1002 w->click_state = (1 << 3) << _build_depot_direction;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1003 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1004
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1005 r = _cur_railtype;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1006 DrawTrainDepotSprite(70, 17, 0, r);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1007 DrawTrainDepotSprite(70, 69, 1, r);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1008 DrawTrainDepotSprite(2, 69, 2, r);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1009 DrawTrainDepotSprite(2, 17, 3, r);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1010 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1011 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1012 case WE_CLICK: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1013 switch(e->click.widget) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1014 case 0:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1015 ResetObjectToPlace();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1016 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1017 case 3:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1018 case 4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1019 case 5:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1020 case 6:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1021 _build_depot_direction = e->click.widget - 3;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
1022 SndPlayFx(SND_15_BEEP);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1023 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1024 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1025 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1026 } break;
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
1027
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1028 case WE_MOUSELOOP:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1029 if (WP(w,def_d).close)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1030 DeleteWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1031 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1032 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1033 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1034
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1035 static const Widget _build_depot_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1036 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1037 { WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1038 { WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1039 { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1040 { WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1041 { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1042 { WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 159
diff changeset
1043 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1044 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1045
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1046 static const WindowDesc _build_depot_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1047 -1,-1, 140, 122,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1048 WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1049 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1050 _build_depot_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1051 BuildTrainDepotWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1052 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1053
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1054 static void ShowBuildTrainDepotPicker()
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1055 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1056 AllocateWindowDesc(&_build_depot_desc);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1057 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1058
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1059
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1060 static void BuildWaypointWndProc(Window *w, WindowEvent *e)
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1061 {
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1062 switch(e->event) {
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1063 case WE_PAINT: {
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1064 int r;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1065
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1066 w->click_state = (1 << 3) << _cur_waypoint_type;
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1067 DrawWindowWidgets(w);
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1068
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1069 r = 4*w->hscroll.pos;
415
88e0ffa216fe (svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik <dominik@openttd.org>
parents: 411
diff changeset
1070 if(r+0<=_waypoint_count) DrawWaypointSprite(2, 25, r + 0, _cur_railtype);
88e0ffa216fe (svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik <dominik@openttd.org>
parents: 411
diff changeset
1071 if(r+1<=_waypoint_count) DrawWaypointSprite(70, 25, r + 1, _cur_railtype);
88e0ffa216fe (svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik <dominik@openttd.org>
parents: 411
diff changeset
1072 if(r+2<=_waypoint_count) DrawWaypointSprite(138, 25, r + 2, _cur_railtype);
88e0ffa216fe (svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik <dominik@openttd.org>
parents: 411
diff changeset
1073 if(r+3<=_waypoint_count) DrawWaypointSprite(206, 25, r + 3, _cur_railtype);
88e0ffa216fe (svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik <dominik@openttd.org>
parents: 411
diff changeset
1074 if(r+4<=_waypoint_count) DrawWaypointSprite(274, 25, r + 4, _cur_railtype);
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1075 break;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1076 }
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1077 case WE_CLICK: {
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1078 switch(e->click.widget) {
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1079 case 0:
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1080 ResetObjectToPlace();
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1081 break;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1082 case 3:
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1083 case 4:
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1084 case 5:
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1085 case 6:
411
27a4386a1082 (svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik <dominik@openttd.org>
parents: 410
diff changeset
1086 case 7:
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1087 _cur_waypoint_type = e->click.widget - 3;
541
facaef10d233 (svn r925) Use sound enums
tron <tron@openttd.org>
parents: 514
diff changeset
1088 SndPlayFx(SND_15_BEEP);
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1089 SetWindowDirty(w);
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1090 break;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1091 }
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1092 break;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1093 }
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1094
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1095 case WE_MOUSELOOP:
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1096 if (WP(w,def_d).close)
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1097 DeleteWindow(w);
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1098 return;
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1099 }
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1100 }
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1101
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1102 static const Widget _build_waypoint_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1103 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1104 { WWT_CAPTION, RESIZE_NONE, 7, 11, 343, 0, 13, STR_WAYPOINT,STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1105 { WWT_PANEL, RESIZE_NONE, 7, 0, 343, 14, 91, 0x0, 0},
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1106
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1107 { WWT_PANEL, RESIZE_NONE, 7, 3, 68, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1108 { WWT_PANEL, RESIZE_NONE, 7, 71, 136, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1109 { WWT_PANEL, RESIZE_NONE, 7, 139, 204, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1110 { WWT_PANEL, RESIZE_NONE, 7, 207, 272, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 855
diff changeset
1111 { WWT_PANEL, RESIZE_NONE, 7, 275, 340, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1112
894
80d683e27190 (svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater <darkvater@openttd.org>
parents: 867
diff changeset
1113 { WWT_HSCROLLBAR, RESIZE_NONE, 7, 1, 343, 80, 91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
417
721e9310944e (svn r614) [newgrf] Some minor code fixes
dominik <dominik@openttd.org>
parents: 415
diff changeset
1114 { WIDGETS_END},
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1115 };
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1116
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1117 static const WindowDesc _build_waypoint_desc = {
411
27a4386a1082 (svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik <dominik@openttd.org>
parents: 410
diff changeset
1118 -1,-1, 344, 92,
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1119 WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1120 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1121 _build_waypoint_widgets,
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1122 BuildWaypointWndProc
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1123 };
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1124
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1125 static void ShowBuildWaypointPicker()
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1126 {
395
9566850ffa0d (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater <darkvater@openttd.org>
parents: 393
diff changeset
1127 Window *w = AllocateWindowDesc(&_build_waypoint_desc);
411
27a4386a1082 (svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik <dominik@openttd.org>
parents: 410
diff changeset
1128 w->hscroll.cap = 5;
27a4386a1082 (svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik <dominik@openttd.org>
parents: 410
diff changeset
1129 w->hscroll.count = (uint) (_waypoint_count+4) / 5;
393
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1130 }
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1131
18c2ad751b06 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater <darkvater@openttd.org>
parents: 389
diff changeset
1132
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1133 void InitializeRailGui()
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1134 {
201
f2b49b0674c6 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents: 179
diff changeset
1135 _build_depot_direction = 3;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1136 _railstation.numtracks = 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1137 _railstation.platlength = 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1138 _railstation.dragdrop = true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1139 }