(svn r16080) -Codechange: Introducing a constant for order-list line height.

This commit is contained in:
alberth 2009-04-18 14:12:30 +00:00
parent 06a8a8ce8d
commit 2fa61c6af7

View File

@ -377,6 +377,8 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
struct OrdersWindow : public Window { struct OrdersWindow : public Window {
private: 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? */ /** Under what reason are we using the PlaceObject functionality? */
enum OrderPlaceObjectState { enum OrderPlaceObjectState {
OPOS_GOTO, OPOS_GOTO,
@ -410,12 +412,7 @@ private:
*/ */
int GetOrderFromPt(int y) int GetOrderFromPt(int y)
{ {
/* int sel = (y - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / ORDER_LIST_LINE_HEIGHT; // Selected line in the ORDER_WIDGET_ORDER_LIST panel.
* 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;
if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER; if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER;
@ -629,7 +626,7 @@ public:
{ {
this->owner = v->owner; this->owner = v->owner;
this->vscroll.cap = 6; this->vscroll.cap = 6;
this->resize.step_height = 10; this->resize.step_height = ORDER_LIST_LINE_HEIGHT;
this->selected_order = -1; this->selected_order = -1;
this->vehicle = v; this->vehicle = v;
@ -829,7 +826,7 @@ public:
if (i - this->vscroll.pos >= this->vscroll.cap) break; 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); 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++; i++;
order = order->next; order = order->next;
@ -1138,7 +1135,7 @@ public:
virtual void OnResize(Point delta) virtual void OnResize(Point delta)
{ {
/* Update the scroll + matrix */ /* 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() virtual void OnTimeout()