My XNA Developer Console is now available for download. The entire console is contained in a relatively simple single static class. I wanted to keep it simple enough that a relative beginner could custom and tweak it for their project. For this reason the features have been kept to a bare minimum, and I have commented in explanations where I believed they would be necessary.
I do understand that there are already quite a few consoles out there, but most of them are for the old XNA 3 specification, and those that aren’t; despite being feature rich, are often hard for someone who is learning to program to understand and make modifications to.
Instructions:
- Download the class and add it into your project. Change the namespace to match that of your project.
- Add in the consoles Initialize method to set up the console. This needs to be done before anything else console related.
- Choose your display setting: Push to display or key toggle. For details check the method list below.
- Add the Update and Draw methods in (preferably) your Game1 class. The drawing method should be called after all other drawing has been completed to make sure it is displayed on top.
- Now add any Writing methods to display what you want.
- Run the game and open the console window to view any variables you specified to be written to the console.
The console has the following methods, all are accessed via QuickConsole.MethodName(Parameters):
- Initialize() – This must be called before anything else and sets up the position and various other parameters for the console. There are two versions, one for a window and one for a fullscreen console.
- Clear() – This simply clears the consoles line list.
- Fullscreen(GraphicsDevice) – This sets the console to fullscreen using the parameters contained in the graphics device.
- EnablePushToDisplay(Keys) – Sets the console to only be drawn when a certain key is held.
- EnableKeyToggle(Keys) – Sets the console to toggle display on and off when a certain key is pressed.
- WriteLine(string) – Writes a single string to the console.
- WriteLine(object) – Writes any object to the console using the .ToString() method.
- WriteLine(object, object) – Writes any object to the console alongside a sender object. It uses this syntax: “object [sender]”
- WriteLines(string[]) – Write an array of strings to the console. (Each on a separate line) There is also an overload method that contains a sender extension.
- WriteLines(List<string>) – Write a list of strings to the console. (Each on a separate line) There is also an overload method that contains a sender extension.
- FindIndex(int) – A private method used to transform a line index to make it the standard 4 digits long.
- Update() and Draw() – Methods that can be called to update the console and draw it to the screen.
If you have any questions please comment below!