orxonox::GUIManager Class Reference

Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler. More...

#include <src/orxonox/gui/GUIManager.h>

Inheritance diagram for orxonox::GUIManager:

orxonox::KeyHandler orxonox::MouseHandler orxonox::InputHandler orxonox::InputHandler

List of all members.

Public Types

enum  State { Uninitialised, Ready, OnDisplay }

Public Member Functions

void executeCode (const std::string &str)
 Executes Lua code.
void getLevelList ()
GUIOverlaygetOverlay (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 GUIManagergetInstance ()
static GUIManagergetInstancePtr ()

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::OgreCEGUIRendererguiRenderer_
 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::LuaScriptModulescriptModule_
 CEGUI's script module to use Lua.
State state_
 reflects state of the GUIManager

Static Private Attributes

static GUIManagersingletonRef_s = 0
 Singleton reference to GUIManager.


Detailed Description

Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.

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.


Member Enumeration Documentation

The current state of the GUIManager. There should maybe be more (or we can omit this totally).

Enumerator:
Uninitialised  Initial state of the GUIManager.
Ready  State after initialisation if ready.
OnDisplay  State if GUI is displayed.


Constructor & Destructor Documentation

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)


Member Function Documentation

void orxonox::GUIManager::executeCode ( const std::string str  ) 

Executes Lua code.

Parameters:
str reference to string object holding the Lua code which is to be executed
This function gives total access to the GUI. You can execute ANY Lua code here.

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]

static GUIManager* orxonox::GUIManager::getInstancePtr (  )  [inline, static]

void orxonox::GUIManager::getLevelList (  ) 

GUIOverlay * orxonox::GUIManager::getOverlay ( const std::string name  ) 

Get the GUIOverlay of the GUI with the given name.

Parameters:
name The name of the GUI.
Returns:
Returns a pointer to the GUIOverlay.

References guiOverlays_.

Referenced by orxonox::QuestManager::getQuestTree().

bool orxonox::GUIManager::initialise ( Ogre::RenderWindow *  renderWindow  ) 

Initialises the GUIManager by starting up CEGUI.

Parameters:
renderWindow Ogre's render window. Without this, the GUI cannot be displayed.
Returns:
true if success, otherwise false
Before this call the GUIManager won't do anything, but can be accessed.

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]

void orxonox::GUIManager::keyReleased ( const KeyEvent evt  )  [private, virtual]

void orxonox::GUIManager::loadLuaCode (  )  [private]

Calls main Lua script.

Todo:
Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk. However CEGUI is able to execute a startup script. We could maybe put this call in this startup code.
This function calls the main Lua script for our GUI.

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.

Parameters:
id ID of the mouse button which got pressed
This function is inherited by MouseHandler and injects the event into CEGUI. It is for CEGUI to process the event.

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.

Parameters:
id ID of the mouse button which got released
This function is inherited by MouseHandler and injects the event into CEGUI. It is for CEGUI to process the event.

Implements orxonox::MouseHandler.

References orxonox::convertButton(), COUT, and guiSystem_.

void orxonox::GUIManager::mouseMoved ( IntVector2  abs,
IntVector2  rel,
IntVector2  clippingSize 
) [private, virtual]

void orxonox::GUIManager::mouseScrolled ( int  abs,
int  rel 
) [private, virtual]

Implements orxonox::MouseHandler.

References guiSystem_.

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.

Parameters:
name The name of the GUI.
overlay A pointer to the GUIOverlay of the GUI.
Returns:
Returns false if the Overlay was already present.

References guiOverlays_.

Referenced by orxonox::GUIOverlay::XMLPort().

void orxonox::GUIManager::setCamera ( Ogre::Camera *  camera  ) 

Tells the GUIManager which SceneManager to use.

Parameters:
camera The current camera on which the GUI should be displayed on.
In fact the GUIManager needs the SceneManager and not the Camera to display the GUI. This means the GUI is not bound to a camera but rather to the SceneManager. Hidding the GUI when needed can therefore not be solved by just NOT setting the current camera.

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.

Parameters:
name The name of the GUI
The function executes the Lua function with the same name in case the GUIManager is ready. For more details check out loadGUI_2.lua where the function presides.

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

Parameters:
time clock which provides time value for the GUI System
Ticking the GUI means updating it with a certain regularity. The elapsed time since the last call is given in the time value provided by the clock. This time value is then used to provide a fluent animation of the GUI.

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.


Member Data Documentation

CEGUI::Logger* orxonox::GUIManager::ceguiLogger_ [private]

CEGUI's logger to be able to log CEGUI errors in our log.

Referenced by initialise().

A list of all GUIOverlay's.

Referenced by getOverlay(), and registerOverlay().

CEGUI's interface to the Ogre Engine.

Referenced by initialise(), setCamera(), and ~GUIManager().

CEGUI::System* orxonox::GUIManager::guiSystem_ [private]

lua_State* orxonox::GUIManager::luaState_ [private]

Lua state, access point to the Lua engine.

Referenced by initialise(), and ~GUIManager().

Ogre::RenderWindow* orxonox::GUIManager::renderWindow_ [private]

Ogre's render window to give CEGUI access to it.

Referenced by initialise().

CEGUI::ResourceProvider* orxonox::GUIManager::resourceProvider_ [private]

CEGUI's resource provider.

Referenced by initialise().

CEGUI's script module to use Lua.

Referenced by executeCode(), getLevelList(), initialise(), loadLuaCode(), showGUI(), and ~GUIManager().

Singleton reference to GUIManager.

Referenced by GUIManager(), and ~GUIManager().

reflects state of the GUIManager

Referenced by initialise(), and showGUI().


The documentation for this class was generated from the following files:

Generated on Tue Jul 28 16:22:34 2009 for Orxonox by  doxygen 1.5.6