#include <src/orxonox/gui/GUIManager.h>
Public Types | |
enum | State { Uninitialised, Ready, OnDisplay } |
Public Member Functions | |
void | executeCode (const std::string &str) |
Executes Lua code. | |
void | getLevelList () |
GUIOverlay * | getOverlay (const std::string &name) |
Get the GUIOverlay of the GUI with the given name. | |
GUIManager () | |
bool | initialise (Ogre::RenderWindow *renderWindow) |
Initialises the GUIManager by starting up CEGUI. | |
bool | registerOverlay (const std::string &name, GUIOverlay *overlay) |
Register a GUIOverlay with the GUIManager. | |
void | setCamera (Ogre::Camera *camera) |
Tells the GUIManager which SceneManager to use. | |
void | showGUI (const std::string &name) |
Displays specified GUI on screen. | |
void | update (const Clock &time) |
used to tick the GUI | |
~GUIManager () | |
Deconstructor of the GUIManager. | |
Static Public Member Functions | |
static GUIManager & | getInstance () |
static GUIManager * | getInstancePtr () |
Private Member Functions | |
GUIManager (const GUIManager &instance) | |
private constructor (this is a singleton class) | |
void | keyHeld (const KeyEvent &evt) |
void | keyPressed (const KeyEvent &evt) |
void | keyReleased (const KeyEvent &evt) |
void | loadLuaCode () |
Calls main Lua script. | |
void | mouseButtonHeld (MouseButtonCode::ByEnum id) |
void | mouseButtonPressed (MouseButtonCode::ByEnum id) |
Function receiving a mouse button pressed event. | |
void | mouseButtonReleased (MouseButtonCode::ByEnum id) |
Function receiving a mouse button released event. | |
void | mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) |
void | mouseScrolled (int abs, int rel) |
void | updateInput (float dt) |
void | updateKey (float dt) |
void | updateMouse (float dt) |
Private Attributes | |
CEGUI::Logger * | ceguiLogger_ |
CEGUI's logger to be able to log CEGUI errors in our log. | |
std::map< std::string, GUIOverlay * > | guiOverlays_ |
A list of all GUIOverlay's. | |
CEGUI::OgreCEGUIRenderer * | guiRenderer_ |
CEGUI's interface to the Ogre Engine. | |
CEGUI::System * | guiSystem_ |
CEGUI's main system. | |
lua_State * | luaState_ |
Lua state, access point to the Lua engine. | |
Ogre::RenderWindow * | renderWindow_ |
Ogre's render window to give CEGUI access to it. | |
CEGUI::ResourceProvider * | resourceProvider_ |
CEGUI's resource provider. | |
CEGUI::LuaScriptModule * | scriptModule_ |
CEGUI's script module to use Lua. | |
State | state_ |
reflects state of the GUIManager | |
Static Private Attributes | |
static GUIManager * | singletonRef_s = 0 |
Singleton reference to GUIManager. |
The GUIManager is a singleton and can be called anywhere when access on the GUI is needed. Creation of the GUIManager is therefore not possible and the cunstructor is private.
Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler. Those input events are then injected into CEGUI in Lua.
The current state of the GUIManager. There should maybe be more (or we can omit this totally).
Uninitialised | Initial state of the GUIManager. |
Ready | State after initialisation if ready. |
OnDisplay | State if GUI is displayed. |
orxonox::GUIManager::GUIManager | ( | ) |
References singletonRef_s.
orxonox::GUIManager::~GUIManager | ( | ) |
Deconstructor of the GUIManager.
Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.
References guiRenderer_, guiSystem_, luaState_, scriptModule_, and singletonRef_s.
orxonox::GUIManager::GUIManager | ( | const GUIManager & | instance | ) | [private] |
private constructor (this is a singleton class)
void orxonox::GUIManager::executeCode | ( | const std::string & | str | ) |
Executes Lua code.
str | reference to string object holding the Lua code which is to be executed |
References COUT, CEGUI::LuaScriptModule::executeString(), and scriptModule_.
Referenced by orxonox::GUIOverlay::changedVisibility(), orxonox::GSLevel::showIngameGUI(), orxonox::GSGraphics::toggleGUI(), orxonox::PickupInventory::toggleInventory(), and orxonox::PickupSpawner::XMLPort().
static GUIManager& orxonox::GUIManager::getInstance | ( | ) | [inline, static] |
Referenced by orxonox::GSMainMenu::activate(), orxonox::GUIOverlay::changedVisibility(), orxonox::GSMainMenu::deactivate(), orxonox::QuestManager::getQuestTree(), orxonox::GSLevel::showIngameGUI(), orxonox::GSGraphics::toggleGUI(), orxonox::PickupInventory::toggleInventory(), tolua_Orxonox_orxonox_GUIManager_getInstance00(), orxonox::CameraManager::useCamera(), orxonox::GUIOverlay::XMLPort(), and orxonox::PickupSpawner::XMLPort().
static GUIManager* orxonox::GUIManager::getInstancePtr | ( | ) | [inline, static] |
Referenced by orxonox::GSMainMenu::activate(), and orxonox::GSLevel::activate().
void orxonox::GUIManager::getLevelList | ( | ) |
GUIOverlay * orxonox::GUIManager::getOverlay | ( | const std::string & | name | ) |
Get the GUIOverlay of the GUI with the given name.
name | The name of the GUI. |
References guiOverlays_.
Referenced by orxonox::QuestManager::getQuestTree().
bool orxonox::GUIManager::initialise | ( | Ogre::RenderWindow * | renderWindow | ) |
Initialises the GUIManager by starting up CEGUI.
renderWindow | Ogre's render window. Without this, the GUI cannot be displayed. |
Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine. The log is set up and connected to the CEGUILogger. After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code. Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically).
References ceguiLogger_, COUT, CEGUI::OgreCEGUIRenderer::createResourceProvider(), orxonox::Core::getLogPathString(), CEGUI::LuaScriptModule::getLuaState(), orxonox::Core::getSoftDebugLevel(), guiRenderer_, guiSystem_, orxonox::OutputHandler::LD_Logfile, loadLuaCode(), luaState_, Ready, renderWindow_, resourceProvider_, scriptModule_, state_, tolua_Core_open(), tolua_Orxonox_open(), and Uninitialised.
Referenced by orxonox::GSGraphics::activate().
void orxonox::GUIManager::keyHeld | ( | const KeyEvent & | evt | ) | [inline, private, virtual] |
Implements orxonox::KeyHandler.
void orxonox::GUIManager::keyPressed | ( | const KeyEvent & | evt | ) | [private, virtual] |
Implements orxonox::KeyHandler.
References guiSystem_, orxonox::KeyEvent::key, and orxonox::KeyEvent::text.
void orxonox::GUIManager::keyReleased | ( | const KeyEvent & | evt | ) | [private, virtual] |
void orxonox::GUIManager::loadLuaCode | ( | ) | [private] |
Calls main Lua script.
Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI.
References CEGUI::LuaScriptModule::executeScriptFile(), CEGUI::LuaScriptModule::getLuaState(), orxonox::Core::getMediaPathString(), and scriptModule_.
Referenced by initialise().
void orxonox::GUIManager::mouseButtonHeld | ( | MouseButtonCode::ByEnum | id | ) | [inline, private, virtual] |
Implements orxonox::MouseHandler.
void orxonox::GUIManager::mouseButtonPressed | ( | MouseButtonCode::ByEnum | id | ) | [private, virtual] |
Function receiving a mouse button pressed event.
id | ID of the mouse button which got pressed |
Implements orxonox::MouseHandler.
References orxonox::convertButton(), COUT, and guiSystem_.
void orxonox::GUIManager::mouseButtonReleased | ( | MouseButtonCode::ByEnum | id | ) | [private, virtual] |
Function receiving a mouse button released event.
id | ID of the mouse button which got released |
Implements orxonox::MouseHandler.
References orxonox::convertButton(), COUT, and guiSystem_.
void orxonox::GUIManager::mouseMoved | ( | IntVector2 | abs, | |
IntVector2 | rel, | |||
IntVector2 | clippingSize | |||
) | [private, virtual] |
Implements orxonox::MouseHandler.
References guiSystem_, orxonox::IntVector2::x, and orxonox::IntVector2::y.
void orxonox::GUIManager::mouseScrolled | ( | int | abs, | |
int | rel | |||
) | [private, virtual] |
bool orxonox::GUIManager::registerOverlay | ( | const std::string & | name, | |
GUIOverlay * | overlay | |||
) |
Register a GUIOverlay with the GUIManager.
Registers a GUIOverlay with the GUIManager so that the GUIOverlay can be accessed by it's name through the GUIManager.
name | The name of the GUI. | |
overlay | A pointer to the GUIOverlay of the GUI. |
References guiOverlays_.
Referenced by orxonox::GUIOverlay::XMLPort().
void orxonox::GUIManager::setCamera | ( | Ogre::Camera * | camera | ) |
Tells the GUIManager which SceneManager to use.
camera | The current camera on which the GUI should be displayed on. |
References guiRenderer_, and CEGUI::OgreCEGUIRenderer::setTargetSceneManager().
Referenced by orxonox::GSMainMenu::activate(), orxonox::GSMainMenu::deactivate(), and orxonox::CameraManager::useCamera().
void orxonox::GUIManager::showGUI | ( | const std::string & | name | ) |
Displays specified GUI on screen.
name | The name of the GUI |
References COUT, CEGUI::LuaScriptModule::executeString(), scriptModule_, state_, and Uninitialised.
Referenced by orxonox::GSMainMenu::activate(), orxonox::GSLevel::showIngameGUI(), orxonox::PickupInventory::toggleInventory(), and orxonox::PickupSpawner::XMLPort().
void orxonox::GUIManager::update | ( | const Clock & | time | ) |
used to tick the GUI
time | clock which provides time value for the GUI System |
References orxonox::Clock::getDeltaTime(), and guiSystem_.
Referenced by orxonox::GSGraphics::update().
void orxonox::GUIManager::updateInput | ( | float | dt | ) | [inline, private, virtual] |
Implements orxonox::InputHandler.
void orxonox::GUIManager::updateKey | ( | float | dt | ) | [inline, private, virtual] |
Implements orxonox::KeyHandler.
void orxonox::GUIManager::updateMouse | ( | float | dt | ) | [inline, private, virtual] |
Implements orxonox::MouseHandler.
CEGUI::Logger* orxonox::GUIManager::ceguiLogger_ [private] |
std::map<std::string, GUIOverlay*> orxonox::GUIManager::guiOverlays_ [private] |
CEGUI::System* orxonox::GUIManager::guiSystem_ [private] |
CEGUI's main system.
Referenced by initialise(), keyPressed(), keyReleased(), mouseButtonPressed(), mouseButtonReleased(), mouseMoved(), mouseScrolled(), update(), and ~GUIManager().
lua_State* orxonox::GUIManager::luaState_ [private] |
Ogre::RenderWindow* orxonox::GUIManager::renderWindow_ [private] |
CEGUI::ResourceProvider* orxonox::GUIManager::resourceProvider_ [private] |
CEGUI's script module to use Lua.
Referenced by executeCode(), getLevelList(), initialise(), loadLuaCode(), showGUI(), and ~GUIManager().
GUIManager * orxonox::GUIManager::singletonRef_s = 0 [static, private] |
State orxonox::GUIManager::state_ [private] |