summaryrefslogtreecommitdiff
path: root/src/order_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-02 17:54:40 +0000
committerrubidium <rubidium@openttd.org>2009-09-02 17:54:40 +0000
commita8d768cf6ebb4fb11bae9f0dcf78e115b7f7db1a (patch)
tree3dc889ce298da685d49d89a871196a7db989f25c /src/order_gui.cpp
parent1f5268a1d29d1d15cdd8588834654f328d33296c (diff)
downloadopenttd-a8d768cf6ebb4fb11bae9f0dcf78e115b7f7db1a.tar.xz
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
Diffstat (limited to 'src/order_gui.cpp')
-rw-r--r--src/order_gui.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index ebd40f050..ddbcee345 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -661,6 +661,8 @@ public:
this->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
}
this->FindWindowPlacementAndResize(desc);
+
+ this->OnInvalidateData(-2);
}
virtual void OnInvalidateData(int data)
@@ -680,6 +682,10 @@ public:
this->selected_order = -1;
break;
+ case -2:
+ /* Some other order changes */
+ break;
+
default: {
/* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
* the order is being created / removed */
@@ -711,14 +717,14 @@ public:
this->selected_order = to;
} break;
}
+
+ this->vscroll.SetCount(this->vehicle->GetNumOrders() + 1);
+ this->UpdateButtonState();
}
- virtual void OnPaint()
+ void UpdateButtonState()
{
bool shared_orders = this->vehicle->IsOrderListShared();
-
- this->vscroll.SetCount(this->vehicle->GetNumOrders() + 1);
-
int sel = OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel);
@@ -808,10 +814,6 @@ public:
OrderConditionVariable ocv = order->GetConditionVariable();
this->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
this->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
-
- uint value = order->GetConditionValue();
- if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
- SetDParam(1, value);
} break;
default: // every other orders
@@ -821,10 +823,31 @@ public:
this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
this->DisableWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
this->DisableWidget(ORDER_WIDGET_UNLOAD);
+ break;
}
}
+ this->SetDirty();
+ }
+
+ virtual void OnPaint()
+ {
+ bool shared_orders = this->vehicle->IsOrderListShared();
+ int sel = OrderGetSel();
+ const Order *order = this->vehicle->GetOrder(sel);
+
+ if (this->vehicle->owner == _local_company) {
+ /* Set the strings for the dropdown boxes. */
+ this->widget[ORDER_WIDGET_COND_VARIABLE].data = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()];
+ this->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
+ }
+
SetDParam(0, this->vehicle->index);
+ if (order != NULL && order->IsType(OT_CONDITIONAL)) {
+ uint value = order->GetConditionValue();
+ if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
+ SetDParam(1, value);
+ }
this->DrawWidgets();
int y = 15;
@@ -907,7 +930,7 @@ public:
}
}
- this->SetDirty();
+ this->UpdateButtonState();
} break;
case ORDER_WIDGET_SKIP: