(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.

This commit is contained in:
frosch 2008-05-24 11:19:30 +00:00
parent 080af12d8b
commit 9da2cd6e02
5 changed files with 51 additions and 48 deletions

View File

@ -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()

View File

@ -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);
}

View File

@ -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);
}
/**

View File

@ -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()

View File

@ -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();
};