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
guisys:guieditor:customscripts [2011-06-20 18:03]
carsten Deleted page, contents has been migrated to guisys:guifiles
— (current)
Line 1: Line 1:
-====== Augmenting GUI Editor scripts with custom script code ====== 
- 
-The GUI Editor allows users to define and design the contents and layout of the windows that compose a GUI. 
-However, the work in the GUI Editor is focused mainly on static aspects like window position and size, texts, colors, borders, etc. 
- 
-Everything "​dynamic"​ and all sorts of effects can, by their nature, not be added by means of the GUI Editor, but must be written as custom scripts that augment the script code generated with the GUI Editor. 
- 
-The question is how we can add hand-written code to the script generated by saving a GUI in the GUI Editor, //without// losing the custom changes when the script is modified in the GUI Editor the next time. 
- 
- 
-===== File Inclusion ===== 
- 
-The problem is easily solved by a shift in perspective and the ''​dofile()''​ script command: 
- 
-For example, assume that you're using the GUI Editor in order to create a "Call Lift" GUI. 
-Let's also assume that when done, you want to access your new GUI under the file name ''​CallLift.cgui''​. 
- 
-The trick is that when you save this GUI in the GUI Editor, you'd //not// save it under file name ''​CallLift.cgui''​. Instead, you save it under file name ''​CallLift_init.cgui''​. 
-Next, create a second file next to ''​CallLift_init.cgui''​ with the name that you actually want, ''​CallLift.cgui''​. 
- 
-The new ''​CallLift.cgui''​ file will be the file that you actually use, and it will contain all hand-written custom code. For this to work, it must include the GUI Editor created file, and therefore its content looks like this: 
- 
-<code lua> 
-dofile("​Games/​DeathMatch/​GUIs/​CallLift_init.cgui"​); ​   -- Include the GUI Editor generated file. 
- 
--- Add your hand-written custom code below this line. 
--- ... 
-</​code>​ 
- 
-In summary: 
-  * When you edit your GUI in the GUI Editor, you only load and save file ''​CallLift_init.cgui''​. 
-  * All hand-written code enters file ''​CallLift.cgui''​ instead. 
-  * The connection between the two files is made by the ''​dofile()''​ command. 
- 
-\\ 
-^ Tip by the Cafu development team: ^ 
-| The ''​Games/​DeathMatch/​GUIs/​MainMenu/​MainMenu(_init).cgui''​ files that are natively included with Cafu are prime examples of this technique. | 
- 
- 
-Future versions of the GUI Editor may even mildly enforce the two-files approach, where one file has the normal file name and its "​twin"​ gets the ''​_init''​ suffix automatically appended. This helps e.g. to prevent accidental overwrites when you happen to load ''​CallLift.cgui''​ into the GUI Editor instead of ''​CallLift_init.cgui''​. 
  
guisys/guieditor/customscripts.1308585803.txt.gz ยท Last modified: 2013-01-07 12:07 (external edit)