Show vehicle route markers when cargo load by type window focused.

This commit is contained in:
Jonathan G Rennison
2016-09-22 00:38:44 +01:00
parent 662d0e94ab
commit 16ce37ad14
4 changed files with 31 additions and 0 deletions

View File

@@ -153,6 +153,13 @@ public:
this->owner = v->owner;
}
~CargoTypeOrdersWindow()
{
if (!FocusWindowById(WC_VEHICLE_ORDERS, this->window_number)) {
MarkAllRouteStepsDirty(this);
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
if (widget == WID_CTO_HEADER) {
@@ -241,6 +248,22 @@ public:
SetDParam(2, this->vehicle->GetOrder(this->order_id)->GetDestination());
}
}
virtual void OnFocus(Window *previously_focused_window) OVERRIDE
{
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
MarkAllRoutePathsDirty(this->vehicle);
MarkAllRouteStepsDirty(this);
}
}
virtual void OnFocusLost(Window *newly_focused_window) OVERRIDE
{
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
MarkAllRoutePathsDirty(this->vehicle);
MarkAllRouteStepsDirty(this);
}
}
};
/**
@@ -1289,6 +1312,8 @@ public:
~OrdersWindow()
{
DeleteWindowById(WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, this->window_number, false);
DeleteWindowById(WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, this->window_number, false);
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
MarkAllRouteStepsDirty(this);
}

View File

@@ -877,6 +877,8 @@ void Vehicle::PreDestructor()
DeleteWindowById(WC_VEHICLE_REFIT, this->index);
DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index);
DeleteWindowById(WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, this->index);
DeleteWindowById(WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, this->index);
SetWindowDirty(WC_COMPANY, this->owner);
OrderBackup::ClearVehicle(this);
}

View File

@@ -126,6 +126,8 @@ static inline bool HasFocusedVehicleChanged(const VehicleID vid, Window *ref_win
case WC_VEHICLE_ORDERS:
case WC_VEHICLE_TIMETABLE:
case WC_VEHICLE_VIEW:
case WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS:
case WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS:
return ((uint32) wn != vid);
}
}

View File

@@ -1714,6 +1714,8 @@ static inline Vehicle *GetVehicleFromWindow(Window *w)
case WC_VEHICLE_TIMETABLE:
case WC_VEHICLE_DETAILS:
case WC_VEHICLE_REFIT:
case WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS:
case WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS:
if (wn != INVALID_VEHICLE) return Vehicle::Get(wn);
break;
default: