Skip to content

Commit 0918529

Browse files
author
Alexis Huvier
committed
refactor
1 parent 75ed392 commit 0918529

2 files changed

Lines changed: 29 additions & 26 deletions

File tree

SharpEngine.Core/Utils/SeImGui/SEImGuiConsole.cs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class SeImGuiConsole
2626
/// <summary>
2727
/// Input of Console
2828
/// </summary>
29-
public string ConsoleInput = "";
29+
private string ConsoleInput = "";
3030

3131
/// <summary>
3232
/// Add Text to Console
@@ -61,36 +61,39 @@ public void Display(Window window)
6161

6262
if (ImGui.InputText("Input", ref ConsoleInput, 100, ImGuiInputTextFlags.EnterReturnsTrue))
6363
{
64-
if (ConsoleInput.Length > 0)
65-
{
66-
AddText("> " + ConsoleInput);
67-
68-
var command = ConsoleInput.Split(" ");
69-
var commandName = command[0];
70-
var commandArgs = Array.Empty<string>();
71-
if (command.Length > 1)
72-
commandArgs = command[1..];
73-
74-
var found = false;
75-
foreach (var commandObject in Commands)
76-
{
77-
if(commandObject.Command == commandName)
78-
{
79-
commandObject.Process(commandArgs, this, window);
80-
found = true;
81-
break;
82-
}
83-
}
84-
85-
if (!found)
86-
AddText("Unknown command.");
87-
}
64+
if (ConsoleInput.Length > 0)
65+
ProcessCommand(window);
8866

8967
ConsoleInput = "";
9068
ImGui.SetKeyboardFocusHere(-1);
9169
}
9270

9371
ImGui.End();
9472
}
73+
74+
private void ProcessCommand(Window window)
75+
{
76+
AddText("> " + ConsoleInput);
77+
78+
var command = ConsoleInput.Split(" ");
79+
var commandName = command[0];
80+
var commandArgs = Array.Empty<string>();
81+
if (command.Length > 1)
82+
commandArgs = command[1..];
83+
84+
var found = false;
85+
foreach (var commandObject in Commands)
86+
{
87+
if (commandObject.Command == commandName)
88+
{
89+
commandObject.Process(commandArgs, this, window);
90+
found = true;
91+
break;
92+
}
93+
}
94+
95+
if (!found)
96+
AddText("Unknown command.");
97+
}
9598
}
9699
}

SharpEngine.Core/Utils/SeImGui/SeImGuiWindows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SharpEngine.Core.Utils.SeImGui
1212
/// <summary>
1313
/// Class which have imgui windows
1414
/// </summary>
15-
public class SeImGuiWindows
15+
public static class SeImGuiWindows
1616
{
1717
private static SeImGuiConsole Console { get; } = new();
1818

0 commit comments

Comments
 (0)