User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
guisys:guifiles [2011-06-26 10:55]
Carsten Removed now obsolete passages of text
guisys:guifiles [2011-06-26 15:40]
Carsten Removed more obsolete passages of text
Line 92: Line 92:
 ==== cgui files are Lua scripts ==== ==== cgui files are Lua scripts ====
  
-The Cafu Engine and the Model Editor load ''​cmdl''​ files as [[http://​www.lua.org/​|Lua]] scripts, and as such they can be inspected or edited in a text editor ​if desired.+The Cafu Engine and the Model Editor load ''​cmdl''​ files as [[http://​www.lua.org/​|Lua]] scripts, and as such they can be inspected or edited in a text editor.
  
 +As the GUI Editor is usually used to create and edit the static aspects of GUI windows, and dynamic aspects like animations or other kinds of effects typically require custom script code, editing ''​cgui''​ files (usually the ''​_main.cgui''​ file) is what you likely want to do often.
  
-{{ guisys:reallyquit.jpg?​300}} === General structure === +See the [[http://api.cafu.de/scripting/group__GUI.html|GUI Scripting Reference Documentation]] for more details.
- +
-The most important insight is that each GUI is in fact //a hierarchy of windows//, just like a program dialog of a real OSEach window is basically just a rectangle with certain properties, like position, size, border color and thickness, text to display, etc. +
- +
-However, the most important statements that we have to provide in order to instantiate a new window are its //class// (or //type//), and its //name//. +
- +
-The **class** of a window determines the most crucial features of the window, e.g. if it displays text, if the user can enter text, if it shows a value as a slider control, if it presents a list of items to select from, etc. Section [[guisys:​window_classes]] shows a list of all available window classes, however the most commonly used window class is just ''​windowClass'',​ which provides you with an all-purpose window with basic capabilities. +
- +
-The **name** of a window must be //unique// throughout the entire GUI -- no other window must have the same name. This is important because both scripts and engine code may refer to windows by name, and things tend to become very confusing if two or more windows have a name in common. +
  
 === How cgui files are loaded === === How cgui files are loaded ===
  
-When a new Lua program for a GUI is created, it is initially empty. During initialization,​ the GuiSys then adds several Lua tables to the empty program in order to provide the subsequent script code something to work with. Note that in  Lua, tables are very general and very powerful, and they are used to express several independent concepts. For example, the functions of a library are all kept in a common table, or object-oriented programming behaviour is simulated by considering a table as an object, where the table entries correspond to member variables and member functions (methods). Several examples for these cases are included below, however you should also study the relevant concepts in the Lua documentation,​ e.g. online at [[http://​www.lua.org/​pil/​11.html]]. +The initialization consists of the following steps:
- +
-Only after the empty Lua program for a GUI has been initialized with several tables is the code from all the ''​script''​ blocks concatenated to the program and the initialization complete. +
-More precisely, the initialization consists of the following steps:+
  
   - Most of the Lua Standard Libraries are loaded, namely the ''​basic'',​ ''​package'',​ ''​table'',​ ''​io'',​ ''​os'',​ ''​string''​ and ''​math''​ libraries. Please refer to the Lua documentation for details, online resources are at http://​www.lua.org/​pil/​18.html and [[http://​www.lua.org/​manual/​5.1/​manual.html#​5]]. With these libraries, you can for example use expressions like <​code=lua>​   - Most of the Lua Standard Libraries are loaded, namely the ''​basic'',​ ''​package'',​ ''​table'',​ ''​io'',​ ''​os'',​ ''​string''​ and ''​math''​ libraries. Please refer to the Lua documentation for details, online resources are at http://​www.lua.org/​pil/​18.html and [[http://​www.lua.org/​manual/​5.1/​manual.html#​5]]. With these libraries, you can for example use expressions like <​code=lua>​
guisys/guifiles.txt · Last modified: 2017-02-21 11:42 by Carsten