Files
OpenRCT2-Web/src/openrct2/interface/Window_internal.cpp
T
duncanspumpkin 904e6c6987 Implement GetSprite and use it in a number of places
This will eventually replace all of the get_sprite and try_get_sprite calls

Further use of GetSprite

Use GetSprite in all remaining easy to use functions

Correct formatting

Rename GetSprite to GetEntity

Make suggested changes

Remove const to allow for building

Fix crashes due to next sprite
2020-06-16 20:21:56 +01:00

43 lines
1.1 KiB
C++

#include "Window_internal.h"
#include "../world/Sprite.h"
void rct_window::SetLocation(int32_t newX, int32_t newY, int32_t newZ)
{
window_scroll_to_location(this, newX, newY, newZ);
flags &= ~WF_SCROLLING_TO_LOCATION;
}
void rct_window::ScrollToViewport()
{
int32_t newX, newY, newZ;
rct_window* mainWindow;
// In original checked to make sure x and y were not -1 as well.
if (viewport == nullptr || viewport_focus_coordinates.y == -1)
return;
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
{
auto* sprite = GetEntity(viewport_focus_sprite.sprite_id);
newX = sprite->x;
newY = sprite->y;
newZ = sprite->z;
}
else
{
newX = viewport_focus_coordinates.x;
newY = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
newZ = viewport_focus_coordinates.z;
}
mainWindow = window_get_main();
if (mainWindow != nullptr)
window_scroll_to_location(mainWindow, newX, newY, newZ);
}
void rct_window::Invalidate()
{
gfx_set_dirty_blocks(windowPos.x, windowPos.y, windowPos.x + width, windowPos.y + height);
}