I'm wondering about design concept for menu systems. I don't want to hard-code manually in my game the functionality and behaviour of my menu system, but rather want to design some abstract system that I can then use to implement a menu that is defined in like a xml file.

Let's say you start a game, and you get this menu:

New gameSettingsAbout gameExit game

And when you press Settings you get:Audio settingsVideo settings

But when you press "Audio settings" you get a little slider, sliding from low to high volume. And in "Video settings" you would be able to select a resolution. It's really not possible to define this functionality in a xml file, that would be a overkill.

I have to admit I did not know what your question was. First you said you want to use a xml instead of hard-coding. Then at the end you say xml would be overkill.

Anyway, the source I linked to contains code to read the xml and create a gui. There is also an example of the xml file. Since you mentioned gui and xml in your first post I thought it might be something you could look at as an example.

Nevermind, I think I can implement this without xml and the overhead that comes with creating a full blown gui menu system.

My idea is to create a abstract class MenuSheet, and then a class called MainMenuSheet (extends MenuSheet) which implements the behaviour of that menu. Or at least something in that direction.

You can think of each MenuSheet as a...sheet or a page, only one sheet is visible at any given time.Each sheet contains buttons, and a button contains a pointer to the sheet it should display if clicked on.When the button is clicked on the current sheet is rendered invisible, and the sheet the button points to is rendered visible.

I think it will be relatively fast, since only the active sheet is updated and drawn each frame.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org