summaryrefslogtreecommitdiff
path: root/src/group_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-01-08 21:16:19 +0000
committerfrosch <frosch@openttd.org>2009-01-08 21:16:19 +0000
commitb522f73ba8f6c53f75639fc4f5d6b2a078827513 (patch)
tree4254262254ea6b50d5e2e525886c9761cf77d415 /src/group_gui.cpp
parent17a9bab1422401e3d7f2c29ed50054ff3bcf3b24 (diff)
downloadopenttd-b522f73ba8f6c53f75639fc4f5d6b2a078827513.tar.xz
(svn r14925) -Fix [FS#2500]: Abort dragging of vehicles in the group window when they are deleted.
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r--src/group_gui.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index a59b7830c..7e5996c13 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -694,6 +694,16 @@ public:
this->vehicle_sel = INVALID_VEHICLE;
this->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
}
+
+ /**
+ * Tests whether a given vehicle is selected in the window, and unselects it if necessary.
+ * Called when the vehicle is deleted.
+ * @param vehicle Vehicle that is going to be deleted
+ */
+ void UnselectVehicle(VehicleID vehicle)
+ {
+ if (this->vehicle_sel == vehicle) ResetObjectToPlace();
+ }
};
@@ -712,3 +722,22 @@ void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | company;
AllocateWindowDescFront<VehicleGroupWindow>(&_group_desc, num);
}
+
+/**
+ * Removes the highlight of a vehicle in a group window
+ * @param *v Vehicle to remove all highlights from
+ */
+void DeleteGroupHighlightOfVehicle(const Vehicle *v)
+{
+ VehicleGroupWindow *w;
+
+ /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any group windows either
+ * If that is the case, we can skip looping though the windows and save time
+ */
+ if (_special_mouse_mode != WSM_DRAGDROP) return;
+
+ VehicleType vehicle_type = v->type;
+ w = dynamic_cast<VehicleGroupWindow *>(FindWindowById(GetWindowClassForVehicleType(vehicle_type), (vehicle_type << 11) | VLW_GROUP_LIST | v->owner));
+ if (w != NULL) w->UnselectVehicle(v->index);
+}
+