summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-10 22:32:53 +0000
committerrubidium <rubidium@openttd.org>2010-12-10 22:32:53 +0000
commit8faa97c060e2bec58c8e0dd41f9af40af3a15412 (patch)
treee074dd206eb7c2fa9f536e9211fea0b23985c46f
parentfff4bdecd8bfd9a4609295348689e0255969d7d3 (diff)
downloadopenttd-8faa97c060e2bec58c8e0dd41f9af40af3a15412.tar.xz
(svn r21457) -Feature(tte) [FS#4215]: scroll to the inserted order (thror)
-rw-r--r--src/order_gui.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 2a6dacaf8..6f1a61539 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -751,6 +751,9 @@ public:
virtual void OnInvalidateData(int data)
{
+ VehicleOrderID from = GB(data, 0, 8);
+ VehicleOrderID to = GB(data, 8, 8);
+
switch (data) {
case 0:
/* Autoreplace replaced the vehicle */
@@ -770,14 +773,11 @@ public:
/* Some other order changes */
break;
- default: {
+ default:
/* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
* the order is being created / removed */
if (this->selected_order == -1) break;
- VehicleOrderID from = GB(data, 0, 8);
- VehicleOrderID to = GB(data, 8, 8);
-
if (from == to) break; // no need to change anything
if (from != this->selected_order) {
@@ -800,11 +800,15 @@ public:
/* Moving selected order */
this->selected_order = to;
break;
- }
}
this->vscroll->SetCount(this->vehicle->GetNumOrders() + 1);
this->UpdateButtonState();
+
+ /* Scroll to the new order. */
+ if (from == INVALID_VEH_ORDER_ID && to != INVALID_VEH_ORDER_ID && !this->vscroll->IsVisible(to)) {
+ this->vscroll->ScrollTowards(to);
+ }
}
void UpdateButtonState()