Began working on a graphical playground for testing.

Improved SDL exception class.

Engine code changes.

General progress.
This commit is contained in:
2020-05-27 00:20:41 -05:00
parent 0f0395fd63
commit a013c476e7
13 changed files with 191 additions and 43 deletions

View File

@@ -0,0 +1,60 @@
using SlatedGameToolkit.Framework;
using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Tools.System;
using SlatedGameToolkit.Tools.System.Interaction;
using SlatedGameToolkit.Tools.Utilities.GraphicalPlayground;
namespace SlatedGameToolkit.Tools.Commands
{
public class GraphicalPlaygroundCommand : IInvocable
{
private readonly string[] invokers = new string[] {"playground"};
public bool Execute(IInteractable interactable, string[] args)
{
if (args.Length != 1) return false;
if (args[0].Equals("start")) {
if (GameEngine.Running) {
interactable.Tell("Engine is already running!");
return true;
}
Manager manager = new Manager("main state", new MainState());
GameEngine.Ignite(manager);
return true;
} else if (args[0].Equals("stop")) {
if (!GameEngine.Running) {
interactable.Tell("Engine was never running!");
return true;
}
GameEngine.Stop();
return true;
} else if (args[0].Equals("status")) {
interactable.Tell("Running: " + GameEngine.Running);
interactable.Tell("Target FPS: " + GameEngine.targetFPS);
interactable.Tell("Target Update Rate: " + GameEngine.UpdatesPerSecond);
return true;
}
return false;
}
public string getDescription()
{
return "Starts and stops the graphical playground.";
}
public string[] GetInvokers()
{
return invokers;
}
public string getUsage(string arg)
{
return "Usage: \"playground [start | stop | status]\" the required argument being whether to start, stop or get the current status of the game engine.";
}
public void Dispose()
{
GameEngine.Stop();
}
}
}

View File

@@ -52,5 +52,10 @@ namespace SlatedGameToolkit.Tools.Commands
{
return invokers;
}
public void Dispose()
{
}
}
}

View File

@@ -27,5 +27,9 @@ namespace SlatedGameToolkit.Tools.Commands
{
return invokers;
}
public void Dispose()
{
}
}
}

View File

@@ -11,8 +11,10 @@ namespace SlatedGameToolkit.Tools
static private bool running;
static void Main(string[] args)
{
CommandMap commands = new CommandMap(new StopCommand());
CommandMap commands = new CommandMap();
commands.Add(new StopCommand());
commands.Add(new HelpCommand(commands));
commands.Add(new GraphicalPlaygroundCommand());
CommandProcessor processor = new CommandProcessor("The command \"{input}\" was not understood. Please type \"help\" for more information.", commands);
AssemblyName name = Assembly.GetExecutingAssembly().GetName();
ConsoleInteraction consoleInteracter = new ConsoleInteraction("Tools");
@@ -24,6 +26,7 @@ namespace SlatedGameToolkit.Tools
processor.Process(consoleInteracter);
}
consoleInteracter.Tell("Exiting tool.");
commands.Dispose();
}
public static void Stop() {

View File

@@ -5,7 +5,7 @@ using SlatedGameToolkit.Tools.System.Interaction;
namespace SlatedGameToolkit.Tools.System
{
public class CommandMap : ICollection<IInvocable> {
public class CommandMap : ICollection<IInvocable>, IDisposable {
Dictionary<string, IInvocable> invocations;
HashSet<IInvocable> values;
@@ -79,5 +79,17 @@ namespace SlatedGameToolkit.Tools.System
values.Remove(item);
return true;
}
public void Dispose()
{
foreach (IInvocable invocable in this)
{
invocable.Dispose();
}
}
~CommandMap() {
Dispose();
}
}
}

View File

@@ -1,8 +1,9 @@
using System;
using SlatedGameToolkit.Tools.System.Interaction;
namespace SlatedGameToolkit.Tools.System
{
public interface IInvocable
public interface IInvocable : IDisposable
{
/// <summary>
/// Invokers are the strings that should invoke this command.

View File

@@ -4,7 +4,6 @@ namespace SlatedGameToolkit.Tools.System.Interaction
{
void Tell(string message);
void Separate();
string Listen();
}
}

View File

@@ -0,0 +1,40 @@
using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Framework.StateSystem.States;
namespace SlatedGameToolkit.Tools.Utilities.GraphicalPlayground
{
public class MainState : IState
{
public bool Activate()
{
return true;
}
public bool Deactivate()
{
return true;
}
public void Dispose()
{
}
public string getName()
{
return "main state";
}
public void Initialize(Manager manager)
{
}
public void Render(double delta)
{
}
public void Update(double delta)
{
}
}
}