Fixed typo, playground debug now attaches log listener on toggle.

This commit is contained in:
Harrison Deng 2020-07-06 18:06:46 -05:00
parent 636efaaaf9
commit fd7edc2629
2 changed files with 8 additions and 8 deletions

View File

@ -87,7 +87,7 @@ namespace SlatedGameToolkit.Framework.StateSystem
/// <summary>
/// Adds the given state to this manager under it's own name.
/// Initializes the state as well.
/// Will not iniitialize the state if this method returns false.
/// Will not initialize the state if this method returns false.
/// </summary>
/// <param name="state">The state to be added to this manager.</param>
/// <returns>False if a state of this name has already been registered.</returns>
@ -115,6 +115,7 @@ namespace SlatedGameToolkit.Framework.StateSystem
Logger.Log("Removing state: " + name, LogLevel.DEBUG);
try {
state.Deinitialize();
Logger.Log("State deinitialized: " + name, LogLevel.DEBUG);
} catch (Exception e) {
Logger.Log(e.ToString(), LogLevel.WARNING);
Logger.Log("Failed to deinitialize state: " + state.getName(), LogLevel.WARNING);

View File

@ -11,7 +11,6 @@ namespace SlatedGameToolkit.Tools.Commands
{
private readonly string[] invokers = new string[] {"playground"};
private ConsolePlaygroundListener logListener;
private bool debugging;
public bool Execute(IInteractable interactable, string[] args)
{
@ -38,18 +37,18 @@ namespace SlatedGameToolkit.Tools.Commands
interactable.Tell("Debug logging: " + logListener.Debug);
return true;
} else if (args[0].Equals("debug")) {
debugging = !debugging;
if (logListener != null) {
logListener.Debug = debugging;
interactable.Tell("Debug logging: " + logListener.Debug);
if (logListener == null) {
Logger.AddLogListener((logListener = new ConsolePlaygroundListener(interactable as ConsoleInteraction)));
logListener.Debug = true;
interactable.Tell("Attached log listener.");
} else {
interactable.Tell(string.Format("Debug will be turned {0} when playground is started.", debugging ? "on" : "off"));
logListener.Debug = !logListener.Debug;
}
interactable.Tell(string.Format("Debug logging has been turned {0}.", logListener.Debug ? "on" : "off"));
return true;
} else if (args[0].Equals("log")) {
if (logListener == null) {
Logger.AddLogListener((logListener = new ConsolePlaygroundListener(interactable as ConsoleInteraction)));
logListener.Debug = debugging;
interactable.Tell("Listening to game engine's logging.");
} else {
Logger.RemoveLogListener(logListener);