23 #include <Rocket/Core.h> 24 #include <Rocket/Controls.h> 27 #include <Rocket/Debugger.h> 46 m_inputProcessor(NULL) {
47 Rocket::Core::SetSystemInterface(
this);
49 Rocket::Core::Initialise();
50 Rocket::Controls::Initialise();
56 Rocket::Core::Shutdown();
64 m_context = Rocket::Core::CreateContext(
"default", Rocket::Core::Vector2i(screenWidth, screenHeight));
76 return timeManager->
getTime() / 1000.0f;
91 m_context->SetDimensions(Rocket::Core::Vector2i(width, height));
97 throw GuiException(
"Id: " +
id +
" already used!");
100 Rocket::Core::String rocketDocumentPath(documentPath.c_str());
102 Rocket::Core::ElementDocument* document =
m_context->LoadDocument(rocketDocumentPath);
104 if(document != NULL) {
107 throw GuiException(
"Could not load document " + documentPath +
"!");
114 std::map<std::string, Rocket::Core::ElementDocument*>::iterator doc(
m_openDocuments.find(
id));
116 throw GuiException(
"Rocket document with id " +
id +
" doesn't exist!");
122 std::map<std::string, Rocket::Core::ElementDocument*>::iterator currDoc(
m_openDocuments.begin());
123 std::map<std::string, Rocket::Core::ElementDocument*>::iterator endDocs(
m_openDocuments.end());
125 for(; currDoc != endDocs;) {
126 if(currDoc->second == document) {
127 m_context->UnloadDocument(currDoc->second);
137 std::map<std::string, Rocket::Core::ElementDocument*>::iterator doc(
m_openDocuments.find(
id));
146 Rocket::Core::String rocketFontPath(filepath.c_str());
148 bool succeeded = Rocket::Core::FontDatabase::LoadFontFace(rocketFontPath);
150 throw GuiException(
"Librocket cannot open font: " + filepath);
161 if(!Rocket::Debugger::IsVisible()) {
162 Rocket::Debugger::SetVisible(
true);
169 if(Rocket::Debugger::IsVisible()) {
170 Rocket::Debugger::SetVisible(
false);
177 std::map<std::string, Rocket::Core::ElementDocument*>::iterator currDoc(
m_openDocuments.begin());
178 std::map<std::string, Rocket::Core::ElementDocument*>::iterator endDocs(
m_openDocuments.end());
180 for(; currDoc != endDocs; ++currDoc) {
181 m_context->UnloadDocument(currDoc->second);
virtual void turn()
Updates and renders the gui.
virtual Rocket::Core::ElementDocument * loadDocument(const std::string &id, const std::string &documentPath)
Loads a rocket .rml file and shows it.
virtual void unloadDocument(Rocket::Core::ElementDocument *document)
Unloads a rocket document.
void showDebugger() const
Shows the librocket debugger.
uint32_t getTime() const
Get the time.
virtual float GetElapsedTime()
NOTE There is an inconsistency in the naming of this method.
void init(const std::string &backend, int32_t screenWidth, int32_t screenHeight)
Initializes the librocket manager.
LibRocketInputProcessor * m_inputProcessor
Input processor for librocket.
std::map< std::string, Rocket::Core::ElementDocument * > m_openDocuments
A set of all open documents.
void hideDebugger() const
Hides the librocket debugger.
static TimeManager * instance()
void freeTextures()
Frees all textures that are no longer needed by librocket.
LibRocketRenderInterface * m_renderInterface
Render Interface for librocket.
virtual void loadFont(const std::string &filepath)
Loads a font to be used by librocket.
LibRocketManager()
Constructor.
virtual void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Resizes the top container.
virtual bool onSdlEvent(SDL_Event &evt)
Receives input and converts it to librocket format, then it forwards it to librocket.
void unloadDocuments()
Unloads documents opened by librocket.
virtual Rocket::Core::ElementDocument * getDocument(const std::string &id)
Rocket::Core::Context * m_context
Librocket's context.
void render()
Renders librocket gui.
virtual ~LibRocketManager()
Destructor.