Robot Devastation
ScreenManager.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_SCREEN_MANAGER_HPP__
6 #define __RD_SCREEN_MANAGER_HPP__
7 
8 #include <string>
9 #include <vector>
10 #include <map>
11 
12 #include "Screen.hpp"
13 #include "ImageManager.hpp"
14 #include "Player.hpp"
15 #include "Target.hpp"
16 #include "Weapon.hpp"
17 
18 namespace rd{
19 
36 {
37  public:
38  //------------------------------ Construction & destruction ---------------------------------------------------//
45 
51  static ScreenManager * getScreenManager(const std::string & id);
52 
54  static bool destroyScreenManager();
55 
56  virtual ~ScreenManager();
57 
58  //------------------------------ Manager Startup & Halting ----------------------------------------------------//
64  virtual bool start() = 0;
65 
67  virtual bool stop() = 0;
68 
70  virtual bool isStopped() const = 0;
71 
72  //------------------------------ Configuration ----------------------------------------------------------------//
74  virtual bool configure(const std::string & parameter, const std::string & value);
75 
76 
77  //------------------------------- Screen Manager functions -----------------------------------------------------//
79  virtual void setCurrentScreen(Screen* screen);
80 
82  virtual bool show() = 0;
83 
85  virtual bool update(const std::string & parameter, const std::string & value);
86 
88  virtual bool update(const std::string & parameter, const Image & value); //-- Required by GameScreen and DeadScreen
89 
91  virtual bool update(const std::string & parameter, const Player & value); //-- Required by GameScreen
92 
94  virtual bool update(const std::string & parameter, const std::vector<Player> & value); //-- Required by GameScreen
95 
97  virtual bool update(const std::string & parameter, const std::vector<Target> & value); //-- Required by GameScreen
98 
100  virtual bool update(const std::string & parameter, const Weapon & value); //-- Required by GameScreen
101 
102  protected:
107  static bool Register(ScreenManager * manager, const std::string & id);
108 
109  Screen * screen;
110 
111  private:
114 
116  static std::string currentId;
117 
119  static std::map< std::string, ScreenManager * > screenManagerRegistry;
120 
121 
122 
123 };
124 
125 }
126 
127 #endif //-- __RD_SCREEN_MANAGER_HPP__
rd::ScreenManager::screenManagerRegistry
static std::map< std::string, ScreenManager * > screenManagerRegistry
Stores all the ScreenManager that have been registered.
Definition: ScreenManager.hpp:119
rd::ScreenManager::stop
virtual bool stop()=0
Stops the ScreenManager.
rd::ScreenManager::screenManagerInstance
static ScreenManager * screenManagerInstance
Stores the unique instance of the ScreenManager.
Definition: ScreenManager.hpp:113
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::ScreenManager::destroyScreenManager
static bool destroyScreenManager()
Deallocate all the registered ScreenManager.
Definition: ScreenManager.cpp:54
rd::Weapon
Class that represents a weapon.
Definition: Weapon.hpp:22
rd::ScreenManager::getScreenManager
static ScreenManager * getScreenManager()
Get a reference to the ScreenManager.
Definition: ScreenManager.cpp:17
rd::ScreenManager::Register
static bool Register(ScreenManager *manager, const std::string &id)
This function allows subclasses to install their unique instances in the singleton register to be sel...
Definition: ScreenManager.cpp:135
rd::ScreenManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: ScreenManager.cpp:95
rd::ScreenManager::update
virtual bool update(const std::string &parameter, const std::string &value)
Update some Screen parameter through the ScreenManager.
Definition: ScreenManager.cpp:105
rd::ScreenManager::currentId
static std::string currentId
Stores the id of the current unique instance used.
Definition: ScreenManager.hpp:116
rd::ScreenManager::show
virtual bool show()=0
Display the current Screen on the game window.
rd::ScreenManager
Manage game screens.
Definition: ScreenManager.hpp:35
rd::ScreenManager::setCurrentScreen
virtual void setCurrentScreen(Screen *screen)
Set a Screen as current Screen.
Definition: ScreenManager.cpp:100
rd::ScreenManager::start
virtual bool start()=0
Start the ScreenManager.
rd::ScreenManager::isStopped
virtual bool isStopped() const =0
True if the manager is not active.