Re-introduce prototype code
This commit is contained in:
52
src/menu/Menu.cs
Normal file
52
src/menu/Menu.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public interface IMenu : IControl
|
||||
{
|
||||
event Menu.NewGameEventHandler NewGame;
|
||||
event Menu.QuitEventHandler Quit;
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Menu : Control, IMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node]
|
||||
public IButton NewGameButton { get; set; } = default!;
|
||||
|
||||
[Node]
|
||||
public IButton QuitButton { get; set; } = default!;
|
||||
|
||||
[Signal]
|
||||
public delegate void NewGameEventHandler();
|
||||
[Signal]
|
||||
public delegate void QuitEventHandler();
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
NewGameButton.Pressed += OnNewGamePressed;
|
||||
QuitButton.Pressed += OnQuitPressed;
|
||||
NewGameButton.GrabFocus();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
NewGameButton.Pressed -= OnNewGamePressed;
|
||||
QuitButton.Pressed -= OnQuitPressed;
|
||||
}
|
||||
|
||||
public void OnNewGamePressed() => EmitSignal(SignalName.NewGame);
|
||||
|
||||
public void OnQuitPressed() => EmitSignal(SignalName.Quit);
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (Input.IsActionJustPressed(GameInputs.Attack))
|
||||
OnNewGamePressed();
|
||||
}
|
||||
}
|
||||
30
src/menu/splash/Splash.cs
Normal file
30
src/menu/splash/Splash.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public interface ISplash : IControl;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Splash : Control, ISplash
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency]
|
||||
public IAppRepo AppRepo => this.DependOn<IAppRepo>();
|
||||
|
||||
[Node]
|
||||
public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void OnReady() =>
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
|
||||
public void OnExitTree()
|
||||
=> AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
||||
|
||||
public void OnAnimationFinished(StringName name)
|
||||
=> AppRepo.SkipSplashScreen();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user