Changeset - r14048:b6b28d2ae582
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-12-22 11:22:07
alberth@openttd.org
(svn r18601) -Codechange: Use resize step of the order list panel widget for order line calculations.
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/order_gui.cpp
Show inline comments
 
@@ -488,13 +488,14 @@ private:
 
	 *
 
	 * @param y Y-value of the click relative to the window origin
 
	 * @return The selected order if the order is valid, else return \c INVALID_ORDER.
 
	 */
 
	int GetOrderFromPt(int y)
 
	{
 
		int sel = (y - this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height; // Selected line in the ORDER_WIDGET_ORDER_LIST panel.
 
		NWidgetBase *nwid = this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST);
 
		int sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the ORDER_WIDGET_ORDER_LIST panel.
 

	
 
		if ((uint)sel >= this->vscroll.GetCapacity()) return INVALID_ORDER;
 

	
 
		sel += this->vscroll.GetPosition();
 

	
 
		return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_ORDER;
 
@@ -940,22 +941,23 @@ public:
 
		bool rtl = _dynlang.text_dir == TD_RTL;
 
		SetDParam(0, 99);
 
		int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
 
		int middle = rtl ? r.right - WD_FRAMETEXT_RIGHT - index_column_width : r.left + WD_FRAMETEXT_LEFT + index_column_width;
 

	
 
		int y = r.top + WD_FRAMERECT_TOP;
 
		int line_height = this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST)->resize_y;
 

	
 
		int i = this->vscroll.GetPosition();
 
		const Order *order = this->vehicle->GetOrder(i);
 
		StringID str;
 
		while (order != NULL) {
 
			/* Don't draw anything if it extends past the end of the window. */
 
			if (!this->vscroll.IsVisible(i)) break;
 

	
 
			DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, r.left + WD_FRAMETEXT_LEFT, middle, r.right - WD_FRAMETEXT_RIGHT);
 
			y += this->resize.step_height;
 
			y += line_height;
 

	
 
			i++;
 
			order = order->next;
 
		}
 

	
 
		if (this->vscroll.IsVisible(i)) {
0 comments (0 inline, 0 general)