Changes between Version 4 and Version 5 of code/doc/GUI
- Timestamp:
- Apr 30, 2009, 2:31:05 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/GUI
v4 v5 39 39 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. Our implementation ensures that a GUI cannot be loaded more than once. 40 40 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. 41 If 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 {{{ 43 gui = require("gui") 44 local P = gui:new() --inherit everything from the gui package 42 45 43 To load a GUI you can just call the showGUI()-function of the GUIManager with the file name of your Lua-script: 46 mainmenu = P 47 48 P.filename = "mainmenu" 49 P.layoutString = "MainMenu.layout" 50 51 ... 52 53 return mainmenu 54 }}} 55 56 Specify events in your GUI as follows: 57 {{{ 58 -- events for mainmenu 59 function P.button_quit_clicked(e) 60 ... -- do something 61 end 62 }}} 63 64 To load a GUI from inside Orxonox, you can just call the showGUI()-function of the GUIManager with the file name of your Lua-script: 44 65 {{{ 45 66 // shows the GUI called "mainmenu" and loads it beforehand if necessary