Interactive Console Version 1

Tagged:

This provides a basic interactive console in which you can
1) Provide a hide-able area for displaying debug information
2) Provides a mechanism to to register c# methods with the console class, allowing you to call c# methods from inside your game.

To use this console
1) Import the entity into your project
2) Set the ConsoleToggleKey property from your screen (I use the tilde key)
3) Create a method in your screen that matches the signature of the ConsoleMethod delegate
e.g. private void MyTest(InteractiveConsole console, params string[] parameters) { console.AddOutput("Test call successful: " + (parameters.Length > 0 ? parameters[0] : "No input")); }
4) Call the console instance's RegisterMethod() and pass in MyTest
5) Log text to the console by calling the console instance's AddOutput() with your logged message
6) Run your game
7) Press the ConsoleTogglekey to open the console
8) Type "MyTest(test1234)"
9) Watch in amazement

I have many improvements to add to this (easy re-use of commands, scrolling to see previous output, etc...) but this should work for basic things. I'll update as I add new features.

------------------------------
7/18/12 - Added ConsoleScrollUp and ConsoleScrollDown properties. You can set these keys in your screen, and on press if there is enough console in the buffer it will scroll console's visible text. F
- Fixed an issue where zooming the camera would cause the console to scroll too.
- Added Built-in ListMethod() call which shows all methods available to call

Product File: 
Syndicate content