Jump to content

  • Log In with Google      Sign In   
  • Create Account


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: 1993

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 computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


Sponsor:

#2 Paradigm Shifter   Crossbones+   -  Reputation: 5154

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: 1993

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 computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


#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