Add Resume/Exit buttons to pause menu, handle logic for returning to main menu and starting a new game
This commit is contained in:
@@ -1,20 +1,14 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Collections;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using NathanHoad;
|
||||
using SimpleInjector.Lifestyles;
|
||||
using System;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using static Zennysoft.Game.Ma.SceneLoader;
|
||||
using static Zennysoft.Ma.Adapter.AppLogic.State;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -37,8 +31,6 @@ public partial class App : Node, IApp
|
||||
|
||||
[Node] private GalleryMenu GalleryMenu { get; set; }
|
||||
|
||||
public IInstantiator Instantiator { get; set; } = default!;
|
||||
|
||||
IAppRepo IProvide<IAppRepo>.Value() => AppRepo;
|
||||
|
||||
public IAppRepo AppRepo { get; set; } = default!;
|
||||
@@ -57,9 +49,6 @@ public partial class App : Node, IApp
|
||||
private IGame _game;
|
||||
private IDataViewer _enemyViewer;
|
||||
|
||||
private event Action OnGameLoaded;
|
||||
private event Action OnEnemyViewerLoaded;
|
||||
|
||||
private double _reportedProgress = 0;
|
||||
|
||||
public void Initialize()
|
||||
@@ -110,6 +99,11 @@ public partial class App : Node, IApp
|
||||
this.Provide();
|
||||
}
|
||||
|
||||
private void GameExitRequested()
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
}
|
||||
|
||||
private void DeleteSaveData()
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
@@ -150,27 +144,31 @@ public partial class App : Node, IApp
|
||||
})
|
||||
.Handle((in AppLogic.Output.SetupGameScene _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadGame(GAME_SCENE_PATH);
|
||||
MainMenu.ReleaseFocus();
|
||||
MainMenu.Hide();
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowMainMenu _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowGame _) =>
|
||||
.Handle((in AppLogic.Output.CloseGame _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
_game.GameExitRequested -= GameExitRequested;
|
||||
MainMenu.StartGameButton.GrabFocus();
|
||||
_game.CallDeferred(MethodName.QueueFree, []);
|
||||
GetTree().Paused = false;
|
||||
})
|
||||
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
|
||||
{
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerOpened _) =>
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadEnemyViewer(ENEMY_VIEWER_PATH);
|
||||
MainMenu.ReleaseFocus();
|
||||
MainMenu.Hide();
|
||||
})
|
||||
.Handle((in AppLogic.Output.EnemyViewerExited _) =>
|
||||
{
|
||||
LoadingScreen.Hide();
|
||||
if (_enemyViewer != null && _enemyViewer is DataViewer enemyViewer)
|
||||
enemyViewer.CallDeferred(MethodName.QueueFree);
|
||||
MainMenu.Show();
|
||||
@@ -202,6 +200,7 @@ public partial class App : Node, IApp
|
||||
{
|
||||
var scene = await LoadSceneInternal(sceneName);
|
||||
_game = scene as IGame;
|
||||
_game.GameExitRequested += GameExitRequested;
|
||||
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
}
|
||||
@@ -216,6 +215,7 @@ public partial class App : Node, IApp
|
||||
|
||||
private async Task<Node> LoadSceneInternal(string sceneName)
|
||||
{
|
||||
LoadingScreen.Show();
|
||||
LoadingScreen.ProgressBar.Value = 0;
|
||||
var sceneLoader = new SceneLoader();
|
||||
CallDeferred(MethodName.AddChild, sceneLoader);
|
||||
|
||||
Reference in New Issue
Block a user