Fix export

This commit is contained in:
2025-03-31 01:18:36 -07:00
parent ffc3177244
commit 20dad3069a
15 changed files with 212 additions and 189 deletions

View File

@@ -38,80 +38,80 @@ public partial class App : CanvasLayer, IApp
public void Initialize()
{
var container = new SimpleInjector.Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.Register<IAppRepo, AppRepo>(Lifestyle.Singleton);
container.Register<IAppLogic, AppLogic>(Lifestyle.Singleton);
container.Verify();
var container = new SimpleInjector.Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.RegisterSingleton<IAppRepo, AppRepo>();
container.RegisterSingleton<IAppLogic, AppLogic>();
//container.Verify();
Instantiator = new Instantiator(GetTree());
Instantiator = new Instantiator(GetTree());
AppRepo = container.GetInstance<IAppRepo>();
AppLogic = container.GetInstance<IAppLogic>();
AppRepo = container.GetInstance<IAppRepo>();
AppLogic = container.GetInstance<IAppLogic>();
AppLogic.Set(AppRepo);
AppLogic.Set(new AppLogic.Data());
AppLogic.Set(AppRepo);
AppLogic.Set(new AppLogic.Data());
Menu.NewGame += OnNewGame;
Menu.LoadGame += OnLoadGame;
Menu.Quit += OnQuit;
Menu.NewGame += OnNewGame;
Menu.LoadGame += OnLoadGame;
Menu.Quit += OnQuit;
AnimationPlayer.AnimationFinished += OnAnimationFinished;
AnimationPlayer.AnimationFinished += OnAnimationFinished;
Input.MouseMode = Input.MouseModeEnum.Visible;
this.Provide();
Input.MouseMode = Input.MouseModeEnum.Visible;
this.Provide();
}
public void OnReady()
{
AppBinding = AppLogic.Bind();
AppBinding = AppLogic.Bind();
AppBinding
.Handle((in AppLogic.Output.ShowSplashScreen _) =>
{
HideMenus();
BlankScreen.Hide();
Splash.Show();
})
.Handle((in AppLogic.Output.HideSplashScreen _) =>
{
BlankScreen.Show();
FadeToBlack();
})
.Handle((in AppLogic.Output.SetupGameScene _) =>
{
Game = Instantiator.LoadAndInstantiate<Game>(GAME_SCENE_PATH);
GameWindow.AddChildEx(Game);
Instantiator.SceneTree.Paused = false;
})
.Handle((in AppLogic.Output.ShowMainMenu _) =>
{
// Load everything while we're showing a black screen, then fade in.
HideMenus();
Menu.Show();
AppBinding
.Handle((in AppLogic.Output.ShowSplashScreen _) =>
{
HideMenus();
BlankScreen.Hide();
Splash.Show();
})
.Handle((in AppLogic.Output.HideSplashScreen _) =>
{
BlankScreen.Show();
FadeToBlack();
})
.Handle((in AppLogic.Output.SetupGameScene _) =>
{
Game = Instantiator.LoadAndInstantiate<Game>(GAME_SCENE_PATH);
GameWindow.AddChildEx(Game);
Instantiator.SceneTree.Paused = false;
})
.Handle((in AppLogic.Output.ShowMainMenu _) =>
{
// Load everything while we're showing a black screen, then fade in.
HideMenus();
Menu.Show();
FadeInFromBlack();
Menu.NewGameButton.GrabFocus();
})
.Handle((in AppLogic.Output.FadeToBlack _) => FadeToBlack())
.Handle((in AppLogic.Output.HideGame _) => FadeToBlack())
.Handle((in AppLogic.Output.ShowGame _) =>
{
HideMenus();
FadeInFromBlack();
})
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
{
Game.SaveFileLoaded += OnSaveFileLoaded;
Game.LoadExistingGame();
})
.Handle((in AppLogic.Output.ExitGame _) =>
{
GetTree().Quit();
});
FadeInFromBlack();
Menu.NewGameButton.GrabFocus();
})
.Handle((in AppLogic.Output.FadeToBlack _) => FadeToBlack())
.Handle((in AppLogic.Output.HideGame _) => FadeToBlack())
.Handle((in AppLogic.Output.ShowGame _) =>
{
HideMenus();
FadeInFromBlack();
})
.Handle((in AppLogic.Output.StartLoadingSaveFile _) =>
{
Game.SaveFileLoaded += OnSaveFileLoaded;
Game.LoadExistingGame();
})
.Handle((in AppLogic.Output.ExitGame _) =>
{
GetTree().Quit();
});
AppLogic.Start();
AppLogic.Start();
}
public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame());
@@ -122,44 +122,44 @@ public partial class App : CanvasLayer, IApp
public void OnSaveFileLoaded()
{
Game.SaveFileLoaded -= OnSaveFileLoaded;
AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
Game.SaveFileLoaded -= OnSaveFileLoaded;
AppLogic.Input(new AppLogic.Input.SaveFileLoaded());
}
public void FadeInFromBlack()
{
BlankScreen.Show();
AnimationPlayer.Play("fade_in");
BlankScreen.Show();
AnimationPlayer.Play("fade_in");
}
public void FadeToBlack()
{
BlankScreen.Show();
AnimationPlayer.Play("fade_out");
BlankScreen.Show();
AnimationPlayer.Play("fade_out");
}
public void HideMenus()
{
Splash.Hide();
Menu.Hide();
Splash.Hide();
Menu.Hide();
}
public void OnAnimationFinished(StringName animation)
{
if (animation == "fade_in")
{
AppLogic.Input(new AppLogic.Input.FadeInFinished());
BlankScreen.Hide();
return;
}
if (animation == "fade_in")
{
AppLogic.Input(new AppLogic.Input.FadeInFinished());
BlankScreen.Hide();
return;
}
AppLogic.Input(new AppLogic.Input.FadeOutFinished());
AppLogic.Input(new AppLogic.Input.FadeOutFinished());
}
public void OnExitTree()
{
AppLogic.Stop();
AppBinding.Dispose();
AppRepo.Dispose();
AppLogic.Stop();
AppBinding.Dispose();
AppRepo.Dispose();
}
}