Add Resume/Exit buttons to pause menu, handle logic for returning to main menu and starting a new game
This commit is contained in:
@@ -56,6 +56,8 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
[Signal]
|
||||
public delegate void SaveFileLoadedEventHandler();
|
||||
|
||||
public event Action GameExitRequested;
|
||||
#endregion
|
||||
|
||||
public RescuedItemDatabase RescuedItems { get; set; } = default!;
|
||||
@@ -174,6 +176,8 @@ public partial class Game : Node3D, IGame
|
||||
GameOverMenu.NewGame += OnNewGame;
|
||||
GameOverMenu.QuitGame += OnQuit;
|
||||
|
||||
PauseMenu.ExitGamePressed += OnQuit;
|
||||
|
||||
GameRepo.IsPaused.Sync += IsPaused_Sync;
|
||||
InGameUI.PlayerInfoUI.Activate();
|
||||
}
|
||||
@@ -252,6 +256,12 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.Debug))
|
||||
GameState.Input(new GameState.Input.DebugButtonPressed());
|
||||
if (@event.IsActionPressed(GameInputs.Pause))
|
||||
GameState.Input(new GameState.Input.PauseButtonPressed());
|
||||
if (Input.IsActionJustPressed(GameInputs.Inventory))
|
||||
GameState.Input(new GameState.Input.InventoryButtonPressed());
|
||||
if (Input.IsActionJustPressed(GameInputs.Interact))
|
||||
GameState.Input(new GameState.Input.InteractButtonPressed());
|
||||
}
|
||||
|
||||
private void HandleGameLogic()
|
||||
@@ -280,12 +290,13 @@ public partial class Game : Node3D, IGame
|
||||
})
|
||||
.Handle((in GameState.Output.OpenInventoryMenu _) =>
|
||||
{
|
||||
//InGameUI.InventoryMenu.RefreshInventoryScreen();
|
||||
GameRepo.Pause();
|
||||
InGameUI.InventoryMenu.Show();
|
||||
InGameUI.InventoryMenu.SetProcessInput(true);
|
||||
})
|
||||
.Handle((in GameState.Output.CloseInventoryMenu _) =>
|
||||
{
|
||||
GameRepo.Resume();
|
||||
InGameUI.InventoryMenu.Hide();
|
||||
InGameUI.InventoryMenu.SetProcessInput(false);
|
||||
})
|
||||
@@ -337,6 +348,10 @@ public partial class Game : Node3D, IGame
|
||||
}
|
||||
LoadNextLevel.FadeOut();
|
||||
})
|
||||
.Handle((in GameState.Output.ExitGame _) =>
|
||||
{
|
||||
OnQuit();
|
||||
})
|
||||
.Handle((in GameState.Output.GameOver _) =>
|
||||
{
|
||||
//GameRepo.Pause();
|
||||
@@ -507,7 +522,7 @@ public partial class Game : Node3D, IGame
|
||||
LoadNextLevel.Hide();
|
||||
}
|
||||
|
||||
private void OnQuit() => GetTree().Root.QueueFree();
|
||||
private void OnQuit() => GameExitRequested?.Invoke();
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user