Remove focus union and replace with typed focus (#15426)

* Remove focus union and replace with typed focus

This if for the NSF to allow for CoordsXYZ

* Remove legacy structures

* Rework viewport_create to deduplicate logic

* Simplify yet further

* Apply review comments

* Remove intermediate
This commit is contained in:
Duncan authored and GitHub committed 2021-09-18 20:34:38 +01:00
1 parent c05068e8d1
commit fa57b6aea0
19 files changed
+140 -270

No files matched your search

+2 -20
View File
@@ -12,28 +12,10 @@ void rct_window::SetLocation(const CoordsXYZ& coords)
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)
if (viewport == nullptr || !focus2.has_value())
return;
CoordsXYZ newCoords = {};
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
{
auto* sprite = GetEntity(viewport_focus_sprite.sprite_id);
if (sprite == nullptr)
{
return;
}
newCoords.x = sprite->x;
newCoords.y = sprite->y;
newCoords.z = sprite->z;
}
else
{
newCoords.x = viewport_focus_coordinates.x;
newCoords.y = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
newCoords.z = viewport_focus_coordinates.z;
}
CoordsXYZ newCoords = focus2.value().GetPos();
auto mainWindow = window_get_main();
if (mainWindow != nullptr)