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