diff options
author | rubidium <rubidium@openttd.org> | 2008-12-28 20:53:19 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-28 20:53:19 +0000 |
commit | 1f5d51562f190af043a35f21a417ddc38dc8aec6 (patch) | |
tree | d6a5fa7ebed903872ffc171ec995e2d37cee123f | |
parent | 4db5300ac7b0c2b7fde556881f13e4f4c07cd702 (diff) | |
download | openttd-1f5d51562f190af043a35f21a417ddc38dc8aec6.tar.xz |
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
-rw-r--r-- | src/depot_gui.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 555391b96..6b1aa6d3a 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -104,28 +104,28 @@ static const Widget _depot_widgets[] = { static const WindowDesc _train_depot_desc = { - WDP_AUTO, WDP_AUTO, 36, 27, 36, 27, + WDP_AUTO, WDP_AUTO, 36, 27, 362, 123, WC_VEHICLE_DEPOT, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _depot_widgets, }; static const WindowDesc _road_depot_desc = { - WDP_AUTO, WDP_AUTO, 36, 27, 36, 27, + WDP_AUTO, WDP_AUTO, 36, 27, 316, 97, WC_VEHICLE_DEPOT, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _depot_widgets, }; static const WindowDesc _ship_depot_desc = { - WDP_AUTO, WDP_AUTO, 36, 27, 36, 27, + WDP_AUTO, WDP_AUTO, 36, 27, 306, 99, WC_VEHICLE_DEPOT, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _depot_widgets, }; static const WindowDesc _aircraft_depot_desc = { - WDP_AUTO, WDP_AUTO, 36, 27, 36, 27, + WDP_AUTO, WDP_AUTO, 36, 27, 332, 99, WC_VEHICLE_DEPOT, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _depot_widgets, @@ -244,11 +244,14 @@ struct DepotWindow : Window { VehicleList vehicle_list; VehicleList wagon_list; - DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) + DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile) { this->sel = INVALID_VEHICLE; this->generate_list = true; + this->caption_color = GetTileOwner(tile); + this->CreateDepotListWindow(type); + this->FindWindowPlacementAndResize(desc); } @@ -1042,24 +1045,18 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed) */ void ShowDepotWindow(TileIndex tile, VehicleType type) { - DepotWindow *w; + if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return; + const WindowDesc *desc; switch (type) { default: NOT_REACHED(); - case VEH_TRAIN: - w = AllocateWindowDescFront<DepotWindow>(&_train_depot_desc, tile); break; - case VEH_ROAD: - w = AllocateWindowDescFront<DepotWindow>(&_road_depot_desc, tile); break; - case VEH_SHIP: - w = AllocateWindowDescFront<DepotWindow>(&_ship_depot_desc, tile); break; - case VEH_AIRCRAFT: - w = AllocateWindowDescFront<DepotWindow>(&_aircraft_depot_desc, tile); break; + case VEH_TRAIN: desc = &_train_depot_desc; break; + case VEH_ROAD: desc = &_road_depot_desc; break; + case VEH_SHIP: desc = &_ship_depot_desc; break; + case VEH_AIRCRAFT: desc = &_aircraft_depot_desc; break; } - if (w == NULL) return; - - w->caption_color = GetTileOwner(tile); - w->CreateDepotListWindow(type); + new DepotWindow(desc, tile, type); } /** Removes the highlight of a vehicle in a depot window |