Expanding the event manager
GUI events need to be handled for every possible state of the application in order to keep them from piling up, much like SFML events. In order to avoid writing all of that extra code, we're going to use something that was built solely for the purpose of handling them: the event manager.
Let's start by expanding the EventType
enumeration to support GUI events:
enum class EventType{ ... Keyboard = sf::Event::Count + 1, Mouse, Joystick, GUI_Click, GUI_Release, GUI_Hover, GUI_Leave };
It's important to keep these custom event types at the very bottom of the structure because of the way the code we've written in the past works.
Our previous raw implementation of the EventManager
class relied on the fact that any given event can be represented simply by a numeric value. Most SFML events, such as key bindings, fit into that category but a lot of other event types, especially custom events, require additional information in order to be processed...