Startet as a debugging tool for myself, it's now so handy that I polished it a bit and now want to share it with you:
Delta.Console is a quake style development console with some extra features to use with the Delta Engine.
Load the module and bind the key to open/close the consle:Code:
var module = Factory.Create<Delta.Console.Module>(new object[] { InputButton.Pipe, null, null, null, null });
Call any method from the console by just adding the "ConsoleCommand" attribute:Code:
[ConsoleCommand("Render.AddFloats")]
public float AddFloats(float a, float b)
{
return a + b;
}
The ConsoleCommandAttribute takes a string in his constructors where you specific the name that should be used to display and call this method from the console.
You can use this to group you commands by dot notation.
Then add this method to your console:
Code:
module.AddCmdToConsole(typeof(Game).GetMethod("AddFloats"), null);
Now in the console do (lower/uppercase will be ignored):
Code:
Render.AddFloats 2,3 4,89
Result: 7,19
All type information will be automatically displayed in the console.
Autocompletion and history support:Just enter "ren", press Tab and it will be completed to "Render.", if you now also enter "ad", it will completed to "Render.AddFloats".
Additional, commands that starts with the given string will be displayed under the input line.
You can step through the history of entered command by pressing the CursorUp/Down key like the Windows CMD does.
Error detection:If a parameter could not converted to his matching type to pass the method or a parameter is missing you get an message with the information what was wrong:
Code:
Render.AddFloats 2,3
Error: The command has 2 parameters, but you entered 1
Render.AddFloats 2,3 foo
Error: Can't process parameter no. 2: Die Eingabezeichenfolge hat das falsche Format <- Exception Message
Render.Foo
Error: Unknow console command "Render.Foo"!
Plot data:You can plot any data you want on a graph by just implementing the
IPlottable interface.
This is pretty nice to see a history of the FPS, the CPU usage or a count of objects/particles in a scene.
Code:
class TestPlotFps : IPlottable
{
public TestPlotFps()
{
this.PlotName = "FPS";
this.PlotColor = Color.Red;
// We dont know a fixed range of FPS so we enable autoscale
this.UseAutoScale = true;
}
public bool UseAutoScale { get; set; }
public float MinValue { get; set; }
public float MaxValue { get; set; }
public string PlotName { get; set; }
public Color PlotColor { get; set; }
public float UpdatePlot()
{
// Return the current FPS
// Will be auto updated every second so we dont need to cache
return Time.Fps;
}
}
Then add it to the graph:
Code:
module.AddPlotToGraph(new TestPlotFPS());
As you can see the plot can scale automatically or you can specific a fixed range by yourself.
You get also the minimal, maximal and average value of all plot data points that are currently visible in the graph.
Last but not least a screenshot of the module in action:
You can get Delta.Console with a sample game from my GitHub account:https://github.com/mc-kay/Delta.ConsoleHave fun

Edited by user Thursday, September 20, 2012 3:32:30 PM(UTC)
| Reason: test edit to get rid of formating errors