223 static void PlaceRail_AutoSignals(TileIndex tile) |
223 static void PlaceRail_AutoSignals(TileIndex tile) |
224 { |
224 { |
225 VpStartPlaceSizing(tile, VPM_SIGNALDIRS); |
225 VpStartPlaceSizing(tile, VPM_SIGNALDIRS); |
226 } |
226 } |
227 |
227 |
|
228 |
|
229 /** Enum referring to the widgets of the build rail toolbar */ |
|
230 enum { |
|
231 RTW_CAPTION = 1, |
|
232 RTW_BUILD_NS = 4, |
|
233 RTW_BUILD_X = 5, |
|
234 RTW_BUILD_EW = 6, |
|
235 RTW_BUILD_Y = 7, |
|
236 RTW_AUTORAIL = 8, |
|
237 RTW_DEMOLISH = 9, |
|
238 RTW_BUILD_DEPOT = 10, |
|
239 RTW_BUILD_WAYPOINT = 11, |
|
240 RTW_BUILD_STATION = 12, |
|
241 RTW_BUILD_SIGNALS = 13, |
|
242 RTW_BUILD_BRIDGE = 14, |
|
243 RTW_BUILD_TUNNEL = 15, |
|
244 RTW_REMOVE = 16, |
|
245 RTW_CONVERT_RAIL = 17 |
|
246 }; |
|
247 |
|
248 |
228 static void BuildRailClick_N(Window *w) |
249 static void BuildRailClick_N(Window *w) |
229 { |
250 { |
230 HandlePlacePushButton(w, 4, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N); |
251 HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N); |
231 } |
252 } |
232 |
253 |
233 static void BuildRailClick_NE(Window *w) |
254 static void BuildRailClick_NE(Window *w) |
234 { |
255 { |
235 HandlePlacePushButton(w, 5, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE); |
256 HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE); |
236 } |
257 } |
237 |
258 |
238 static void BuildRailClick_E(Window *w) |
259 static void BuildRailClick_E(Window *w) |
239 { |
260 { |
240 HandlePlacePushButton(w, 6, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E); |
261 HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E); |
241 } |
262 } |
242 |
263 |
243 static void BuildRailClick_NW(Window *w) |
264 static void BuildRailClick_NW(Window *w) |
244 { |
265 { |
245 HandlePlacePushButton(w, 7, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW); |
266 HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW); |
246 } |
267 } |
247 |
268 |
248 static void BuildRailClick_AutoRail(Window *w) |
269 static void BuildRailClick_AutoRail(Window *w) |
249 { |
270 { |
250 HandlePlacePushButton(w, 8, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail); |
271 HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail); |
251 } |
272 } |
252 |
273 |
253 static void BuildRailClick_Demolish(Window *w) |
274 static void BuildRailClick_Demolish(Window *w) |
254 { |
275 { |
255 HandlePlacePushButton(w, 9, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
276 HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
256 } |
277 } |
257 |
278 |
258 static void BuildRailClick_Depot(Window *w) |
279 static void BuildRailClick_Depot(Window *w) |
259 { |
280 { |
260 if (HandlePlacePushButton(w, 10, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) { |
281 if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) { |
261 ShowBuildTrainDepotPicker(); |
282 ShowBuildTrainDepotPicker(); |
262 } |
283 } |
263 } |
284 } |
264 |
285 |
265 static void BuildRailClick_Waypoint(Window *w) |
286 static void BuildRailClick_Waypoint(Window *w) |
266 { |
287 { |
267 _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
288 _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
268 if (HandlePlacePushButton(w, 11, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) && |
289 if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) && |
269 _waypoint_count > 1) { |
290 _waypoint_count > 1) { |
270 ShowBuildWaypointPicker(); |
291 ShowBuildWaypointPicker(); |
271 } |
292 } |
272 } |
293 } |
273 |
294 |
274 static void BuildRailClick_Station(Window *w) |
295 static void BuildRailClick_Station(Window *w) |
275 { |
296 { |
276 if (HandlePlacePushButton(w, 12, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder(); |
297 if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder(); |
277 } |
298 } |
278 |
299 |
279 static void BuildRailClick_AutoSignals(Window *w) |
300 static void BuildRailClick_AutoSignals(Window *w) |
280 { |
301 { |
281 HandlePlacePushButton(w, 13, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
302 HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
282 } |
303 } |
283 |
304 |
284 static void BuildRailClick_Bridge(Window *w) |
305 static void BuildRailClick_Bridge(Window *w) |
285 { |
306 { |
286 HandlePlacePushButton(w, 14, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge); |
307 HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge); |
287 } |
308 } |
288 |
309 |
289 static void BuildRailClick_Tunnel(Window *w) |
310 static void BuildRailClick_Tunnel(Window *w) |
290 { |
311 { |
291 HandlePlacePushButton(w, 15, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel); |
312 HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel); |
292 } |
313 } |
293 |
314 |
294 static void BuildRailClick_Remove(Window *w) |
315 static void BuildRailClick_Remove(Window *w) |
295 { |
316 { |
296 if (IsWindowWidgetDisabled(w, 16)) return; |
317 if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return; |
297 SetWindowDirty(w); |
318 SetWindowDirty(w); |
298 SndPlayFx(SND_15_BEEP); |
319 SndPlayFx(SND_15_BEEP); |
299 |
320 |
300 ToggleWidgetLoweredState(w, 16); |
321 ToggleWidgetLoweredState(w, RTW_REMOVE); |
301 _remove_button_clicked = IsWindowWidgetLowered(w, 16); |
322 _remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE); |
302 SetSelectionRed(_remove_button_clicked); |
323 SetSelectionRed(_remove_button_clicked); |
303 |
324 |
304 // handle station builder |
325 // handle station builder |
305 if (_remove_button_clicked) { |
326 if (_remove_button_clicked) { |
306 SetTileSelectSize(1, 1); |
327 SetTileSelectSize(1, 1); |
307 } |
328 } |
308 } |
329 } |
309 |
330 |
310 static void BuildRailClick_Convert(Window *w) |
331 static void BuildRailClick_Convert(Window *w) |
311 { |
332 { |
312 HandlePlacePushButton(w, 17, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail); |
333 HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail); |
313 } |
334 } |
314 |
335 |
315 static void BuildRailClick_Landscaping(Window *w) |
336 static void BuildRailClick_Landscaping(Window *w) |
316 { |
337 { |
317 ShowTerraformToolbar(); |
338 ShowTerraformToolbar(); |
404 |
425 |
405 static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget) |
426 static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget) |
406 { |
427 { |
407 /* If it is the removal button that has been clicked, do nothing, |
428 /* If it is the removal button that has been clicked, do nothing, |
408 * as it is up to the other buttons to drive removal status */ |
429 * as it is up to the other buttons to drive removal status */ |
409 if (clicked_widget == 16) return; |
430 if (clicked_widget == RTW_REMOVE) return; |
410 |
431 |
411 switch (clicked_widget) { |
432 switch (clicked_widget) { |
412 case 4: case 5: case 6: case 7: case 8: case 11: case 12: case 13: |
433 case RTW_BUILD_NS: |
|
434 case RTW_BUILD_X: |
|
435 case RTW_BUILD_EW: |
|
436 case RTW_BUILD_Y: |
|
437 case RTW_AUTORAIL: |
|
438 case RTW_BUILD_WAYPOINT: |
|
439 case RTW_BUILD_STATION: |
|
440 case RTW_BUILD_SIGNALS: |
413 /* Removal button is enabled only if the rail/signal/waypoint/station |
441 /* Removal button is enabled only if the rail/signal/waypoint/station |
414 * button is still lowered. Once raised, it has to be disabled */ |
442 * button is still lowered. Once raised, it has to be disabled */ |
415 SetWindowWidgetDisabledState(w, 16, !IsWindowWidgetLowered(w, clicked_widget)); |
443 SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget)); |
416 break; |
444 break; |
417 |
445 |
418 default: |
446 default: |
419 /* When any other buttons than rail/signal/waypoint/station, raise and |
447 /* When any other buttons than rail/signal/waypoint/station, raise and |
420 * disable the removal button*/ |
448 * disable the removal button*/ |
421 DisableWindowWidget(w, 16); |
449 DisableWindowWidget(w, RTW_REMOVE); |
422 RaiseWindowWidget(w, 16); |
450 RaiseWindowWidget(w, RTW_REMOVE); |
423 break; |
451 break; |
424 } |
452 } |
425 } |
453 } |
426 |
454 |
427 static void BuildRailToolbWndProc(Window *w, WindowEvent *e) |
455 static void BuildRailToolbWndProc(Window *w, WindowEvent *e) |
428 { |
456 { |
429 switch (e->event) { |
457 switch (e->event) { |
430 case WE_CREATE: DisableWindowWidget(w, 16); break; |
458 case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break; |
431 |
459 |
432 case WE_PAINT: DrawWindowWidgets(w); break; |
460 case WE_PAINT: DrawWindowWidgets(w); break; |
433 |
461 |
434 case WE_CLICK: |
462 case WE_CLICK: |
435 if (e->we.click.widget >= 4) { |
463 if (e->we.click.widget >= 4) { |