Jump to content
  • Advertisement
Sign in to follow this  
RealMarkP

GUI/Menuing System Design

This topic is 3407 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'm toying around with different ways of designing (coding) a GUI system. I'm trying to make it very versatile, so I'm thinking of using a decorator pattern for rendering. But I do not have a way of actually passing messages around (such as OnButtonClick, etc). I was thinking of using something similar to a message queue in which message are processed at the next time I update. This has a down side because I'm forced to use a huge switch statement in order to sift through all the messages (much is the problem with Win32 coding). What is the best way of processing messages like this? I'm open to any ideas. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Your event/messaging system could make use of the observer pattern.

You would get around needing the giant switch by making use of OO constructs. Virtual functions, polymorphism, functors, etc. can all be used in place of a discrete enum to define event types and a giant switch to handle them.

Share this post


Link to post
Share on other sites
Personally, I prefer the setup where a button is setup with a delegate/event/functor that is triggered (or at least enqueued) when it's clicked.

Share this post


Link to post
Share on other sites
Quote:
Original post by y2kiah
Your event/messaging system could make use of the observer pattern.

You would get around needing the giant switch by making use of OO constructs. Virtual functions, polymorphism, functors, etc. can all be used in place of a discrete enum to define event types and a giant switch to handle them.


Good call, The problem is that this now takes the switch statement and splits it into many functions or classes. Which is easier to read but it makes a ton of files and classes. Hmm....I guess there is no way around this.

Quote:
Personally, I prefer the setup where a button is setup with a delegate/event/functor that is triggered (or at least enqueued) when it's clicked.

This is what I'm aiming for, or something close to it.

Share this post


Link to post
Share on other sites
Since games are generally periodic/polling at their core, I go with an immediate-mode solution ala IMGUI. It completely avoids the need for a callback system, since you can just immediately notify the calling code of any events.

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!