2019-06-15 17:01:41 +02:00
|
|
|
#include "Window_internal.h"
|
|
|
|
|
|
2021-02-23 10:49:41 +01:00
|
|
|
#include "../world/EntityList.h"
|
2019-06-15 17:12:14 +02:00
|
|
|
#include "../world/Sprite.h"
|
|
|
|
|
|
2020-07-16 17:01:42 -04:00
|
|
|
void rct_window::SetLocation(const CoordsXYZ& coords)
|
2019-06-15 17:01:41 +02:00
|
|
|
{
|
2020-07-16 17:01:42 -04:00
|
|
|
window_scroll_to_location(this, coords);
|
2019-06-15 17:01:41 +02:00
|
|
|
flags &= ~WF_SCROLLING_TO_LOCATION;
|
|
|
|
|
}
|
2019-06-15 17:12:14 +02:00
|
|
|
|
|
|
|
|
void rct_window::ScrollToViewport()
|
|
|
|
|
{
|
|
|
|
|
// In original checked to make sure x and y were not -1 as well.
|
|
|
|
|
if (viewport == nullptr || viewport_focus_coordinates.y == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-07-15 22:26:27 -04:00
|
|
|
CoordsXYZ newCoords = {};
|
2019-06-15 17:12:14 +02:00
|
|
|
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
|
|
|
|
|
{
|
2020-06-06 11:32:37 +01:00
|
|
|
auto* sprite = GetEntity(viewport_focus_sprite.sprite_id);
|
2020-07-06 22:02:25 +01:00
|
|
|
if (sprite == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-15 22:26:27 -04:00
|
|
|
newCoords.x = sprite->x;
|
|
|
|
|
newCoords.y = sprite->y;
|
|
|
|
|
newCoords.z = sprite->z;
|
2019-06-15 17:12:14 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-15 22:26:27 -04:00
|
|
|
newCoords.x = viewport_focus_coordinates.x;
|
|
|
|
|
newCoords.y = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
|
|
|
|
|
newCoords.z = viewport_focus_coordinates.z;
|
2019-06-15 17:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-15 22:26:27 -04:00
|
|
|
auto mainWindow = window_get_main();
|
2019-06-15 17:12:14 +02:00
|
|
|
if (mainWindow != nullptr)
|
2020-07-15 22:26:27 -04:00
|
|
|
window_scroll_to_location(mainWindow, newCoords);
|
2019-06-15 17:12:14 +02:00
|
|
|
}
|
2019-06-15 17:20:16 +02:00
|
|
|
|
|
|
|
|
void rct_window::Invalidate()
|
|
|
|
|
{
|
2020-07-08 12:16:24 -04:00
|
|
|
gfx_set_dirty_blocks({ windowPos, windowPos + ScreenCoordsXY{ width, height } });
|
2019-06-15 17:20:16 +02:00
|
|
|
}
|
2020-09-28 23:38:58 +03:00
|
|
|
|
|
|
|
|
void rct_window::RemoveViewport()
|
|
|
|
|
{
|
|
|
|
|
if (viewport == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-01-07 21:06:49 +02:00
|
|
|
viewport_remove(viewport);
|
2020-09-28 23:38:58 +03:00
|
|
|
viewport = nullptr;
|
|
|
|
|
}
|