Skip to content

Commit 0983464

Browse files
committed
feat(debugmanager): add AddConsoleCommand
1 parent eb0c771 commit 0983464

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

SharpEngine.Core/Manager/DebugManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using SharpEngine.Core.Renderer;
88
using SharpEngine.Core.Utils;
99
using SharpEngine.Core.Utils.SeImGui;
10+
using SharpEngine.Core.Utils.SeImGui.ConsoleCommand;
1011

1112
namespace SharpEngine.Core.Manager;
1213

@@ -52,6 +53,13 @@ public static void SeRenderImGui(Window window)
5253
window._imguiDisplayConsole = !window._imguiDisplayConsole;
5354
}
5455

56+
/// <summary>
57+
/// Add Console Command
58+
/// </summary>
59+
/// <param name="command">Console Command</param>
60+
public static void AddConsoleCommand(ISeImGuiConsoleCommand command) =>
61+
SeImGuiWindows.Console.Commands.Add(command);
62+
5563
/// <summary>
5664
/// Log Message
5765
/// </summary>

SharpEngine.Core/Utils/SeImGui/SeImGuiWindows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace SharpEngine.Core.Utils.SeImGui
1414
/// </summary>
1515
public static class SeImGuiWindows
1616
{
17-
private static SeImGuiConsole Console { get; } = new();
17+
internal static SeImGuiConsole Console { get; } = new();
1818

1919
/// <summary>
2020
/// Display ImGui Console for SharpEngine

Testing/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private static void Main()
2828

2929
window.AddScene(new MyScene());
3030

31+
DebugManager.AddConsoleCommand(new TestConsoleCommand());
32+
3133
window.Run();
3234
}
3335
}

Testing/TestConsoleCommand.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using SharpEngine.Core;
2+
using SharpEngine.Core.Utils.SeImGui;
3+
using SharpEngine.Core.Utils.SeImGui.ConsoleCommand;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Testing
11+
{
12+
internal class TestConsoleCommand : ISeImGuiConsoleCommand
13+
{
14+
public string Command => "test";
15+
16+
public void Process(string[] args, SeImGuiConsole console, Window window)
17+
{
18+
console.AddText(window.IndexCurrentScene.ToString());
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)