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

Function ScrollMainWindowTo

src/smallmap_gui.cpp:2078–2092  ·  view source on GitHub ↗

* Scrolls the main window to given coordinates. * @param x x coordinate * @param y y coordinate * @param z z coordinate; -1 to scroll to terrain height * @param instant scroll instantly (meaningful only when smooth_scrolling is active) * @return did the viewport position change? */

Source from the content-addressed store, hash-verified

2076 * @return did the viewport position change?
2077 */
2078bool ScrollMainWindowTo(int x, int y, int z, bool instant)
2079{
2080 bool res = ScrollWindowTo(x, y, z, GetMainWindow(), instant);
2081
2082 /* If a user scrolls to a tile (via what way what so ever) and already is on
2083 * that tile (e.g.: pressed twice), move the smallmap to that location,
2084 * so you directly see where you are on the smallmap. */
2085
2086 if (res) return res;
2087
2088 SmallMapWindow *w = dynamic_cast<SmallMapWindow*>(FindWindowById(WC_SMALLMAP, 0));
2089 if (w != nullptr) w->SmallMapCenterOnCurrentPos();
2090
2091 return res;
2092}
2093
2094/**
2095 * Determine the middle of a station in the smallmap window.

Callers 6

HandleViewportScrollFunction · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
StopGlobalFollowVehicleFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
OnHotkeyMethod · 0.85

Calls 4

ScrollWindowToFunction · 0.85
GetMainWindowFunction · 0.85
FindWindowByIdFunction · 0.85

Tested by

no test coverage detected