From 6a9a62ab495b52f0d9580574368e0103f433a6d3 Mon Sep 17 00:00:00 2001 From: drojf <1249449+drojf@users.noreply.github.com> Date: Mon, 11 Dec 2023 22:45:06 +1100 Subject: [PATCH] Fix 'return to main menu', 'quit', and 'load' not working in choices - Not all chapters are broken in the same way - See https://github.com/07th-mod/higurashi-assembly/issues/106 - See https://github.com/07th-mod/higurashi-rei/issues/2#issue-1320921974 - This was semi-applied in Rei (5796215), but it did not fix loading during a choice, and had some issues, so I'm going to revert that in Rei --- Assets.Scripts.Core/GameSystem.cs | 13 +++++++++++-- Assets.Scripts.UI.Menu/MenuUIButton.cs | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets.Scripts.Core/GameSystem.cs b/Assets.Scripts.Core/GameSystem.cs index 2fa40b31..17a08a4e 100644 --- a/Assets.Scripts.Core/GameSystem.cs +++ b/Assets.Scripts.Core/GameSystem.cs @@ -492,8 +492,17 @@ public void CloseChoiceIfExists() { if (ChoiceController != null) { - ChoiceController.Destroy(); - ChoiceController = null; + if (GameSystem.Instance.GameState == GameState.ChoiceScreen) + { + // If you're currently on the choice screen, then cleanly leave the choices state and delete the choice controller + LeaveChoices(); + } + else + { + // If you're on another screen layered ontop of the choice screen (eg the load screen), just delete the choice controller and hope for the best. + ChoiceController.Destroy(); + ChoiceController = null; + } } } diff --git a/Assets.Scripts.UI.Menu/MenuUIButton.cs b/Assets.Scripts.UI.Menu/MenuUIButton.cs index 37efc6d9..9773ab29 100644 --- a/Assets.Scripts.UI.Menu/MenuUIButton.cs +++ b/Assets.Scripts.UI.Menu/MenuUIButton.cs @@ -51,6 +51,7 @@ private void OnClick() gameSystem.PopStateStack(); GameSystem.Instance.PushStateObject(new StateDialogPrompt(PromptType.DialogTitle, delegate { + gameSystem.CloseChoiceIfExists(); gameSystem.ClearActions(); gameSystem.ClearAllWaits(); gameSystem.TextController.ClearText(); @@ -74,6 +75,7 @@ private void OnClick() gameSystem.PopStateStack(); GameSystem.Instance.PushStateObject(new StateDialogPrompt(PromptType.DialogExit, delegate { + gameSystem.CloseChoiceIfExists(); gameSystem.CanExit = true; Application.Quit(); }, delegate