Jump to content
  • Advertisement
Sign in to follow this  
superman3275

Is my Menu Class's system bad?

This topic is 2066 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a class called Menu which I use for main menu's, other types of menus, pretty much all menus. To make a specific menu, you would define a class which inherits from it.

 

It starts out blank, and you add buttons to it by calling menu.addButton(). AddButton takes a position, an image address, and the buttons name. Later, whenever you check if the mouse is hovering over / clicking on a button, you call menu.checkHover(). You pass a name to checkHover(). checkHover() then sees if there are any buttons with that name and if the mouse is hovering over the button with that name.

 

This system is giving me a bad feeling. What do you think?

 

Cheers :)!

Share this post


Link to post
Share on other sites
Advertisement

I'd do it more event/callback based.

 

Presumably you have some sort of window manager which knows the hit rect of your menu items.

 

Provide a pure virtual OnHover function which is called by the window manager when the mouse is over the window (either for a specified amount of time, or pass the time as a parameter to OnHover and let the function decide whether to handle the event yet).

Share this post


Link to post
Share on other sites

this may be too late, but unless you are doing this for educational reasons, try a GUI library, for example CEGUI (LGPL, new version MIT, iirc) or if you got tons of cash, Scaleform or something. i strongly recommend using a library for this, im talking from experience here, tried doing it all from scratch. it was painful. CEGUI is also *very* easy to setup and use, only your artist may be a bit annoyed that it isn't as WYSIWYG as one would wish (this is being worked on atm, in form of an appropriate editor, but which wont be under a lenient license...).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!