Skip to content

Prevent some unnecessary window invalidations #24433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix staff window viewport issues
  • Loading branch information
mixiate committed May 22, 2025
commit 98f62f2e97a4bfdbe2f0e7327df1c1dff4c218a3
32 changes: 17 additions & 15 deletions src/openrct2-ui/windows/Staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ namespace OpenRCT2::Ui::Windows

if (staff->AssignedStaffType == StaffType::Entertainer)
_availableCostumes = getAvailableCostumeStrings(AnimationPeepType::Entertainer);

ViewportInit();
}

void OnOpen() override
Expand Down Expand Up @@ -531,6 +533,14 @@ namespace OpenRCT2::Ui::Windows

widgets[WIDX_FIRE].left = width - 25;
widgets[WIDX_FIRE].right = width - 2;

if (viewport != nullptr)
{
const Widget& viewportWidget = widgets[WIDX_VIEWPORT];
viewport->pos = windowPos + ScreenCoordsXY{ viewportWidget.left + 1, viewportWidget.top + 1 };
viewport->width = widgets[WIDX_VIEWPORT].width() - 1;
viewport->height = widgets[WIDX_VIEWPORT].height() - 1;
}
}

void OverviewDraw(RenderTarget& rt)
Expand Down Expand Up @@ -605,21 +615,6 @@ namespace OpenRCT2::Ui::Windows
{
WindowSetResize(*this, { WW, WH }, { 500, 450 });

if (viewport != nullptr)
{
auto widget = widgets[WIDX_VIEWPORT];
auto newWidth = widget.width() - 1;
auto newHeight = widget.height() - 1;
viewport->pos = windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 };

// Update the viewport size
if (viewport->width != newWidth || viewport->height != newHeight)
{
viewport->width = newWidth;
viewport->height = newHeight;
}
}

ViewportInit();
}

Expand Down Expand Up @@ -648,6 +643,13 @@ namespace OpenRCT2::Ui::Windows
picked_peep_frame %= pickAnimLength * 4;

InvalidateWidget(WIDX_TAB_1);

const std::optional<Focus> tempFocus = staff->State != PeepState::Picked ? std::optional(Focus(staff->Id))
: std::nullopt;
if (focus != tempFocus)
{
ViewportInit();
}
}

void OverviewToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
Expand Down