Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix 'return to main menu', 'quit', and 'load' not working in choices #113

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Assets.Scripts.Core/GameSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Assets.Scripts.UI.Menu/MenuUIButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down