summaryrefslogtreecommitdiff
path: root/src/vehicle_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/vehicle_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/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index ab71d06c7..ee2c448ac 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -39,6 +39,7 @@
#include "company_base.h"
#include "engine_func.h"
#include "station_base.h"
+#include "tilehighlight_func.h"
#include "table/strings.h"
@@ -1269,7 +1270,7 @@ public:
if (id_v >= this->vehicles.Length()) return; // click out of list bound
const Vehicle *v = this->vehicles[id_v];
- ShowVehicleViewWindow(v);
+ if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
break;
}
@@ -2344,6 +2345,23 @@ void ShowVehicleViewWindow(const Vehicle *v)
AllocateWindowDescFront<VehicleViewWindow>((v->type == VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->index);
}
+/**
+ * Dispatch a "vehicle selected" event if any window waits for it.
+ * @param v selected vehicle;
+ * @return did any window accept vehicle selection?
+ */
+bool VehicleClicked(const Vehicle *v)
+{
+ assert(v != NULL);
+ if (!(_thd.place_mode & HT_VEHICLE)) return false;
+
+ v = v->First();
+ if (!v->IsPrimaryVehicle()) return false;
+
+ FindWindowById(_thd.window_class, _thd.window_number)->OnVehicleSelect(v);
+ return true;
+}
+
void StopGlobalFollowVehicle(const Vehicle *v)
{
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);