63 byte station_count; ///< Number of custom stations (if newstations is \c true ) |
63 byte station_count; ///< Number of custom stations (if newstations is \c true ) |
64 } _railstation; |
64 } _railstation; |
65 |
65 |
66 |
66 |
67 static void HandleStationPlacement(TileIndex start, TileIndex end); |
67 static void HandleStationPlacement(TileIndex start, TileIndex end); |
68 static void ShowBuildTrainDepotPicker(); |
68 static void ShowBuildTrainDepotPicker(Window *parent); |
69 static void ShowBuildWaypointPicker(); |
69 static void ShowBuildWaypointPicker(Window *parent); |
70 static void ShowStationBuilder(); |
70 static void ShowStationBuilder(Window *parent); |
71 static void ShowSignalBuilder(); |
71 static void ShowSignalBuilder(Window *parent); |
72 |
72 |
73 void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) |
73 void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) |
74 { |
74 { |
75 if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); |
75 if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); |
76 } |
76 } |
390 * @see BuildRailToolbWndProc() |
390 * @see BuildRailToolbWndProc() |
391 */ |
391 */ |
392 static void BuildRailClick_Depot(Window *w) |
392 static void BuildRailClick_Depot(Window *w) |
393 { |
393 { |
394 if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) { |
394 if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) { |
395 ShowBuildTrainDepotPicker(); |
395 ShowBuildTrainDepotPicker(w); |
396 } |
396 } |
397 } |
397 } |
398 |
398 |
399 /** |
399 /** |
400 * The "build waypoint"-button click proc of the build-rail toolbar. |
400 * The "build waypoint"-button click proc of the build-rail toolbar. |
405 static void BuildRailClick_Waypoint(Window *w) |
405 static void BuildRailClick_Waypoint(Window *w) |
406 { |
406 { |
407 _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
407 _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
408 if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) && |
408 if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) && |
409 _waypoint_count > 1) { |
409 _waypoint_count > 1) { |
410 ShowBuildWaypointPicker(); |
410 ShowBuildWaypointPicker(w); |
411 } |
411 } |
412 } |
412 } |
413 |
413 |
414 /** |
414 /** |
415 * The "build station"-button click proc of the build-rail toolbar. |
415 * The "build station"-button click proc of the build-rail toolbar. |
416 * @param w Build-rail toolbar window |
416 * @param w Build-rail toolbar window |
417 * @see BuildRailToolbWndProc() |
417 * @see BuildRailToolbWndProc() |
418 */ |
418 */ |
419 static void BuildRailClick_Station(Window *w) |
419 static void BuildRailClick_Station(Window *w) |
420 { |
420 { |
421 if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(); |
421 if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(w); |
422 } |
422 } |
423 |
423 |
424 /** |
424 /** |
425 * The "build signal"-button click proc of the build-rail toolbar. |
425 * The "build signal"-button click proc of the build-rail toolbar. |
426 * Start ShowSignalBuilder() and/or HandleAutoSignalPlacement(). |
426 * Start ShowSignalBuilder() and/or HandleAutoSignalPlacement(). |
428 * @see BuildRailToolbWndProc() |
428 * @see BuildRailToolbWndProc() |
429 */ |
429 */ |
430 static void BuildRailClick_AutoSignals(Window *w) |
430 static void BuildRailClick_AutoSignals(Window *w) |
431 { |
431 { |
432 if (_patches.enable_signal_gui != _ctrl_pressed) { |
432 if (_patches.enable_signal_gui != _ctrl_pressed) { |
433 if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(); |
433 if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w); |
434 } else { |
434 } else { |
435 HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
435 HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
436 } |
436 } |
437 } |
437 } |
438 |
438 |
965 * @param w Staion build window |
965 * @param w Staion build window |
966 * @param e Window event to handle |
966 * @param e Window event to handle |
967 */ |
967 */ |
968 |
968 |
969 public: |
969 public: |
970 BuildRailStationWindow(const WindowDesc *desc, bool newstation) : PickerWindowBase(desc) |
970 BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent) |
971 { |
971 { |
972 this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); |
972 this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); |
973 if (_railstation.dragdrop) { |
973 if (_railstation.dragdrop) { |
974 this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP); |
974 this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP); |
975 } else { |
975 } else { |
1331 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1331 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1332 _newstation_builder_widgets, |
1332 _newstation_builder_widgets, |
1333 }; |
1333 }; |
1334 |
1334 |
1335 /** Open station build window */ |
1335 /** Open station build window */ |
1336 static void ShowStationBuilder() |
1336 static void ShowStationBuilder(Window *parent) |
1337 { |
1337 { |
1338 if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) { |
1338 if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) { |
1339 new BuildRailStationWindow(&_station_builder_desc, false); |
1339 new BuildRailStationWindow(&_station_builder_desc, parent, false); |
1340 } else { |
1340 } else { |
1341 new BuildRailStationWindow(&_newstation_builder_desc, true); |
1341 new BuildRailStationWindow(&_newstation_builder_desc, parent, true); |
1342 } |
1342 } |
1343 } |
1343 } |
1344 |
1344 |
1345 /** Enum referring to the widgets of the signal window */ |
1345 /** Enum referring to the widgets of the signal window */ |
1346 enum BuildSignalWidgets { |
1346 enum BuildSignalWidgets { |
1377 this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 - xrel - xsize / 2 + |
1377 this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 - xrel - xsize / 2 + |
1378 this->IsWidgetLowered(widget_index), this->widget[widget_index].bottom - 3 + this->IsWidgetLowered(widget_index)); |
1378 this->IsWidgetLowered(widget_index), this->widget[widget_index].bottom - 3 + this->IsWidgetLowered(widget_index)); |
1379 } |
1379 } |
1380 |
1380 |
1381 public: |
1381 public: |
1382 BuildSignalWindow(const WindowDesc *desc) : PickerWindowBase(desc) |
1382 BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
1383 { |
1383 { |
1384 this->FindWindowPlacementAndResize(desc); |
1384 this->FindWindowPlacementAndResize(desc); |
1385 }; |
1385 }; |
1386 |
1386 |
1387 virtual void OnPaint() |
1387 virtual void OnPaint() |
1486 }; |
1486 }; |
1487 |
1487 |
1488 /** |
1488 /** |
1489 * Open the signal selection window |
1489 * Open the signal selection window |
1490 */ |
1490 */ |
1491 static void ShowSignalBuilder() |
1491 static void ShowSignalBuilder(Window *parent) |
1492 { |
1492 { |
1493 new BuildSignalWindow(&_signal_builder_desc); |
1493 new BuildSignalWindow(&_signal_builder_desc, parent); |
1494 } |
1494 } |
1495 |
1495 |
1496 struct BuildRailDepotWindow : public PickerWindowBase { |
1496 struct BuildRailDepotWindow : public PickerWindowBase { |
1497 private: |
1497 private: |
1498 /** Enum referring to the widgets of the build rail depot window */ |
1498 /** Enum referring to the widgets of the build rail depot window */ |
1557 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
1557 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
1558 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1558 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1559 _build_depot_widgets, |
1559 _build_depot_widgets, |
1560 }; |
1560 }; |
1561 |
1561 |
1562 static void ShowBuildTrainDepotPicker() |
1562 static void ShowBuildTrainDepotPicker(Window *parent) |
1563 { |
1563 { |
1564 new BuildRailDepotWindow(&_build_depot_desc); |
1564 new BuildRailDepotWindow(&_build_depot_desc, parent); |
1565 } |
1565 } |
1566 |
1566 |
1567 struct BuildRailWaypointWindow : PickerWindowBase { |
1567 struct BuildRailWaypointWindow : PickerWindowBase { |
1568 private: |
1568 private: |
1569 /** Enum referring to the widgets of the build NewGRF rail waypoint window */ |
1569 /** Enum referring to the widgets of the build NewGRF rail waypoint window */ |
1658 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
1658 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
1659 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1659 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1660 _build_waypoint_widgets, |
1660 _build_waypoint_widgets, |
1661 }; |
1661 }; |
1662 |
1662 |
1663 static void ShowBuildWaypointPicker() |
1663 static void ShowBuildWaypointPicker(Window *parent) |
1664 { |
1664 { |
1665 new BuildRailWaypointWindow(&_build_waypoint_desc); |
1665 new BuildRailWaypointWindow(&_build_waypoint_desc, parent); |
1666 } |
1666 } |
1667 |
1667 |
1668 /** |
1668 /** |
1669 * Initialize rail building GUI settings |
1669 * Initialize rail building GUI settings |
1670 */ |
1670 */ |