61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
#ifndef OVERLAYBASE
|
|
#define OVERLAYBASE
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <SDL/SDL.h>
|
|
#include <map>
|
|
#include <list>
|
|
|
|
namespace Engine {
|
|
|
|
class ModelBase;
|
|
|
|
/** \brief Base class for user-interfaces
|
|
*/
|
|
class OverlayBase {
|
|
public:
|
|
OverlayBase () {};
|
|
virtual ~OverlayBase() {};
|
|
|
|
virtual void Init() {};
|
|
|
|
virtual bool OnKeyDown (const SDL_keysym &keysym) { return false; };
|
|
virtual bool OnKeyUp (const SDL_keysym &keysym) { return false; };
|
|
virtual bool OnMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos) { return false; };
|
|
virtual bool OnMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos) { return false; };
|
|
|
|
virtual void Draw () = 0;
|
|
|
|
void _strange_function_for_vtable () {};
|
|
};
|
|
|
|
typedef boost::shared_ptr<OverlayBase> OverlayBasePtr;
|
|
|
|
/** \brief Takes care of all OverlayBase classes and proxies input and drawing with regard to the current game state of ModelBase
|
|
*
|
|
* \node You need to set the ModelBase pointer manually by calling OverlayManager::SetModel()!
|
|
*/
|
|
class OverlayManager {
|
|
public:
|
|
/** \brief Calls OverlayBase::Init() for all registered Overlays */
|
|
void InitOverlays();
|
|
|
|
void Draw();
|
|
void Register (OverlayBasePtr overlay, unsigned int game_state);
|
|
|
|
/* Input forwarding for the overlays */
|
|
bool SendKeyDown (const SDL_keysym &keysym);
|
|
bool SendKeyUp (const SDL_keysym &keysym);
|
|
bool SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos);
|
|
bool SendMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos);
|
|
|
|
private:
|
|
/** \brief Keeps the list of OverlayBase for each game state */
|
|
std::map<unsigned int, std::list<OverlayBasePtr> > mOverlays;
|
|
};
|
|
|
|
};
|
|
|
|
#endif /* OVERLAYBASE */
|