CabConModding
Facebook
Twitter
youtube
Discord
Contact us
RSS
Menu
CabConModding
Home
New
Top
Premium
Rules
FAQ - Frequently Asked Questions
Games
Fornite
Call of Duty: Black Ops 3
Clash of Clans
Grand Theft Auto 5
Apex Legends
Assassin’s Creed Origins
Forums
Premium
Latest posts
What's new
Latest posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Log in
Register
What's new
Premium
Latest posts
Menu
Log in
Register
Navigation
Install the app
Install
More options
Dark Theme
Contact us
Close Menu
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
Easy Sub Menu Adding
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="BullyWiiPlaza" data-source="post: 3171" data-attributes="member: 543"><p>I figured that I would "release" this since it can tremendously help people with managing and adding submenus.</p><p></p><p>The problem is that if you add an options to a menu that does not yet exist you will freeze. If you get confused with all the parameters and submenus it might happen. To</p><p>make the process easier, I made a wrapper function that adds an option and a menu at once. It looks as follows:</p><p></p><p>[CODE]addSubMenu(previousMenu, newMenu, menuText)</p><p>{</p><p> menuOptionText = undefined;</p><p></p><p> if(isDefined(menuText))</p><p> {</p><p> menuOptionText = menuText;</p><p> }</p><p> else</p><p> {</p><p> menuOptionText = newMenu;</p><p> }</p><p></p><p> self add_option(previousMenu, menuOptionText, ::submenu, newMenu, newMenu);</p><p> self add_menu(newMenu, previousMenu, newMenu);</p><p>}[/CODE]</p><p>If you can't tell yet what this does, let me explain it to you. In order to add a submenu named "My Sub Menu" to the menu called "My Previous Menu", you would write the following code:</p><p>[CODE]self addSubMenu("My previous menu", "My new submenu");[/CODE]</p><p>Before you would write something like this:</p><p>[CODE]self add_option("My previous menu", menuOptionText, ::submenu, "My new submenu", "My new submenu");</p><p>self add_menu("My new submenu", "My previous menu", "My new submenu");[/CODE]</p><p>The code line above does the same thing. Now adding options is the the same as usual so I won't show it.</p><p></p><p>You might be left wondering why my function has a 3rd argument when it's not used? Well, that is for <strong>menus that are named differently from the displayed option title </strong>because you might have menus with the same title but obviously different menu so in that case you would simply write:</p><p>[CODE]self addSubMenu("My whatever menu", "My more whatever menu", "more...");[/CODE]</p><p>I use this for 2nd pages mostly if not all entries fit on one page. Since the "more..." menu is defined here and we want it to say "more..." instead, we need to change the menu title manually.</p><p></p><p>As a reminder, my <strong>add_option()</strong> and <strong>add_menu() </strong>functions so that you can make sure that yours are the same or at least similar:</p><p>[CODE]add_menu(Menu, prevmenu, menutitle)</p><p>{</p><p> self.menu.status[Menu] = "Verified";</p><p> self.menu.getmenu[Menu] = Menu;</p><p> self.menu.scrollerpos[Menu] = 0;</p><p> self.menu.curs[Menu] = 0;</p><p> self.menu.menucount[Menu] = 0;</p><p> self.menu.subtitle[Menu] = menutitle;</p><p> self.menu.previousmenu[Menu] = prevmenu;</p><p>}</p><p></p><p>add_option(Menu, Text, Func, arg1, arg2)</p><p>{</p><p> Menu = self.menu.getmenu[Menu];</p><p> Num = self.menu.menucount[Menu];</p><p> self.menu.menuopt[Menu][Num] = Text;</p><p> self.menu.menufunc[Menu][Num] = Func;</p><p> self.menu.menuinput[Menu][Num] = arg1;</p><p> self.menu.menuinput1[Menu][Num] = arg2;</p><p> self.menu.menucount[Menu] += 1;</p><p>}[/CODE]</p><p><strong><u>Note:</u></strong></p><p>This obviously depends on the menu base you're using but I hope you get the point.</p><p></p><p>Enjoy guys <img src="/styles/default/xenforo/smilies.emoji/people/smile.emoji.svg" class="smilie" loading="lazy" alt=":grinning:" title="Grinning :grinning:" data-shortname=":grinning:" /></p></blockquote><p></p>
[QUOTE="BullyWiiPlaza, post: 3171, member: 543"] I figured that I would "release" this since it can tremendously help people with managing and adding submenus. The problem is that if you add an options to a menu that does not yet exist you will freeze. If you get confused with all the parameters and submenus it might happen. To make the process easier, I made a wrapper function that adds an option and a menu at once. It looks as follows: [CODE]addSubMenu(previousMenu, newMenu, menuText) { menuOptionText = undefined; if(isDefined(menuText)) { menuOptionText = menuText; } else { menuOptionText = newMenu; } self add_option(previousMenu, menuOptionText, ::submenu, newMenu, newMenu); self add_menu(newMenu, previousMenu, newMenu); }[/CODE] If you can't tell yet what this does, let me explain it to you. In order to add a submenu named "My Sub Menu" to the menu called "My Previous Menu", you would write the following code: [CODE]self addSubMenu("My previous menu", "My new submenu");[/CODE] Before you would write something like this: [CODE]self add_option("My previous menu", menuOptionText, ::submenu, "My new submenu", "My new submenu"); self add_menu("My new submenu", "My previous menu", "My new submenu");[/CODE] The code line above does the same thing. Now adding options is the the same as usual so I won't show it. You might be left wondering why my function has a 3rd argument when it's not used? Well, that is for [B]menus that are named differently from the displayed option title [/B]because you might have menus with the same title but obviously different menu so in that case you would simply write: [CODE]self addSubMenu("My whatever menu", "My more whatever menu", "more...");[/CODE] I use this for 2nd pages mostly if not all entries fit on one page. Since the "more..." menu is defined here and we want it to say "more..." instead, we need to change the menu title manually. As a reminder, my [B]add_option()[/B] and [B]add_menu() [/B]functions so that you can make sure that yours are the same or at least similar: [CODE]add_menu(Menu, prevmenu, menutitle) { self.menu.status[Menu] = "Verified"; self.menu.getmenu[Menu] = Menu; self.menu.scrollerpos[Menu] = 0; self.menu.curs[Menu] = 0; self.menu.menucount[Menu] = 0; self.menu.subtitle[Menu] = menutitle; self.menu.previousmenu[Menu] = prevmenu; } add_option(Menu, Text, Func, arg1, arg2) { Menu = self.menu.getmenu[Menu]; Num = self.menu.menucount[Menu]; self.menu.menuopt[Menu][Num] = Text; self.menu.menufunc[Menu][Num] = Func; self.menu.menuinput[Menu][Num] = arg1; self.menu.menuinput1[Menu][Num] = arg2; self.menu.menucount[Menu] += 1; }[/CODE] [B][U]Note:[/U][/B] This obviously depends on the menu base you're using but I hope you get the point. Enjoy guys :grinning: [/QUOTE]
Verification
Post reply
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
Easy Sub Menu Adding
CabConModding is now on facebook! Check the latest Updates, the Site Status and much more now!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top