Start refactoring UI concerns away from game and into UI logic class

This commit is contained in:
2025-03-07 16:48:45 -08:00
parent c3bfab5f53
commit 93c04440d4
11 changed files with 111 additions and 23 deletions

View File

@@ -2,6 +2,8 @@ using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
using Renci.SshNet.Messages;
using Zennysoft.Game.Ma.Implementation;
namespace Zennysoft.Game.Ma;
@@ -31,9 +33,34 @@ public partial class InGameUI : Control, IInGameUI
[Node] public IUseTeleportPrompt UseTeleportPrompt { get; set; } = default!;
[Dependency] private IGameRepo _gameRepo => this.DependOn<IGameRepo>();
public IInGameUILogic InGameUILogic { get; set; } = default!;
public InGameUILogic.IBinding InGameUILogicBinding { get; set; } = default!;
[Signal]
public delegate void MinimapButtonReleasedEventHandler();
public void Setup()
{
InGameUILogic = new InGameUILogic();
InGameUILogic.Set(_gameRepo);
}
public void OnResolved()
{
InGameUILogicBinding = InGameUILogic.Bind();
InGameUILogicBinding
.Handle((in InGameUILogic.Output.AnnounceMessage output) =>
{
PlayerInfoUI.DisplayMessage(output.Message);
});
InGameUILogic.Start();
}
public override void _UnhandledInput(InputEvent @event)
{
if (@event.IsActionReleased(GameInputs.MiniMap))