summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_cmd.c14
-rw-r--r--aircraft_gui.c21
-rw-r--r--misc_gui.c5
-rw-r--r--roadveh_cmd.c18
-rw-r--r--roadveh_gui.c19
-rw-r--r--ship_cmd.c16
-rw-r--r--ship_gui.c21
-rw-r--r--station_cmd.c1
-rw-r--r--train_cmd.c18
-rw-r--r--train_gui.c25
-rw-r--r--vehicle.c2
-rw-r--r--vehicle.h4
-rw-r--r--water_cmd.c2
13 files changed, 90 insertions, 76 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index d6af6737d..7d0c5eb6e 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -343,7 +343,7 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
// 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 @@ static bool UpdateAircraftSpeed(Vehicle *v)
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 @@ static void AircraftEntersTerminal(Vehicle *v)
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)
diff --git a/aircraft_gui.c b/aircraft_gui.c
index b6ee48588..2d2561650 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -503,7 +503,8 @@ static void ShowAircraftDetailsWindow(Vehicle *v)
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 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
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 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
}
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 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
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 void AircraftViewWndProc(Window *w, WindowEvent *e)
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
};
diff --git a/misc_gui.c b/misc_gui.c
index e9906297a..a5e7db7a0 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -675,7 +675,12 @@ void UnclickSomeWindowButtons(Window *w, uint32 mask)
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);
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index c051039c0..38c6583b8 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -204,7 +204,7 @@ int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ static void RoadVehCrash(Vehicle *v)
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 @@ static bool RoadVehAccelerate(Vehicle *v)
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 @@ again:
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 @@ again:
*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 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
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 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
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)
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 061a310eb..4d0678256 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -188,7 +188,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
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 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
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 void RoadVehViewWndProc(Window *w, WindowEvent *e)
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 Widget _roadveh_view_widgets[] = {
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,
};
diff --git a/ship_cmd.c b/ship_cmd.c
index 201ccadac..a75074d1a 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -109,7 +109,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
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 @@ static void CheckIfShipNeedsService(Vehicle *v)
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 @@ static bool ShipAccelerate(Vehicle *v)
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 @@ static void ShipController(Vehicle *v)
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 @@ static void ShipController(Vehicle *v)
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 @@ int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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);
}
}
diff --git a/ship_gui.c b/ship_gui.c
index cdeb969d1..935013187 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -472,7 +472,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
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 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
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 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
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 void ShipViewWndProc(Window *w, WindowEvent *e) {
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 Widget _ship_view_widgets[] = {
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
};
diff --git a/station_cmd.c b/station_cmd.c
index 4ce56ea54..72ea344e5 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1683,6 +1683,7 @@ END_TILE_LOOP(tile_cur, w,h,tile)
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;
diff --git a/train_cmd.c b/train_cmd.c
index c33de2d8d..8f1b4442c 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -752,7 +752,7 @@ int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ static void SetLastSpeed(Vehicle *v, int spd) {
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 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ static void TrainEnterStation(Vehicle *v, int station)
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 @@ static void SetVehicleCrashed(Vehicle *v)
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 @@ static void TrainController(Vehicle *v)
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 @@ static void CheckIfTrainNeedsService(Vehicle *v)
* 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 @@ static void CheckIfTrainNeedsService(Vehicle *v)
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)
diff --git a/train_gui.c b/train_gui.c
index c64230744..203a68ee8 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -734,7 +734,8 @@ static void ShowRailVehicleRefitWindow(Vehicle *v)
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 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
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 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
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 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
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 void TrainViewWndProc(Window *w, WindowEvent *e)
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
};
diff --git a/vehicle.c b/vehicle.c
index 87590054d..2ae3aff8b 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1489,7 +1489,7 @@ void EndVehicleMove(Vehicle *v)
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);
}
diff --git a/vehicle.h b/vehicle.h
index fdc91c92f..551244705 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -456,4 +456,8 @@ VARDEF BackuppedOrders _backup_orders_data[1];
#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 */
diff --git a/water_cmd.c b/water_cmd.c
index 04d6cc2c5..9201a374f 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -554,7 +554,7 @@ static void FloodVehicle(Vehicle *v)
} 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);