{"id":19,"date":"2008-03-30T00:39:00","date_gmt":"2008-03-30T05:39:00","guid":{"rendered":"http:\/\/lukerymarz.com\/alearningexperience\/2008\/03\/new-menu-code.html"},"modified":"2008-03-30T00:39:00","modified_gmt":"2008-03-30T05:39:00","slug":"new-menu-code","status":"publish","type":"post","link":"http:\/\/lukerymarz.com\/alearningexperience\/2008\/03\/new-menu-code.html","title":{"rendered":"New Menu Code"},"content":{"rendered":"<p><a href=\"http:\/\/www.lukerymarz.com\/blog\/GameMenuSampleV3.zip\">Download source code for this project<\/a><\/p>\n<p>Okay, It&#8217;s been busy at home lately.  I&#8217;ve been moving it.  But I&#8217;ve been trying to find a little time every day to work on my XNA stuff, and I&#8217;ve got a much more complete menu system now.<\/p>\n<p>I&#8217;ve made some changes:<\/p>\n<p>&#8211;  The menu now shows a default &#8220;Return&#8221; choice at the bottom of each list.  This can be turned off by setting the &#8220;showBackChoice&#8221; boolean.<br \/>&#8211;  The menu now has two types of choices, Normal and LeftRight.  Normal choice will show their child choices as a separate menu when they are executed.  LeftRight choices will show their child choices as a list to the left of the parent choice when they are SELECTED.<\/p>\n<p>I&#8217;ve also made the sample code show a bit more info in the console as you are viewing the menu.  The sample code initializes the menu as follows:<\/p>\n<p><!-- {\\rtf1\\ansi\\ansicpg\\lang1024\\noproof1252\\uc1 \\deff0{\\fonttbl{\\f0\\fnil\\fcharset0\\fprq1 Courier New;}}{\\colortbl;??\\red0\\green0\\blue0;\\red255\\green255\\blue255;\\red163\\green21\\blue21;\\red43\\green145\\blue175;\\red0\\green0\\blue255;}??\\fs20             mainMenu.AddChoice(\\cf3 \"Choice 1\"\\cf0 );\\par ??            \\cf4 MenuChoice\\cf0  choice = mainMenu.AddChoice(\\cf3 \"LR Choice\"\\cf0 );\\par ??            choice.AddLeftRightChoices(\\cf5 new\\cf0  \\cf5 string\\cf0 [] \\{ \\cf3 \"one\"\\cf0 , \\cf3 \"two\"\\cf0 , \\cf3 \"three\"\\cf0  \\});\\par ??\\par ??            choice = mainMenu.AddChoice(\\cf3 \"Sub Menu\"\\cf0 );\\par ??            choice.AddChoice(\\cf3 \"Sub choice 1\"\\cf0 );\\par ??            choice.AddChoice(\\cf3 \"Sub choice 2\"\\cf0 );\\par ??\\par ??            mainMenu.ChoiceExecuted += \\cf5 new\\cf0  \\cf4 Menu\\cf0 .\\cf4 ChoiceExecutedHandler\\cf0 (ChoiceExecuted);\\par ??            mainMenu.ChoiceSelected += \\cf5 new\\cf0  \\cf4 Menu\\cf0 .\\cf4 ChoiceSelectedHandler\\cf0 (ChoiceSelected);\\par ??            mainMenu.ChoiceDeselected += \\cf5 new\\cf0  \\cf4 Menu\\cf0 .\\cf4 ChoiceDeselectedHandler\\cf0 (ChoiceDeselected);} --> <\/p>\n<div    style=\"background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;\">\n<p style=\"margin: 0px;\">mainMenu.AddChoice(<span style=\"color: rgb(163, 21, 21);\">&#8220;Choice 1&#8221;<\/span>);<\/p>\n<p style=\"margin: 0px;\"><span style=\"color: rgb(43, 145, 175);\">MenuChoice<\/span> choice = mainMenu.AddChoice(<span style=\"color: rgb(163, 21, 21);\">&#8220;LR Choice&#8221;<\/span>);<\/p>\n<p style=\"margin: 0px;\">choice.AddLeftRightChoices(<span style=\"color:blue;\">new<\/span> <span style=\"color:blue;\">string<\/span>[] { <span style=\"color: rgb(163, 21, 21);\">&#8220;one&#8221;<\/span>, <span style=\"color: rgb(163, 21, 21);\">&#8220;two&#8221;<\/span>, <span style=\"color: rgb(163, 21, 21);\">&#8220;three&#8221;<\/span> });<\/p>\n<p style=\"margin: 0px;\">\n<p style=\"margin: 0px;\">choice = mainMenu.AddChoice(<span style=\"color: rgb(163, 21, 21);\">&#8220;Sub Menu&#8221;<\/span>);<\/p>\n<p style=\"margin: 0px;\">choice.AddChoice(<span style=\"color: rgb(163, 21, 21);\">&#8220;Sub choice 1&#8221;<\/span>);<\/p>\n<p style=\"margin: 0px;\">choice.AddChoice(<span style=\"color: rgb(163, 21, 21);\">&#8220;Sub choice 2&#8221;<\/span>);<\/p>\n<p style=\"margin: 0px;\">\n<p style=\"margin: 0px;\">mainMenu.ChoiceExecuted += <span style=\"color:blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">Menu<\/span>.<span style=\"color: rgb(43, 145, 175);\">ChoiceExecutedHandler<\/span>(ChoiceExecuted);<\/p>\n<p style=\"margin: 0px;\">mainMenu.ChoiceSelected += <span style=\"color:blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">Menu<\/span>.<span style=\"color: rgb(43, 145, 175);\">ChoiceSelectedHandler<\/span>(ChoiceSelected);<\/p>\n<p style=\"margin: 0px;\">mainMenu.ChoiceDeselected += <span style=\"color:blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">Menu<\/span>.<span style=\"color: rgb(43, 145, 175);\">ChoiceDeselectedHandler<\/span>(ChoiceDeselected);<\/p>\n<\/div>\n<p>So there you go.  Pretty simple.  If I make any more changes, I&#8217;ll be sure to post them.  Possible changes could be:<\/p>\n<p>&#8211;  using a proper spriteFont to display the text (so we could use something besides Times new Roman).<br \/>&#8211;  making background images actually work.<br \/>&#8211;  something I overlooked&#8230;.<\/p>\n<p>I&#8217;ve realized as I&#8217;ve been working on this that is might have been easier to just implement it using a full on tree, rather than a bunch of sneaky lists.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Download source code for this project Okay, It&#8217;s been busy at home lately. I&#8217;ve been moving it. But I&#8217;ve been trying to find a little time every day to work on my XNA stuff, and I&#8217;ve got a much more complete menu system now. I&#8217;ve made some changes: &#8211; The menu now shows a default [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-xna"],"_links":{"self":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}