1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix extra viewport invalidating every frame

This commit is contained in:
mix
2025-05-18 03:17:36 +01:00
parent 7fcfef97f7
commit 5e51c89d9f
2 changed files with 5 additions and 19 deletions

View File

@@ -98,7 +98,7 @@ namespace OpenRCT2::Ui::Windows
viewport->flags |= VIEWPORT_FLAG_SOUND_ON | VIEWPORT_FLAG_INDEPEDENT_ROTATION;
WindowSetResize(*this, { WW, WH }, { WW, WH });
WindowSetResize(*this, { WW, WH }, { (ContextGetWidth() * 4) / 5, (ContextGetHeight() * 4) / 5 });
}
void OnUpdate() override
@@ -107,14 +107,11 @@ namespace OpenRCT2::Ui::Windows
if (mainWindow == nullptr)
return;
if (viewport != nullptr && viewport->flags != mainWindow->viewport->flags)
if (viewport != nullptr && viewport->flags != (mainWindow->viewport->flags | VIEWPORT_FLAG_INDEPEDENT_ROTATION))
{
viewport->flags = mainWindow->viewport->flags | VIEWPORT_FLAG_INDEPEDENT_ROTATION;
Invalidate();
InvalidateWidget(WIDX_VIEWPORT);
}
// Not sure how to invalidate part of the viewport that has changed, this will have to do for now
// widget_invalidate(*this, WIDX_VIEWPORT);
}
void OnMouseUp(WidgetIndex widgetIndex) override
@@ -220,17 +217,6 @@ namespace OpenRCT2::Ui::Windows
WindowBase* ViewportOpen()
{
int32_t screenWidth = ContextGetWidth();
int32_t screenHeight = ContextGetHeight();
int32_t width = (screenWidth / 2);
int32_t height = (screenHeight / 2);
auto* windowMgr = GetWindowManager();
auto* w = windowMgr->Create<ViewportWindow>(
WindowClass::Viewport, std::max(WW, width), std::max(WH, height), WF_RESIZABLE);
if (w != nullptr)
return w;
return nullptr;
return GetWindowManager()->Create<ViewportWindow>(WindowClass::Viewport, 300, 300, WF_RESIZABLE);
}
} // namespace OpenRCT2::Ui::Windows

View File

@@ -589,7 +589,7 @@ namespace OpenRCT2
// rct2: 0x006E7A15
static void ViewportSetUndergroundFlag(int32_t underground, WindowBase* window, Viewport* viewport)
{
if (window->classification != WindowClass::MainWindow
if ((window->classification != WindowClass::MainWindow && window->classification != WindowClass::Viewport)
|| (window->classification == WindowClass::MainWindow && !window->viewport_smart_follow_sprite.IsNull()))
{
if (!underground)