Change: Use scaled WidgetDimensions.

This commit is contained in:
Peter Nelson
2022-09-23 09:36:22 +01:00
committed by PeterN
parent 61da064b82
commit 890b2666d3
60 changed files with 881 additions and 864 deletions

View File

@@ -550,7 +550,7 @@ private:
VehicleOrderID GetOrderFromPt(int y)
{
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
uint sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
uint sel = (y - nwid->pos_y - WidgetDimensions::scaled.framerect.top) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
if (sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
@@ -1074,10 +1074,10 @@ public:
{
if (widget != WID_O_ORDER_LIST) return;
Rect ir = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMERECT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMERECT_BOTTOM);
Rect ir = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
bool rtl = _current_text_dir == TD_RTL;
SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + WidgetDimensions::scaled.hsep_normal;
int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
int y = ir.top;
@@ -1093,7 +1093,7 @@ public:
if (i != this->selected_order && i == this->order_over) {
/* Highlight dragged order destination. */
int top = (this->order_over < this->selected_order ? y : y + line_height) - WD_FRAMERECT_TOP;
int top = (this->order_over < this->selected_order ? y : y + line_height) - WidgetDimensions::scaled.framerect.top;
int bottom = std::min(top + 2, ir.bottom);
top = std::max(top - 3, ir.top);
GfxFillRect(ir.left, top, ir.right, bottom, _colour_gradient[COLOUR_GREY][7]);