Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 30, 2009, 2:31:05 PM (16 years ago)
Author:
bknecht
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/GUI

    v4 v5  
    3939Lua-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.
    4040
    41 Usually 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.
     41If you want to create a new GUI you need to create a lua file with the following header. Of course you would change ''mainmenu'' to the name of your GUI. The name of the GUI and the filename should be the same.
     42{{{
     43gui = require("gui")
     44local P = gui:new() --inherit everything from the gui package
    4245
    43 To load a GUI you can just call the showGUI()-function of the GUIManager with the file name of your Lua-script:
     46mainmenu = P
     47
     48P.filename = "mainmenu"
     49P.layoutString = "MainMenu.layout"
     50
     51...
     52
     53return mainmenu
     54}}}
     55
     56Specify events in your GUI as follows:
     57{{{
     58-- events for mainmenu
     59function P.button_quit_clicked(e)
     60  ... -- do something
     61end
     62}}}
     63
     64To load a GUI from inside Orxonox, you can just call the showGUI()-function of the GUIManager with the file name of your Lua-script:
    4465{{{
    4566// shows the GUI called "mainmenu" and loads it beforehand if necessary