feat: add in-game debug console UI

This commit is contained in:
2026-08-22 19:40:12 +02:00
parent 4f57c77b7b
commit a749d97b99
9 changed files with 217 additions and 2 deletions
+19
View File
@@ -1,4 +1,8 @@
using Game.Features.Console.Application.Commands;
using Game.Features.Console.Godot;
using Game.Features.Console.Infrastructure;
using Game.Godot;
using Game.Godot.Extensions;
using Game.Godot.Mappings;
using Godot;
@@ -6,9 +10,24 @@ namespace Game.Godot.Bootstrap;
public partial class GameBootstrap : Node
{
[Export] public ConsoleController Console;
private void RegisterConsoleCommands()
{
CommandRegistry registry = new();
registry.Register(new HelpCommand(registry));
registry.Register(new EchoCommand());
registry.Register(new ClearCommand());
Console.UseCommandRegistry(registry);
}
public override void _Ready()
{
this.AssertRequiredExports();
MouseCapture.Capture();
RegisterConsoleCommands();
}
public override void _UnhandledInput(InputEvent @event)
+29
View File
@@ -0,0 +1,29 @@
using Godot;
namespace Game.Godot;
public static class GamePause
{
private static SceneTree Tree => (SceneTree)Engine.GetMainLoop();
public static bool IsPaused => Tree.Paused;
public static void Pause() => Tree.Paused = true;
public static void Resume() => Tree.Paused = false;
public static void Toggle()
{
if (IsPaused)
{
Resume();
}
else
{
Pause();
}
}
public static void SetIgnoresPause(Node node, bool value) =>
node.ProcessMode = value ? Node.ProcessModeEnum.Always : Node.ProcessModeEnum.Inherit;
}
+1
View File
@@ -0,0 +1 @@
uid://i7fuhrb208r8
+3 -1
View File
@@ -9,7 +9,8 @@ public enum InputAction
MoveForward,
MoveBack,
Jump,
Cancel
Cancel,
ToggleConsole
}
public static class InputActionExtensions
@@ -25,6 +26,7 @@ public static class InputActionExtensions
InputAction.MoveBack => "move_back",
InputAction.Jump => "jump",
InputAction.Cancel => "ui_cancel",
InputAction.ToggleConsole => "toggle_console",
_ => throw new ArgumentOutOfRangeException(nameof(action), action, null)
};
}