Sign in to follow this  
superman3275

Is my Menu Class's system bad?

Recommended Posts

superman3275    2061

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

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
Tasche    222

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

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