summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-03-13 21:33:02 +0000
committerfrosch <frosch@openttd.org>2011-03-13 21:33:02 +0000
commitf051a81b4e5064f6b5c1d00f4a7d0ae38f768e35 (patch)
treed46d4b664842c0baa010d593bb864e1e9eca1702 /src/vehicle_gui.cpp
parent0ff4f31723c22a53dec3c44de64b0385355e972d (diff)
downloadopenttd-f051a81b4e5064f6b5c1d00f4a7d0ae38f768e35.tar.xz
(svn r22244) -Codechange: Make vehicle windows handle command-/GUI-scope invalidations themself (from autoreplace and refitting).
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 26b8666a3..a20e44a67 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -690,14 +690,8 @@ struct RefitWindow : public Window {
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
- if (!gui_scope) return;
switch (data) {
- case -666:
- /* Autoreplace replaced the vehicle.
- * Nothing to do though for this window.
- * This case is _not_ called asynchronously. Get out directly, rest can be done later */
- break;
-
+ case -666: // Autoreplace replaced the vehicle; selected_vehicle became invalid.
case 0: { // The consist has changed; rebuild the entire list.
/* Clear the selection. */
Vehicle *v = Vehicle::Get(this->window_number);
@@ -707,6 +701,7 @@ struct RefitWindow : public Window {
}
case 2: { // The vehicle selection has changed; rebuild the entire list.
+ if (!gui_scope) break;
this->BuildRefitList();
/* The vehicle width has changed too. */
@@ -732,6 +727,7 @@ struct RefitWindow : public Window {
}
case 1: // A new cargo has been selected.
+ if (!gui_scope) break;
this->cargo = GetRefitOption();
break;
}
@@ -1132,8 +1128,8 @@ static inline void ChangeVehicleWindow(WindowClass window_class, VehicleID from_
_thd.window_number = to_index;
}
- /* Notify the window immediately, without scheduling. */
- w->InvalidateData(-666);
+ /* Notify the window. */
+ w->InvalidateData(-666, false);
}
}
@@ -1806,13 +1802,12 @@ struct VehicleDetailsWindow : Window {
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
- if (!gui_scope) return;
if (data == -666) {
/* Autoreplace replaced the vehicle.
- * Nothing to do for this window though.
- * This case is _not_ called asynchronously. Get out directly, rest can be done later */
+ * Nothing to do for this window. */
return;
}
+ if (!gui_scope) return;
const Vehicle *v = Vehicle::Get(this->window_number);
if (v->type == VEH_ROAD) {
const NWidgetBase *nwid_info = this->GetWidget<NWidgetBase>(VLD_WIDGET_MIDDLE_DETAILS);
@@ -2621,11 +2616,9 @@ public:
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
- if (!gui_scope) return;
if (data == -666) {
/* Autoreplace replaced the vehicle.
- * Nothing to do for this window though.
- * This case is _not_ called asynchronously. Get out directly, rest can be done later */
+ * Nothing to do for this window. */
return;
}
}