FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cegui-0manager.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 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-0/CEGUI/CEGUI.h>
26 #include <cegui-0/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 "cegui-0manager.h"
36 
37 namespace FIFE {
38 
40 #ifdef HAVE_OPENGL
41  CEGUI::OpenGLRenderer::bootstrapSystem();
42 #else
43  throw GuiException("CEGUI can be used only if opengl is enabled!");
44 #endif
46 
48 
49  }
50 
52  delete m_inputProcessor;
53 
54  CEGUI::OpenGLRenderer::destroySystem();
55  }
56 
59 
60  CEGUI::System::getSingleton().renderAllGUIContexts();
61  }
62 
64  }
65 
66  bool CEGui_0Manager::onSdlEvent(SDL_Event &event) {
67  return m_inputProcessor->onSdlEvent(event);
68  }
69 
70  void CEGui_0Manager::setRootWindow(CEGUI::Window* root) {
71  m_guiRoot = root;
72  CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(m_guiRoot);
73  }
74 
75  CEGUI::Window* CEGui_0Manager::getRootWindow() {
76  return m_guiRoot;
77  }
78 
80 
81  double timeNow = TimeManager::instance()->getTime() / 1000.0;
82  float time_pulse = float(timeNow - m_lastTimePulse);
83 
84  CEGUI::System::getSingleton().injectTimePulse(time_pulse);
85  CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse(time_pulse);
86 
87  m_lastTimePulse = timeNow;
88  }
89 }
CEGUI::Window * m_guiRoot
Our root gui window.
CEGUI::Window * getRootWindow()
virtual bool onSdlEvent(SDL_Event &event)
Receives input and converts it to librocket format, then it forwards it to librocket.
CEGui_0InputProcessor * m_inputProcessor
Input processor.
double m_lastTimePulse
Last time pulse injected to CEGUI.
bool onSdlEvent(SDL_Event &event)
Injects input to the CEGUI system.
static TimeManager * instance()
Definition: singleton.h:84
void injectTimePulse()
Inject a time pulse to CEGUI.
uint32_t getTime() const
Get the time.
void setRootWindow(CEGUI::Window *setRootWindow)
Sets the root window of the gui system.
virtual void turn()
Updates and renders the gui.
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_0Manager()
Constructor.