Changeset - r10528:99ad5205b347
[Not reviewed]
master
0 7 0
rubidium - 15 years ago 2009-01-02 20:59:04
rubidium@openttd.org
(svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
7 files changed with 34 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/station.cpp
Show inline comments
 
@@ -33,6 +33,7 @@
 
#include "order_func.h"
 
#include "news_func.h"
 
#include "aircraft.h"
 
#include "vehicle_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
@@ -87,6 +88,11 @@ Station::~Station()
 
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
 

	
 
	DeleteWindowById(WC_STATION_VIEW, index);
 
	WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner;
 
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 

	
 
	/* Now delete all orders that go to the station */
 
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
src/station_gui.cpp
Show inline comments
 
@@ -700,10 +700,10 @@ struct StationViewWindow : public Window
 
		WindowNumber wno =
 
			(this->window_number << 16) | VLW_STATION_LIST | GetStation(this->window_number)->owner;
 

	
 
		DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
		DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
		DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
		DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 
		DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
 
		DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
 
		DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11), false);
 
		DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11), false);
 
	}
 

	
 
	virtual void OnPaint()
src/train_cmd.cpp
Show inline comments
 
@@ -1293,6 +1293,10 @@ CommandCost CmdMoveRailVehicle(TileIndex
 
			if (IsFrontEngine(src)) {
 
				/* the vehicle was previously a loco. need to free the order list and delete vehicle windows etc. */
 
				DeleteWindowById(WC_VEHICLE_VIEW, src->index);
 
				DeleteWindowById(WC_VEHICLE_ORDERS, src->index);
 
				DeleteWindowById(WC_VEHICLE_REFIT, src->index);
 
				DeleteWindowById(WC_VEHICLE_DETAILS, src->index);
 
				DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index);
 
				DeleteVehicleOrders(src);
 
				RemoveVehicleFromGroup(src);
 
			}
 
@@ -1402,6 +1406,10 @@ CommandCost CmdSellRailWagon(TileIndex t
 
	if (flags & DC_EXEC) {
 
		if (v == first && IsFrontEngine(first)) {
 
			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 
			DeleteWindowById(WC_VEHICLE_ORDERS, first->index);
 
			DeleteWindowById(WC_VEHICLE_REFIT, first->index);
 
			DeleteWindowById(WC_VEHICLE_DETAILS, first->index);
 
			DeleteWindowById(WC_VEHICLE_TIMETABLE, first->index);
 
		}
 
		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
src/vehicle.cpp
Show inline comments
 
@@ -672,8 +672,10 @@ void Vehicle::PreDestructor()
 

	
 
	if (this->IsPrimaryVehicle()) {
 
		DeleteWindowById(WC_VEHICLE_VIEW, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->index);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index);
 
		InvalidateWindow(WC_COMPANY, this->owner);
 
	}
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
src/vehicle_gui.cpp
Show inline comments
 
@@ -1817,10 +1817,10 @@ struct VehicleViewWindow : Window {
 

	
 
	~VehicleViewWindow()
 
	{
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number, false);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number, false);
 
	}
 

	
 
	virtual void OnPaint()
src/window.cpp
Show inline comments
 
@@ -492,10 +492,16 @@ Window *FindWindowById(WindowClass cls, 
 
 * Delete a window by its class and window number (if it is open).
 
 * @param cls Window class
 
 * @param number Number of the window within the window class
 
 * @param force force deletion; if false don't delete when stickied
 
 */
 
void DeleteWindowById(WindowClass cls, WindowNumber number)
 
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
 
{
 
	delete FindWindowById(cls, number);
 
	Window *w = FindWindowById(cls, number);
 
	if (force || w == NULL ||
 
			(w->desc_flags & WDF_STICKY_BUTTON) == 0 ||
 
			(w->flags4 & WF_STICKY) == 0) {
 
		delete w;
 
	}
 
}
 

	
 
/**
src/window_func.h
Show inline comments
 
@@ -35,7 +35,7 @@ void InvalidateWindowWidget(WindowClass 
 
void InvalidateWindow(WindowClass cls, WindowNumber number);
 
void InvalidateWindowClasses(WindowClass cls);
 

	
 
void DeleteWindowById(WindowClass cls, WindowNumber number);
 
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true);
 
void DeleteWindowByClass(WindowClass cls);
 

	
 
#endif /* WINDOW_FUNC_H */
0 comments (0 inline, 0 general)