diff -r 488d4cd37ddd src/lang/english.txt --- a/src/lang/english.txt Wed May 19 18:38:18 2010 +0000 +++ b/src/lang/english.txt Thu May 20 16:56:23 2010 +0200 @@ -3126,6 +3126,8 @@ 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 delete the whole list. STR_ORDERS_GO_TO_BUTTON :{BLACK}Go To STR_ORDER_GO_TO_NEAREST_DEPOT :Go to nearest depot @@ -3659,6 +3661,7 @@ 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 diff -r 488d4cd37ddd src/order_gui.cpp --- a/src/order_gui.cpp Wed May 19 18:38:18 2010 +0000 +++ b/src/order_gui.cpp Thu May 20 16:56:23 2010 +0200 @@ -41,6 +41,7 @@ ORDER_WIDGET_SCROLLBAR, ORDER_WIDGET_SKIP, ORDER_WIDGET_DELETE, + ORDER_WIDGET_STOP_SHARING, ORDER_WIDGET_NON_STOP, ORDER_WIDGET_GOTO, ORDER_WIDGET_FULL_LOAD, @@ -54,6 +55,7 @@ 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, }; @@ -456,6 +458,10 @@ 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; @@ -662,6 +668,31 @@ } /** + * 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 | (other_shared->index << 16), CO_COPY, 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. * @param i Dummy parameter. @@ -809,9 +840,17 @@ /* skip */ this->SetWidgetDisabledState(ORDER_WIDGET_SKIP, this->vehicle->GetNumOrders() <= 1); - /* delete */ - this->SetWidgetDisabledState(ORDER_WIDGET_DELETE, + /* delete / stop sharing */ + NWidgetStacked *delete_sel = this->GetWidget(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); @@ -1031,6 +1070,10 @@ this->OrderClick_Delete(0); break; + case ORDER_WIDGET_STOP_SHARING: + this->OrderClick_StopSharing(0); + break; + case ORDER_WIDGET_NON_STOP: if (this->GetWidget(widget)->ButtonHit(pt)) { this->OrderClick_Nonstop(-1); @@ -1181,6 +1224,10 @@ case ORDER_WIDGET_DELETE: this->OrderClick_Delete(0); break; + + case ORDER_WIDGET_STOP_SHARING: + this->OrderClick_StopSharing(0); + break; } ResetObjectToPlace(); @@ -1273,7 +1320,7 @@ 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[]. */ @@ -1334,8 +1381,12 @@ 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(), @@ -1400,8 +1451,12 @@ 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),