Latest version: AGS 3.5.0 - Patch 9
What's new in AGS 3.5.0 - Patch 9?
Help / FAQs
We are not responsible for the content of external links
GUI Scripting Part 2
Please make sure you've read the Introduction to Scripting tutorial, and played about with it enough to be comfortable writing basic scripts. Also, make sure you've attempted making a simple Quit GUI, so that you understand the basics of GUI construction.
Making a Save/Load GUI
I'm sure you've noticed by now that the default save and restore GUIs are rather ugly. Plain, grey and boring -- but at least they get the job done.
The default Save GUI ... how dull
For the purposes of this tutorial, I'm going to continue using the "Roger's Adventure" game that we created during the other tutorials. It doesn't really matter what game you use though, the process is the same.
1. Create the GUIs
In the GUI tab in the editor, create two new GUI's. Name one of them SAVEGAME and the other RESTOREGAME. I'll use a size of about 250x150, but feel free to make your GUIs any size you feel appropriate.
|For more detail on how to create GUIs and size them, please refer back to the Making a Quit GUI tutorial.|
As with the Quit GUI, I'm going to change the colour of my save/load GUIs to make them a bit more pleasing on the eye, by setting the GUI background colour to 65232.
2. Add controls to the GUI
The basic controls we need are a list box, to display the list of saved games; an OK button, to allow the player to activate the dialog; and a Cancel button, to allow the player to abort the operation. We'll also add a Label to provide some title text for the GUI.
On the Save GUI, we also need a text box, to allow the player to type in the name of the save game slot.
So, create these controls on your GUI, ending up with something like this for the Save GUI:
Our nice and spangly Save GUI
And something like this for the Restore GUI:
Our nice and spangly Restore GUI
Now, we need to assign a script name to the controls that we'll be using. Because the GUI controls are globally accessible in the script, you cannot have the same control name on two different GUIs. Therefore, I'm going to name the controls as follows:
- lstSaveGameList -- the list box on the Save GUI
- btnSaveSave -- the Save button on the Save GUI
- btnSaveCancel -- the Cancel button on the Save GUI
- txtSaveGameName -- the text box on the Save GUI
- lstRestoreGameList -- the list box on the Restore GUI
- btnRestoreRestore -- the Restore button on the Restore GUI
- btnRestoreCancel -- the Cancel button on the Restore GUI
It's best if you name your controls accordingly, so that you can easily follow the rest of the tutorial.
3. Set up GUI for scripting
Select the Save GUI, and change its Visible property from Normal to "Popup Modal". As with the Quit GUI, this ensures that the GUI is initially off when you start the game. Do the same for the Restore GUI.
TO BE FINISHED