author | Darkvater |
Sun, 19 Mar 2006 09:03:25 +0000 | |
branch | 0.4.5 |
changeset 9941 | 2dd05b8458d9 |
parent 9928 | cc7b6d3bea3e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
3 |
/** @file rail_gui.c File for dealing with rail construction user interface */ |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1884
diff
changeset
|
6 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1227
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
449
diff
changeset
|
8 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
651
diff
changeset
|
10 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1123
diff
changeset
|
11 |
#include "tile.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gui.h" |
|
14 |
#include "viewport.h" |
|
15 |
#include "gfx.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
288
diff
changeset
|
16 |
#include "sound.h" |
0 | 17 |
#include "command.h" |
18 |
#include "vehicle.h" |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
19 |
#include "station.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1363
diff
changeset
|
20 |
#include "waypoint.h" |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
21 |
#include "debug.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2049
diff
changeset
|
22 |
#include "variables.h" |
0 | 23 |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
24 |
static RailType _cur_railtype; |
0 | 25 |
static bool _remove_button_clicked; |
26 |
static byte _build_depot_direction; |
|
2639 | 27 |
static byte _waypoint_count = 1; |
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
28 |
static byte _cur_waypoint_type; |
0 | 29 |
|
2630 | 30 |
static struct { |
0 | 31 |
byte orientation; |
32 |
byte numtracks; |
|
33 |
byte platlength; |
|
34 |
bool dragdrop; |
|
35 |
} _railstation; |
|
36 |
||
37 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
38 |
static void HandleStationPlacement(TileIndex start, TileIndex end); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
39 |
static void ShowBuildTrainDepotPicker(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
40 |
static void ShowBuildWaypointPicker(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
41 |
static void ShowStationBuilder(void); |
0 | 42 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
43 |
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 44 |
{ |
541 | 45 |
if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 46 |
} |
47 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
48 |
static void GenericPlaceRail(TileIndex tile, int cmd) |
0 | 49 |
{ |
50 |
DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
51 |
_remove_button_clicked ? |
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
52 |
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER : |
0 | 53 |
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER |
2639 | 54 |
); |
0 | 55 |
} |
56 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
57 |
static void PlaceRail_N(TileIndex tile) |
0 | 58 |
{ |
59 |
int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5; |
|
60 |
GenericPlaceRail(tile, cmd); |
|
61 |
} |
|
62 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
63 |
static void PlaceRail_NE(TileIndex tile) |
0 | 64 |
{ |
65 |
VpStartPlaceSizing(tile, VPM_FIX_Y); |
|
66 |
} |
|
67 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
68 |
static void PlaceRail_E(TileIndex tile) |
0 | 69 |
{ |
70 |
int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; |
|
71 |
GenericPlaceRail(tile, cmd); |
|
72 |
} |
|
73 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
74 |
static void PlaceRail_NW(TileIndex tile) |
0 | 75 |
{ |
76 |
VpStartPlaceSizing(tile, VPM_FIX_X); |
|
77 |
} |
|
78 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
79 |
static void PlaceRail_AutoRail(TileIndex tile) |
0 | 80 |
{ |
81 |
VpStartPlaceSizing(tile, VPM_RAILDIRS); |
|
82 |
} |
|
83 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
84 |
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
0 | 85 |
{ |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1990
diff
changeset
|
86 |
byte b = _m[tile].m5; |
0 | 87 |
|
2663 | 88 |
if (GB(b, 6, 2) != RAIL_TYPE_NORMAL >> 6) return; |
89 |
if (!(b & (extra >> 8))) return; |
|
0 | 90 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
91 |
DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_AUTO | CMD_NO_WATER); |
0 | 92 |
} |
93 |
||
94 |
static const uint16 _place_depot_extra[12] = { |
|
95 |
0x604, 0x2102, 0x1202, 0x505, |
|
96 |
0x2400, 0x2801, 0x1800, 0x1401, |
|
97 |
0x2203, 0x904, 0x0A05, 0x1103, |
|
98 |
}; |
|
99 |
||
100 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
101 |
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 102 |
{ |
103 |
if (success) { |
|
104 |
int dir = p2; |
|
105 |
||
541 | 106 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 107 |
ResetObjectToPlace(); |
108 |
||
900 | 109 |
tile += TileOffsByDir(dir); |
0 | 110 |
|
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
980
diff
changeset
|
111 |
if (IsTileType(tile, MP_RAILWAY)) { |
0 | 112 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir]); |
113 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); |
|
114 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); |
|
115 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
116 |
} |
0 | 117 |
} |
118 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
119 |
static void PlaceRail_Depot(TileIndex tile) |
0 | 120 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
121 |
DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot, |
0 | 122 |
CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); |
123 |
} |
|
124 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
125 |
static void PlaceRail_Waypoint(TileIndex tile) |
0 | 126 |
{ |
127 |
if (!_remove_button_clicked) { |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
128 |
DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); |
0 | 129 |
} else { |
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
130 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT)); |
0 | 131 |
} |
132 |
} |
|
133 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
134 |
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 135 |
{ |
136 |
if (success) { |
|
541 | 137 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 138 |
ResetObjectToPlace(); |
139 |
} |
|
140 |
} |
|
141 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
142 |
static void PlaceRail_Station(TileIndex tile) |
0 | 143 |
{ |
144 |
if(_remove_button_clicked) |
|
145 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); |
|
146 |
else if (_railstation.dragdrop) { |
|
147 |
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED); |
|
148 |
VpSetPlaceSizingLimit(_patches.station_spread); |
|
149 |
} else { |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
150 |
// TODO: Custom station selector GUI. Now we just try using first custom station |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
151 |
// (and fall back to normal stations if it isn't available). |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
152 |
DoCommandP(tile, _railstation.orientation | (_railstation.numtracks<<8) | (_railstation.platlength<<16),_cur_railtype|1<<4, CcStation, |
0 | 153 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
154 |
} |
|
155 |
} |
|
156 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
157 |
static void GenericPlaceSignals(TileIndex tile) |
0 | 158 |
{ |
159 |
uint trackstat; |
|
2639 | 160 |
uint i; |
0 | 161 |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
59
diff
changeset
|
162 |
trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL); |
0 | 163 |
|
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
164 |
if ((trackstat & 0x30)) // N-S direction |
0 | 165 |
trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? 0x20 : 0x10; |
166 |
||
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
167 |
if ((trackstat & 0x0C)) // E-W direction |
0 | 168 |
trackstat = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? 4 : 8; |
169 |
||
170 |
// Lookup the bit index |
|
171 |
i = 0; |
|
2639 | 172 |
if (trackstat != 0) { |
173 |
for (; !(trackstat & 1); trackstat >>= 1) i++; |
|
174 |
} |
|
0 | 175 |
|
176 |
if (!_remove_button_clicked) { |
|
177 |
DoCommandP(tile, i + (_ctrl_pressed ? 8 : 0), 0, CcPlaySound1E, |
|
178 |
CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)); |
|
179 |
} else { |
|
180 |
DoCommandP(tile, i, 0, CcPlaySound1E, |
|
181 |
CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM)); |
|
182 |
} |
|
183 |
} |
|
184 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
185 |
static void PlaceRail_Bridge(TileIndex tile) |
0 | 186 |
{ |
187 |
VpStartPlaceSizing(tile, VPM_X_OR_Y); |
|
188 |
} |
|
189 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
190 |
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 191 |
{ |
192 |
if (success) { |
|
541 | 193 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 194 |
ResetObjectToPlace(); |
195 |
} else { |
|
196 |
SetRedErrorSquare(_build_tunnel_endtile); |
|
197 |
} |
|
198 |
} |
|
199 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
200 |
static void PlaceRail_Tunnel(TileIndex tile) |
0 | 201 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
202 |
DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel, |
0 | 203 |
CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); |
204 |
} |
|
205 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
206 |
void PlaceProc_BuyLand(TileIndex tile) |
0 | 207 |
{ |
208 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); |
|
209 |
} |
|
210 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
211 |
static void PlaceRail_ConvertRail(TileIndex tile) |
0 | 212 |
{ |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
213 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea); |
0 | 214 |
} |
215 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
216 |
static void PlaceRail_AutoSignals(TileIndex tile) |
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
217 |
{ |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
218 |
VpStartPlaceSizing(tile, VPM_SIGNALDIRS); |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
219 |
} |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
220 |
|
0 | 221 |
static void BuildRailClick_N(Window *w) |
222 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
223 |
HandlePlacePushButton(w, 4, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N); |
0 | 224 |
} |
225 |
||
226 |
static void BuildRailClick_NE(Window *w) |
|
227 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
228 |
HandlePlacePushButton(w, 5, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE); |
0 | 229 |
} |
230 |
||
231 |
static void BuildRailClick_E(Window *w) |
|
232 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
233 |
HandlePlacePushButton(w, 6, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E); |
0 | 234 |
} |
235 |
||
236 |
static void BuildRailClick_NW(Window *w) |
|
237 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
238 |
HandlePlacePushButton(w, 7, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW); |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
239 |
} |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
240 |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
241 |
static void BuildRailClick_AutoRail(Window *w) |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
242 |
{ |
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
243 |
HandlePlacePushButton(w, 8, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail); |
0 | 244 |
} |
245 |
||
246 |
static void BuildRailClick_Demolish(Window *w) |
|
247 |
{ |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
248 |
HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
0 | 249 |
} |
250 |
||
251 |
static void BuildRailClick_Depot(Window *w) |
|
252 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
253 |
if (HandlePlacePushButton(w, 10, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) { |
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
254 |
ShowBuildTrainDepotPicker(); |
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
255 |
} |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
256 |
} |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
257 |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
258 |
static void BuildRailClick_Waypoint(Window *w) |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
259 |
{ |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
260 |
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
2639 | 261 |
if (HandlePlacePushButton(w, 11, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) && |
262 |
_waypoint_count > 1) { |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
263 |
ShowBuildWaypointPicker(); |
2639 | 264 |
} |
0 | 265 |
} |
266 |
||
267 |
static void BuildRailClick_Station(Window *w) |
|
268 |
{ |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
269 |
if (HandlePlacePushButton(w, 12, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder(); |
0 | 270 |
} |
271 |
||
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
272 |
static void BuildRailClick_AutoSignals(Window *w) |
0 | 273 |
{ |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1035
diff
changeset
|
274 |
HandlePlacePushButton(w, 13, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
0 | 275 |
} |
276 |
||
277 |
static void BuildRailClick_Bridge(Window *w) |
|
278 |
{ |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
279 |
HandlePlacePushButton(w, 14, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge); |
0 | 280 |
} |
281 |
||
282 |
static void BuildRailClick_Tunnel(Window *w) |
|
283 |
{ |
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
284 |
HandlePlacePushButton(w, 15, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel); |
0 | 285 |
} |
286 |
||
287 |
static void BuildRailClick_Remove(Window *w) |
|
288 |
{ |
|
2635 | 289 |
if (HASBIT(w->disabled_state, 16)) return; |
0 | 290 |
SetWindowDirty(w); |
541 | 291 |
SndPlayFx(SND_15_BEEP); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
292 |
|
2635 | 293 |
TOGGLEBIT(w->click_state, 16); |
9928
cc7b6d3bea3e
(svn r3958) Change HASBIT() to return 0/1 instead of 0/value of tested bit. Backport of r3747 from trunk
Darkvater
parents:
2725
diff
changeset
|
294 |
_remove_button_clicked = HASBIT(w->click_state, 16); |
cc7b6d3bea3e
(svn r3958) Change HASBIT() to return 0/1 instead of 0/value of tested bit. Backport of r3747 from trunk
Darkvater
parents:
2725
diff
changeset
|
295 |
SetSelectionRed(HASBIT(w->click_state, 16)); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
296 |
|
0 | 297 |
// handle station builder |
2635 | 298 |
if (HASBIT(w->click_state, 16)) { |
2639 | 299 |
if (_remove_button_clicked) { |
0 | 300 |
SetTileSelectSize(1, 1); |
2639 | 301 |
} else { |
0 | 302 |
BringWindowToFrontById(WC_BUILD_STATION, 0); |
2639 | 303 |
} |
0 | 304 |
} |
305 |
} |
|
306 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
307 |
static void BuildRailClick_Convert(Window *w) |
0 | 308 |
{ |
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
309 |
HandlePlacePushButton(w, 17, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail); |
0 | 310 |
} |
311 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
312 |
static void BuildRailClick_Landscaping(Window *w) |
0 | 313 |
{ |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
314 |
ShowTerraformToolbar(); |
0 | 315 |
} |
316 |
||
317 |
static void DoRailroadTrack(int mode) |
|
318 |
{ |
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
319 |
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
320 |
_remove_button_clicked ? |
0 | 321 |
CMD_REMOVE_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
322 |
CMD_BUILD_RAILROAD_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) |
0 | 323 |
); |
324 |
} |
|
325 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
326 |
static void HandleAutodirPlacement(void) |
0 | 327 |
{ |
328 |
TileHighlightData *thd = &_thd; |
|
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
329 |
int trackstat = thd->drawstyle & 0xF; // 0..5 |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
330 |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1035
diff
changeset
|
331 |
if (thd->drawstyle & HT_RAIL) { // one tile case |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
332 |
GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat); |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
333 |
return; |
0 | 334 |
} |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
335 |
|
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
336 |
DoRailroadTrack(trackstat); |
0 | 337 |
} |
338 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1035
diff
changeset
|
339 |
static void HandleAutoSignalPlacement(void) |
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
340 |
{ |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
341 |
TileHighlightData *thd = &_thd; |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
342 |
byte trackstat = thd->drawstyle & 0xF; // 0..5 |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
343 |
|
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
344 |
if (thd->drawstyle == HT_RECT) { // one tile case |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
345 |
GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); |
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
346 |
return; |
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
347 |
} |
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
348 |
|
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
349 |
// _patches.drag_signals_density is given as a parameter such that each user in a network |
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
350 |
// game can specify his/her own signal density |
2639 | 351 |
DoCommandP( |
352 |
TileVirtXY(thd->selstart.x, thd->selstart.y), |
|
353 |
TileVirtXY(thd->selend.x, thd->selend.y), |
|
354 |
(_ctrl_pressed ? 1 << 3 : 0) | (trackstat << 4) | (_patches.drag_signals_density << 24), |
|
355 |
CcPlaySound1E, |
|
356 |
_remove_button_clicked ? |
|
357 |
CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : |
|
358 |
CMD_BUILD_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) |
|
359 |
); |
|
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
360 |
} |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
361 |
|
2639 | 362 |
|
363 |
typedef void OnButtonClick(Window *w); |
|
364 |
||
0 | 365 |
static OnButtonClick * const _build_railroad_button_proc[] = { |
366 |
BuildRailClick_N, |
|
367 |
BuildRailClick_NE, |
|
368 |
BuildRailClick_E, |
|
369 |
BuildRailClick_NW, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
370 |
BuildRailClick_AutoRail, |
0 | 371 |
BuildRailClick_Demolish, |
372 |
BuildRailClick_Depot, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
373 |
BuildRailClick_Waypoint, |
0 | 374 |
BuildRailClick_Station, |
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
375 |
BuildRailClick_AutoSignals, |
0 | 376 |
BuildRailClick_Bridge, |
377 |
BuildRailClick_Tunnel, |
|
378 |
BuildRailClick_Remove, |
|
379 |
BuildRailClick_Convert, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
380 |
BuildRailClick_Landscaping, |
0 | 381 |
}; |
382 |
||
383 |
static const uint16 _rail_keycodes[] = { |
|
384 |
'1', |
|
385 |
'2', |
|
386 |
'3', |
|
387 |
'4', |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
388 |
'5', |
0 | 389 |
'6', |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
390 |
'7', // depot |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
391 |
'8', // waypoint |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
392 |
'9', // station |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
393 |
'S', // signals |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
394 |
'B', // bridge |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
395 |
'T', // tunnel |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
396 |
'R', // remove |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
397 |
'C', // convert rail |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
398 |
'L', // landscaping |
0 | 399 |
}; |
400 |
||
401 |
||
402 |
static void BuildRailToolbWndProc(Window *w, WindowEvent *e) |
|
403 |
{ |
|
2639 | 404 |
switch (e->event) { |
0 | 405 |
case WE_PAINT: |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
406 |
w->disabled_state &= ~(1 << 16); |
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
407 |
if (!(w->click_state & ((1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<11)|(1<<12)|(1<<13)))) { |
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
408 |
w->disabled_state |= (1 << 16); |
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
409 |
w->click_state &= ~(1<<16); |
0 | 410 |
} |
411 |
DrawWindowWidgets(w); |
|
412 |
break; |
|
413 |
||
414 |
case WE_CLICK: |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
415 |
if (e->click.widget >= 4) { |
0 | 416 |
_remove_button_clicked = false; |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
417 |
_build_railroad_button_proc[e->click.widget - 4](w); |
0 | 418 |
} |
419 |
break; |
|
420 |
||
421 |
case WE_KEYPRESS: { |
|
2639 | 422 |
uint i; |
616
3ab1124303e0
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
606
diff
changeset
|
423 |
|
2639 | 424 |
for (i = 0; i != lengthof(_rail_keycodes); i++) { |
0 | 425 |
if (e->keypress.keycode == _rail_keycodes[i]) { |
426 |
e->keypress.cont = false; |
|
427 |
_remove_button_clicked = false; |
|
428 |
_build_railroad_button_proc[i](w); |
|
429 |
break; |
|
430 |
} |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
431 |
} |
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
432 |
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
0 | 433 |
break; |
434 |
} |
|
435 |
||
436 |
case WE_PLACE_OBJ: |
|
437 |
_place_proc(e->place.tile); |
|
438 |
return; |
|
439 |
||
440 |
case WE_PLACE_DRAG: { |
|
441 |
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF); |
|
442 |
return; |
|
443 |
} |
|
444 |
||
445 |
case WE_PLACE_MOUSEUP: |
|
446 |
if (e->click.pt.x != -1) { |
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
447 |
TileIndex start_tile = e->place.starttile; |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
448 |
TileIndex end_tile = e->place.tile; |
0 | 449 |
|
450 |
if (e->place.userdata == VPM_X_OR_Y) { |
|
451 |
ResetObjectToPlace(); |
|
452 |
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
|
453 |
} else if (e->place.userdata == VPM_RAILDIRS) { |
|
454 |
bool old = _remove_button_clicked; |
|
455 |
if (_ctrl_pressed) _remove_button_clicked = true; |
|
456 |
HandleAutodirPlacement(); |
|
457 |
_remove_button_clicked = old; |
|
58
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
458 |
} else if (e->place.userdata == VPM_SIGNALDIRS) { |
b9fdcc9b5c90
(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
parents:
0
diff
changeset
|
459 |
HandleAutoSignalPlacement(); |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
460 |
} else if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
461 |
if (GUIPlaceProcDragXY(e)) break; |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
462 |
|
1656
9dd38e83c003
(svn r2160) - Fix (Regression): Convert rail failed to work; stupid bitshifts :P (sorry)
Darkvater
parents:
1632
diff
changeset
|
463 |
if ((e->place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
464 |
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
0 | 465 |
} else if (e->place.userdata == VPM_X_AND_Y_LIMITED) { |
466 |
HandleStationPlacement(start_tile, end_tile); |
|
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
467 |
} else |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
468 |
DoRailroadTrack(e->place.userdata & 1); |
0 | 469 |
} |
470 |
break; |
|
471 |
||
472 |
case WE_ABORT_PLACE_OBJ: |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
473 |
UnclickWindowButtons(w); |
0 | 474 |
SetWindowDirty(w); |
475 |
||
476 |
w = FindWindowById(WC_BUILD_STATION, 0); |
|
2639 | 477 |
if (w != NULL) WP(w,def_d).close = true; |
0 | 478 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
2639 | 479 |
if (w != NULL) WP(w,def_d).close = true; |
0 | 480 |
break; |
481 |
||
482 |
case WE_PLACE_PRESIZE: { |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
483 |
TileIndex tile = e->place.tile; |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
484 |
|
0 | 485 |
DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); |
2639 | 486 |
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); |
0 | 487 |
} break; |
2619
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2571
diff
changeset
|
488 |
|
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2571
diff
changeset
|
489 |
case WE_DESTROY: |
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2571
diff
changeset
|
490 |
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2571
diff
changeset
|
491 |
break; |
0 | 492 |
} |
493 |
} |
|
494 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
495 |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
496 |
static const Widget _build_rail_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
497 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
498 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 359, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
499 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 360, 371, 0, 13, 0x0, STR_STICKY_BUTTON}, |
0 | 500 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
501 |
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL}, |
0 | 502 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
503 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, 0x4E3, STR_1018_BUILD_RAILROAD_TRACK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
504 |
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, 0x4E4, STR_1018_BUILD_RAILROAD_TRACK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
505 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 35, 0x4E5, STR_1018_BUILD_RAILROAD_TRACK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
506 |
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 35, 0x4E6, STR_1018_BUILD_RAILROAD_TRACK}, |
2571
ab7413dfe35a
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2557
diff
changeset
|
507 |
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_AUTORAIL, STR_BUILD_AUTORAIL_TIP}, |
0 | 508 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
509 |
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
510 |
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, 0x50E, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING}, |
2571
ab7413dfe35a
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2557
diff
changeset
|
511 |
{ WWT_PANEL, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_IMG_WAYPOINT, STR_CONVERT_RAIL_TO_WAYPOINT_TIP}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
512 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
513 |
{ WWT_PANEL, RESIZE_NONE, 7, 180, 221, 14, 35, 0x512, STR_101A_BUILD_RAILROAD_STATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
514 |
{ WWT_PANEL, RESIZE_NONE, 7, 222, 243, 14, 35, 0x50B, STR_101B_BUILD_RAILROAD_SIGNALS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
515 |
{ WWT_PANEL, RESIZE_NONE, 7, 244, 285, 14, 35, 0xA22, STR_101C_BUILD_RAILROAD_BRIDGE}, |
2571
ab7413dfe35a
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2557
diff
changeset
|
516 |
{ WWT_PANEL, RESIZE_NONE, 7, 286, 305, 14, 35, SPR_IMG_TUNNEL_RAIL, STR_101D_BUILD_RAILROAD_TUNNEL}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
517 |
{ WWT_PANEL, RESIZE_NONE, 7, 306, 327, 14, 35, 0x2CA, STR_101E_TOGGLE_BUILD_REMOVE_FOR}, |
2571
ab7413dfe35a
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2557
diff
changeset
|
518 |
{ WWT_PANEL, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_IMG_CONVERT_RAIL, STR_CONVERT_RAIL_TIP}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
519 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
520 |
{ WWT_PANEL, RESIZE_NONE, 7, 350, 371, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP}, |
0 | 521 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
522 |
{ WIDGETS_END}, |
0 | 523 |
}; |
524 |
||
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
525 |
static const WindowDesc _build_rail_desc = { |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
526 |
640-372, 22, 372, 36, |
0 | 527 |
WC_BUILD_TOOLBAR,0, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
528 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
529 |
_build_rail_widgets, |
0 | 530 |
BuildRailToolbWndProc |
531 |
}; |
|
532 |
||
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
533 |
/** Enum referring to the widgets of the build rail toolbar |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
534 |
*/ |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
535 |
typedef enum { |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
536 |
RTW_CAPTION = 1, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
537 |
RTW_BUILD_NS = 4, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
538 |
RTW_BUILD_X = 5, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
539 |
RTW_BUILD_EW = 6, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
540 |
RTW_BUILD_Y = 7, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
541 |
RTW_AUTORAIL = 8, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
542 |
RTW_BUILD_DEPOT = 10, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
543 |
RTW_BUILD_TUNNEL = 15, |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
544 |
RTW_CONVERT_RAIL = 17 |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
545 |
} RailToolbarWidgets; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
546 |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
547 |
/** Configures the rail toolbar for railtype given |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
548 |
* @param railtype the railtype to display |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
549 |
* @param w the window to modify |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
550 |
*/ |
2639 | 551 |
static void SetupRailToolbar(RailType railtype, Window* w) |
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
552 |
{ |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
553 |
const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
0 | 554 |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
555 |
assert(railtype < RAILTYPE_END); |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
556 |
w->widget[RTW_CAPTION].unkA = rti->strings.toolbar_caption; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
557 |
w->widget[RTW_BUILD_NS].unkA = rti->gui_sprites.build_ns_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
558 |
w->widget[RTW_BUILD_X].unkA = rti->gui_sprites.build_x_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
559 |
w->widget[RTW_BUILD_EW].unkA = rti->gui_sprites.build_ew_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
560 |
w->widget[RTW_BUILD_Y].unkA = rti->gui_sprites.build_y_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
561 |
w->widget[RTW_AUTORAIL].unkA = rti->gui_sprites.auto_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
562 |
w->widget[RTW_BUILD_DEPOT].unkA = rti->gui_sprites.build_depot; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
563 |
w->widget[RTW_CONVERT_RAIL].unkA = rti->gui_sprites.convert_rail; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
564 |
w->widget[RTW_BUILD_TUNNEL].unkA = rti->gui_sprites.build_tunnel; |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
565 |
} |
0 | 566 |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
567 |
void ShowBuildRailToolbar(RailType railtype, int button) |
0 | 568 |
{ |
569 |
Window *w; |
|
570 |
||
946
81cf624bbdc5
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
926
diff
changeset
|
571 |
if (_current_player == OWNER_SPECTATOR) return; |
81cf624bbdc5
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
926
diff
changeset
|
572 |
|
0 | 573 |
// don't recreate the window if we're clicking on a button and the window exists. |
574 |
if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) { |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
575 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
576 |
_cur_railtype = railtype; |
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
577 |
w = AllocateWindowDesc(&_build_rail_desc); |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
578 |
SetupRailToolbar(railtype, w); |
0 | 579 |
} |
580 |
||
288
6bd97cdf1652
(svn r294) -Fix: autorail always builds rail, instead of occasional rail removal (on pressing hotkey after pressing 'bulldozer')
darkvater
parents:
201
diff
changeset
|
581 |
_remove_button_clicked = false; |
0 | 582 |
if (w != NULL && button >= 0) _build_railroad_button_proc[button](w); |
2619
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2571
diff
changeset
|
583 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(); |
0 | 584 |
} |
585 |
||
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
586 |
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks! |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
587 |
* --pasky */ |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
588 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
589 |
static void HandleStationPlacement(TileIndex start, TileIndex end) |
0 | 590 |
{ |
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
591 |
uint sx = TileX(start); |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
592 |
uint sy = TileY(start); |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
593 |
uint ex = TileX(end); |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
594 |
uint ey = TileY(end); |
0 | 595 |
uint w,h; |
596 |
||
1884
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1782
diff
changeset
|
597 |
if (sx > ex) uintswap(sx,ex); |
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1782
diff
changeset
|
598 |
if (sy > ey) uintswap(sy,ey); |
0 | 599 |
w = ex - sx + 1; |
600 |
h = ey - sy + 1; |
|
1884
ae1d6213c6dd
(svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents:
1782
diff
changeset
|
601 |
if (!_railstation.orientation) uintswap(w,h); |
0 | 602 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
603 |
// TODO: Custom station selector GUI. Now we just try using first custom station |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
604 |
// (and fall back to normal stations if it isn't available). |
1981 | 605 |
DoCommandP(TileXY(sx, sy), _railstation.orientation | (w << 8) | (h << 16), _cur_railtype | 1 << 4, CcStation, |
0 | 606 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
607 |
} |
|
608 |
||
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
609 |
static void StationBuildWndProc(Window *w, WindowEvent *e) |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
610 |
{ |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
611 |
switch (e->event) { |
0 | 612 |
case WE_PAINT: { |
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
613 |
int rad; |
0 | 614 |
uint bits; |
615 |
||
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
616 |
if (WP(w,def_d).close) return; |
0 | 617 |
|
618 |
bits = (1<<3) << ( _railstation.orientation); |
|
619 |
if (_railstation.dragdrop) { |
|
620 |
bits |= (1<<19); |
|
621 |
} else { |
|
622 |
bits |= (1<<(5-1)) << (_railstation.numtracks); |
|
623 |
bits |= (1<<(12-1)) << (_railstation.platlength); |
|
624 |
} |
|
625 |
bits |= (1<<20) << (_station_show_coverage); |
|
626 |
w->click_state = bits; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
627 |
|
0 | 628 |
if (_railstation.dragdrop) { |
629 |
SetTileSelectSize(1, 1); |
|
630 |
} else { |
|
631 |
int x = _railstation.numtracks; |
|
632 |
int y = _railstation.platlength; |
|
633 |
if (_railstation.orientation == 0) intswap(x,y); |
|
634 |
if(!_remove_button_clicked) |
|
635 |
SetTileSelectSize(x, y); |
|
636 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
637 |
|
980
4d1b8af9866b
(svn r1476) -Fix: [1099209] Catchment area with drag&drop stations (Celestar)
darkvater
parents:
946
diff
changeset
|
638 |
rad = (_patches.modified_catchment) ? CA_TRAIN : 4; |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
639 |
|
0 | 640 |
if (_station_show_coverage) |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
641 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
0 | 642 |
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
643 |
/* Update buttons for correct spread value */ |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
644 |
w->disabled_state = 0; |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
645 |
for (bits = _patches.station_spread; bits < 7; bits++) { |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
646 |
SETBIT(w->disabled_state, bits + 5); |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
647 |
SETBIT(w->disabled_state, bits + 12); |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
648 |
} |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
649 |
|
0 | 650 |
DrawWindowWidgets(w); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
651 |
|
0 | 652 |
StationPickerDrawSprite(39, 42, _cur_railtype, 2); |
653 |
StationPickerDrawSprite(107, 42, _cur_railtype, 3); |
|
654 |
||
655 |
DrawStringCentered(74, 15, STR_3002_ORIENTATION, 0); |
|
656 |
DrawStringCentered(74, 76, STR_3003_NUMBER_OF_TRACKS, 0); |
|
657 |
DrawStringCentered(74, 101, STR_3004_PLATFORM_LENGTH, 0); |
|
658 |
DrawStringCentered(74, 141, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0); |
|
659 |
||
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
660 |
DrawStationCoverageAreaText(2, 166, (uint)-1, rad); |
0 | 661 |
} break; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
662 |
|
0 | 663 |
case WE_CLICK: { |
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
664 |
switch (e->click.widget) { |
0 | 665 |
case 3: |
666 |
case 4: |
|
667 |
_railstation.orientation = e->click.widget - 3; |
|
541 | 668 |
SndPlayFx(SND_15_BEEP); |
0 | 669 |
SetWindowDirty(w); |
670 |
break; |
|
671 |
||
672 |
case 5: |
|
673 |
case 6: |
|
674 |
case 7: |
|
675 |
case 8: |
|
676 |
case 9: |
|
677 |
case 10: |
|
678 |
case 11: |
|
679 |
_railstation.numtracks = (e->click.widget - 5) + 1; |
|
680 |
_railstation.dragdrop = false; |
|
541 | 681 |
SndPlayFx(SND_15_BEEP); |
0 | 682 |
SetWindowDirty(w); |
683 |
break; |
|
684 |
||
685 |
case 12: |
|
686 |
case 13: |
|
687 |
case 14: |
|
688 |
case 15: |
|
689 |
case 16: |
|
690 |
case 17: |
|
691 |
case 18: |
|
692 |
_railstation.platlength = (e->click.widget - 12) + 1; |
|
693 |
_railstation.dragdrop = false; |
|
541 | 694 |
SndPlayFx(SND_15_BEEP); |
0 | 695 |
SetWindowDirty(w); |
696 |
break; |
|
697 |
||
698 |
case 19: |
|
699 |
_railstation.dragdrop ^= true; |
|
541 | 700 |
SndPlayFx(SND_15_BEEP); |
0 | 701 |
SetWindowDirty(w); |
702 |
break; |
|
703 |
||
704 |
case 20: |
|
705 |
case 21: |
|
706 |
_station_show_coverage = e->click.widget - 20; |
|
541 | 707 |
SndPlayFx(SND_15_BEEP); |
0 | 708 |
SetWindowDirty(w); |
709 |
break; |
|
710 |
} |
|
711 |
} break; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
712 |
|
2639 | 713 |
case WE_MOUSELOOP: |
0 | 714 |
if (WP(w,def_d).close) { |
715 |
DeleteWindow(w); |
|
716 |
return; |
|
717 |
} |
|
718 |
CheckRedrawStationCoverage(w); |
|
2639 | 719 |
break; |
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
720 |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
721 |
case WE_DESTROY: |
2639 | 722 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
723 |
break; |
0 | 724 |
} |
725 |
} |
|
726 |
||
727 |
static const Widget _station_builder_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
728 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
729 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
730 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 199, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
731 |
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
732 |
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION}, |
0 | 733 |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
734 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
735 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
736 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
737 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
738 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
739 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 87, 98, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
740 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 87, 98, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, |
0 | 741 |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
742 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
743 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
744 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
745 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
746 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
747 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 112, 123, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
748 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 112, 123, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD}, |
0 | 749 |
|
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
750 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
751 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 152, 163, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2663
diff
changeset
|
752 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 152, 163, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
753 |
{ WIDGETS_END}, |
0 | 754 |
}; |
755 |
||
756 |
static const WindowDesc _station_builder_desc = { |
|
757 |
-1, -1, 148, 200, |
|
758 |
WC_BUILD_STATION,WC_BUILD_TOOLBAR, |
|
759 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
760 |
_station_builder_widgets, |
|
761 |
StationBuildWndProc |
|
762 |
}; |
|
763 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
764 |
static void ShowStationBuilder(void) |
0 | 765 |
{ |
766 |
AllocateWindowDesc(&_station_builder_desc); |
|
767 |
} |
|
768 |
||
769 |
static void BuildTrainDepotWndProc(Window *w, WindowEvent *e) |
|
770 |
{ |
|
771 |
switch(e->event) { |
|
772 |
case WE_PAINT: { |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
773 |
RailType r; |
0 | 774 |
|
775 |
w->click_state = (1 << 3) << _build_depot_direction; |
|
776 |
DrawWindowWidgets(w); |
|
777 |
||
778 |
r = _cur_railtype; |
|
779 |
DrawTrainDepotSprite(70, 17, 0, r); |
|
780 |
DrawTrainDepotSprite(70, 69, 1, r); |
|
2639 | 781 |
DrawTrainDepotSprite( 2, 69, 2, r); |
782 |
DrawTrainDepotSprite( 2, 17, 3, r); |
|
0 | 783 |
break; |
784 |
} |
|
2639 | 785 |
|
786 |
case WE_CLICK: |
|
787 |
switch (e->click.widget) { |
|
788 |
case 3: |
|
789 |
case 4: |
|
790 |
case 5: |
|
791 |
case 6: |
|
792 |
_build_depot_direction = e->click.widget - 3; |
|
793 |
SndPlayFx(SND_15_BEEP); |
|
794 |
SetWindowDirty(w); |
|
795 |
break; |
|
0 | 796 |
} |
2639 | 797 |
break; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
798 |
|
0 | 799 |
case WE_MOUSELOOP: |
2639 | 800 |
if (WP(w,def_d).close) DeleteWindow(w); |
0 | 801 |
return; |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
802 |
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
803 |
case WE_DESTROY: |
2639 | 804 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
805 |
break; |
0 | 806 |
} |
807 |
} |
|
808 |
||
809 |
static const Widget _build_depot_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
810 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
811 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
812 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
813 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
814 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
815 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
816 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
817 |
{ WIDGETS_END}, |
0 | 818 |
}; |
819 |
||
820 |
static const WindowDesc _build_depot_desc = { |
|
821 |
-1,-1, 140, 122, |
|
822 |
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR, |
|
823 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
824 |
_build_depot_widgets, |
|
825 |
BuildTrainDepotWndProc |
|
826 |
}; |
|
827 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
828 |
static void ShowBuildTrainDepotPicker(void) |
0 | 829 |
{ |
830 |
AllocateWindowDesc(&_build_depot_desc); |
|
831 |
} |
|
832 |
||
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
833 |
|
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
834 |
static void BuildWaypointWndProc(Window *w, WindowEvent *e) |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
835 |
{ |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
836 |
switch (e->event) { |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
837 |
case WE_PAINT: { |
2639 | 838 |
uint i; |
839 |
||
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
840 |
w->click_state = (1 << 3) << (_cur_waypoint_type - w->hscroll.pos); |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
841 |
DrawWindowWidgets(w); |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
842 |
|
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
843 |
for (i = 0; i < 5; i++) { |
2639 | 844 |
if (w->hscroll.pos + i < _waypoint_count) { |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
845 |
DrawWaypointSprite(2 + i * 68, 25, w->hscroll.pos + i, _cur_railtype); |
2639 | 846 |
} |
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
847 |
} |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
848 |
break; |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
849 |
} |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
850 |
case WE_CLICK: { |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
851 |
switch (e->click.widget) { |
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
852 |
case 3: case 4: case 5: case 6: case 7: |
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
853 |
_cur_waypoint_type = e->click.widget - 3 + w->hscroll.pos; |
541 | 854 |
SndPlayFx(SND_15_BEEP); |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
855 |
SetWindowDirty(w); |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
856 |
break; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
857 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
858 |
break; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
859 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
860 |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
861 |
case WE_MOUSELOOP: |
2639 | 862 |
if (WP(w,def_d).close) DeleteWindow(w); |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
863 |
break; |
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
864 |
|
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
865 |
case WE_DESTROY: |
2639 | 866 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
867 |
break; |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
868 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
869 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
870 |
|
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
871 |
static const Widget _build_waypoint_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
872 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
873 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 343, 0, 13, STR_WAYPOINT,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
874 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 343, 14, 91, 0x0, 0}, |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
875 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
876 |
{ WWT_PANEL, RESIZE_NONE, 7, 3, 68, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
877 |
{ WWT_PANEL, RESIZE_NONE, 7, 71, 136, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
878 |
{ WWT_PANEL, RESIZE_NONE, 7, 139, 204, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
879 |
{ WWT_PANEL, RESIZE_NONE, 7, 207, 272, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
880 |
{ WWT_PANEL, RESIZE_NONE, 7, 275, 340, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
881 |
|
894
ab8a5f7ea3db
(svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater
parents:
867
diff
changeset
|
882 |
{ WWT_HSCROLLBAR, RESIZE_NONE, 7, 1, 343, 80, 91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
417 | 883 |
{ WIDGETS_END}, |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
884 |
}; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
885 |
|
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
886 |
static const WindowDesc _build_waypoint_desc = { |
411
18495773b26e
(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik
parents:
410
diff
changeset
|
887 |
-1,-1, 344, 92, |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
888 |
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR, |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
889 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
890 |
_build_waypoint_widgets, |
4c990f33dab7
(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
parents:
393
diff
changeset
|
891 |
BuildWaypointWndProc |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
892 |
}; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
893 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
894 |
static void ShowBuildWaypointPicker(void) |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
895 |
{ |
395
4c990f33dab7
(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
parents:
393
diff
changeset
|
896 |
Window *w = AllocateWindowDesc(&_build_waypoint_desc); |
411
18495773b26e
(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik
parents:
410
diff
changeset
|
897 |
w->hscroll.cap = 5; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
898 |
w->hscroll.count = _waypoint_count; |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
899 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
900 |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
901 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1074
diff
changeset
|
902 |
void InitializeRailGui(void) |
0 | 903 |
{ |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
904 |
_build_depot_direction = 3; |
0 | 905 |
_railstation.numtracks = 1; |
906 |
_railstation.platlength = 1; |
|
907 |
_railstation.dragdrop = true; |
|
908 |
} |