summaryrefslogtreecommitdiff
path: root/src/order_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-04-18 14:12:30 +0000
committeralberth <alberth@openttd.org>2009-04-18 14:12:30 +0000
commit2fa61c6af79c33021d8e77f4bb58bda34b483551 (patch)
tree370f42843e3066e331bd05a3736d4800c9f57c8b /src/order_gui.cpp
parent06a8a8ce8d32f8a71bd595aee3e7dc84ee2e9902 (diff)
downloadopenttd-2fa61c6af79c33021d8e77f4bb58bda34b483551.tar.xz
(svn r16080) -Codechange: Introducing a constant for order-list line height.
Diffstat (limited to 'src/order_gui.cpp')
-rw-r--r--src/order_gui.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 28e67443a..51a41f6bc 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()