summaryrefslogtreecommitdiff
path: root/src/group_gui.cpp
diff options
context:
space:
mode:
authorstormcone <48624099+stormcone@users.noreply.github.com>2019-05-10 19:49:50 +0200
committerCharles Pigott <charlespigott@googlemail.com>2019-12-23 18:04:10 +0000
commitcc1d72c3a370f3c9a13e8722f8d69f5735b95285 (patch)
treea0ed6ff8fbd7f8d4e537d1f20dc7409a2336b483 /src/group_gui.cpp
parenta363933d0899f6e79bf04eb38097ce1170f02bee (diff)
downloadopenttd-cc1d72c3a370f3c9a13e8722f8d69f5735b95285.tar.xz
Feature: Control + click on the vehicle details button in the vehicle view window opens the vehicle group window, then selects and scrolls to the vehicle's group.
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r--src/group_gui.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 8d7c042d2..842e3fbb0 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -1046,18 +1046,31 @@ static WindowDesc _train_group_desc(
* Show the group window for the given company and vehicle type.
* @param company The company to show the window for.
* @param vehicle_type The type of vehicle to show it for.
+ * @param group The group to be selected. Defaults to INVALID_GROUP.
+ * @param need_existing_window Whether the existing window is needed. Defaults to false.
*/
-void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
+void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group = INVALID_GROUP, bool need_existing_window = false)
{
if (!Company::IsValidID(company)) return;
- WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
+ const WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
+ VehicleGroupWindow *w;
if (vehicle_type == VEH_TRAIN) {
- AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num);
+ w = AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num, need_existing_window);
} else {
_other_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
- AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num);
+ w = AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num, need_existing_window);
}
+ if (w != nullptr) w->SelectGroup(group);
+}
+
+/**
+ * Show the group window for the given vehicle.
+ * @param v The vehicle to show the window for.
+ */
+void ShowCompanyGroupForVehicle(const Vehicle *v)
+{
+ ShowCompanyGroup(v->owner, v->type, v->group_id, true);
}
/**