Creating Custom Save and Load Dialogs: Difference between revisions

Jump to navigation Jump to search
no edit summary
*>CMK2901
No edit summary
*>CMK2901
No edit summary
Line 4: Line 4:


Here, I will (hopefully) make custom save/load dialogs a fairly trivial matter.  This guide will step you through the creation of the save GUI...translating this to a load GUI will be discussed at the end.
Here, I will (hopefully) make custom save/load dialogs a fairly trivial matter.  This guide will step you through the creation of the save GUI...translating this to a load GUI will be discussed at the end.
It is very likely that, beyond the core coding found here, you will need to add new code specific to your game for closing other GUIs, like an option menu.




Line 13: Line 15:


In the above image, the elements used are three buttons, a text box, and a GUI list box.  The GUI list box is added using the circled button.  Resize and reposition these elements as needed.
In the above image, the elements used are three buttons, a text box, and a GUI list box.  The GUI list box is added using the circled button.  Resize and reposition these elements as needed.


== Give Elements Script Names ==
== Give Elements Script Names ==
Line 41: Line 40:


<code>
<code>
//Turn off the save dialog
  //Turn off the save dialog
   gSavegame.Visible = false;</code>
   gSavegame.Visible = false;</code>
It is probable that you will need to add more to this to unpause the game, or activate GUIs, but that is game specific.


== Script the Save Button ==
== Script the Save Button ==
Line 90: Line 87:
   }</code>
   }</code>


This code first checks that the text box is not empty.  It then checks whether the currently highlighted save game is the same as the one in the text box.  If so, it overwrites.  If not, a new save is created, if there is enough room.  AGS is currently limited to 20 save slots.
This code first checks that the text box is not empty.  It then checks whether the currently highlighted save game is the same as the one in the text box.  If so, it overwrites.  If not, a new save is created, if there is enough room.  AGS is currently limited to 20 save slots.  Immediately before saving, the "Save" GUI is closed, so the player can keep playing.
 
It is important that anything you want to do when saving is placed '''before/above''' the "SaveGameSlot()" commands.  Anything below "SaveGameSlot()" will be executed, but NOT saved into the file, because it occurs after the save command.




Line 151: Line 150:
This leaves you with a set of save/load dialogues that can be customized to your needs.
This leaves you with a set of save/load dialogues that can be customized to your needs.


== Putting Dialogs in the Game ==
To use these dialogs, simply find any instances of the following two functions:
<code>
  SaveGameDialog();
  LoadGameDialog();</code>
and replace them with the following, respectively:
<code>
  gSavegame.visible = true;
  gLoadgame.visible = true;</code>
This will cause the save/load buttons to display your custom GUIs, rather than the default ones.


== Known Bugs ==
== Known Bugs ==
Anonymous user

Navigation menu