Game Session In_Game_Menu_GUI load_button
In my game I have a Game class which handles high level stuff relevant to the game (including manipulating the Session object) and a Session class which represents a session of gameplay. Session holds all game data that should be re-read from file if a new game is started. There is an in-game menu (In_Game_Menu_GUI) that has options like resume, load game, save game, exit. The load game button pushes an event notification to the Screen Event Manager which notifies anyone who has registered for BUTTON_UP. My problem is that before the notification function called by the button is finished, the session has already re-read all its data, which includes the button itself.
I'm looking for an elegant solution to this problem. I've thought of some things:
- Set a bool e.g. load_game to true when notified of the load game button's MOUSE_UP event, instead of re-reading the session data straight away. This is the nicest solution to me but still seems a bit hacky for some reason...
- Move the In_Game_Menu_GUI to the Game class so that it is only read once and hence never has to be destroyed when loading games. My problem with this is that the Session data handles all session-related data and the Game class only needs to have access to Session's functions like Load(), Save(), New(), Delete(), Pause(), etc. There are two other GUI classes in Session that I'd want to move if I moved In_Game_Menu_GUI as well... but I don't like the idea of having classes in Game that logically belong in Session.
Any advice would be appreciated. :)
Cheers.