|
@@ -402,14 +402,17 @@ struct RefitWindow : public Window {
|
|
|
/* Skip cargo type if it's not listed */
|
|
|
if (!HasBit(cmask, cid)) {
|
|
|
current_index++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
/* Check the vehicle's callback mask for cargo suffixes */
|
|
|
if (HasBit(callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) {
|
|
|
/* Check the vehicle's callback mask for cargo suffixes.
|
|
|
* This is not supported for ordered refits, since subtypes only have a meaning
|
|
|
* for a specific vehicle at a specific point in time, which conflicts with shared orders,
|
|
|
* autoreplace, autorenew, clone, order restoration, ... */
|
|
|
if (this->order == INVALID_VEH_ORDER_ID && HasBit(callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) {
|
|
|
/* Make a note of the original cargo type. It has to be
|
|
|
* changed to test the cargo & subtype... */
|
|
|
CargoID temp_cargo = v->cargo_type;
|
|
|
byte temp_subtype = v->cargo_subtype;
|
|
|
|
|
|
v->cargo_type = cid;
|
|
@@ -484,12 +487,13 @@ struct RefitWindow : public Window {
|
|
|
}
|
|
|
|
|
|
RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window()
|
|
|
{
|
|
|
this->sel = -1;
|
|
|
this->auto_refit = auto_refit;
|
|
|
this->order = order;
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
|
|
this->vscroll = this->GetScrollbar(WID_VR_SCROLLBAR);
|
|
|
this->hscroll = (v->IsGroundVehicle() ? this->GetScrollbar(WID_VR_HSCROLLBAR) : NULL);
|
|
|
this->GetWidget<NWidgetCore>(WID_VR_SELECT_HEADER)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->type;
|
|
|
this->GetWidget<NWidgetCore>(WID_VR_MATRIX)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->type;
|
|
@@ -499,13 +503,12 @@ struct RefitWindow : public Window {
|
|
|
this->GetWidget<NWidgetStacked>(WID_VR_SHOW_HSCROLLBAR)->SetDisplayedPlane(v->IsGroundVehicle() ? 0 : SZSP_HORIZONTAL);
|
|
|
this->GetWidget<NWidgetCore>(WID_VR_VEHICLE_PANEL_DISPLAY)->tool_tip = (v->type == VEH_TRAIN) ? STR_REFIT_SELECT_VEHICLES_TOOLTIP : STR_NULL;
|
|
|
|
|
|
this->FinishInitNested(desc, v->index);
|
|
|
this->owner = v->owner;
|
|
|
|
|
|
this->order = order;
|
|
|
this->SetWidgetDisabledState(WID_VR_REFIT, this->sel == -1);
|
|
|
}
|
|
|
|
|
|
virtual void OnInit()
|
|
|
{
|
|
|
if (this->cargo != NULL) {
|
|
@@ -844,13 +847,13 @@ struct RefitWindow : public Window {
|
|
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
|
|
|
|
|
if (this->order == INVALID_VEH_ORDER_ID) {
|
|
|
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
|
|
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) delete this;
|
|
|
} else {
|
|
|
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
|
|
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -921,13 +924,13 @@ static const WindowDesc _vehicle_refit_d
|
|
|
_nested_vehicle_refit_widgets, lengthof(_nested_vehicle_refit_widgets)
|
|
|
);
|
|
|
|
|
|
/**
|
|
|
* Show the refit window for a vehicle
|
|
|
* @param *v The vehicle to show the refit window for
|
|
|
* @param order of the vehicle ( ? )
|
|
|
* @param order of the vehicle to assign refit to, or INVALID_VEH_ORDER_ID to refit the vehicle now
|
|
|
* @param parent the parent window of the refit window
|
|
|
* @param auto_refit Choose cargo for auto-refitting
|
|
|
*/
|
|
|
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
|
|
|
{
|
|
|
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
|