Codechange: Use GetScrolled(Row/Item)FromWidget in more places.
In many instances the clicked row position is 'manually' calculated instead of using the GetScrolledRowFromWidget helper function, with variations on checks. Replace with the two helpers where possible.
This commit is contained in:
@@ -215,13 +215,10 @@ struct TimetableWindow : Window {
|
||||
|
||||
int GetOrderFromTimetableWndPt(int y, const Vehicle *v)
|
||||
{
|
||||
uint sel = (y - this->GetWidget<NWidgetBase>(WID_VT_TIMETABLE_PANEL)->pos_y - WidgetDimensions::scaled.framerect.top) / FONT_HEIGHT_NORMAL;
|
||||
|
||||
if (sel >= this->vscroll->GetCapacity()) return INVALID_ORDER;
|
||||
|
||||
sel += this->vscroll->GetPosition();
|
||||
|
||||
return (sel < v->GetNumOrders() * 2u) ? sel : INVALID_ORDER;
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(y, this, WID_VT_TIMETABLE_PANEL, WidgetDimensions::scaled.framerect.top);
|
||||
if (sel == INT_MAX) return INVALID_ORDER;
|
||||
assert(IsInsideBS(sel, 0, v->GetNumOrders() * 2));
|
||||
return sel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user