Orxonox
0.0.5 Codename: Arcturus
|
Provides a simple interface to CEGUI with tolua methods and console commands.More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/GUIManager.h>
Public Member Functions | |
GUIManager (const std::pair< int, int > &mousePosition) | |
Constructs the GUIManager by starting up CEGUI. More... | |
~GUIManager ()=default | |
Leave empty and use cleanup() instead. More... | |
void | changedGUIScheme (void) |
const std::string & | createInputState (const std::string &name, tribool showCursor=tribool(true), tribool useKeyboard=tribool(true), bool bBlockJoyStick=false) |
Creates a new InputState to be used with a GUI Sheet. More... | |
void | destroy () |
Destructor that also executes when object fails to construct. More... | |
Ogre::Camera * | getCamera () |
CEGUI::Window * | getHUDRootWindow () |
Returns the root window for all HUD sheets. More... | |
std::vector< std::string > | getLoadedGUIs () |
LuaState * | getLuaState (void) |
CEGUI::Window * | getMenuRootWindow () |
Returns the root window for all menu sheets. More... | |
orxonox::PlayerInfo * | getPlayer (const std::string &guiname) const |
void | keyESC () |
void | loadGUI (const std::string &name) |
Loads a GUI sheet by Lua script. More... | |
void | preUpdate (const Clock &time) |
used to tick the GUI More... | |
void | setBackgroundImage (const std::string &imageSet, const std::string imageName) |
void | setBackgroundImage (const std::string &image) |
void | setCamera (Ogre::Camera *camera) |
Tells the GUIManager which SceneManager to use. More... | |
void | setConfigValues (void) |
void | setPlayer (const std::string &guiname, PlayerInfo *player) |
void | showGUIExtra (const std::string &name, const std::string &ptr, bool bHidePrevious=false, bool bNoInput=false) |
Hack-ish. More... | |
void | toggleGUIHelper (const std::string &name, bool bHidePrevious, bool bNoInput, bool show) |
Helper method to toggle a specified GUI. More... | |
bool | usingOldCEGUI (void) |
Check whether CEGUI is version < 0.7. More... | |
Public Member Functions inherited from orxonox::InputHandler | |
virtual | ~InputHandler ()=default |
virtual void | allDevicesUpdated (float dt) |
virtual void | axisMoved (unsigned int joyStick, unsigned int axis, float value) |
template<class T > | |
void | buttonEvent (unsigned int device, T button, ButtonEvent::TPress) |
template<class T > | |
void | buttonEvent (unsigned int device, T button, ButtonEvent::TRelease) |
template<class T > | |
void | buttonEvent (unsigned int device, T button, ButtonEvent::THold) |
virtual void | buttonHeld (const KeyEvent &evt) |
virtual void | buttonHeld (MouseButtonCode::ByEnum button) |
virtual void | buttonHeld (unsigned int joyStick, JoyStickButtonCode::ByEnum button) |
virtual void | buttonPressed (unsigned int joyStick, JoyStickButtonCode::ByEnum button) |
virtual void | buttonReleased (unsigned int joyStick, JoyStickButtonCode::ByEnum button) |
virtual void | joyStickUpdated (unsigned int joyStick, float dt) |
virtual void | keyboardUpdated (float dt) |
virtual void | mouseUpdated (float dt) |
Public Member Functions inherited from orxonox::Listable | |
Listable () | |
Constructor: Allocates space in the element list. More... | |
Listable (Context *context) | |
Constructor: Allocates space in the element list and assigns the context. More... | |
virtual | ~Listable () |
Destructor: Removes the object from the object-lists. More... | |
Context * | getContext () const |
void | setContext (Context *context) |
Changes the context. More... | |
void | unregisterObject () |
Removes this object from the object-lists. More... | |
Public Member Functions inherited from orxonox::Identifiable | |
Identifiable () | |
Constructor: Sets the default values. More... | |
virtual | ~Identifiable () |
ORX_FORCEINLINE void * | getDerivedPointer (unsigned int classID) |
Returns a valid pointer of any derived type that is registered in the class hierarchy. More... | |
template<class T > | |
ORX_FORCEINLINE T * | getDerivedPointer (unsigned int classID) |
Version of getDerivedPointer with template. More... | |
template<class T > | |
ORX_FORCEINLINE const T * | getDerivedPointer (unsigned int classID) const |
Const version of getDerivedPointer with template. More... | |
Identifier * | getIdentifier () const |
Returns the Identifier of the object. More... | |
bool | isA (const Identifier *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
template<class B > | |
bool | isA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isA (const Identifiable *object) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isChildOf (const Identifier *identifier) |
Returns true if the object's class is a child of the given type. More... | |
template<class B > | |
bool | isChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a child of the given type. More... | |
bool | isChildOf (const Identifiable *object) |
Returns true if the object's class is a child of the given type. More... | |
bool | isDirectChildOf (const Identifier *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
template<class B > | |
bool | isDirectChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectChildOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectParentOf (const Identifier *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
template<class B > | |
bool | isDirectParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
bool | isDirectParentOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isExactlyA (const Identifier *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
template<class B > | |
bool | isExactlyA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isExactlyA (const Identifiable *object) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isParentOf (const Identifier *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
template<class B > | |
bool | isParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
bool | isParentOf (const Identifiable *object) |
Returns true if the object's class is a parent of the given type. More... | |
Static Public Member Functions | |
static void | addFontHelper (const std::string &name, int size, const std::string &fontName) |
Adds a new freetype font to the CEGUI system. More... | |
static float | getFontTextExtent (const CEGUI::Font *font, const std::string &text, float x_scale=1.0f) |
static GUIManager & | getInstance () |
static void | hideGUI (const std::string &name) |
Hides specified GUI. More... | |
static bool | inDevMode (void) |
Helper method to get the developer's mode without having to export Core.h. More... | |
static bool | preloadMenuSheets () |
static void | setItemTooltipsEnabledHelper (CEGUI::Listbox *listbox, bool enabled) |
Set whether the tooltips for the input Listbox are enabled. More... | |
static void | setTooltipTextHelper (CEGUI::ListboxItem *item, const std::string &toooltip) |
Set the input tooltip text for the input ListboxItem. More... | |
static void | showGUI (const std::string &name, bool bHidePrevious=false, bool bNoInput=false) |
Displays specified GUI on screen. More... | |
static void | subscribeEventHelper (CEGUI::Window *window, const std::string &event, const std::string &function) |
Subscribe the input function to the input event for the input window. More... | |
static void | toggleGUI (const std::string &name, bool bHidePrevious=false, bool bNoInput=false) |
Toggles specified GUI. More... | |
Static Public Member Functions inherited from orxonox::Singleton< GUIManager > | |
static bool | exists () |
Tells whether the singleton has been created. More... | |
static GUIManager & | getInstance () |
Returns a reference to the singleton instance. More... | |
Private Member Functions | |
GUIManager (const GUIManager &)=delete | |
virtual void | buttonPressed (const KeyEvent &evt) override |
virtual void | buttonPressed (MouseButtonCode::ByEnum id) override |
Function receiving a mouse button pressed event. More... | |
virtual void | buttonReleased (const KeyEvent &evt) override |
virtual void | buttonReleased (MouseButtonCode::ByEnum id) override |
Function receiving a mouse button released event. More... | |
void | changedCeguiOutputLevel () |
void | executeCode (const std::string &str) |
Executes Lua code. More... | |
void | mouseLeft () |
Indicates that the mouse left the application's window. More... | |
virtual void | mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) override |
virtual void | mouseScrolled (int abs, int rel) override |
GUIManager & | operator= (const GUIManager &)=delete |
template<typename FunctionType , typename ObjectType > | |
bool | protectedCall (FunctionType function, ObjectType object) |
Executes a CEGUI function normally, but catches CEGUI::ScriptException. More... | |
template<typename FunctionType > | |
bool | protectedCeguiSystemCall (FunctionType function) |
Executes a CEGUI function normally, but catches CEGUI::ScriptException. More... | |
virtual void | windowFocusChanged (bool bFocus) override |
Notify CEGUI if the windows loses the focus (stops highlighting of menu items, etc). More... | |
virtual void | windowResized (unsigned int newWidth, unsigned int newHeight) override |
Callback of window event listener, called if the window is resized. More... | |
Private Attributes | |
bool | bPreloadMenuSheets_ |
If true, menu sheets are pre-loaded during startup. More... | |
Ogre::Camera * | camera_ |
Camera used to render the scene with the GUI. More... | |
CEGUI::Logger * | ceguiLogger_ |
CEGUI's logger to be able to log CEGUI errors in our log. More... | |
DestructionHelper< GUIManager > | destructionHelper_ |
Helper object that executes the surrogate destructor destroy() More... | |
CEGUI::OgreCEGUIRenderer * | guiRenderer_ |
CEGUI's interface to the Ogre Engine. More... | |
std::string | guiScheme_ |
CEGUI::System * | guiSystem_ |
CEGUI's main system. More... | |
CEGUI::Window * | hudRootWindow_ |
Root node for the HUD sheets. More... | |
LuaState * | luaState_ |
LuaState, access point to the Lua engine. More... | |
CEGUI::Window * | menuRootWindow_ |
Root node for the menu sheets (used by Lua) More... | |
int | numScrollLines_ |
How many lines to scroll in a list if the scroll wheel is used. More... | |
bool | oldCEGUI_ |
int | outputLevelCeguiLog_ |
CEGUI's log level. More... | |
std::map< std::string, PlayerInfo * > | players_ |
Stores the player (owner) for each GUI. More... | |
CEGUI::ResourceProvider * | resourceProvider_ |
CEGUI's resource provider. More... | |
std::shared_ptr< ResourceInfo > | rootFileInfo_ |
Resource information about the root script. More... | |
CEGUI::Window * | rootWindow_ |
Root node for all windows. More... | |
CEGUI::LuaScriptModule * | scriptModule_ |
CEGUI's script module to use Lua. More... | |
Static Private Attributes | |
static const std::string | defaultScheme_ = "TaharezGreen" |
static GUIManager * | singletonPtr_s = nullptr |
Singleton reference to GUIManager. More... | |
Friends | |
class | Singleton< GUIManager > |
Additional Inherited Members | |
Static Public Attributes inherited from orxonox::InputHandler | |
static InputHandler | EMPTY |
Use this input handler if you want to occupy a device in an input state. More... | |
Protected Member Functions inherited from orxonox::Singleton< GUIManager > | |
Singleton () | |
Constructor sets the singleton instance pointer. More... | |
virtual | ~Singleton () |
Destructor resets the singleton instance pointer. More... | |
Protected Member Functions inherited from orxonox::WindowEventListener | |
WindowEventListener () | |
virtual | ~WindowEventListener ()=default |
unsigned int | getWindowHeight () const |
Returns the current render window height. More... | |
unsigned int | getWindowWidth () const |
Returns the current render window width. More... | |
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.
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.
orxonox::GUIManager::GUIManager | ( | const std::pair< int, int > & | mousePosition | ) |
Constructs the GUIManager by starting up CEGUI.
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).
|
default |
Leave empty and use cleanup() instead.
|
privatedelete |
|
static |
Adds a new freetype font to the CEGUI system.
name | The name of the new font. |
size | The font size of the new font in pixels. |
fontName | The filename of the font. |
Reimplemented from orxonox::InputHandler.
|
overrideprivatevirtual |
Function receiving a mouse button pressed event.
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.
Reimplemented from orxonox::InputHandler.
Reimplemented from orxonox::InputHandler.
|
overrideprivatevirtual |
Function receiving a mouse button released event.
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.
Reimplemented from orxonox::InputHandler.
|
private |
const std::string & orxonox::GUIManager::createInputState | ( | const std::string & | name, |
tribool | showCursor = tribool(true) , |
||
tribool | useKeyboard = tribool(true) , |
||
bool | bBlockJoyStick = false |
||
) |
Creates a new InputState to be used with a GUI Sheet.
void orxonox::GUIManager::destroy | ( | ) |
Destructor that also executes when object fails to construct.
|
private |
Executes Lua code.
str | reference to string object holding the Lua code which is to be executed |
|
inline |
|
static |
|
inline |
Returns the root window for all HUD sheets.
|
inlinestatic |
std::vector< std::string > orxonox::GUIManager::getLoadedGUIs | ( | ) |
|
inline |
Returns the root window for all menu sheets.
|
inline |
|
static |
Hides specified GUI.
name | The name of the GUI. |
|
static |
Helper method to get the developer's mode without having to export Core.h.
void orxonox::GUIManager::keyESC | ( | ) |
void orxonox::GUIManager::loadGUI | ( | const std::string & | name | ) |
Loads a GUI sheet by Lua script.
name | The name of the GUI (like the script name, but without the extension) |
|
private |
Indicates that the mouse left the application's window.
|
overrideprivatevirtual |
Reimplemented from orxonox::InputHandler.
|
overrideprivatevirtual |
Reimplemented from orxonox::InputHandler.
|
privatedelete |
|
inlinestatic |
used to tick the GUI
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.
|
private |
Executes a CEGUI function normally, but catches CEGUI::ScriptException.
When a ScriptException occurs, the error message will be displayed and the program carries on.
function | Any callable object/function that takes this->guiSystem_ as its only parameter. |
function | Any callable object/function that takes one parameter. |
object | Object to be used as an argument for the function |
|
private |
Executes a CEGUI function normally, but catches CEGUI::ScriptException.
When a ScriptException occurs, the error message will be displayed and the program carries on.
function | Any callable object/function that takes this->guiSystem_ as its only parameter. |
void orxonox::GUIManager::setBackgroundImage | ( | const std::string & | imageSet, |
const std::string | imageName | ||
) |
void orxonox::GUIManager::setBackgroundImage | ( | const std::string & | image | ) |
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. |
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. Hiding the GUI when needed can therefore not be resolved by just NOT setting the current camera.
|
static |
Set whether the tooltips for the input Listbox are enabled.
listbox | The Listbox for which to enable (or disable) tooltips. |
enabled | Whether to enable or disable the tooltips. |
|
inline |
|
static |
Set the input tooltip text for the input ListboxItem.
item | The ListboxItem for which the tooltip should be set. |
tooltip | The tooltip text that should be set. |
|
static |
Displays specified GUI on screen.
name | The name of the GUI |
bHidePrevious | If true all displayed GUIs on the stack, that are below this GUI are hidden. |
bNoInput | If true the GUI is transparent to input. |
The function executes the Lua function with the same name in case the GUIManager is ready.
void orxonox::GUIManager::showGUIExtra | ( | const std::string & | name, |
const std::string & | ptr, | ||
bool | bHidePrevious = false , |
||
bool | bNoInput = false |
||
) |
Hack-ish.
Needed for GUIOverlay.
|
static |
Subscribe the input function to the input event for the input window.
This is a helper to be used in lua, because subscribeScriptedEvent() doesn't work in lua.
window | The window for which the event is subscribed. |
event | The type of event to which we subscribe. |
function | The function that is called when the event occurs. |
|
static |
Toggles specified GUI.
If the GUI with the input name is already shown and on the top, it is hidden, else it is shown.
void orxonox::GUIManager::toggleGUIHelper | ( | const std::string & | name, |
bool | bHidePrevious, | ||
bool | bNoInput, | ||
bool | show | ||
) |
Helper method to toggle a specified GUI.
Is called by lua.
|
inline |
|
overrideprivatevirtual |
Notify CEGUI if the windows loses the focus (stops highlighting of menu items, etc).
Reimplemented from orxonox::WindowEventListener.
|
overrideprivatevirtual |
Callback of window event listener, called if the window is resized.
Sets the display size of CEGUI.
Reimplemented from orxonox::WindowEventListener.
|
friend |
|
private |
If true, menu sheets are pre-loaded during startup.
|
private |
Camera used to render the scene with the GUI.
|
private |
|
staticprivate |
|
private |
Helper object that executes the surrogate destructor destroy()
|
private |
|
private |
|
private |
CEGUI's main system.
|
private |
Root node for the HUD sheets.
|
private |
Root node for the menu sheets (used by Lua)
|
private |
How many lines to scroll in a list if the scroll wheel is used.
|
private |
|
private |
CEGUI's log level.
|
private |
Stores the player (owner) for each GUI.
|
private |
CEGUI's resource provider.
|
private |
Resource information about the root script.
|
private |
Root node for all windows.
|
private |
CEGUI's script module to use Lua.
|
staticprivate |
Singleton reference to GUIManager.