From 2fa61c6af79c33021d8e77f4bb58bda34b483551 Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 18 Apr 2009 14:12:30 +0000 Subject: [PATCH] (svn r16080) -Codechange: Introducing a constant for order-list line height. --- src/order_gui.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 28e67443a8..51a41f6bc9 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -377,6 +377,8 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) struct OrdersWindow : public Window { private: + static const int ORDER_LIST_LINE_HEIGHT = 10; ///< Height of a line in the ORDER_WIDGET_ORDER_LIST panel. + /** Under what reason are we using the PlaceObject functionality? */ enum OrderPlaceObjectState { OPOS_GOTO, @@ -410,12 +412,7 @@ private: */ int GetOrderFromPt(int y) { - /* - * Calculation description: - * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line) - * 10 = order text hight - */ - int sel = (y - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / 10; + int sel = (y - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / ORDER_LIST_LINE_HEIGHT; // Selected line in the ORDER_WIDGET_ORDER_LIST panel. if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER; @@ -629,7 +626,7 @@ public: { this->owner = v->owner; this->vscroll.cap = 6; - this->resize.step_height = 10; + this->resize.step_height = ORDER_LIST_LINE_HEIGHT; this->selected_order = -1; this->vehicle = v; @@ -829,7 +826,7 @@ public: if (i - this->vscroll.pos >= this->vscroll.cap) break; DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, this->widget[ORDER_WIDGET_ORDER_LIST].right - 4); - y += 10; + y += ORDER_LIST_LINE_HEIGHT; i++; order = order->next; @@ -1138,7 +1135,7 @@ public: virtual void OnResize(Point delta) { /* Update the scroll + matrix */ - this->vscroll.cap = (this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top) / 10; + this->vscroll.cap = (this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top) / ORDER_LIST_LINE_HEIGHT; } virtual void OnTimeout()