From 9377a5c865dd608e340ad149fb0e470d1c77f49b Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Thu, 2 Jan 2025 16:59:26 -0600 Subject: [PATCH] qol changes to the console --- Game.cs | 2 ++ RaylibCogwheelConsole.cs | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Game.cs b/Game.cs index 1fb32b7..3e6496c 100644 --- a/Game.cs +++ b/Game.cs @@ -55,4 +55,6 @@ public class Game { _console.Draw(); } + + } \ No newline at end of file diff --git a/RaylibCogwheelConsole.cs b/RaylibCogwheelConsole.cs index 2dde15e..f968979 100644 --- a/RaylibCogwheelConsole.cs +++ b/RaylibCogwheelConsole.cs @@ -31,11 +31,10 @@ public class RaylibCogwheelConsole : ICogwheelConsole Write(OpeningMessage); } - - [Command(Name = "log", Description = "Logs a message to the console.")] + public void Log(string message) { - Write(message); + WriteColor("[INFO] " + message, new Color(0, 200, 255, 255)); } public void LogError(string message) @@ -57,8 +56,7 @@ public class RaylibCogwheelConsole : ICogwheelConsole public void Write(string message) { - _output += message; - // log [Color=255,0,0,255]G[/Color][Color=0,255,0,255]A[/Color][Color=0,0,255,255]Y[/Color] + _output += message + "\n"; TrimOutputBuffer(); } @@ -117,9 +115,8 @@ public class RaylibCogwheelConsole : ICogwheelConsole if (match.Index > lastIndex) { ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1.0f, 1.0f, 1.0f, 1.0f)); // White for normal text - ImGui.Text(line.Substring(lastIndex, match.Index - lastIndex)); + ImGui.TextUnformatted(line.Substring(lastIndex, match.Index - lastIndex)); ImGui.PopStyleColor(); - ImGui.SameLine(0, 0); } // Set the color for the text inside the color tags @@ -131,9 +128,8 @@ public class RaylibCogwheelConsole : ICogwheelConsole ); ImGui.PushStyleColor(ImGuiCol.Text, color); - ImGui.Text(match.Groups[5].Value); + ImGui.TextUnformatted(match.Groups[5].Value); ImGui.PopStyleColor(); - ImGui.SameLine(0, 0); lastIndex = match.Index + match.Length; } @@ -142,10 +138,9 @@ public class RaylibCogwheelConsole : ICogwheelConsole if (lastIndex < line.Length) { ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1.0f, 1.0f, 1.0f, 1.0f)); // White for normal text - ImGui.Text(line.Substring(lastIndex)); + ImGui.TextUnformatted(line.Substring(lastIndex)); ImGui.PopStyleColor(); } - ImGui.NewLine(); // Move to the next line after processing the current line } if (_scrollToBottom) @@ -175,9 +170,7 @@ public class RaylibCogwheelConsole : ICogwheelConsole private void ProcessInput(string input) { - _output += "\n" + "> " + input + "\n"; - TrimOutputBuffer(); - + Write("\n" + "> " + input + "\n"); COGWHEEL.RunCommand(input); } @@ -190,9 +183,9 @@ public class RaylibCogwheelConsole : ICogwheelConsole } } - [Command(Name = "test")] + [Command(Name = "warn")] private void Test() { - Write("[COLOR=255,0,255,255] Test command executed!"); + LogWarning("This is a test warning message"); } } \ No newline at end of file