summaryrefslogtreecommitdiff
path: root/src/order_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2010-09-06 14:14:09 +0000
committersmatz <smatz@openttd.org>2010-09-06 14:14:09 +0000
commitfd54943c7a0dfa421eaa403b1cd18f06ccc4c6b9 (patch)
tree28bbfab27e7cc9042011a294c6fa49f5800ea8bd /src/order_gui.cpp
parentd2572f94d229ede57a9d5887c3f5de981d30ab43 (diff)
downloadopenttd-fd54943c7a0dfa421eaa403b1cd18f06ccc4c6b9.tar.xz
(svn r20753) -Feature [FS#3999]: make it possible to select vehicle to clone and vehicle to clone orders from directly from vehicle lists and depot window
Diffstat (limited to 'src/order_gui.cpp')
-rw-r--r--src/order_gui.cpp60
1 files changed, 15 insertions, 45 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index ea19baf10..1c8fa2842 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -497,28 +497,6 @@ private:
return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_ORDER;
}
- bool HandleOrderVehClick(const Vehicle *u)
- {
- if (u->type != this->vehicle->type) return false;
-
- if (!u->IsPrimaryVehicle()) {
- u = u->First();
- if (!u->IsPrimaryVehicle()) return false;
- }
-
- /* 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 */
- if (this->vehicle->GetNumOrders() != 0 && _ctrl_pressed == 0) return false;
-
- if (DoCommandP(this->vehicle->tile, this->vehicle->index | (_ctrl_pressed ? CO_SHARE : CO_COPY) << 30, u->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))) {
- this->selected_order = -1;
- ResetObjectToPlace();
- }
-
- return true;
- }
-
/**
* Handle the click on the goto button.
* @param i Dummy parameter.
@@ -528,8 +506,7 @@ private:
this->SetWidgetDirty(ORDER_WIDGET_GOTO);
this->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
if (this->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
- _place_clicked_vehicle = NULL;
- SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT, this);
+ SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT | HT_VEHICLE, this);
this->goto_type = OPOS_GOTO;
} else {
ResetObjectToPlace();
@@ -1260,10 +1237,6 @@ public:
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
if (this->goto_type == OPOS_GOTO) {
- /* check if we're clicking on a vehicle first.. clone orders in that case. */
- const Vehicle *v = CheckMouseOverVehicle();
- if (v != NULL && this->HandleOrderVehClick(v)) return;
-
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
if (cmd.IsType(OT_NOTHING)) return;
@@ -1274,6 +1247,20 @@ 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
+ * TODO: give a warning message */
+ if (this->vehicle->GetNumOrders() != 0 && _ctrl_pressed == 0) 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))) {
+ this->selected_order = -1;
+ ResetObjectToPlace();
+ }
+ }
+
virtual void OnPlaceObjectAbort()
{
if (this->goto_type == OPOS_CONDITIONAL) {
@@ -1301,23 +1288,6 @@ public:
}
}
- virtual void OnMouseLoop()
- {
- const Vehicle *v = _place_clicked_vehicle;
- /*
- * Check if we clicked on a vehicle
- * and if the GOTO button of this window is pressed
- * This is because of all open order windows WE_MOUSELOOP is called
- * and if you have 3 windows open, and this check is not done
- * the order is copied to the last open window instead of the
- * one where GOTO is enabled
- */
- if (v != NULL && this->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
- _place_clicked_vehicle = NULL;
- this->HandleOrderVehClick(v);
- }
- }
-
virtual void OnMouseDrag(Point pt, int widget)
{
if (this->selected_order != -1 && widget == ORDER_WIDGET_ORDER_LIST) {