Changeset - r16721:e05d2c73492b
[Not reviewed]
master
0 2 0
planetmaker - 14 years ago 2010-12-11 13:38:35
planetmaker@openttd.org
(svn r21464) -Add: Explicitly make 'shared orders' an option in the orders menu
2 files changed with 27 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -3214,25 +3214,26 @@ STR_ORDER_CONDITIONAL_VALUE_CAPT        
 
STR_ORDERS_SKIP_BUTTON                                          :{BLACK}Skip
 
STR_ORDERS_SKIP_TOOLTIP                                         :{BLACK}Skip the current order, and start the next. Ctrl+Click skips to the selected order
 

	
 
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
 
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
 

	
 
# String parts to build the order string
 
STR_ORDER_GO_TO_WAYPOINT                                        :Go via {WAYPOINT}
 
STR_ORDER_GO_NON_STOP_TO_WAYPOINT                               :Go non-stop via {WAYPOINT}
 

	
 
STR_ORDER_SERVICE_AT                                            :Service at
 
STR_ORDER_SERVICE_NON_STOP_AT                                   :Service non-stop at
 

	
 
STR_ORDER_NEAREST_DEPOT                                         :the nearest
src/order_gui.cpp
Show inline comments
 
@@ -114,31 +114,33 @@ static const StringID _order_unload_drow
 
	STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
 
	STR_ORDER_DROP_UNLOAD,
 
	STR_ORDER_DROP_TRANSFER,
 
	STR_EMPTY,
 
	STR_ORDER_DROP_NO_UNLOADING,
 
	INVALID_STRING_ID
 
};
 

	
 
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
 
};
 

	
 
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
 
};
 

	
 
static const StringID _order_conditional_variable[] = {
 
	STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE,
 
	STR_ORDER_CONDITIONAL_RELIABILITY,
 
	STR_ORDER_CONDITIONAL_MAX_SPEED,
 
	STR_ORDER_CONDITIONAL_AGE,
 
	STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
 
	STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
 
	INVALID_STRING_ID,
 
};
 
@@ -429,24 +431,25 @@ static Order GetOrderCmdFromTile(const V
 
 * |      SKIP       |     DELETE      |      GOTO       |
 
 * +-----------------+-----------------+-----------------+
 
 * \endverbatim
 
 *
 
 * For vehicles of other companies, both button rows are not displayed.
 
 */
 
struct OrdersWindow : public Window {
 
private:
 
	/** Under what reason are we using the PlaceObject functionality? */
 
	enum OrderPlaceObjectState {
 
		OPOS_GOTO,
 
		OPOS_CONDITIONAL,
 
		OPOS_SHARE,
 
	};
 

	
 
	/** Displayed planes of the #NWID_SELECTION widgets. */
 
	enum DisplayPane {
 
		/* ORDER_WIDGET_SEL_TOP_LEFT */
 
		DP_LEFT_NONSTOP    = 0, ///< Display 'non stop' in the left button of the top row of the train/rv order window.
 
		DP_LEFT_CONDVAR    = 1, ///< Display condition variable in the left button of the top row of the train/rv order window.
 

	
 
		/* ORDER_WIDGET_SEL_TOP_MIDDLE */
 
		DP_MIDDLE_LOAD     = 0, ///< Display 'load' in the middle button of the top row of the train/rv order window.
 
		DP_MIDDLE_REFIT    = 1, ///< Display 'refit' in the middle button of the top row of the train/rv order window.
 
		DP_MIDDLE_COMPARE  = 2, ///< Display compare operator in the middle button of the top row of the train/rv order window.
 
@@ -572,31 +575,43 @@ private:
 
				_settings_client.gui.new_nonstop && (this->vehicle->type == VEH_TRAIN || this->vehicle->type == VEH_ROAD) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
 

	
 
		DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
 
	}
 

	
 
	/**
 
	 * Handle the click on the conditional order button.
 
	 * @param i Dummy parameter.
 
	 */
 
	void OrderClick_Conditional(int i)
 
	{
 
		this->LowerWidget(ORDER_WIDGET_GOTO);
 
		this->SetWidgetDirty(ORDER_WIDGET_GOTO);
 
		this->LowerWidget(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.
 
	 */
 
	void OrderClick_Unload(int unload_type)
 
	{
 
		VehicleOrderID sel_ord = this->OrderGetSel();
 
		const Order *order = this->vehicle->GetOrder(sel_ord);
 

	
 
		if (order == NULL || order->GetUnloadType() == unload_type) return;
 

	
 
		if (unload_type < 0) {
 
			unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
 
		}
 
@@ -1223,24 +1238,25 @@ public:
 
				this->OrderClick_FullLoad(index);
 
				break;
 

	
 
			case ORDER_WIDGET_UNLOAD:
 
				this->OrderClick_Unload(index);
 
				break;
 

	
 
			case ORDER_WIDGET_GOTO:
 
				switch (index) {
 
					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;
 

	
 
			case ORDER_WIDGET_SERVICE:
 
				this->OrderClick_Service(index);
 
				break;
 

	
 
			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));
 
				break;
 

	
 
@@ -1297,31 +1313,34 @@ public:
 
			const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
 
			if (cmd.IsType(OT_NOTHING)) return;
 

	
 
			if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
 
				/* With quick goto the Go To button stays active */
 
				if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
 
			}
 
		}
 
	}
 

	
 
	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();
 
		}
 
	}
 

	
 
	virtual void OnPlaceObjectAbort()
 
	{
 
		if (this->goto_type == OPOS_CONDITIONAL) {
 
			this->goto_type = OPOS_GOTO;
 
			NWidgetBase *nwid = this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST);
 
			if (IsInsideBS(_cursor.pos.x, this->left + nwid->pos_x, nwid->current_x) && IsInsideBS(_cursor.pos.y, this->top + nwid->pos_y, nwid->current_y)) {
 
				int order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
0 comments (0 inline, 0 general)