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

Function GetTileFromScreenXY

src/viewport.cpp:445–454  ·  view source on GitHub ↗

When used for zooming, check area below current coordinates (x,y) * and return the tile of the zoomed out/in position (zoom_x, zoom_y) * when you just want the tile, make x = zoom_x and y = zoom_y */

Source from the content-addressed store, hash-verified

443 * and return the tile of the zoomed out/in position (zoom_x, zoom_y)
444 * when you just want the tile, make x = zoom_x and y = zoom_y */
445static Point GetTileFromScreenXY(int x, int y, int zoom_x, int zoom_y)
446{
447 if (Window *w = FindWindowFromPt(x, y); w != nullptr) {
448 if (Viewport *vp = IsPtInWindowViewport(w, x, y); vp != nullptr) {
449 return TranslateXYToTileCoord(*vp, zoom_x, zoom_y);
450 }
451 }
452
453 return {-1, -1};
454}
455
456Point GetTileBelowCursor()
457{

Callers 2

GetTileBelowCursorFunction · 0.85
GetTileZoomCenterWindowFunction · 0.85

Calls 3

FindWindowFromPtFunction · 0.85
IsPtInWindowViewportFunction · 0.85
TranslateXYToTileCoordFunction · 0.85

Tested by

no test coverage detected