Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Is my Menu Class's system bad?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 superman3275   Crossbones+   -  Reputation: 1374

Like
0Likes
Like

Posted 23 February 2013 - 03:40 PM

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 :)!


I'm a game programmer and photo editor.

Here's Breakout:
Breakout!

If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there Posted Image!

Sponsor:

#2 Paradigm Shifter   Members   -  Reputation: 1844

Like
1Likes
Like

Posted 23 February 2013 - 03:44 PM

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).


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 superman3275   Crossbones+   -  Reputation: 1374

Like
0Likes
Like

Posted 23 February 2013 - 04:27 PM

I changed my system and increased efficiency in a separate way.

 

However, thank you for your suggestions :)!


I'm a game programmer and photo editor.

Here's Breakout:
Breakout!

If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there Posted Image!

#4 Tasche   Members   -  Reputation: 218

Like
0Likes
Like

Posted 23 February 2013 - 06:08 PM

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...).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS