Sign in to follow this  
cptrnet

Designing a menu system

Recommended Posts

Hello gamedev, I have tried to design a menu system and I think that I don't know what I am doing. First of all I made it in C++ but I would like to design something for any language. I just made it like the menus that windows use like Menu, Submenu, MenuItem type stuff. But I was thinking about how to make a menu appear on the main screen, like One Player, Two Player, Options, etc. And then for options it would be another menu. So I would have just two classes Menu and MenuItem. For menu I would have if it is active or not whether or not it renders. I would need it to have input so it would cycle through the menu items. And a command key to whether or not they select them item, that is just for the keyboard. The mouse would be easy, if they clicked on the menu item it would run the command for that item. Should I just start off with that? Am I going to far for something simple, I just want something that I can apply to all my games but a menu system is simple enough I think it doesn't have to have all this complicated stuff, I don't know. If anyone can give me some pointers it would be appreciated.

Share this post


Link to post
Share on other sites
Not sure about your overall question, but I notice that if Menu is derived from MenuItem. Then sub menus are easy to do just by sticking one menu inside another as one of its items.

Share this post


Link to post
Share on other sites
My question is about designing a Menu System. I listed some things I thought it should have and then asked if I should go through all the trouble of building a system or just make a different one per game meaning every game I make I write code for.

Share this post


Link to post
Share on other sites
Quote:
Original post by cptrnet
My question is about designing a Menu System. I listed some things I thought it should have and then asked if I should go through all the trouble of building a system or just make a different one per game meaning every game I make I write code for.


Unless, you're attempting to learn how to create a menu system, you should find a third party GUI that does all of this, and then use it in your games.

It will be much quicker, and as long as you find a reputable one, you can be reasonably sure that it won't be broken.

I'm currently trying to use Crazy Eddie's GUI.

Share this post


Link to post
Share on other sites
Yes I am trying to learn how to do this. Using other peoples code is great and I would like to learn from their code but finding code is the hard part. I would just like to find out how other people are doing this so I can at least make something simple. Thanks for the link.

Share this post


Link to post
Share on other sites
I would probably use three main classes: MenuBar, Menu, MenuItem
MenuBar is an ordered collection of Menu objects, and Menu is an ordered collection of MenuItem objects.

Next, make MenuItem polymorphic and make two subclasses: MenuCommand and SubMenu. MenuCommand will make the menu send a message, return a value, or otherwise indicate to other parts of the program that it's been clicked. SubMenu tells the program to pop up the Menu object it contains.

That is really all you need for the menu system itself, but it requires that you already have a basic GUI system in place.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can see some working code for this in the DWinLib example on CodeProject. The source code is on the main page at http://www.codeproject.com/useritems/DWinLib2Overview.asp, and a sample program using this is at http://www.codeproject.com/useritems/DWinLib2BareApp.asp. I hope it is helpful.

Your task is not the easiest one to take on, because as stated earlier, it must directly tie into your entire GUI system.

Best wishes,
David

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
PS - There is a little write-up on some of the workings of the menus at http://www.codeproject.com/library/DWinLib.asp#buttonClicks.

Share this post


Link to post
Share on other sites
I'm not sure what you mean by menu system here, but if you mean a data driven menu interface, please reconsider. If you have so many options to choose from that you can't be bothered to go through them all and code a proper interface for them, a user isn't going to like going through a menu! It's simply too many items!

Consider a combo box that looks for the option the user types -like a URL bar in most browsers; or intellisense/omnicomplete in many editors.

This way, it can be data driven AND nice to use.

If you're not doing a data driven menu system, I'll shut up now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this