(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
authordarkvater
Tue, 21 Dec 2004 23:27:58 +0000
changeset 755 823358e83abf
parent 754 d419123e39d6
child 756 d1f1dc31b6f4
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
aircraft_cmd.c
aircraft_gui.c
misc_gui.c
roadveh_cmd.c
roadveh_gui.c
ship_cmd.c
ship_gui.c
station_cmd.c
train_cmd.c
train_gui.c
vehicle.c
vehicle.h
water_cmd.c
--- a/aircraft_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/aircraft_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -343,7 +343,7 @@
 
 	if (flags & DC_EXEC) {
 		v->vehstatus ^= VS_STOPPED;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 	}
 
@@ -366,7 +366,7 @@
 			if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 	} else {
 		st = DEREF_STATION(v->u.air.targetairport);
@@ -379,7 +379,7 @@
 			v->current_order.type = OT_GOTO_DEPOT;
 			v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
 			v->current_order.station = v->u.air.targetairport;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 	}
 
@@ -481,11 +481,11 @@
 //		v->u.air.targetairport = st->index;
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	} else if (v->current_order.type == OT_GOTO_DEPOT) {
 		v->current_order.type = OT_DUMMY;
 		v->current_order.flags = 0;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 }
 
@@ -674,7 +674,7 @@
 	if (spd != v->cur_speed) {
 		v->cur_speed = spd;
 		if (_patches.vehicle_speed)
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	if (!(v->direction & 1)) {
@@ -1148,7 +1148,7 @@
 
 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
 	LoadUnloadVehicle(v);
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
 
 static void AircraftEnterHangar(Vehicle *v)
--- a/aircraft_gui.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/aircraft_gui.c	Tue Dec 21 23:27:58 2004 +0000
@@ -503,7 +503,8 @@
 
 static const Widget _aircraft_view_widgets[] = {
 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,    14,    11,   249,     0,    13, STR_A00A,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{    WWT_CAPTION,    14,    11,   237,     0,    13, STR_A00A,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_A027_CURRENT_AIRCRAFT_ACTION},
@@ -520,7 +521,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		Vehicle *v = &_vehicles[w->window_number];
-		uint32 disabled = 1<<7;
+		uint32 disabled = 1<<8;
 		StringID str;
 
 		{
@@ -532,7 +533,7 @@
 		}
 
 		if (v->owner != _local_player)
-			disabled |= 1<<7 | 1<<6;
+			disabled |= 1<<8 | 1<<7;
 		w->disabled_state = disabled;
 
 		/* draw widgets & caption */
@@ -583,22 +584,22 @@
 		Vehicle *v = &_vehicles[w->window_number];
 
 		switch(e->click.widget) {
-		case 4: /* start stop */
+		case 5: /* start stop */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT));
 			break;
-		case 5: /* center main view */
+		case 6: /* center main view */
 			ScrollMainWindowTo(v->x_pos, v->y_pos);
 			break;
-		case 6: /* goto hangar */
+		case 7: /* goto hangar */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO));
 			break;
-		case 7: /* refit */
+		case 8: /* refit */
 			ShowAircraftRefitWindow(v);
 			break;
-		case 8: /* show orders */
+		case 9: /* show orders */
 			ShowOrdersWindow(v);
 			break;
-		case 9: /* show details */
+		case 10: /* show details */
 			ShowAircraftDetailsWindow(v);
 			break;
 		}
@@ -616,7 +617,7 @@
 static const WindowDesc _aircraft_view_desc = {
 	-1,-1, 250, 116,
 	WC_VEHICLE_VIEW ,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
 	_aircraft_view_widgets,
 	AircraftViewWndProc
 };
--- a/misc_gui.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/misc_gui.c	Tue Dec 21 23:27:58 2004 +0000
@@ -675,7 +675,12 @@
 
 void UnclickWindowButtons(Window *w)
 {
+	bool sticky = false;
+	if (w->desc_flags & WDF_STICKY_BUTTON && HASBIT(w->click_state, 2))	sticky = true;
+
 	UnclickSomeWindowButtons(w, (uint32)-1);
+
+	if (sticky) SETBIT(w->click_state, 2);
 }
 
 
--- a/roadveh_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/roadveh_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -204,7 +204,7 @@
 
 	if (flags & DC_EXEC) {
 		v->vehstatus ^= VS_STOPPED;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 	}
 
@@ -307,7 +307,7 @@
 				v->cur_order_index++;
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 		return 0;
 	}
@@ -321,7 +321,7 @@
 		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
 		v->current_order.station = (byte)depot;
 		v->dest_tile = _depots[depot].xy;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	return 0;
@@ -491,7 +491,7 @@
 	v->u.road.crashed_ctr++;
 	v->vehstatus |= VS_CRASHED;
 
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
 	pass = 1;
 	if (v->cargo_type == 0)
@@ -753,7 +753,7 @@
 	if (spd != v->cur_speed) {
 		v->cur_speed = spd;
 		if (_patches.vehicle_speed)
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	// Decrease somewhat when turning
@@ -1339,7 +1339,7 @@
 				InvalidateWindow(WC_ROADVEH_LIST, v->owner);
 				MarkRoadVehDirty(v);
 			}
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			return;
 		}
 
@@ -1354,7 +1354,7 @@
 		*b |= 0x80;
 
 		StartRoadVehSound(v);
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	r = VehicleEnterTile(v, v->tile, x, y);
@@ -1455,7 +1455,7 @@
 		if (v->current_order.type == OT_GOTO_DEPOT) {
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 		return;
 	}
@@ -1469,7 +1469,7 @@
 	v->current_order.flags = OF_NON_STOP;
 	v->current_order.station = (byte)i;
 	v->dest_tile = (&_depots[i])->xy;
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
 
 void OnNewDay_RoadVeh(Vehicle *v)
--- a/roadveh_gui.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/roadveh_gui.c	Tue Dec 21 23:27:58 2004 +0000
@@ -188,7 +188,7 @@
 		Vehicle *v = &_vehicles[w->window_number];
 		StringID str;
 
-		w->disabled_state = (v->owner != _local_player) ? (1<<7 | 1<<6) : 0;
+		w->disabled_state = (v->owner != _local_player) ? (1<<8 | 1<<7) : 0;
 
 		/* draw widgets & caption */
 		SetDParam(0, v->string_id);
@@ -242,22 +242,22 @@
 		Vehicle *v = &_vehicles[w->window_number];
 
 		switch(e->click.widget) {
-		case 4: /* start stop */
+		case 5: /* start stop */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE));
 			break;
-		case 5: /* center main view */
+		case 6: /* center main view */
 			ScrollMainWindowTo(v->x_pos, v->y_pos);
 			break;
-		case 6: /* goto hangar */
+		case 7: /* goto hangar */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT));
 			break;
-		case 7: /* turn around */
+		case 8: /* turn around */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
 			break;
-		case 8: /* show orders */
+		case 9: /* show orders */
 			ShowOrdersWindow(v);
 			break;
-		case 9: /* show details */
+		case 10: /* show details */
 			ShowRoadVehDetailsWindow(v);
 			break;
 		}
@@ -272,7 +272,8 @@
 
 static const Widget _roadveh_view_widgets[] = {
 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,    14,    11,   249,     0,    13, STR_9002,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{    WWT_CAPTION,    14,    11,   237,     0,    13, STR_9002,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_901C_CURRENT_VEHICLE_ACTION},
@@ -287,7 +288,7 @@
 static const WindowDesc _roadveh_view_desc = {
 	-1,-1, 250, 116,
 	WC_VEHICLE_VIEW,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
 	_roadveh_view_widgets,
 	RoadVehViewWndProc,
 };
--- a/ship_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/ship_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -109,7 +109,7 @@
 		if (v->current_order.type == OT_GOTO_DEPOT) {
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 		return;
 	}
@@ -118,7 +118,7 @@
 	v->current_order.flags = OF_NON_STOP;
 	v->current_order.station = (byte)i;
 	v->dest_tile = (&_depots[i])->xy;
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
 
 void OnNewDay_Ship(Vehicle *v)
@@ -367,7 +367,7 @@
 	if (spd != v->cur_speed) {
 		v->cur_speed = spd;
 		if (_patches.vehicle_speed)
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	// Decrease somewhat when turning
@@ -692,7 +692,7 @@
 							InvalidateWindow(WC_SHIPS_LIST, v->owner);
 							MarkShipDirty(v);
 						}
-						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 					} else { /* leave buoys right aways */
 						v->current_order.type = OT_LEAVESTATION;
 						v->current_order.flags = 0;
@@ -706,7 +706,7 @@
 			if (v->current_order.type == OT_LEAVESTATION) {
 				v->current_order.type = OT_NOTHING;
 				v->current_order.flags = 0;
-				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			}
 		}
 	} else {
@@ -915,7 +915,7 @@
 
 	if (flags & DC_EXEC) {
 		v->vehstatus ^= VS_STOPPED;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 	}
 
@@ -937,7 +937,7 @@
 			if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 	} else {
 		depot = FindClosestShipDepot(v);
@@ -949,7 +949,7 @@
 			v->current_order.type = OT_GOTO_DEPOT;
 			v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
 			v->current_order.station = depot;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 	}
 
--- a/ship_gui.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/ship_gui.c	Tue Dec 21 23:27:58 2004 +0000
@@ -472,7 +472,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		Vehicle *v = &_vehicles[w->window_number];
-		uint32 disabled = 1<<7;
+		uint32 disabled = 1<<8;
 		StringID str;
 
 		// Possible to refit?
@@ -483,7 +483,7 @@
 			disabled = 0;
 
 		if (v->owner != _local_player)
-			disabled |= 1<<7 | 1<<6;
+			disabled |= 1<<8 | 1<<7;
 		w->disabled_state = disabled;
 
 		/* draw widgets & caption */
@@ -536,22 +536,22 @@
 		Vehicle *v = &_vehicles[w->window_number];
 
 		switch(e->click.widget) {
-		case 4: /* start stop */
+		case 5: /* start stop */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
 			break;
-		case 5: /* center main view */
+		case 6: /* center main view */
 			ScrollMainWindowTo(v->x_pos, v->y_pos);
 			break;
-		case 6: /* goto hangar */
+		case 7: /* goto hangar */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
 			break;
-		case 7: /* refit */
+		case 8: /* refit */
 			ShowShipRefitWindow(v);
 			break;
-		case 8: /* show orders */
+		case 9: /* show orders */
 			ShowOrdersWindow(v);
 			break;
-		case 9: /* show details */
+		case 10: /* show details */
 			ShowShipDetailsWindow(v);
 			break;
 		}
@@ -567,7 +567,8 @@
 
 static const Widget _ship_view_widgets[] = {
 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,    14,    11,   249,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{    WWT_CAPTION,    14,    11,   237,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_9827_CURRENT_SHIP_ACTION_CLICK},
@@ -582,7 +583,7 @@
 static const WindowDesc _ship_view_desc = {
 	-1,-1, 250, 116,
 	WC_VEHICLE_VIEW,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
 	_ship_view_widgets,
 	ShipViewWndProc
 };
--- a/station_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/station_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -1683,6 +1683,7 @@
 
 		for (i = 0; i < afc->nof_depots; ++i)
 			DeleteWindowById(WC_VEHICLE_DEPOT, tile + afc->airport_depots[i]);
+
 		st->airport_tile = 0;
 		st->facilities &= ~FACIL_AIRPORT;
 
--- a/train_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/train_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -752,7 +752,7 @@
 	if (flags & DC_EXEC) {
 		v->u.rail.days_since_order_progr = 0;
 		v->vehstatus ^= VS_STOPPED;
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 	}
 	return 0;
@@ -912,7 +912,7 @@
 	if (spd != old) {
 		v->u.rail.last_speed = spd;
 		if (_patches.vehicle_speed || !old != !spd)
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 }
 
@@ -1184,7 +1184,7 @@
 
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 		return 0;
 	}
@@ -1198,7 +1198,7 @@
 		v->current_order.type = OT_GOTO_DEPOT;
 		v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
 		v->current_order.station = GetDepotByTile(tfdd.tile);
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 
 	return 0;
@@ -1805,7 +1805,7 @@
 		MarkTrainDirty(v);
 		UpdateTrainAcceleration(v);
 	}
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
 
 static byte AfterSetTrainPos(Vehicle *v)
@@ -1997,7 +1997,7 @@
 		v->vehstatus |= VS_CRASHED;
 	END_ENUM_WAGONS(v)
 
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, u->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, u->index, STATUS_BAR);
 }
 
 static int CountPassengersInTrain(Vehicle *v)
@@ -2116,7 +2116,7 @@
 					if (v->current_order.type == OT_LEAVESTATION) {
 						v->current_order.type = OT_NOTHING;
 						v->current_order.flags = 0;
-						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+						InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 					}
 				}
 			} else {
@@ -2681,7 +2681,7 @@
 			 * schedule? */
 			v->current_order.type = OT_DUMMY;
 			v->current_order.flags = 0;
-			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
 		return;
 	}
@@ -2697,7 +2697,7 @@
 	v->current_order.flags = OF_NON_STOP;
 	v->current_order.station = depot;
 	v->dest_tile = tfdd.tile;
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 }
 
 int32 GetTrainRunningCost(Vehicle *v)
--- a/train_gui.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/train_gui.c	Tue Dec 21 23:27:58 2004 +0000
@@ -734,7 +734,8 @@
 
 static Widget _train_view_widgets[] = {
 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,    14,    11,   249,     0,    13, STR_882E,STR_018C_WINDOW_TITLE_DRAG_THIS},
+{    WWT_CAPTION,    14,    11,   237,     0,    13, STR_882E,STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,     STR_STICKY_BUTTON},
 {      WWT_PANEL,    14,     0,   231,    14,   121, 0x0,			STR_NULL},
 {          WWT_6,    14,     2,   229,    16,   119, 0x0,			STR_NULL},
 { WWT_PUSHIMGBTN,    14,     0,   249,   122,   133, 0x0,			STR_8846_CURRENT_TRAIN_ACTION_CLICK},
@@ -757,7 +758,7 @@
 
 		v = &_vehicles[w->window_number];
 
-		w->disabled_state = (v->owner == _local_player) ? 0 : 0x1C0;
+		w->disabled_state = (v->owner == _local_player) ? 0 : 0x380;
 
 
 		/* draw widgets & caption */
@@ -825,29 +826,29 @@
 		Vehicle *v = &_vehicles[w->window_number];
 
 		switch(wid) {
-		case 4: /* start/stop train */
+		case 5: /* start/stop train */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
 			break;
-		case 5:	/* center main view */
+		case 6:	/* center main view */
 			ScrollMainWindowTo(v->x_pos, v->y_pos);
 			break;
-		case 6:	/* goto depot */
+		case 7:	/* goto depot */
 			/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT));
 			break;
-		case 7: /* force proceed */
+		case 8: /* force proceed */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
 			break;
-		case 8: /* reverse direction */
+		case 9: /* reverse direction */
 			DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));
 			break;
-		case 9: /* show train orders */
+		case 10: /* show train orders */
 			ShowOrdersWindow(v);
 			break;
-		case 10: /* show train details */
+		case 11: /* show train details */
 			ShowTrainDetailsWindow(v);
 			break;
-		case 11:
+		case 12:
 			ShowRailVehicleRefitWindow(v);
 			break;
 		}
@@ -865,7 +866,7 @@
 
 		v = &_vehicles[w->window_number];
 		assert(v->type == VEH_Train);
-		h = CheckStoppedInDepot(v) >= 0 ? (1 << 8) : (1 << 11);
+		h = CheckStoppedInDepot(v) >= 0 ? (1 << 9) : (1 << 12);
 		if (h != w->hidden_state) {
 			w->hidden_state = h;
 			SetWindowDirty(w);
@@ -879,7 +880,7 @@
 static const WindowDesc _train_view_desc = {
 	-1,-1, 250, 134,
 	WC_VEHICLE_VIEW,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
 	_train_view_widgets,
 	TrainViewWndProc
 };
--- a/vehicle.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/vehicle.c	Tue Dec 21 23:27:58 2004 +0000
@@ -1489,7 +1489,7 @@
 
 void InvalidateVehicleOrderWidget(Vehicle *v)
 {
-	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	InvalidateWindowWidget(WC_VEHICLE_ORDERS, v->index, 2);
 }
 
--- a/vehicle.h	Tue Dec 21 22:53:55 2004 +0000
+++ b/vehicle.h	Tue Dec 21 23:27:58 2004 +0000
@@ -456,4 +456,8 @@
 #define MIN_SERVINT_DAYS    30
 #define MAX_SERVINT_DAYS   800
 
+/* A lot of code calls for the invalidation of the status bar, which is widget 5.
+ * Best is to have a virtual value for it when it needs to change again */
+#define STATUS_BAR 5
+
 #endif /* VEHICLE_H */
--- a/water_cmd.c	Tue Dec 21 22:53:55 2004 +0000
+++ b/water_cmd.c	Tue Dec 21 23:27:58 2004 +0000
@@ -554,7 +554,7 @@
 		} else
 			return;
 
-		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
 		SetDParam(0, pass);