Changed to custom logging solution.
This commit is contained in:
@@ -1,28 +1,47 @@
|
||||
using System;
|
||||
using SlatedGameToolkit.Framework.Logging;
|
||||
|
||||
namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
|
||||
{
|
||||
public class ConsoleInteraction : IInteractable
|
||||
public class ConsoleInteraction : IInteractable, ILogListener
|
||||
{
|
||||
private volatile bool listening;
|
||||
string prefix;
|
||||
public bool Debug { get; set; }
|
||||
public LogLevel Level => Debug ? LogLevel.DEBUG : LogLevel.INFO;
|
||||
|
||||
public ConsoleInteraction(string prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public void Separate()
|
||||
{
|
||||
listening = false;
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
public string Listen()
|
||||
{
|
||||
listening = true;
|
||||
Console.Write(prefix + "> ");
|
||||
return Console.ReadLine();
|
||||
}
|
||||
|
||||
public void Tell(string message)
|
||||
{
|
||||
listening = false;
|
||||
Console.SetCursorPosition(0, Console.CursorTop);
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public void LogMesesage(string message, DateTime time, LogLevel level)
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.CursorTop);
|
||||
Console.WriteLine(string.Format("Playground [{0}] [{1}]: {2}", level, time.ToString("H:mm:ss"), message));
|
||||
if (listening) {
|
||||
Console.SetCursorPosition(0, Console.CursorTop);
|
||||
Console.Write(prefix + "> ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
using SlatedGameToolkit.Framework.Logging;
|
||||
|
||||
namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
|
||||
{
|
||||
public interface IInteractable
|
||||
public interface IInteractable : ILogListener
|
||||
{
|
||||
void Tell(string message);
|
||||
void Separate();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SlatedGameToolkit.Framework.Logging;
|
||||
using SlatedGameToolkit.Tools.CommandSystem.Exceptions;
|
||||
|
||||
namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
|
||||
@@ -10,6 +11,9 @@ namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
|
||||
public SingleConsoleInteraction(string oneTime) {
|
||||
this.oneTime = oneTime;
|
||||
}
|
||||
|
||||
public LogLevel Level => LogLevel.DEBUG;
|
||||
|
||||
public string Listen()
|
||||
{
|
||||
if (interacted) throw new FatalUsageException("Command attempted to request for more information. This generally occurs if the command being ran requires more user input.");
|
||||
@@ -17,6 +21,12 @@ namespace SlatedGameToolkit.Tools.CommandSystem.Interaction
|
||||
return oneTime;
|
||||
}
|
||||
|
||||
public void LogMesesage(string message, DateTime time, LogLevel level)
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.CursorTop);
|
||||
Console.WriteLine(string.Format("Game Engine [{0}] [{1}]: \n{2}", level, time.ToString(), message));
|
||||
}
|
||||
|
||||
public void Separate()
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using SlatedGameToolkit.Framework;
|
||||
using SlatedGameToolkit.Framework.Logging;
|
||||
using SlatedGameToolkit.Framework.StateSystem;
|
||||
using SlatedGameToolkit.Tools.CommandSystem;
|
||||
using SlatedGameToolkit.Tools.CommandSystem.Interaction;
|
||||
@@ -19,7 +20,7 @@ namespace SlatedGameToolkit.Tools.Commands
|
||||
interactable.Tell("Engine is already running!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger.AddLogListener(interactable);
|
||||
GameEngine.Ignite(new MainState());
|
||||
return true;
|
||||
} else if (args[0].Equals("stop")) {
|
||||
|
@@ -28,7 +28,6 @@ namespace SlatedGameToolkit.Tools
|
||||
interactable.Tell("Welcome to SlatedGameToolkit.Tools! These tools are meant for the developers using the SlatedGameToolkit. Type \"help\" for a list of things this tool can currently do.");
|
||||
live = true;
|
||||
while (live) {
|
||||
interactable.Separate();
|
||||
processor.Process(interactable);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user