What is a clean way of traversing intricate menus?

I’m making my main menu, at first it was fine to just use switch statements, at least for testing it out. But now I’m adding the functionality to it, options, level select, character customization, etc. etc. and using switch statements will get far too messy far too fast.

Does anyone know a clean, organised and flexible way of traversing menus within menus within menus? If you recommend some kind of helper class, an example or at least sufficient elaboration would be great.

Any and all help is greatly appreciated, thanks in advanced,

Bombshell

2 Answers

2

NGUI is a great plugin I just started using. It changes buttons, sliders, and other GUI stuff to event driven, which is so much cleaner.

I fixed the issue via making some classes and using them as helpers, I’ll probably make some subs of these classes to deal with many menu items of similar functionality.

to make a long story short,
MainMenu hold a dictionary of Menus which hold a dictionary of MenuItems, Menus and MenuItems have their own onGUI functions, menuitems onGUI is run through Menu which is run through the MainMenu via the current selected menu. On changing the menu the current menu reference is changed to another menu and so another menus onGUI is ran.

its fairly basic, but it solves my problem by keeping things fairly organised, as mentioned above if I need to clean things up further I’ll simply make subclasses of menu and menuitem to make initializing a lot simpler than using a bunch of lambda expressions.