mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r21461) -Feature(tte) [FS#3711]: make it more clear that you're stopping a shared order, and make it possible retain the order list upon unsharing (sbr)
This commit is contained in:
parent
b8c9931f75
commit
834f4f157a
@ -3216,6 +3216,8 @@ STR_ORDERS_SKIP_TOOLTIP :{BLACK}Skip the
|
||||
|
||||
STR_ORDERS_DELETE_BUTTON :{BLACK}Delete
|
||||
STR_ORDERS_DELETE_TOOLTIP :{BLACK}Delete the highlighted order
|
||||
STR_ORDERS_STOP_SHARING_BUTTON :{BLACK}Stop sharing
|
||||
STR_ORDERS_STOP_SHARING_TOOLTIP :{BLACK}Stop sharing the order list. Ctrl+Click deletes the complete order list
|
||||
|
||||
STR_ORDERS_GO_TO_BUTTON :{BLACK}Go To
|
||||
STR_ORDER_GO_TO_NEAREST_DEPOT :Go to nearest depot
|
||||
@ -3764,6 +3766,7 @@ STR_ERROR_CAN_T_ADD_ORDER :{WHITE}... vehi
|
||||
STR_ERROR_CAN_T_ADD_ORDER_SHARED :{WHITE}... a vehicle sharing this order can't go to that station
|
||||
|
||||
STR_ERROR_CAN_T_SHARE_ORDER_LIST :{WHITE}Can't share order list...
|
||||
STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST :{WHITE}Can't stop sharing order list...
|
||||
STR_ERROR_CAN_T_COPY_ORDER_LIST :{WHITE}Can't copy order list...
|
||||
STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION :{WHITE}... too far from previous destination
|
||||
|
||||
|
@ -40,6 +40,7 @@ enum OrderWindowWidgets {
|
||||
ORDER_WIDGET_SCROLLBAR,
|
||||
ORDER_WIDGET_SKIP,
|
||||
ORDER_WIDGET_DELETE,
|
||||
ORDER_WIDGET_STOP_SHARING,
|
||||
ORDER_WIDGET_NON_STOP,
|
||||
ORDER_WIDGET_GOTO,
|
||||
ORDER_WIDGET_FULL_LOAD,
|
||||
@ -53,6 +54,7 @@ enum OrderWindowWidgets {
|
||||
ORDER_WIDGET_SEL_TOP_MIDDLE, ///< #NWID_SELECTION widget for middle part of the top row of the 'your train' order window.
|
||||
ORDER_WIDGET_SEL_TOP_RIGHT, ///< #NWID_SELECTION widget for right part of the top row of the 'your train' order window.
|
||||
ORDER_WIDGET_SEL_TOP_ROW, ///< #NWID_SELECTION widget for the top row of the 'your non-trains' order window.
|
||||
ORDER_WIDGET_SEL_BOTTOM_MIDDLE, ///< #NWID_SELECTION widget for the middle part of the bottom row of the 'your train' order window.
|
||||
ORDER_WIDGET_SHARED_ORDER_LIST,
|
||||
};
|
||||
|
||||
@ -458,6 +460,10 @@ private:
|
||||
DP_ROW_LOAD = 0, ///< Display 'load' / 'unload' 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.
|
||||
|
||||
/* ORDER_WIDGET_SEL_BOTTOM_MIDDLE */
|
||||
DP_BOTTOM_MIDDLE_DELETE = 0, ///< Display 'delete' in the middle button of the bottom row of the vehicle order window.
|
||||
DP_BOTTOM_MIDDLE_STOP_SHARING = 1, ///< Display 'stop sharing' in the middle button of the bottom row of the vehicle order window.
|
||||
};
|
||||
|
||||
int selected_order;
|
||||
@ -672,6 +678,31 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the click on the 'stop sharing' button.
|
||||
* If 'End of Shared Orders' isn't selected, do nothing. If Ctrl is pressed, call OrderClick_Delete and exit.
|
||||
* To stop sharing this vehicle order list, we copy the orders of a vehicle that share this order list. That way we
|
||||
* exit the group of shared vehicles while keeping the same order list.
|
||||
* @param i Dummy parameter.
|
||||
*/
|
||||
void OrderClick_StopSharing(int i)
|
||||
{
|
||||
/* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
|
||||
if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
|
||||
/* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
|
||||
if (_ctrl_pressed) {
|
||||
this->OrderClick_Delete(i);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get another vehicle that share orders with this vehicle. */
|
||||
Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
|
||||
/* Copy the order list of the other vehicle. */
|
||||
if (DoCommandP(this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index, CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST))) {
|
||||
this->UpdateButtonState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the click on the refit button.
|
||||
* If ctrl is pressed, cancel refitting, else show the refit window.
|
||||
@ -823,9 +854,17 @@ public:
|
||||
/* skip */
|
||||
this->SetWidgetDisabledState(ORDER_WIDGET_SKIP, this->vehicle->GetNumOrders() <= 1);
|
||||
|
||||
/* delete */
|
||||
this->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
|
||||
/* delete / stop sharing */
|
||||
NWidgetStacked *delete_sel = this->GetWidget<NWidgetStacked>(ORDER_WIDGET_SEL_BOTTOM_MIDDLE);
|
||||
if (shared_orders && this->selected_order == this->vehicle->GetNumOrders()) {
|
||||
/* The 'End of Shared Orders' order is selected, show the 'stop sharing' button. */
|
||||
delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_STOP_SHARING);
|
||||
} else {
|
||||
/* The 'End of Shared Orders' order isn't selected, show the 'delete' button. */
|
||||
delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_DELETE);
|
||||
this->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
|
||||
(uint)this->vehicle->GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
|
||||
}
|
||||
|
||||
/* First row. */
|
||||
this->RaiseWidget(ORDER_WIDGET_FULL_LOAD);
|
||||
@ -1072,6 +1111,10 @@ public:
|
||||
this->OrderClick_Delete(0);
|
||||
break;
|
||||
|
||||
case ORDER_WIDGET_STOP_SHARING:
|
||||
this->OrderClick_StopSharing(0);
|
||||
break;
|
||||
|
||||
case ORDER_WIDGET_NON_STOP:
|
||||
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||
this->OrderClick_Nonstop(-1);
|
||||
@ -1225,6 +1268,10 @@ public:
|
||||
case ORDER_WIDGET_DELETE:
|
||||
this->OrderClick_Delete(0);
|
||||
break;
|
||||
|
||||
case ORDER_WIDGET_STOP_SHARING:
|
||||
this->OrderClick_StopSharing(0);
|
||||
break;
|
||||
}
|
||||
|
||||
ResetObjectToPlace();
|
||||
@ -1327,7 +1374,7 @@ public:
|
||||
virtual void OnTimeout()
|
||||
{
|
||||
static const int raise_widgets[] = {
|
||||
ORDER_WIDGET_TIMETABLE_VIEW, ORDER_WIDGET_SKIP, ORDER_WIDGET_DELETE, ORDER_WIDGET_REFIT, ORDER_WIDGET_SHARED_ORDER_LIST, WIDGET_LIST_END,
|
||||
ORDER_WIDGET_TIMETABLE_VIEW, ORDER_WIDGET_SKIP, ORDER_WIDGET_DELETE, ORDER_WIDGET_STOP_SHARING, ORDER_WIDGET_REFIT, ORDER_WIDGET_SHARED_ORDER_LIST, WIDGET_LIST_END,
|
||||
};
|
||||
|
||||
/* Unclick all buttons in raise_widgets[]. */
|
||||
@ -1407,8 +1454,12 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_BOTTOM_MIDDLE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
@ -1473,8 +1524,12 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, ORDER_WIDGET_SEL_BOTTOM_MIDDLE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
|
Loading…
Reference in New Issue
Block a user