Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 3 and Version 4 of code/doc/GUI


Ignore:
Timestamp:
Apr 13, 2009, 6:09:53 PM (15 years ago)
Author:
bknecht
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/GUI

    v3 v4  
    1616Written in C++ the GUIManager manages all the GUIs in Orxonox and represents the interface to CEGUI. Connected to Lua via a tolua++ interface it is able to load Lua-scripts and connect C++-functions to Lua and vice versa.
    1717
     18To use the GUIManager in C++-code you can call it easily as it is a singleton:
     19{{{
     20#include "gui/GUIManager.h"
     21
     22...
     23
     24GUIManager guiMan = GUIManager::getInstance();
     25GUIManager* guiManPtr = GUIManager::getInstancePtr();
     26}}}
     27
     28Find out more about the GUIManager's methods in the [http://www.orxonox.net/doxygen/classorxonox_1_1GUIManager.html Doxygen-Documentation]
     29
     30To access C++-code in Lua you have to mark them. You can see how this is done on [wiki:Scripting this page]. Afterwards calling a method of a C++-class you can proceed as below (''--'' denote commentaries in Lua)
     31
     32{{{
     33-- using namespace orxonox and calling method "getInstance()" of GUIManager
     34guiman = orxonox.GUIManager:getInstance()
     35}}}
     36
    1837=== Lua-scripts ===
    1938
    20 Lua-scripts are written in Lua and implement the functionalities of CEGUI like interactivity. Each GUI needs a separate Lua-script which will be loaded by the main script.
     39Lua-scripts are written in Lua and implement the functionalities of CEGUI like interactivity. Each GUI needs a separate Lua-script which will be loaded by the main script. Our implementation ensures that a GUI cannot be loaded more than once.
    2140
    2241Usually you would set some variables and define some events inside the Lua-script. You may want for instance to define what layout you want to load. Check out the existing scripts to get an idea of the intended use.
    2342
     43To load a GUI you can just call the showGUI()-function of the GUIManager with the file name of your Lua-script:
     44{{{
     45// shows the GUI called "mainmenu" and loads it beforehand if necessary
     46GUIManager::getInstance().showGUI("mainmenu");
     47}}}
     48
    2449=== Imagesets ===
    2550
    26 Images are loaded in so called imagesets. As the name suggests, you can group several images into one single imageset. This can be used for instance when defining "active", "hover", "clicked" and "inactive" state of a button. You'd load just one image file into the imageset, but define various images from that imageset.
     51Images are loaded into so called imagesets. As the name suggests, you can group several images into one single imageset. This can be used for instance when defining "active", "hover", "clicked" and "inactive" state of a button. You'd load just one image file into the imageset, but define various images from that imageset.
    2752
    28 Imageset files are written in XML and very easy to use. To be able to use the specified images though, you need to include the imageset into a scheme file.
     53Imageset files are written in XML and very easy to use. To be able to use the specified images though, you need to include the imageset into a scheme file. Schemes are explicated in the next section.
     54
     55To add an image file to a imageset and defining one or more images from this imageset this example code should help:
     56{{{
     57<Imageset Name="MainMenuBackground" Imagefile="main_menu_1.jpg" NativeHorzRes="1400" NativeVertRes="1050" AutoScaled="true">
     58<Image Name="Background" XPos="0" YPos="0" Width="1400" Height="1050"/>
     59<!-- define more images similar to the line above -->
     60</Imageset>
     61}}}
    2962
    3063=== Schemes ===
     
    3972
    4073Every GUI-element is a window. The underlying class-structure inherits everything from a basic window element. Buttons and text input elements implement various new parameters and functions. They also need different kinds of images. At the moment we advise to use a predefined look for our GUI, namely the !TaharezLook. However this may change in the future, when we want to define our own looks. Check out the parameters and functions of each element in the layouts already in the media directory or in the [http://www.cegui.org.uk/api_reference/ CEGUI-API]. The API is written for C++, but you can access the same function in a similar fashion, using Lua or XML.
    41 
    42 ==== Windows ====
    43 
    44 ==== Cursor ====