1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Prevent closing object selection window when selection is invalid (#23968)

* EditorObjectSelectionWindowCheck: move window close out to caller side

* WindowManager: apply CanClose check again

* Amend changelog
This commit is contained in:
Aaron van Geffen
2025-03-11 21:14:04 +01:00
committed by GitHub
parent 1dd1564904
commit 7411b718bc
4 changed files with 17 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
- Fix: [#4225] Ride Construction window offers non-existent banked sloped to level curve (original bug). - Fix: [#4225] Ride Construction window offers non-existent banked sloped to level curve (original bug).
- Fix: [#10379] Banners outside the park can be renamed and modified (original bug). - Fix: [#10379] Banners outside the park can be renamed and modified (original bug).
- Fix: [#10582] Low clearance tunnels below water are drawn incorrectly (original bug). - Fix: [#10582] Low clearance tunnels below water are drawn incorrectly (original bug).
- Fix: [#23486] Object selection minimum requirements can be bypassed with close window hotkey.
- Fix: [#23743] Parks with guest goals over 32767 do not appear in the scenario list. - Fix: [#23743] Parks with guest goals over 32767 do not appear in the scenario list.
- Fix: [#23844] Sound effects keep playing when loading another save. - Fix: [#23844] Sound effects keep playing when loading another save.
- Fix: [#23891] Inverted Hairpin Coaster track can draw over things above it (original bug). - Fix: [#23891] Inverted Hairpin Coaster track can draw over things above it (original bug).

View File

@@ -931,6 +931,12 @@ public:
*/ */
void Close(WindowBase& w) override void Close(WindowBase& w) override
{ {
if (!w.CanClose())
{
// Something's preventing this window from closing -- bail out early
return;
}
w.OnClose(); w.OnClose();
// Remove viewport // Remove viewport

View File

@@ -199,6 +199,9 @@ namespace OpenRCT2::Ui::Windows
if (!EditorObjectSelectionWindowCheck()) if (!EditorObjectSelectionWindowCheck())
return; return;
auto* windowMgr = Ui::GetWindowManager();
windowMgr->CloseByClass(WindowClass::EditorObjectSelection);
FinishObjectSelection(); FinishObjectSelection();
if (gLegacyScene == LegacyScene::trackDesigner) if (gLegacyScene == LegacyScene::trackDesigner)
{ {

View File

@@ -366,9 +366,13 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex) switch (widgetIndex)
{ {
case WIDX_CLOSE: case WIDX_CLOSE:
if (!(gLegacyScene == LegacyScene::trackDesignsManager) && !EditorObjectSelectionWindowCheck()) {
if (gLegacyScene != LegacyScene::trackDesignsManager && !EditorObjectSelectionWindowCheck())
return; return;
auto* windowMgr = Ui::GetWindowManager();
windowMgr->CloseByClass(WindowClass::EditorObjectSelection);
if (isInEditorMode()) if (isInEditorMode())
{ {
FinishObjectSelection(); FinishObjectSelection();
@@ -382,6 +386,7 @@ namespace OpenRCT2::Ui::Windows
context->SetActiveScene(context->GetTitleScene()); context->SetActiveScene(context->GetTitleScene());
} }
break; break;
}
case WIDX_SUB_TAB_0: case WIDX_SUB_TAB_0:
case WIDX_SUB_TAB_1: case WIDX_SUB_TAB_1:
@@ -1708,17 +1713,15 @@ namespace OpenRCT2::Ui::Windows
bool EditorObjectSelectionWindowCheck() bool EditorObjectSelectionWindowCheck()
{ {
auto* windowMgr = Ui::GetWindowManager();
auto [missingObjectType, errorString] = Editor::CheckObjectSelection(); auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::none) if (missingObjectType == ObjectType::none)
{ {
windowMgr->CloseByClass(WindowClass::EditorObjectSelection);
return true; return true;
} }
ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {}); ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
auto* windowMgr = Ui::GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::EditorObjectSelection); WindowBase* w = windowMgr->FindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr) if (w != nullptr)
{ {