mirror of https://github.com/OpenTTD/OpenTTD
(svn r23089) -Add: Allow specifying refits for go-to station orders.
parent
5ee765b2b2
commit
3f853e7a56
|
@ -3190,6 +3190,10 @@ STR_ORDER_TOOLTIP_UNLOAD :{BLACK}Change t
|
||||||
|
|
||||||
STR_ORDER_REFIT :{BLACK}Refit
|
STR_ORDER_REFIT :{BLACK}Refit
|
||||||
STR_ORDER_REFIT_TOOLTIP :{BLACK}Select what cargo type to refit to in this order. Ctrl+Click to remove refit instruction
|
STR_ORDER_REFIT_TOOLTIP :{BLACK}Select what cargo type to refit to in this order. Ctrl+Click to remove refit instruction
|
||||||
|
STR_ORDER_REFIT_AUTO :{BLACK}Auto-refit
|
||||||
|
STR_ORDER_REFIT_AUTO_TOOLTIP :{BLACK}Select what cargo type to auto-refit to in this order. Ctrl+Click to remove refit instruction. Auto-refitting will only be done if the vehicle allows it
|
||||||
|
STR_ORDER_DROP_REFIT_AUTO :Fixed cargo
|
||||||
|
STR_ORDER_DROP_REFIT_AUTO_ANY :Available cargo
|
||||||
|
|
||||||
STR_ORDER_SERVICE :{BLACK}Service
|
STR_ORDER_SERVICE :{BLACK}Service
|
||||||
STR_ORDER_DROP_GO_ALWAYS_DEPOT :Always go
|
STR_ORDER_DROP_GO_ALWAYS_DEPOT :Always go
|
||||||
|
@ -3279,6 +3283,21 @@ STR_ORDER_NO_UNLOAD_FULL_LOAD :(No unloading a
|
||||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY :(No unloading and wait for any full load)
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY :(No unloading and wait for any full load)
|
||||||
STR_ORDER_NO_UNLOAD_NO_LOAD :(No unloading and no loading)
|
STR_ORDER_NO_UNLOAD_NO_LOAD :(No unloading and no loading)
|
||||||
|
|
||||||
|
STR_ORDER_AUTO_REFIT :(Auto-refit to {STRING})
|
||||||
|
STR_ORDER_FULL_LOAD_REFIT :(Full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_FULL_LOAD_ANY_REFIT :(Full load any cargo with auto-refit to {STRING})
|
||||||
|
STR_ORDER_UNLOAD_REFIT :(Unload and take cargo with auto-refit to {STRING})
|
||||||
|
STR_ORDER_UNLOAD_FULL_LOAD_REFIT :(Unload and wait for full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT :(Unload and wait for any full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_TRANSFER_REFIT :(Transfer and take cargo with auto-refit to {STRING})
|
||||||
|
STR_ORDER_TRANSFER_FULL_LOAD_REFIT :(Transfer and wait for full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT :(Transfer and wait for any full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_NO_UNLOAD_REFIT :(No unloading and take cargo with auto-refit to {STRING})
|
||||||
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT :(No unloading and wait for full load with auto-refit to {STRING})
|
||||||
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT :(No unloading and wait for any full load with auto-refit to {STRING})
|
||||||
|
|
||||||
|
STR_ORDER_AUTO_REFIT_ANY :available cargo
|
||||||
|
|
||||||
STR_ORDER_STOP_LOCATION_NEAR_END :[near end]
|
STR_ORDER_STOP_LOCATION_NEAR_END :[near end]
|
||||||
STR_ORDER_STOP_LOCATION_MIDDLE :[middle]
|
STR_ORDER_STOP_LOCATION_MIDDLE :[middle]
|
||||||
STR_ORDER_STOP_LOCATION_FAR_END :[far end]
|
STR_ORDER_STOP_LOCATION_FAR_END :[far end]
|
||||||
|
|
|
@ -48,6 +48,7 @@ enum OrderWindowWidgets {
|
||||||
ORDER_WIDGET_REFIT,
|
ORDER_WIDGET_REFIT,
|
||||||
ORDER_WIDGET_SERVICE,
|
ORDER_WIDGET_SERVICE,
|
||||||
ORDER_WIDGET_EMPTY,
|
ORDER_WIDGET_EMPTY,
|
||||||
|
ORDER_WIDGET_REFIT_DROPDOWN,
|
||||||
ORDER_WIDGET_COND_VARIABLE,
|
ORDER_WIDGET_COND_VARIABLE,
|
||||||
ORDER_WIDGET_COND_COMPARATOR,
|
ORDER_WIDGET_COND_COMPARATOR,
|
||||||
ORDER_WIDGET_COND_VALUE,
|
ORDER_WIDGET_COND_VALUE,
|
||||||
|
@ -61,7 +62,9 @@ enum OrderWindowWidgets {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Order load types that could be given to station orders. */
|
/** Order load types that could be given to station orders. */
|
||||||
static const StringID _station_load_types[][5] = {
|
static const StringID _station_load_types[][5][5] = {
|
||||||
|
{
|
||||||
|
/* No refitting. */
|
||||||
{
|
{
|
||||||
STR_EMPTY,
|
STR_EMPTY,
|
||||||
INVALID_STRING_ID,
|
INVALID_STRING_ID,
|
||||||
|
@ -93,6 +96,40 @@ static const StringID _station_load_types[][5] = {
|
||||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
|
||||||
STR_ORDER_NO_UNLOAD_NO_LOAD,
|
STR_ORDER_NO_UNLOAD_NO_LOAD,
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
/* With auto-refitting. No loading and auto-refitting do not work together. */
|
||||||
|
{
|
||||||
|
STR_ORDER_AUTO_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
STR_ORDER_FULL_LOAD_REFIT,
|
||||||
|
STR_ORDER_FULL_LOAD_ANY_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
}, {
|
||||||
|
STR_ORDER_UNLOAD_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
|
||||||
|
STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
}, {
|
||||||
|
STR_ORDER_TRANSFER_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
|
||||||
|
STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
}, {
|
||||||
|
/* Unload and transfer do not work together. */
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
}, {
|
||||||
|
STR_ORDER_NO_UNLOAD_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
|
||||||
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const StringID _order_non_stop_drowdown[] = {
|
static const StringID _order_non_stop_drowdown[] = {
|
||||||
|
@ -181,6 +218,12 @@ static int DepotActionStringIndex(const Order *order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const StringID _order_refit_action_dropdown[] = {
|
||||||
|
STR_ORDER_DROP_REFIT_AUTO,
|
||||||
|
STR_ORDER_DROP_REFIT_AUTO_ANY,
|
||||||
|
INVALID_STRING_ID
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws an order in order or timetable GUI
|
* Draws an order in order or timetable GUI
|
||||||
* @param v Vehicle the order belongs to
|
* @param v Vehicle the order belongs to
|
||||||
|
@ -247,7 +290,10 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||||
SetTimetableParams(6, 7, order->wait_time);
|
SetTimetableParams(6, 7, order->wait_time);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]);
|
SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[order->IsRefit()][unload][load]);
|
||||||
|
if (order->IsRefit()) {
|
||||||
|
SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
|
||||||
|
}
|
||||||
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
||||||
SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
||||||
}
|
}
|
||||||
|
@ -423,7 +469,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
* The top-row buttons of one of your trains or road vehicles is one of the following three cases:
|
* The top-row buttons of one of your trains or road vehicles is one of the following three cases:
|
||||||
* \verbatim
|
* \verbatim
|
||||||
* +-----------------+-----------------+-----------------+-----------------+
|
* +-----------------+-----------------+-----------------+-----------------+
|
||||||
* | NON-STOP | FULL_LOAD | UNLOAD | (empty) | (normal)
|
* | NON-STOP | FULL_LOAD | UNLOAD | REFIT | (normal)
|
||||||
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
||||||
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
||||||
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
||||||
|
@ -433,9 +479,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
*
|
*
|
||||||
* Airplanes and ships have one of the following three top-row button rows:
|
* Airplanes and ships have one of the following three top-row button rows:
|
||||||
* \verbatim
|
* \verbatim
|
||||||
* +--------------------------+--------------------------+
|
* +-----------------+-----------------+-----------------+
|
||||||
* | FULL_LOAD | UNLOAD | (normal)
|
* | FULL_LOAD | UNLOAD | REFIT | (normal)
|
||||||
* +-----------------+--------+--------+-----------------+
|
* +-----------------+-----------------+-----------------+
|
||||||
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
||||||
* +-----------------+--------+--------+-----------------+
|
* +-----------------+--------+--------+-----------------+
|
||||||
* | REFIT | SERVICE | (for depot order)
|
* | REFIT | SERVICE | (for depot order)
|
||||||
|
@ -477,9 +523,10 @@ private:
|
||||||
|
|
||||||
/* ORDER_WIDGET_SEL_TOP_RIGHT */
|
/* ORDER_WIDGET_SEL_TOP_RIGHT */
|
||||||
DP_RIGHT_EMPTY = 0, ///< Display an empty panel in the right button of the top row of the train/rv order window.
|
DP_RIGHT_EMPTY = 0, ///< Display an empty panel in the right button of the top row of the train/rv order window.
|
||||||
|
DP_RIGHT_REFIT = 1, ///< Display 'refit' in the right button of the top row of the train/rv order window.
|
||||||
|
|
||||||
/* ORDER_WIDGET_SEL_TOP_ROW */
|
/* ORDER_WIDGET_SEL_TOP_ROW */
|
||||||
DP_ROW_LOAD = 0, ///< Display 'load' / 'unload' buttons in the top row of the ship/airplane order window.
|
DP_ROW_LOAD = 0, ///< Display 'load' / 'unload' / 'refit' buttons in the top row of the ship/airplane order window.
|
||||||
DP_ROW_DEPOT = 1, ///< Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
|
DP_ROW_DEPOT = 1, ///< Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
|
||||||
DP_ROW_CONDITIONAL = 2, ///< Display the conditional order buttons in the top row of the ship/airplane order window.
|
DP_ROW_CONDITIONAL = 2, ///< Display the conditional order buttons in the top row of the ship/airplane order window.
|
||||||
|
|
||||||
|
@ -493,6 +540,7 @@ private:
|
||||||
OrderPlaceObjectState goto_type;
|
OrderPlaceObjectState goto_type;
|
||||||
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
|
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
|
||||||
Scrollbar *vscroll;
|
Scrollbar *vscroll;
|
||||||
|
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the memorised selected order.
|
* Return the memorised selected order.
|
||||||
|
@ -740,15 +788,29 @@ private:
|
||||||
/**
|
/**
|
||||||
* Handle the click on the refit button.
|
* Handle the click on the refit button.
|
||||||
* If ctrl is pressed, cancel refitting, else show the refit window.
|
* If ctrl is pressed, cancel refitting, else show the refit window.
|
||||||
* @param i Dummy parameter.
|
* @param i Selected refit command.
|
||||||
|
* @param auto_refit Select refit for auto-refitting.
|
||||||
*/
|
*/
|
||||||
void OrderClick_Refit(int i)
|
void OrderClick_Refit(int i, bool auto_refit)
|
||||||
{
|
{
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
/* Cancel refitting */
|
/* Cancel refitting */
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
|
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
|
||||||
} else {
|
} else {
|
||||||
ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this);
|
if (i == 1) { // Auto-refit to available cargo type.
|
||||||
|
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | CT_AUTO_REFIT, CMD_ORDER_REFIT);
|
||||||
|
} else {
|
||||||
|
ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cache auto-refittability of the vehicle chain. */
|
||||||
|
void UpdateAutoRefitState()
|
||||||
|
{
|
||||||
|
this->can_do_autorefit = false;
|
||||||
|
for (const Vehicle *w = this->vehicle; w != NULL; w = w->Next()) {
|
||||||
|
if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,6 +828,8 @@ public:
|
||||||
this->order_over = INVALID_VEH_ORDER_ID;
|
this->order_over = INVALID_VEH_ORDER_ID;
|
||||||
this->owner = v->owner;
|
this->owner = v->owner;
|
||||||
|
|
||||||
|
this->UpdateAutoRefitState();
|
||||||
|
|
||||||
if (_settings_client.gui.quick_goto && v->owner == _local_company) {
|
if (_settings_client.gui.quick_goto && v->owner == _local_company) {
|
||||||
/* If there are less than 2 station, make Go To active. */
|
/* If there are less than 2 station, make Go To active. */
|
||||||
int station_orders = 0;
|
int station_orders = 0;
|
||||||
|
@ -825,6 +889,7 @@ public:
|
||||||
case -666:
|
case -666:
|
||||||
/* Autoreplace replaced the vehicle */
|
/* Autoreplace replaced the vehicle */
|
||||||
this->vehicle = Vehicle::Get(this->window_number);
|
this->vehicle = Vehicle::Get(this->window_number);
|
||||||
|
this->UpdateAutoRefitState();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -945,6 +1010,7 @@ public:
|
||||||
}
|
}
|
||||||
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
||||||
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
||||||
|
this->DisableWidget(ORDER_WIDGET_REFIT_DROPDOWN);
|
||||||
} else {
|
} else {
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
|
this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
||||||
|
@ -957,12 +1023,16 @@ public:
|
||||||
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
||||||
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
||||||
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
||||||
right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
|
right_sel->SetDisplayedPlane(DP_RIGHT_REFIT);
|
||||||
this->EnableWidget(ORDER_WIDGET_NON_STOP);
|
this->EnableWidget(ORDER_WIDGET_NON_STOP);
|
||||||
this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
||||||
}
|
}
|
||||||
this->SetWidgetLoweredState(ORDER_WIDGET_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
|
this->SetWidgetLoweredState(ORDER_WIDGET_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
|
||||||
this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
|
this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
|
||||||
|
|
||||||
|
/* Can only do refitting when stopping at the destination and loading cargo. */
|
||||||
|
this->SetWidgetDisabledState(ORDER_WIDGET_REFIT_DROPDOWN, !this->can_do_autorefit || order->GetLoadType() == OLFB_NO_LOAD || order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_WAYPOINT:
|
case OT_GOTO_WAYPOINT:
|
||||||
|
@ -978,6 +1048,7 @@ public:
|
||||||
}
|
}
|
||||||
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
||||||
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
||||||
|
this->DisableWidget(ORDER_WIDGET_REFIT_DROPDOWN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
|
@ -1024,6 +1095,7 @@ public:
|
||||||
}
|
}
|
||||||
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
||||||
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
this->DisableWidget(ORDER_WIDGET_UNLOAD);
|
||||||
|
this->DisableWidget(ORDER_WIDGET_REFIT_DROPDOWN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1292,7 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ORDER_WIDGET_REFIT:
|
case ORDER_WIDGET_REFIT:
|
||||||
this->OrderClick_Refit(0);
|
this->OrderClick_Refit(0, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ORDER_WIDGET_SERVICE:
|
case ORDER_WIDGET_SERVICE:
|
||||||
|
@ -1231,6 +1303,14 @@ public:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ORDER_WIDGET_REFIT_DROPDOWN:
|
||||||
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||||
|
this->OrderClick_Refit(0, true);
|
||||||
|
} else {
|
||||||
|
ShowDropDownMenu(this, _order_refit_action_dropdown, 0, ORDER_WIDGET_REFIT_DROPDOWN, 0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ORDER_WIDGET_TIMETABLE_VIEW:
|
case ORDER_WIDGET_TIMETABLE_VIEW:
|
||||||
ShowTimetableWindow(this->vehicle);
|
ShowTimetableWindow(this->vehicle);
|
||||||
break;
|
break;
|
||||||
|
@ -1317,6 +1397,10 @@ public:
|
||||||
this->OrderClick_Service(index);
|
this->OrderClick_Service(index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ORDER_WIDGET_REFIT_DROPDOWN:
|
||||||
|
this->OrderClick_Refit(index, true);
|
||||||
|
break;
|
||||||
|
|
||||||
case ORDER_WIDGET_COND_VARIABLE:
|
case ORDER_WIDGET_COND_VARIABLE:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||||
break;
|
break;
|
||||||
|
@ -1505,6 +1589,8 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_TOP_RIGHT),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_TOP_RIGHT),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
||||||
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_REFIT_DROPDOWN), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||||
|
SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
|
@ -1561,12 +1647,14 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
||||||
/* First button row. */
|
/* First button row. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_TOP_ROW),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_TOP_ROW),
|
||||||
/* load + unload buttons. */
|
/* Load + unload + refit buttons. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_FULL_LOAD), SetMinimalSize(186, 12), SetFill(1, 0),
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_FULL_LOAD), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
|
SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
|
||||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_UNLOAD), SetMinimalSize(186, 12), SetFill(1, 0),
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_UNLOAD), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
|
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
|
||||||
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_REFIT_DROPDOWN), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
|
SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
/* Refit + service buttons. */
|
/* Refit + service buttons. */
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
|
|
|
@ -371,6 +371,7 @@ struct RefitWindow : public Window {
|
||||||
int click_x; ///< Position of the first click while dragging.
|
int click_x; ///< Position of the first click while dragging.
|
||||||
VehicleID selected_vehicle; ///< First vehicle in the current selection.
|
VehicleID selected_vehicle; ///< First vehicle in the current selection.
|
||||||
uint8 num_vehicles; ///< Number of selected vehicles.
|
uint8 num_vehicles; ///< Number of selected vehicles.
|
||||||
|
bool auto_refit; ///< Select cargo for auto-refitting.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects all (cargo, subcargo) refit options of a vehicle chain.
|
* Collects all (cargo, subcargo) refit options of a vehicle chain.
|
||||||
|
@ -392,6 +393,8 @@ struct RefitWindow : public Window {
|
||||||
|
|
||||||
/* Skip this engine if it does not carry anything */
|
/* Skip this engine if it does not carry anything */
|
||||||
if (!e->CanCarryCargo()) continue;
|
if (!e->CanCarryCargo()) continue;
|
||||||
|
/* Skip this engine if we build the list for auto-refitting and engine doesn't allow it. */
|
||||||
|
if (this->auto_refit && !HasBit(e->info.misc_flags, EF_AUTO_REFIT)) continue;
|
||||||
|
|
||||||
/* Loop through all cargos in the refit mask */
|
/* Loop through all cargos in the refit mask */
|
||||||
int current_index = 0;
|
int current_index = 0;
|
||||||
|
@ -479,9 +482,10 @@ struct RefitWindow : public Window {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window()
|
RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window()
|
||||||
{
|
{
|
||||||
this->sel = -1;
|
this->sel = -1;
|
||||||
|
this->auto_refit = auto_refit;
|
||||||
this->CreateNestedTree(desc);
|
this->CreateNestedTree(desc);
|
||||||
|
|
||||||
this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
|
||||||
|
@ -587,7 +591,7 @@ struct RefitWindow : public Window {
|
||||||
{
|
{
|
||||||
assert(_current_company == _local_company);
|
assert(_current_company == _local_company);
|
||||||
Vehicle *v = Vehicle::Get(this->window_number);
|
Vehicle *v = Vehicle::Get(this->window_number);
|
||||||
CommandCost cost = DoCommand(v->tile, this->selected_vehicle, option->cargo | option->subtype << 8 |
|
CommandCost cost = DoCommand(v->tile, this->selected_vehicle, option->cargo | (int)this->auto_refit << 6 | option->subtype << 8 |
|
||||||
this->num_vehicles << 16, DC_QUERY_COST, GetCmdRefitVeh(v->type));
|
this->num_vehicles << 16, DC_QUERY_COST, GetCmdRefitVeh(v->type));
|
||||||
|
|
||||||
if (cost.Failed()) return INVALID_STRING_ID;
|
if (cost.Failed()) return INVALID_STRING_ID;
|
||||||
|
@ -910,11 +914,12 @@ static const WindowDesc _vehicle_refit_desc(
|
||||||
* @param *v The vehicle to show the refit window for
|
* @param *v The vehicle to show the refit window for
|
||||||
* @param order of the vehicle ( ? )
|
* @param order of the vehicle ( ? )
|
||||||
* @param parent the parent window of the refit window
|
* @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)
|
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
|
||||||
{
|
{
|
||||||
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
|
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
|
||||||
RefitWindow *w = new RefitWindow(&_vehicle_refit_desc, v, order);
|
RefitWindow *w = new RefitWindow(&_vehicle_refit_desc, v, order, auto_refit);
|
||||||
w->parent = parent;
|
w->parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "engine_type.h"
|
#include "engine_type.h"
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
|
|
||||||
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent);
|
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
|
||||||
|
|
||||||
/** Constants of vehicle view widget indices */
|
/** Constants of vehicle view widget indices */
|
||||||
enum VehicleViewWindowWidgets {
|
enum VehicleViewWindowWidgets {
|
||||||
|
|
Loading…
Reference in New Issue