diff options
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r-- | src/vehicle_gui.cpp | 20 |
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); |