Robot Devastation
SDLScreenManager.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_SDL_SCREEN_MANAGER_HPP__
6 #define __RD_SDL_SCREEN_MANAGER_HPP__
7 
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include <mutex>
12 
13 #include <SDL.h>
14 
15 #include "ScreenManager.hpp"
16 #include "Screen.hpp"
17 #include "ImageManager.hpp"
18 #include "Player.hpp"
19 #include "Target.hpp"
20 #include "Weapon.hpp"
21 
22 namespace rd{
23 
31 {
32  public:
33  //------------------------------- Screen Manager functions -----------------------------------------------------//
35  virtual void setCurrentScreen(Screen* screen);
36 
38  virtual bool show();
39 
41  virtual bool update(const std::string & parameter, const std::string & value);
42 
44  virtual bool update(const std::string & parameter, const Image & value); //-- Required by GameScreen and DeadScreen
45 
47  virtual bool update(const std::string & parameter, const Player & value); //-- Required by GameScreen
48 
50  virtual bool update(const std::string & parameter, const std::vector<Player> & value); //-- Required by GameScreen
51 
53  virtual bool update(const std::string & parameter, const std::vector<Target> & value); //-- Required by GameScreen
54 
56  virtual bool update(const std::string & parameter, const Weapon & value); //-- Required by GameScreen
57 
59  static bool initSDL();
60 
62  static bool cleanupSDL();
63 
64  //------------------------------ Configuration ----------------------------------------------------------------//
66  virtual bool configure(const std::string & parameter, const std::string & value);
67 
68  static const std::string PARAM_FULLSCREEN;
69 
70  //---------------- Manager Stuff ----------------------------------------------------------------------//
71  virtual bool start();
72  virtual bool stop();
73  virtual bool isStopped() const;
74 
80  static bool RegisterManager();
81 
83  virtual ~SDLScreenManager();
84 
85 
87  static const std::string id;
88 
89 
90  private:
98 
100  SDLScreenManager & operator=(const SDLScreenManager &);
101 
104 
105  bool stopped;
106  bool sdl_initialized;
107  bool fullscreen;
108 
109  SDL_Window * window;
110  mutable std::mutex mutex;
111 };
112 
113 }
114 
115 #endif //-- __RD_SDL_SCREEN_MANAGER_HPP__
rd::SDLScreenManager::update
virtual bool update(const std::string &parameter, const std::string &value)
Update some Screen parameter through the ScreenManager.
Definition: SDLScreenManager.cpp:97
rd::SDLScreenManager::isStopped
virtual bool isStopped() const
True if the manager is not active.
Definition: SDLScreenManager.cpp:222
rd::Player
Class that represents a player of this game, with a 'unique' id, name, health, team id and score.
Definition: Player.hpp:21
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::Screen
A User Interface.
Definition: Screen.hpp:24
rd::SDLScreenManager::RegisterManager
static bool RegisterManager()
Register this manager in the ScreenManager registry so that can be used.
Definition: SDLScreenManager.cpp:227
rd::SDLScreenManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: SDLScreenManager.cpp:181
rd::SDLScreenManager::SDLScreenManager
SDLScreenManager()
Constructor.
Definition: SDLScreenManager.cpp:20
rd::SDLScreenManager::initSDL
static bool initSDL()
SDL initialization.
Definition: SDLScreenManager.cpp:145
rd::SDLScreenManager::cleanupSDL
static bool cleanupSDL()
SDL Cleanup.
Definition: SDLScreenManager.cpp:172
rd::Weapon
Class that represents a weapon.
Definition: Weapon.hpp:22
rd::SDLScreenManager
Manage game screens using SDL libraries.
Definition: SDLScreenManager.hpp:30
rd::SDLScreenManager::id
static const std::string id
String that identifies this manager.
Definition: SDLScreenManager.hpp:87
rd::SDLScreenManager::start
virtual bool start()
Start the ScreenManager.
Definition: SDLScreenManager.cpp:202
rd::SDLScreenManager::~SDLScreenManager
virtual ~SDLScreenManager()
Destructor. Used to reset the local static reference after destroying this manager.
Definition: SDLScreenManager.cpp:237
rd::SDLScreenManager::setCurrentScreen
virtual void setCurrentScreen(Screen *screen)
Set a Screen as current Screen.
Definition: SDLScreenManager.cpp:28
rd::ScreenManager
Manage game screens.
Definition: ScreenManager.hpp:35
rd::SDLScreenManager::stop
virtual bool stop()
Stops the ScreenManager.
Definition: SDLScreenManager.cpp:214
rd::SDLScreenManager::show
virtual bool show()
Display the current Screen on the game window.
Definition: SDLScreenManager.cpp:38
rd::SDLScreenManager::uniqueInstance
static SDLScreenManager * uniqueInstance
Stores the unique instance of the SDLScreenManager.
Definition: SDLScreenManager.hpp:103