Screen Manager
The ScreenManager class defines the interface required for managing the UI system in Robot Devastation. Other classes can then define the implementation of the ScreenManager according to, for instance, the library selected for displaying graphics on the screen.
The main methods of a ScreenManager are:
start(),stop()andisStopped(): control the manager startup and halting.configure(): configure some UI parameters (e.g. to enable fullscreen mode).setCurrentScreen(): sets aScreento be displayed.show(): display the currently selectedScreen.update(): updates some UI aspect. Currently, several signatures are used as they are required by the correspondingScreen. An alternative implementation could usevoid *or templates to simplify the API, leaving a singleupdate()method.
SDLScreenManager class
SDLScreenManager is an implementation of the ScreenManager interface using SDL to display graphics.
About the SDL graphics loop
To work properly, SDL requires that all SDL calls (for input, music, graphics, etc) must be performed in the same thread. Otherwise, thread-related exceptions and error start to appear. The typical loop of a SDL program is:
while not exit do
read inputs
process inputs, compute actions / consecuences
process actions
display / update graphicsTherefore, as SDLScreenManager uses SDL as graphics backend, one must be careful and ensure all the calls to show() occur in the same thread as the input is read.
Last updated