I'm currently creating a 2D RPG in C++11 with Allegro 5 and boost.
My goal is to somehow update my game settings when an option is changed in the Options Menu. I don't want to force the user to restart my game. Other games don't require a restart when changing resolution or going from fullscreen to windowed, so my game shouldn't either. Please see a simplified view of the system below.
Please note that I am not necessarily wanting to directly call my Game object from the OptionsScreen. The dashed line is merely to illustrate the effect I am trying to achieve; to somehow cause an update of the game when an option is changed in a different part of the system.
Detailed explanation
The ScreenManager contains a list of all GameScreen
objects currently in existence. These will be various screens in the game including popups. This design adheres more or less to the Game State Management sample in C#/XNA.
The ScreenManager
contains a reference to my Game
object. The Game
object initializes and modifies the game's settings. If I want to change the resolution, go fullscreen, or mute the volume I would do so in the Game
class.
However, the OptionsScreen currently cannot access the Game class. See below diagram:
A GameScreen can signal three events, onFinished
, onTransitionStart
and onTransitionEnd
. There is no onOptionsChanged
because only one screen does that. The ScreenManager cannot set-up the event handling for that because it handles all screens as GameScreen
s.
My question is, how can I change my design so that a change in the OptionsMenu doesn't require a restart, but is changed immediately? I would preferably request my Game
object to update once the apply button is clicked.