From fd54943c7a0dfa421eaa403b1cd18f06ccc4c6b9 Mon Sep 17 00:00:00 2001 From: smatz Date: Mon, 6 Sep 2010 14:14:09 +0000 Subject: (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 --- src/vehicle_gui.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/vehicle_gui.cpp') 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((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); -- cgit v1.2.3-54-g00ecf