MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / FindWidgetFromPoint

Method FindWidgetFromPoint

src/openrct2-ui/WindowManager.cpp:1198–1229  ·  view source on GitHub ↗

* * rct2: 0x006EA594 * returns widget_index if found, -1 otherwise */

Source from the content-addressed store, hash-verified

1196 * returns widget_index if found, -1 otherwise
1197 */
1198 WidgetIndex FindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords) override
1199 {
1200 // Invalidate the window
1201 w.onPrepareDraw();
1202
1203 // Find the widget at point x, y
1204 WidgetIndex widget_index = kWidgetIndexNull;
1205 for (auto i = 0u; i < w.widgets.size(); i++)
1206 {
1207 const auto& widget = w.widgets[i];
1208
1209 if (widget.type != WidgetType::empty && widget.isVisible())
1210 {
1211 if (screenCoords.x >= w.windowPos.x + widget.left && screenCoords.x <= w.windowPos.x + widget.right
1212 && screenCoords.y >= w.windowPos.y + widget.top && screenCoords.y <= w.windowPos.y + widget.bottom)
1213 {
1214 widget_index = i;
1215 }
1216 }
1217 }
1218
1219 // Return next widget if a dropdown
1220 if (widget_index != kWidgetIndexNull)
1221 {
1222 const auto& widget = w.widgets[widget_index];
1223 if (widget.type == WidgetType::dropdownMenu)
1224 widget_index++;
1225 }
1226
1227 // Return the widget index
1228 return widget_index;
1229 }
1230
1231 /**
1232 * Invalidates the specified window.

Callers 7

WindowAllWheelInputFunction · 0.45
onPeriodicUpdateMethod · 0.45
onUpdateMethod · 0.45
LandToolDragMethod · 0.45
GetResearchItemAtMethod · 0.45
GameHandleInputMouseFunction · 0.45
ProcessMouseOverFunction · 0.45

Calls 3

onPrepareDrawMethod · 0.45
sizeMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected