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

Function WindowScrollToLocation

src/openrct2/interface/Window.cpp:340–421  ·  view source on GitHub ↗

* * rct2: 0x006E7C9C * @param w (esi) * @param x (eax) * @param y (ecx) * @param z (edx) */

Source from the content-addressed store, hash-verified

338 * @param z (edx)
339 */
340 void WindowScrollToLocation(WindowBase& w, const CoordsXYZ& coords)
341 {
342 WindowUnfollowSprite(w);
343
344 if (w.viewport == nullptr)
345 {
346 return;
347 }
348
349 int16_t height = TileElementHeight(coords);
350 if (coords.z < height - 16)
351 {
352 if (!(w.viewport->flags & VIEWPORT_FLAG_UNDERGROUND_INSIDE))
353 {
354 w.viewport->flags |= VIEWPORT_FLAG_UNDERGROUND_INSIDE;
355 w.invalidate();
356 }
357 }
358 else
359 {
360 if (w.viewport->flags & VIEWPORT_FLAG_UNDERGROUND_INSIDE)
361 {
362 w.viewport->flags &= ~VIEWPORT_FLAG_UNDERGROUND_INSIDE;
363 w.invalidate();
364 }
365 }
366
367 auto screenCoords = Translate3DTo2DWithZ(w.viewport->rotation, coords);
368
369 int32_t i = 0;
370 if (gLegacyScene != LegacyScene::titleSequence)
371 {
372 bool found = false;
373 while (!found)
374 {
375 auto x2 = w.viewport->pos.x + static_cast<int32_t>(w.viewport->width * kWindowScrollLocations[i][0]);
376 auto y2 = w.viewport->pos.y + static_cast<int32_t>(w.viewport->height * kWindowScrollLocations[i][1]);
377
378 auto it = WindowGetIterator(&w);
379 for (; it != gWindowList.end(); it++)
380 {
381 if ((*it)->flags.has(WindowFlag::dead))
382 continue;
383
384 auto w2 = it->get();
385 auto x1 = w2->windowPos.x - 10;
386 auto y1 = w2->windowPos.y - 10;
387 if (x2 >= x1 && x2 <= w2->width + x1 + 20)
388 {
389 if (y2 >= y1 && y2 <= w2->height + y1 + 20)
390 {
391 // window is covering this area, try the next one
392 i++;
393 found = false;
394 break;
395 }
396 }
397 }

Callers 12

ReplayCommandsMethod · 0.85
setViewportLocationMethod · 0.85
RideScrollToTrackErrorFunction · 0.85
RideConstructionStartFunction · 0.85
scrollToViewportMethod · 0.85
onScrollMouseDownMethod · 0.85
onMouseUpMethod · 0.85
onUpdateNewsMethod · 0.85
onMouseUpOverviewMethod · 0.85
onMouseUpMethod · 0.85
scrollToMethod · 0.85

Calls 12

WindowUnfollowSpriteFunction · 0.85
TileElementHeightFunction · 0.85
Translate3DTo2DWithZFunction · 0.85
WindowGetIteratorFunction · 0.85
ViewWidthMethod · 0.80
ViewHeightMethod · 0.80
endMethod · 0.65
hasMethod · 0.65
getMethod · 0.65
setMethod · 0.65
invalidateMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected