Tutorial Easy Sub Menu Adding

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
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);
}
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");
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");
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 menus that are named differently from the displayed option title 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...");
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 add_option() and add_menu() 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;
}
Note:
This obviously depends on the menu base you're using but I hope you get the point.

Enjoy guys :grinning:
 
Last edited:

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
Honestly if people aren't able to add submenus themselfs they should stay away from it, and finish 6th grade instead.
This is more a release of a useful function but whatever bro, I can guarantee you're not using a smart function like that for your menu but rather the original tedious way
 

Procyon

BANNED
Messages
325
Reaction score
119
Points
43
This is more a release of a useful function but whatever bro, I can guarantee you're not using a smart function like that for your menu but rather the original tedious way
It's standard submenu function from Sharks's base.
 
Top