diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3f58187cef..51ef5249ec 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -9,6 +9,7 @@ - Change: [#24069] [Plugin] Plugins are now available in the scenario editor and track designer. - Change: [#24135] Compress Emscripten js/wasm files. - Change: [#24235] Small changes to RCT1 theme. +- Fix: [#21207] Track List window gets positioned incorrectly. - Fix: [#21919] Non-recolourable cars still show colour picker. - Fix: [#22182] [Plugin] Crash when using map.getAllEntities("car"). - Fix: [#22634] Asset packs with sound effect overrides are not loaded correctly at startup. diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 1a58214527..86d352426f 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -838,7 +838,7 @@ public: WindowBase* Create( std::unique_ptr&& wp, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, - uint32_t flags) override + WindowFlags flags) override { height += wp->getTitleBarDiffTarget(); @@ -1070,7 +1070,7 @@ public: /** * Closes all windows, save for those having any of the passed flags. */ - void CloseAllExceptFlags(uint16_t flags) override + void CloseAllExceptFlags(WindowFlags flags) override { CloseByCondition([flags](WindowBase* w) -> bool { return !(w->flags & flags); }); } @@ -1347,7 +1347,7 @@ public: return &w; } - WindowBase* BringToFrontByClassWithFlags(WindowClass cls, uint16_t flags) override + WindowBase* BringToFrontByClassWithFlags(WindowClass cls, WindowFlags flags) override { WindowBase* w = FindByClass(cls); if (w != nullptr) diff --git a/src/openrct2-ui/scripting/ScViewport.hpp b/src/openrct2-ui/scripting/ScViewport.hpp index 6ba5b930b1..80165d24c4 100644 --- a/src/openrct2-ui/scripting/ScViewport.hpp +++ b/src/openrct2-ui/scripting/ScViewport.hpp @@ -275,7 +275,7 @@ namespace OpenRCT2::Scripting { viewport->viewPos.x = left; viewport->viewPos.y = top; - viewport->flags &= ~WF_SCROLLING_TO_LOCATION; + w->flags &= ~WF_SCROLLING_TO_LOCATION; w->savedViewPos.x = viewport->viewPos.x; w->savedViewPos.y = viewport->viewPos.y; viewport->Invalidate(); diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index 340cfa731b..7b35529df0 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -423,11 +423,8 @@ namespace OpenRCT2::Ui::Windows gTrackDesignSceneryToggle = false; _currentTrackPieceDirection = 2; - int32_t screenWidth = ContextGetWidth(); - int32_t screenHeight = ContextGetHeight(); - auto screenPos = ScreenCoordsXY{ screenWidth / 2 - 201, std::max(kTopToolbarHeight + 1, screenHeight / 2 - 200) }; - - auto* window = windowMgr->FocusOrCreate(WindowClass::InstallTrack, screenPos, WW, WH, 0); + auto* window = windowMgr->FocusOrCreate( + WindowClass::InstallTrack, WW, WH, WF_AUTO_POSITION | WF_CENTRE_SCREEN); window->SetupTrack(path, std::move(trackDesign)); return window; diff --git a/src/openrct2-ui/windows/TrackDesignManage.cpp b/src/openrct2-ui/windows/TrackDesignManage.cpp index 043c0b8498..d97033f0c5 100644 --- a/src/openrct2-ui/windows/TrackDesignManage.cpp +++ b/src/openrct2-ui/windows/TrackDesignManage.cpp @@ -189,15 +189,11 @@ namespace OpenRCT2::Ui::Windows auto* windowMgr = Ui::GetWindowManager(); windowMgr->CloseByClass(WindowClass::TrackDeletePrompt); - int32_t screenWidth = ContextGetWidth(); - int32_t screenHeight = ContextGetHeight(); auto trackDeletePromptWindow = std::make_unique(tdFileRef); windowMgr->Create( - std::move(trackDeletePromptWindow), WindowClass::TrackDeletePrompt, - ScreenCoordsXY( - std::max(kTopToolbarHeight + 1, (screenWidth - WW_DELETE_PROMPT) / 2), (screenHeight - WH_DELETE_PROMPT) / 2), - WW_DELETE_PROMPT, WH_DELETE_PROMPT, WF_STICK_TO_FRONT | WF_TRANSPARENT); + std::move(trackDeletePromptWindow), WindowClass::TrackDeletePrompt, {}, WW_DELETE_PROMPT, WH_DELETE_PROMPT, + WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_AUTO_POSITION | WF_CENTRE_SCREEN); } void TrackDeletePromptWindow::OnOpen() diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 19b7f5939c..1d28843852 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -756,19 +756,18 @@ namespace OpenRCT2::Ui::Windows auto* windowMgr = Ui::GetWindowManager(); windowMgr->CloseConstructionWindows(); + WindowFlags flags = 0; ScreenCoordsXY screenPos{}; if (gLegacyScene == LegacyScene::trackDesignsManager) { - int32_t screenWidth = ContextGetWidth(); - int32_t screenHeight = ContextGetHeight(); - screenPos = { screenWidth / 2 - 300, std::max(kTopToolbarHeight + 1, screenHeight / 2 - 200) }; + flags = WF_AUTO_POSITION | WF_CENTRE_SCREEN; } else { screenPos = { 0, kTopToolbarHeight + 2 }; } - return windowMgr->Create(WindowClass::TrackDesignList, WW, WH, 0, item); + return windowMgr->Create(WindowClass::TrackDesignList, screenPos, WW, WH, flags, item); } void WindowTrackDesignListReloadTracks() diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index fae2c72762..752f5c3f8e 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -96,6 +96,7 @@ namespace OpenRCT2 WF_AUTO_POSITION = (1 << 16), WF_CENTRE_SCREEN = (1 << 17), }; + using WindowFlags = uint32_t; enum { diff --git a/src/openrct2/interface/WindowBase.h b/src/openrct2/interface/WindowBase.h index 02dd52acd4..8428fbcb19 100644 --- a/src/openrct2/interface/WindowBase.h +++ b/src/openrct2/interface/WindowBase.h @@ -88,7 +88,7 @@ namespace OpenRCT2 rct_windownumber number{}; RideId rideId; }; - uint16_t flags{}; + WindowFlags flags{}; OpenRCT2::ScrollArea scrolls[3]; uint16_t no_list_items{}; // 0 for no items int16_t selected_list_item{}; // -1 for none selected diff --git a/src/openrct2/ui/DummyWindowManager.cpp b/src/openrct2/ui/DummyWindowManager.cpp index c389e20dc2..40ba91309f 100644 --- a/src/openrct2/ui/DummyWindowManager.cpp +++ b/src/openrct2/ui/DummyWindowManager.cpp @@ -73,7 +73,7 @@ namespace OpenRCT2::Ui WindowBase* Create( std::unique_ptr&& w, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, - uint32_t flags) override + WindowFlags flags) override { return nullptr; } @@ -86,7 +86,7 @@ namespace OpenRCT2::Ui void CloseTop() override {}; void CloseAll() override {}; void CloseAllExceptClass(WindowClass cls) override {}; - void CloseAllExceptFlags(uint16_t flags) override {}; + void CloseAllExceptFlags(WindowFlags flags) override {}; void CloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls) override {}; void CloseConstructionWindows() override {}; @@ -127,7 +127,7 @@ namespace OpenRCT2::Ui { return nullptr; } - WindowBase* BringToFrontByClassWithFlags(WindowClass cls, uint16_t flags) override + WindowBase* BringToFrontByClassWithFlags(WindowClass cls, WindowFlags flags) override { return nullptr; } diff --git a/src/openrct2/ui/WindowManager.h b/src/openrct2/ui/WindowManager.h index 99aadaee80..eb959f0c1b 100644 --- a/src/openrct2/ui/WindowManager.h +++ b/src/openrct2/ui/WindowManager.h @@ -44,26 +44,27 @@ namespace OpenRCT2::Ui virtual WindowBase* GetOwner(const Viewport* viewport) = 0; virtual WindowBase* Create( - std::unique_ptr&& w, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, uint32_t flags) + std::unique_ptr&& w, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, + WindowFlags flags) = 0; template::value>::type* = nullptr> T* Create( - WindowClass cls, const ScreenCoordsXY& pos = {}, int32_t width = 0, int32_t height = 0, uint32_t flags = 0, + WindowClass cls, const ScreenCoordsXY& pos = {}, int32_t width = 0, int32_t height = 0, WindowFlags flags = 0, TArgs&&... args) { return static_cast(Create(std::make_unique(std::forward(args)...), cls, pos, width, height, flags)); } template::value>::type* = nullptr> - T* Create(WindowClass cls, int32_t width, int32_t height, uint32_t flags, TArgs&&... args) + T* Create(WindowClass cls, int32_t width, int32_t height, WindowFlags flags, TArgs&&... args) { return static_cast( Create(std::make_unique(std::forward(args)...), cls, {}, width, height, flags | WF_AUTO_POSITION)); } template::value>::type* = nullptr> - T* FocusOrCreate(WindowClass cls, const ScreenCoordsXY& pos, int32_t width, int32_t height, uint32_t flags = 0) + T* FocusOrCreate(WindowClass cls, const ScreenCoordsXY& pos, int32_t width, int32_t height, WindowFlags flags = 0) { auto* w = BringToFrontByClass(cls); if (w == nullptr) @@ -74,7 +75,7 @@ namespace OpenRCT2::Ui } template::value>::type* = nullptr> - T* FocusOrCreate(WindowClass cls, int32_t width, int32_t height, uint32_t flags = 0) + T* FocusOrCreate(WindowClass cls, int32_t width, int32_t height, WindowFlags flags = 0) { auto* w = BringToFrontByClass(cls); if (w == nullptr) @@ -92,7 +93,7 @@ namespace OpenRCT2::Ui virtual void CloseTop() = 0; virtual void CloseAll() = 0; virtual void CloseAllExceptClass(WindowClass cls) = 0; - virtual void CloseAllExceptFlags(uint16_t flags) = 0; + virtual void CloseAllExceptFlags(WindowFlags flags) = 0; virtual void CloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls) = 0; virtual void CloseConstructionWindows() = 0; @@ -112,7 +113,7 @@ namespace OpenRCT2::Ui virtual WindowBase* BringToFront(WindowBase& w) = 0; virtual WindowBase* BringToFrontByClass(WindowClass cls) = 0; - virtual WindowBase* BringToFrontByClassWithFlags(WindowClass cls, uint16_t flags) = 0; + virtual WindowBase* BringToFrontByClassWithFlags(WindowClass cls, WindowFlags flags) = 0; virtual WindowBase* BringToFrontByNumber(WindowClass cls, rct_windownumber number) = 0; };