From 54908db5ef6f1779d2268889705ffe2e2f4138c6 Mon Sep 17 00:00:00 2001 From: planetmaker Date: Sat, 11 Dec 2010 13:38:35 +0000 Subject: [PATCH] (svn r21464) -Add: Explicitly make 'shared orders' an option in the orders menu --- src/lang/english.txt | 3 ++- src/order_gui.cpp | 31 +++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index a4213a529e..2732d7452c 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3223,7 +3223,8 @@ STR_ORDERS_GO_TO_BUTTON :{BLACK}Go To STR_ORDER_GO_TO_NEAREST_DEPOT :Go to nearest depot STR_ORDER_GO_TO_NEAREST_HANGAR :Go to nearest hangar STR_ORDER_CONDITIONAL :Conditional order jump -STR_ORDERS_GO_TO_TOOLTIP :{BLACK}Insert a new order before the highlighted order, or add to end of list. Ctrl makes station orders 'full load any cargo', waypoint orders 'non-stop' and depot orders 'service' +STR_ORDER_SHARE :Share orders +STR_ORDERS_GO_TO_TOOLTIP :{BLACK}Insert a new order before the highlighted order, or add to end of list. Ctrl makes station orders 'full load any cargo', waypoint orders 'non-stop' and depot orders 'service'. 'Share orders' lets this vehicle share orders with the selected vehicle. STR_ORDERS_GO_TO_DROPDOWN_TOOLTIP :{BLACK}Insert an advanced order STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP :{BLACK}Show all vehicles that share this schedule diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 748d9e395b..149ffc3f4e 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -123,6 +123,7 @@ static const StringID _order_goto_dropdown[] = { STR_ORDER_GO_TO, STR_ORDER_GO_TO_NEAREST_DEPOT, STR_ORDER_CONDITIONAL, + STR_ORDER_SHARE, INVALID_STRING_ID }; @@ -130,6 +131,7 @@ static const StringID _order_goto_dropdown_aircraft[] = { STR_ORDER_GO_TO, STR_ORDER_GO_TO_NEAREST_HANGAR, STR_ORDER_CONDITIONAL, + STR_ORDER_SHARE, INVALID_STRING_ID }; @@ -438,6 +440,7 @@ private: enum OrderPlaceObjectState { OPOS_GOTO, OPOS_CONDITIONAL, + OPOS_SHARE, }; /** Displayed planes of the #NWID_SELECTION widgets. */ @@ -581,12 +584,24 @@ private: */ void OrderClick_Conditional(int i) { - this->SetWidgetDirty(ORDER_WIDGET_GOTO); this->LowerWidget(ORDER_WIDGET_GOTO); + this->SetWidgetDirty(ORDER_WIDGET_GOTO); SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT, this); this->goto_type = OPOS_CONDITIONAL; } + /** + * Handle the click on the share button. + * @param i Dummy parameter. + */ + void OrderClick_Share(int i) + { + this->LowerWidget(ORDER_WIDGET_GOTO); + this->SetWidgetDirty(ORDER_WIDGET_GOTO); + SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT | HT_VEHICLE, this); + this->goto_type = OPOS_SHARE; + } + /** * Handle the click on the unload button. */ @@ -1232,6 +1247,7 @@ public: case 0: this->OrderClick_Goto(0); break; case 1: this->OrderClick_NearestDepot(0); break; case 2: this->OrderClick_Conditional(0); break; + case 3: this->OrderClick_Share(0); break; default: NOT_REACHED(); } break; @@ -1306,13 +1322,16 @@ public: virtual void OnVehicleSelect(const Vehicle *v) { - /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet - * obviously if you press CTRL on a non-empty orders vehicle you know what you are doing + /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet. + * We disallow copying orders of other vehicles if we already have at least one order entry + * ourself as it easily copies orders of vehicles within a station when we mean the station. + * Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing * TODO: give a warning message */ - if (this->vehicle->GetNumOrders() != 0 && _ctrl_pressed == 0) return; + bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE; + if (this->vehicle->GetNumOrders() != 0 && !share_order) return; - if (DoCommandP(this->vehicle->tile, this->vehicle->index | (_ctrl_pressed ? CO_SHARE : CO_COPY) << 30, v->index, - _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { + if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index, + share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { this->selected_order = -1; ResetObjectToPlace(); }