{"id":249,"date":"2011-08-20T08:18:41","date_gmt":"2011-08-20T08:18:41","guid":{"rendered":"http:\/\/strikelimit.co.uk\/m\/?page_id=249"},"modified":"2011-08-20T08:18:41","modified_gmt":"2011-08-20T08:18:41","slug":"xna-4-developer-console","status":"publish","type":"page","link":"http:\/\/strikelimit.co.uk\/m\/?page_id=249","title":{"rendered":"XNA 4 Developer Console"},"content":{"rendered":"<p>My XNA Developer Console is now <a href=\"http:\/\/dl.dropbox.com\/u\/6080323\/XNA%20SAMPLES\/QuickConsole.cs\">available for download<\/a>. 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.<\/p>\n<p>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&#8217;t; despite being feature rich, are often hard for someone who is learning to program to understand and make modifications to.<\/p>\n<p>Instructions:<\/p>\n<ol>\n<li><a href=\"http:\/\/dl.dropbox.com\/u\/6080323\/XNA%20SAMPLES\/QuickConsole.cs\">Download the class<\/a> and add it into your project. Change the namespace to match that of your project.<\/li>\n<li>Add in the consoles <em>Initialize<\/em> method to set up the console. This needs to be done before anything else console related.<\/li>\n<li>Choose your display setting: <em>Push to display<\/em> or <em>key toggle<\/em>. For details check the method list below.<\/li>\n<li>Add the<em> Update and Draw<\/em> methods in (preferably) your <em>Game1<\/em> class. The drawing method should be called after all other drawing has been completed to make sure it is displayed on top.<\/li>\n<li>Now add any <em>Writing<\/em> methods to display what you want.<\/li>\n<li>Run the game and open the console window to view any variables you specified to be written to the console.<\/li>\n<\/ol>\n<p>The console has the following methods, all are accessed via <em>QuickConsole.MethodName(Parameters)<\/em>:<\/p>\n<ol>\n<li><em>Initialize()<\/em> &#8211; 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.<\/li>\n<li><em>Clear()<\/em> &#8211; This simply clears the consoles line list.<\/li>\n<li><em>Fullscreen(GraphicsDevice) &#8211; <\/em>This sets the console to fullscreen using the parameters contained in the graphics device.<\/li>\n<li><em>EnablePushToDisplay(Keys) &#8211; <\/em>Sets the console to only be drawn when a certain key is held.<\/li>\n<li><em>EnableKeyToggle(Keys) &#8211; <\/em>Sets the console to toggle display on and off when a certain key is pressed.<\/li>\n<li><em>WriteLine(string) &#8211; <\/em>Writes a single string to the console.<\/li>\n<li><em>WriteLine(object) &#8211; <\/em>Writes any object to the console using the .ToString() method.<\/li>\n<li><em>WriteLine(object, object) &#8211; <\/em>Writes any object to the console alongside a sender object. It uses this syntax: &#8220;object [sender]&#8221;<\/li>\n<li><em>WriteLines(string[]) &#8211; <\/em>Write an array of strings to the console. (Each on a separate line) There is also an overload method that contains a sender extension.<\/li>\n<li><em>WriteLines(List&lt;string&gt;<\/em>) &#8211; Write a list of strings to the console. (Each on a separate line) There is also an overload method that contains a sender extension.<\/li>\n<li><em>FindIndex(int) <\/em>&#8211; A private method used to transform a line index to make it the standard 4 digits long.<\/li>\n<li><em>Update() and Draw() &#8211; <\/em>Methods that can be called to update the console and draw it to the screen.<\/li>\n<\/ol>\n<p>If you have any questions please comment below!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/strikelimit.co.uk\/m\/?page_id=249\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/pages\/249"}],"collection":[{"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":1,"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/pages\/249\/revisions"}],"predecessor-version":[{"id":252,"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=\/wp\/v2\/pages\/249\/revisions\/252"}],"wp:attachment":[{"href":"http:\/\/strikelimit.co.uk\/m\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}