MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetOrderFromPt

Method GetOrderFromPt

src/order_gui.cpp:564–571  ·  view source on GitHub ↗

* Calculate the selected order. * The calculation is based on the relative (to the window) y click position and * the position of the scrollbar. * * @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_VEH_ORDER_ID. */

Source from the content-addressed store, hash-verified

562 * @return The selected order if the order is valid, else return \c INVALID_VEH_ORDER_ID.
563 */
564 VehicleOrderID GetOrderFromPt(int y)
565 {
566 int32_t sel = this->vscroll->GetScrolledRowFromWidget(y, this, WID_O_ORDER_LIST, WidgetDimensions::scaled.framerect.top);
567 if (sel == INT32_MAX) return INVALID_VEH_ORDER_ID;
568 /* One past the orders is the 'End of Orders' line. */
569 assert(IsInsideBS(sel, 0, vehicle->GetNumOrders() + 1));
570 return sel;
571 }
572
573 /**
574 * Handle the click on the goto button.

Callers 3

OnClickMethod · 0.95
OnDragDropMethod · 0.95
OnMouseDragMethod · 0.95

Calls 3

IsInsideBSFunction · 0.85
GetNumOrdersMethod · 0.45

Tested by

no test coverage detected