summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 81231658f..35aef4581 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -17,6 +17,7 @@
#include "gfx.h"
#include "variables.h"
#include "vehicle_gui.h"
+#include "viewport.h"
Sorting _sorting;
@@ -1084,3 +1085,42 @@ void InitializeGUI(void)
{
memset(&_sorting, 0, sizeof(_sorting));
}
+
+/** Assigns an already open vehicle window to a new vehicle.
+* Assigns an already open vehicle window to a new vehicle. If the vehicle got any sub window open (orders and so on) it will change owner too
+* @param *from_v the current owner of the window
+* @param *to_v the new owner of the window
+*/
+void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v)
+{
+ Window *w;
+
+ w = FindWindowById(WC_VEHICLE_VIEW, from_v->index);
+
+ if (w != NULL) {
+ w->window_number = to_v->index;
+ WP(w, vp_d).follow_vehicle = (VehicleID)(w->window_number & 0xFFFF);
+ SetWindowDirty(w);
+
+ w = FindWindowById(WC_VEHICLE_ORDERS, from_v->index);
+
+ if (w != NULL) {
+ w->window_number = to_v->index;
+ SetWindowDirty(w);
+ }
+
+ w = FindWindowById(WC_VEHICLE_REFIT, from_v->index);
+
+ if (w != NULL) {
+ w->window_number = to_v->index;
+ SetWindowDirty(w);
+ }
+
+ w = FindWindowById(WC_VEHICLE_DETAILS, from_v->index);
+
+ if (w != NULL) {
+ w->window_number = to_v->index;
+ SetWindowDirty(w);
+ }
+ }
+}