mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-13 11:02:47 +01:00
Merge pull request #24248 from Gymnasiast/fix/window-bugs
Fix window bugs
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -838,7 +838,7 @@ public:
|
||||
|
||||
WindowBase* Create(
|
||||
std::unique_ptr<WindowBase>&& 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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<InstallTrackWindow>(WindowClass::InstallTrack, screenPos, WW, WH, 0);
|
||||
auto* window = windowMgr->FocusOrCreate<InstallTrackWindow>(
|
||||
WindowClass::InstallTrack, WW, WH, WF_AUTO_POSITION | WF_CENTRE_SCREEN);
|
||||
window->SetupTrack(path, std::move(trackDesign));
|
||||
|
||||
return window;
|
||||
|
||||
@@ -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<TrackDeletePromptWindow>(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()
|
||||
|
||||
@@ -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<TrackListWindow>(WindowClass::TrackDesignList, WW, WH, 0, item);
|
||||
return windowMgr->Create<TrackListWindow>(WindowClass::TrackDesignList, screenPos, WW, WH, flags, item);
|
||||
}
|
||||
|
||||
void WindowTrackDesignListReloadTracks()
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace OpenRCT2
|
||||
WF_AUTO_POSITION = (1 << 16),
|
||||
WF_CENTRE_SCREEN = (1 << 17),
|
||||
};
|
||||
using WindowFlags = uint32_t;
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRCT2::Ui
|
||||
|
||||
WindowBase* Create(
|
||||
std::unique_ptr<WindowBase>&& 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;
|
||||
}
|
||||
|
||||
@@ -44,26 +44,27 @@ namespace OpenRCT2::Ui
|
||||
virtual WindowBase* GetOwner(const Viewport* viewport) = 0;
|
||||
|
||||
virtual WindowBase* Create(
|
||||
std::unique_ptr<WindowBase>&& w, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, uint32_t flags)
|
||||
std::unique_ptr<WindowBase>&& w, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height,
|
||||
WindowFlags flags)
|
||||
= 0;
|
||||
|
||||
template<typename T, typename... TArgs, typename std::enable_if<std::is_base_of<WindowBase, T>::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<T*>(Create(std::make_unique<T>(std::forward<TArgs>(args)...), cls, pos, width, height, flags));
|
||||
}
|
||||
|
||||
template<typename T, typename... TArgs, typename std::enable_if<std::is_base_of<WindowBase, T>::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<T*>(
|
||||
Create(std::make_unique<T>(std::forward<TArgs>(args)...), cls, {}, width, height, flags | WF_AUTO_POSITION));
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<std::is_base_of<WindowBase, T>::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<typename T, typename std::enable_if<std::is_base_of<WindowBase, T>::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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user