FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
ceguimanager.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 
24 // 3rd party library includes
25 #include <CEGUI/CEGUI.h>
26 #include <CEGUI/RendererModules/OpenGL/GLRenderer.h>
27 
28 // FIFE includes
29 // These includes are split up in two parts, separated by one empty line
30 // First block: files included from the FIFE root src directory
31 // Second block: files included from the same folder
33 #include "util/time/timemanager.h"
34 
35 #include "ceguimanager.h"
36 
37 namespace FIFE {
38 
40 #ifdef HAVE_OPENGL
41  CEGUI::OpenGLRenderer::bootstrapSystem();
42  dynamic_cast<CEGUI::OpenGLRenderer*>(CEGUI::System::getSingleton().getRenderer())->
43  enableExtraStateSettings(true);
44 #else
45  throw GuiException("CEGUI can be used only if opengl is enabled!");
46 #endif
48 
50 
51  }
52 
54  delete m_inputProcessor;
55 
56  CEGUI::OpenGLRenderer::destroySystem();
57  }
58 
61 
62  CEGUI::System::getSingleton().renderAllGUIContexts();
63  }
64 
66  CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Sizef(width, height));
67  }
68 
69  bool CEGuiManager::onSdlEvent(SDL_Event &event) {
70  return m_inputProcessor->onSdlEvent(event);
71  }
72 
73  void CEGuiManager::setRootWindow(CEGUI::Window* root) {
74  m_guiRoot = root;
75  CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(m_guiRoot);
76  }
77 
78  CEGUI::Window* CEGuiManager::getRootWindow() {
79  return m_guiRoot;
80  }
81 
83 
84  double timeNow = TimeManager::instance()->getTime() / 1000.0;
85  float time_pulse = float(timeNow - m_lastTimePulse);
86 
87  CEGUI::System::getSingleton().injectTimePulse(time_pulse);
88  CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse(time_pulse);
89 
90  m_lastTimePulse = timeNow;
91  }
92 }
CEGuiManager()
Constructor.
uint32_t getTime() const
Get the time.
CEGUI::Window * getRootWindow()
virtual bool onSdlEvent(SDL_Event &event)
Receives input and converts it to librocket format, then it forwards it to librocket.
static TimeManager * instance()
Definition: singleton.h:84
void injectTimePulse()
Inject a time pulse to CEGUI.
CEGuiInputProcessor * m_inputProcessor
Input processor.
Definition: ceguimanager.h:90
virtual ~CEGuiManager()
double m_lastTimePulse
Last time pulse injected to CEGUI.
Definition: ceguimanager.h:94
bool onSdlEvent(SDL_Event &event)
Injects input to the CEGUI system.
void setRootWindow(CEGUI::Window *setRootWindow)
Sets the root window of the gui system.
unsigned int uint32_t
Definition: core.h:40
virtual void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Resizes the top container.
CEGUI::Window * m_guiRoot
Our root gui window.
Definition: ceguimanager.h:98
virtual void turn()
Updates and renders the gui.