Skip to content

Commit 6113774

Browse files
committed
Fix staff window viewport not appearing on open
1 parent 9ae3cbc commit 6113774

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/openrct2-ui/windows/Staff.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ namespace OpenRCT2::Ui::Windows
531531

532532
widgets[WIDX_FIRE].left = width - 25;
533533
widgets[WIDX_FIRE].right = width - 2;
534+
535+
if (viewport != nullptr)
536+
{
537+
const Widget& viewportWidget = widgets[WIDX_VIEWPORT];
538+
viewport->pos = windowPos + ScreenCoordsXY{ viewportWidget.left + 1, viewportWidget.top + 1 };
539+
viewport->width = widgets[WIDX_VIEWPORT].width() - 1;
540+
viewport->height = widgets[WIDX_VIEWPORT].height() - 1;
541+
}
534542
}
535543

536544
void OverviewDraw(RenderTarget& rt)
@@ -605,21 +613,6 @@ namespace OpenRCT2::Ui::Windows
605613
{
606614
WindowSetResize(*this, { WW, WH }, { 500, 450 });
607615

608-
if (viewport != nullptr)
609-
{
610-
auto widget = widgets[WIDX_VIEWPORT];
611-
auto newWidth = widget.width() - 1;
612-
auto newHeight = widget.height() - 1;
613-
viewport->pos = windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 };
614-
615-
// Update the viewport size
616-
if (viewport->width != newWidth || viewport->height != newHeight)
617-
{
618-
viewport->width = newWidth;
619-
viewport->height = newHeight;
620-
}
621-
}
622-
623616
ViewportInit();
624617
}
625618

@@ -1229,7 +1222,10 @@ namespace OpenRCT2::Ui::Windows
12291222
return nullptr;
12301223

12311224
if (w != nullptr)
1225+
{
12321226
w->Initialise(peep->Id);
1227+
w->OnResize(); // Initialise viewport after peep id is set
1228+
}
12331229

12341230
return w;
12351231
}

0 commit comments

Comments
 (0)