Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline mc-kay  
#1 Posted : Monday, June 4, 2012 1:41:48 PM(UTC)
mc-kay

Medals: Admin

Joined: 8/24/2011(UTC)
Posts: 138
Location: Hannover

Thanks: 1 times
Was thanked: 12 time(s) in 7 post(s)
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:
UserPostedImage

You can get Delta.Console with a sample game from my GitHub account:
https://github.com/mc-kay/Delta.Console


Have fun ThumpUp

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

thanks 1 user thanked mc-kay for this useful post.
Benjamin on 9/22/2012(UTC)

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline elasto  
#2 Posted : Monday, June 4, 2012 2:23:51 PM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Looks really nice! I will definitely check it out in due course
Offline internetfreak  
#3 Posted : Monday, June 4, 2012 2:33:23 PM(UTC)
internetfreak

Joined: 12/19/2011(UTC)
Posts: 529

Thanks: 10 times
Was thanked: 16 time(s) in 15 post(s)
Very nice. This could be a great help when you want to implement a chat or something (only if it's somehow possible)
But also as normal debug console it's a nice addon to have.
Is the console stylable, so we can change the output location and also the size of the console window (maybe with auto wrapping text)?

I hope it will be included in the delta engine repo because I think it's a must-have and very helpful.
Mein Blog: www.internetfreak.net

- Inoffizieller DeltaEngine-Supporter und Tutorialschreiber -
Offline mc-kay  
#4 Posted : Tuesday, June 5, 2012 11:23:17 AM(UTC)
mc-kay

Medals: Admin

Joined: 8/24/2011(UTC)
Posts: 138
Location: Hannover

Thanks: 1 times
Was thanked: 12 time(s) in 7 post(s)
Good point, I added some more param to the Module, you can now change the Margin, the background material, the Color of the font and the max. line count.
Pass NULL to use the default values.
Just check out the new ctore.
Offline Benjamin  
#5 Posted : Monday, June 11, 2012 11:03:08 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Yeah, very cool. I am a little confused by your AddFloat methods, shouldn't it just accept 2 float parameters and not 4 (or 2 points)? And the result is also very strange, why does it result in 7,19?

In previous projects I used XnaConsole a bit: http://xnaconsole.codeplex.com/ But other than for demo purposes I did not use it much. Maybe it should allow all dynamic types at least to be called (via the EngineTypeList). Also the console only worked with XNA in Windows, where I much rather use Visual Studio ^^

The plotting is very nice also. This is definitely something we want to support soon as well :) Good work.

BTW: Funny Git commit messages ^^
Offline elasto  
#6 Posted : Monday, June 11, 2012 11:07:41 AM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Originally Posted by: Benjamin Nitschke (DeltaEngine) Go to Quoted Post
Yeah, very cool. I am a little confused by your AddFloat methods, shouldn't it just accept 2 float parameters and not 4 (or 2 points)? And the result is also very strange, why does it result in 7,19?
It's using comma as decimal point.

ie. [2.3 + 4.89 = 7.19] <==> [2,3 + 4,89 = 7,19]
Offline Benjamin  
#7 Posted : Monday, June 11, 2012 11:27:04 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Hmm, I am a German (who use this notation) and could not figure it out ^^ lol BigGrin
Offline elasto  
#8 Posted : Monday, June 11, 2012 11:37:04 AM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Originally Posted by: Benjamin Nitschke (DeltaEngine) Go to Quoted Post
Hmm, I am a German (who use this notation) and could not figure it out ^^ lol BigGrin
Haha! I did wonder! Just shows you how thoroughly Anglicised you have become!

Reminds me of the very first interview I went to for a coding/programming job:

"Which languages do you know?" I was asked. I am slightly thrown by this.
"Umm.. A bit of French? But not very well."
"That's nice... But what programming languages do you know?"
"Oops. Ah." (That makes a bit more sense, I think to myself!)

(I still got the job! :) )
Offline mc-kay  
#9 Posted : Monday, June 11, 2012 11:45:21 AM(UTC)
mc-kay

Medals: Admin

Joined: 8/24/2011(UTC)
Posts: 138
Location: Hannover

Thanks: 1 times
Was thanked: 12 time(s) in 7 post(s)
I think it use comma notation because it's a German environment, in a English one it would be a point probably Confused
The expression is evaluated by .NET, I have nothing do do with the magic behind ^^
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.103 seconds.