MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / screenGetMapXyWithZ

Function screenGetMapXyWithZ

src/OpenLoco/src/Ui/Window.cpp:129–154  ·  view source on GitHub ↗

0x0045FCE6 Input: regs.ax: x regs.bx: y regs.bp: z Output: {x: regs.ax, y: regs.bx}

Source from the content-addressed store, hash-verified

127 // Output:
128 // {x: regs.ax, y: regs.bx}
129 std::optional<World::Pos2> screenGetMapXyWithZ(const Point& mouse, const int16_t z)
130 {
131 Window* w = WindowManager::findAt(mouse.x, mouse.y);
132 if (w == nullptr)
133 {
134 return std::nullopt;
135 }
136
137 Viewport* vp = w->viewports[0];
138 if (vp == nullptr)
139 {
140 return std::nullopt;
141 }
142
143 if (vp->containsUi(mouse))
144 {
145 viewport_pos vpos = vp->screenToViewport(mouse);
146 World::Pos2 position = viewportCoordToMapCoord(vpos.x, vpos.y, z, WindowManager::getCurrentRotation());
147 if (World::validCoords(position))
148 {
149 return position;
150 }
151 }
152
153 return std::nullopt;
154 }
155
156 // 0x0045FD41
157 // Input:

Callers 2

tryMakeRoadJunctionAtLocFunction · 0.85

Calls 6

findAtFunction · 0.85
viewportCoordToMapCoordFunction · 0.85
getCurrentRotationFunction · 0.85
validCoordsFunction · 0.85
containsUiMethod · 0.80
screenToViewportMethod · 0.80

Tested by

no test coverage detected