80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.GodotNodeInterfaces;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
public interface IFloorClearMenu : IControl
|
|
{
|
|
event FloorClearMenu.GoToNextFloorEventHandler GoToNextFloor;
|
|
|
|
event FloorClearMenu.ExitEventHandler Exit;
|
|
|
|
event FloorClearMenu.TransitionCompletedEventHandler TransitionCompleted;
|
|
|
|
void FadeIn();
|
|
|
|
void FadeOut();
|
|
}
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class FloorClearMenu : Control, IFloorClearMenu
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
|
|
|
[Node] public Button ContinueButton { get; set; } = default!;
|
|
|
|
[Node] public Button ExitButton { get; set; } = default!;
|
|
|
|
public void FadeIn() => AnimationPlayer.Play("fade_in");
|
|
|
|
public void FadeOut() => AnimationPlayer.Play("fade_out");
|
|
|
|
[Signal]
|
|
public delegate void TransitionCompletedEventHandler();
|
|
[Signal]
|
|
public delegate void GoToNextFloorEventHandler();
|
|
[Signal]
|
|
public delegate void ExitEventHandler();
|
|
|
|
public void OnResolved()
|
|
{
|
|
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
|
ContinueButton.Pressed += ContinueButton_Pressed;
|
|
ExitButton.Pressed += ExitButton_Pressed;
|
|
}
|
|
|
|
private void ExitButton_Pressed()
|
|
{
|
|
ContinueButton.Disabled = true;
|
|
ExitButton.Disabled = true;
|
|
FadeOut();
|
|
EmitSignal(SignalName.Exit);
|
|
}
|
|
|
|
private void ContinueButton_Pressed()
|
|
{
|
|
ContinueButton.Disabled = true;
|
|
ExitButton.Disabled = true;
|
|
EmitSignal(SignalName.GoToNextFloor);
|
|
}
|
|
|
|
private void AnimationPlayer_AnimationFinished(StringName animName)
|
|
{
|
|
if (animName == "fade_in")
|
|
{
|
|
ContinueButton.Disabled = false;
|
|
ExitButton.Disabled = false;
|
|
ContinueButton.CallDeferred(MethodName.GrabFocus);
|
|
}
|
|
if (animName == "fade_out")
|
|
{
|
|
CallDeferred(MethodName.ReleaseFocus);
|
|
EmitSignal(SignalName.TransitionCompleted);
|
|
}
|
|
}
|
|
}
|