Event SystemWhile putting together my fancy new GUI framework, I decided to bite the bullet and implement an actual event system as well. Prior to now, I had always used either a (very) simple message passing scheme or just tied to subsystems together to communicate information around the various parts of the engine. The primary goals of adding a true event system is to make a single point of communication, the 'EventManager', allow all systems access to one another without actually tying them together with headers.
I have implemented something similar to the Game Code Complete 2nd ed. trigger system. If you haven't read his book yet, Mike McShaffrey (sorry if I spelled it incorrectly...) has quite a bit of good insight into the games industry (especially for someone like me that is on the outside looking in!) and what experiences he has had. Some of the sample code is a tad on the beginner side, but sometimes that what you need - something to get you started.
So the basic structure is to allow the event manager to connect an event listener to a particular type of event. There can be multiple listeners for a given event, and there is no guarantee about if a listener will consume a message or not. If it does, then the remaining listeners don't need to try to handle that event. Seems pretty simple and easy to use.
My first implementation was seeming a bit tedious, and I only implemented a single message! The reason is that I was using separate classes for the event itself and the event data. I'm now combining the two classes, and an event will carry it's own data within itself - there's really no benefit that I see to keeping the separate. Anyhow, once this is changed over I should be able to hack in the remaining GUI messages and start getting some real interaction with the buttons and dialogs - it is kind of funny how you get excited about these silly things isn't it??