XNA 4 Developer Console

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:

  1. Download the class and add it into your project. Change the namespace to match that of your project.
  2. Add in the consoles Initialize method to set up the console. This needs to be done before anything else console related.
  3. Choose your display setting: Push to display or key toggle. For details check the method list below.
  4. 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.
  5. Now add any Writing methods to display what you want.
  6. 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):

  1. 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.
  2. Clear() – This simply clears the consoles line list.
  3. Fullscreen(GraphicsDevice) – This sets the console to fullscreen using the parameters contained in the graphics device.
  4. EnablePushToDisplay(Keys) – Sets the console to only be drawn when a certain key is held.
  5. EnableKeyToggle(Keys) – Sets the console to toggle display on and off when a certain key is pressed.
  6. WriteLine(string) – Writes a single string to the console.
  7. WriteLine(object) – Writes any object to the console using the .ToString() method.
  8. WriteLine(object, object) – Writes any object to the console alongside a sender object. It uses this syntax: “object [sender]”
  9. 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.
  10. 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.
  11. FindIndex(int) – A private method used to transform a line index to make it the standard 4 digits long.
  12. 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!

 

Leave a Reply

Your email address will not be published.