diff options
author | frosch <frosch@openttd.org> | 2008-05-24 11:19:30 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-05-24 11:19:30 +0000 |
commit | 8b1e7c818945959b5d346812dc8dba4be52c343b (patch) | |
tree | 85cbee8e300c85c80bce65d9e54d2735ad3390d3 /src | |
parent | 6884f9cb419d141a09ed96ea6aab6f7bf245a6f5 (diff) | |
download | openttd-8b1e7c818945959b5d346812dc8dba4be52c343b.tar.xz |
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
Diffstat (limited to 'src')
-rw-r--r-- | src/airport_gui.cpp | 10 | ||||
-rw-r--r-- | src/dock_gui.cpp | 20 | ||||
-rw-r--r-- | src/rail_gui.cpp | 42 | ||||
-rw-r--r-- | src/road_gui.cpp | 22 | ||||
-rw-r--r-- | src/window_gui.h | 5 |
5 files changed, 51 insertions, 48 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index db0f2b8ee..091f1bdcf 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -26,7 +26,7 @@ static byte _selected_airport_type; -static void ShowBuildAirportPicker(); +static void ShowBuildAirportPicker(Window *parent); void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) @@ -51,7 +51,7 @@ enum { static void BuildAirClick_Airport(Window *w) { - if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(); + if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(w); } static void BuildAirClick_Demolish(Window *w) @@ -172,7 +172,7 @@ class AirportPickerWindow : public PickerWindowBase { public: - AirportPickerWindow(const WindowDesc *desc) : PickerWindowBase(desc) + AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage); this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage); @@ -298,9 +298,9 @@ static const WindowDesc _build_airport_desc = { _build_airport_picker_widgets, }; -static void ShowBuildAirportPicker() +static void ShowBuildAirportPicker(Window *parent) { - new AirportPickerWindow(&_build_airport_desc); + new AirportPickerWindow(&_build_airport_desc, parent); } void InitializeAirportGui() diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 2e9c6117d..2c837f425 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -25,8 +25,8 @@ #include "table/sprites.h" #include "table/strings.h" -static void ShowBuildDockStationPicker(); -static void ShowBuildDocksDepotPicker(); +static void ShowBuildDockStationPicker(Window *parent); +static void ShowBuildDocksDepotPicker(Window *parent); static Axis _ship_depot_direction; @@ -105,13 +105,13 @@ static void BuildDocksClick_Demolish(Window *w) static void BuildDocksClick_Depot(Window *w) { if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(); + if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w); } static void BuildDocksClick_Dock(Window *w) { if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(); + if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w); } static void BuildDocksClick_Buoy(Window *w) @@ -255,7 +255,7 @@ private: }; public: - BuildDocksStationWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); this->FindWindowPlacementAndResize(desc); @@ -319,9 +319,9 @@ static const WindowDesc _build_dock_station_desc = { _build_dock_station_widgets, }; -static void ShowBuildDockStationPicker() +static void ShowBuildDockStationPicker(Window *parent) { - new BuildDocksStationWindow(&_build_dock_station_desc); + new BuildDocksStationWindow(&_build_dock_station_desc, parent); } struct BuildDocksDepotWindow : public PickerWindowBase { @@ -344,7 +344,7 @@ private: } public: - BuildDocksDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->LowerWidget(_ship_depot_direction + BDDW_X); UpdateDocksDirection(); @@ -394,9 +394,9 @@ static const WindowDesc _build_docks_depot_desc = { }; -static void ShowBuildDocksDepotPicker() +static void ShowBuildDocksDepotPicker(Window *parent) { - new BuildDocksDepotWindow(&_build_docks_depot_desc); + new BuildDocksDepotWindow(&_build_docks_depot_desc, parent); } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 944b53142..8f7bd0e11 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -65,10 +65,10 @@ static struct { static void HandleStationPlacement(TileIndex start, TileIndex end); -static void ShowBuildTrainDepotPicker(); -static void ShowBuildWaypointPicker(); -static void ShowStationBuilder(); -static void ShowSignalBuilder(); +static void ShowBuildTrainDepotPicker(Window *parent); +static void ShowBuildWaypointPicker(Window *parent); +static void ShowStationBuilder(Window *parent); +static void ShowSignalBuilder(Window *parent); void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) { @@ -392,7 +392,7 @@ static void BuildRailClick_Demolish(Window *w) static void BuildRailClick_Depot(Window *w) { if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) { - ShowBuildTrainDepotPicker(); + ShowBuildTrainDepotPicker(w); } } @@ -407,7 +407,7 @@ static void BuildRailClick_Waypoint(Window *w) _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) && _waypoint_count > 1) { - ShowBuildWaypointPicker(); + ShowBuildWaypointPicker(w); } } @@ -418,7 +418,7 @@ static void BuildRailClick_Waypoint(Window *w) */ static void BuildRailClick_Station(Window *w) { - if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(); + if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(w); } /** @@ -430,7 +430,7 @@ static void BuildRailClick_Station(Window *w) static void BuildRailClick_AutoSignals(Window *w) { if (_patches.enable_signal_gui != _ctrl_pressed) { - if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(); + if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w); } else { HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); } @@ -967,7 +967,7 @@ private: */ public: - BuildRailStationWindow(const WindowDesc *desc, bool newstation) : PickerWindowBase(desc) + BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent) { this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); if (_railstation.dragdrop) { @@ -1333,12 +1333,12 @@ static const WindowDesc _newstation_builder_desc = { }; /** Open station build window */ -static void ShowStationBuilder() +static void ShowStationBuilder(Window *parent) { if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) { - new BuildRailStationWindow(&_station_builder_desc, false); + new BuildRailStationWindow(&_station_builder_desc, parent, false); } else { - new BuildRailStationWindow(&_newstation_builder_desc, true); + new BuildRailStationWindow(&_newstation_builder_desc, parent, true); } } @@ -1379,7 +1379,7 @@ private: } public: - BuildSignalWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->FindWindowPlacementAndResize(desc); }; @@ -1488,9 +1488,9 @@ static const WindowDesc _signal_builder_desc = { /** * Open the signal selection window */ -static void ShowSignalBuilder() +static void ShowSignalBuilder(Window *parent) { - new BuildSignalWindow(&_signal_builder_desc); + new BuildSignalWindow(&_signal_builder_desc, parent); } struct BuildRailDepotWindow : public PickerWindowBase { @@ -1507,7 +1507,7 @@ private: }; public: - BuildRailDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); this->FindWindowPlacementAndResize(desc); @@ -1559,9 +1559,9 @@ static const WindowDesc _build_depot_desc = { _build_depot_widgets, }; -static void ShowBuildTrainDepotPicker() +static void ShowBuildTrainDepotPicker(Window *parent) { - new BuildRailDepotWindow(&_build_depot_desc); + new BuildRailDepotWindow(&_build_depot_desc, parent); } struct BuildRailWaypointWindow : PickerWindowBase { @@ -1580,7 +1580,7 @@ private: }; public: - BuildRailWaypointWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->hscroll.cap = 5; this->hscroll.count = _waypoint_count; @@ -1660,9 +1660,9 @@ static const WindowDesc _build_waypoint_desc = { _build_waypoint_widgets, }; -static void ShowBuildWaypointPicker() +static void ShowBuildWaypointPicker(Window *parent) { - new BuildRailWaypointWindow(&_build_waypoint_desc); + new BuildRailWaypointWindow(&_build_waypoint_desc, parent); } /** diff --git a/src/road_gui.cpp b/src/road_gui.cpp index f46f9811c..c5ad09e2d 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -28,8 +28,8 @@ #include "table/sprites.h" #include "table/strings.h" -static void ShowRVStationPicker(RoadStopType rs); -static void ShowRoadDepotPicker(); +static void ShowRVStationPicker(Window *parent, RoadStopType rs); +static void ShowRoadDepotPicker(Window *parent); static bool _remove_button_clicked; static bool _one_way_button_clicked; @@ -324,19 +324,19 @@ static void BuildRoadClick_Demolish(Window *w) static void BuildRoadClick_Depot(Window *w) { if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; - if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker(); + if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker(w); } static void BuildRoadClick_BusStation(Window *w) { if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; - if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(ROADSTOP_BUS); + if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(w, ROADSTOP_BUS); } static void BuildRoadClick_TruckStation(Window *w) { if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; - if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(ROADSTOP_TRUCK); + if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(w, ROADSTOP_TRUCK); } /** @@ -729,7 +729,7 @@ private: }; public: - BuildRoadDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc) + BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE); if ( _cur_roadtype == ROADTYPE_TRAM) { @@ -788,9 +788,9 @@ static const WindowDesc _build_road_depot_desc = { _build_road_depot_widgets, }; -static void ShowRoadDepotPicker() +static void ShowRoadDepotPicker(Window *parent) { - new BuildRoadDepotWindow(&_build_road_depot_desc); + new BuildRoadDepotWindow(&_build_road_depot_desc, parent); } struct BuildRoadStationWindow : public PickerWindowBase { @@ -812,7 +812,7 @@ private: }; public: - BuildRoadStationWindow(const WindowDesc *desc, RoadStopType rs) : PickerWindowBase(desc) + BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent) { /* Trams don't have non-drivethrough stations */ if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) { @@ -930,9 +930,9 @@ static const WindowDesc _rv_station_picker_desc = { _rv_station_picker_widgets, }; -static void ShowRVStationPicker(RoadStopType rs) +static void ShowRVStationPicker(Window *parent, RoadStopType rs) { - new BuildRoadStationWindow(&_rv_station_picker_desc, rs); + new BuildRoadStationWindow(&_rv_station_picker_desc, parent, rs); } void InitializeRoadGui() diff --git a/src/window_gui.h b/src/window_gui.h index bc2df770d..7b62da461 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -426,7 +426,10 @@ public: class PickerWindowBase : public Window { public: - PickerWindowBase(const WindowDesc *desc) : Window(desc) {}; // nothing special yet, just propagation + PickerWindowBase(const WindowDesc *desc, Window *parent) : Window(desc) + { + this->parent = parent; + }; virtual ~PickerWindowBase(); }; |