* * rct2: 0x006E7C9C * @param w (esi) * @param x (eax) * @param y (ecx) * @param z (edx) */
| 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 | } |
no test coverage detected