mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 05:53:02 +01:00
Force object selection window to close when changing scenes
This commit is contained in:
@@ -586,6 +586,10 @@ public:
|
||||
{
|
||||
switch (windowClass)
|
||||
{
|
||||
case WindowClass::EditorObjectSelection:
|
||||
EditorObjectSelectionClose();
|
||||
break;
|
||||
|
||||
case WindowClass::NetworkStatus:
|
||||
WindowNetworkStatusClose();
|
||||
break;
|
||||
|
||||
@@ -261,6 +261,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
u8string _filter;
|
||||
uint32_t _filterFlags = FILTER_RIDES_ALL;
|
||||
uint8_t _selectedSubTab = 0;
|
||||
bool _overrideChecks = false;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -292,10 +293,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
VisibleListRefresh();
|
||||
}
|
||||
|
||||
void SetOverrideChecks(bool newState)
|
||||
{
|
||||
_overrideChecks = newState;
|
||||
}
|
||||
|
||||
bool CanClose() override
|
||||
{
|
||||
// Prevent window closure when selection is invalid
|
||||
return EditorObjectSelectionWindowCheck();
|
||||
return _overrideChecks || EditorObjectSelectionWindowCheck();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1625,6 +1631,20 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowClass::EditorObjectSelection, 755, 400, WF_10 | WF_RESIZABLE | WF_CENTRE_SCREEN);
|
||||
}
|
||||
|
||||
// Used for forced closure
|
||||
void EditorObjectSelectionClose()
|
||||
{
|
||||
auto* windowMgr = GetWindowManager();
|
||||
auto window = windowMgr->FindByClass(WindowClass::EditorObjectSelection);
|
||||
if (window == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto objSelWindow = static_cast<EditorObjectSelectionWindow*>(window);
|
||||
objSelWindow->SetOverrideChecks(true);
|
||||
objSelWindow->Close();
|
||||
}
|
||||
|
||||
static bool VisibleListSortRideName(const ObjectListItem& a, const ObjectListItem& b)
|
||||
{
|
||||
auto nameA = a.repositoryItem->Name.c_str();
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// EditorObjectSelection
|
||||
WindowBase* EditorObjectSelectionOpen();
|
||||
bool EditorObjectSelectionWindowCheck();
|
||||
void EditorObjectSelectionClose();
|
||||
|
||||
// EditorParkEntrance
|
||||
WindowBase* EditorParkEntranceOpen();
|
||||
|
||||
@@ -35,4 +35,9 @@ void GameScene::Tick()
|
||||
void GameScene::Stop()
|
||||
{
|
||||
Audio::StopAll();
|
||||
|
||||
// Force closure of any object selection windows, regardless of valid state.
|
||||
// NB: this is relevant for both in-game scenes and editors, as the window
|
||||
// may be opened in-game using cheats.
|
||||
ContextForceCloseWindowByClass(WindowClass::EditorObjectSelection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user