Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gijs on Tue 28/12/2004 21:39:12

Title: save/load GUI [SOLVED]
Post by: Gijs on Tue 28/12/2004 21:39:12
hello

I started yesterday making a save and load GUI and really don't know how to do it.
I surched the manual but couldn't find anything.
I've also checked th forums and found lots of things about peaple with the same question but none of the answers they got helped for me.
I also saw this greek ags community but that didn't work too.

Well this is what I got:

I starded a new GUI (number 14) and called it SAVE.
object 0 = okay button
object 1 = cancel button
object 2 = list box
object 3 = text box

Then again I started a new GUI (number 15) and called that one LOAD.
object 0 = okay button
object 1 = cancel button
object 2 = list box

Now I've had used over ten kinds of scripts for it nothing worked of it and there isn't much left of it.

Please help

Thanks
Title: Re: save/load GUI
Post by: Gijs on Thu 30/12/2004 13:25:02
It has been more than a day ago when I asked this. :'(
help me out here.
Title: Re: save/load GUI
Post by: Venus on Thu 30/12/2004 14:59:28
I am no surely no scripting expert, but if the all the tutorials and help files didn't help you why don't you take a look at a game where it actually works and check out how it is done there. I just searched for about five minutes to find a template for a DOTT style game with working custom save/load GUIs in it. Maybe you should take a look at those. You can find it and a lot of other templates on Puss' site http://www.freewebs.com/skimbleshanks/templates.htm.

Hope that helps
Title: Re: save/load GUI
Post by: Gijs on Thu 30/12/2004 16:10:21
ok I got something working now :D

if (interface==14) {
   
SetMouseCursor(0);
   if (button==0) {
      // if save is pressed
      // Count saved games
      index=ListBoxGetNumItems(14,2); // Count saved games
      if (index<20) {
         GetTextBoxText(14,3,text); // Get the typed text
         GUIOff (6);
         SaveGameSlot(index,text); // Save game (text as description)
         
      }
      else { // if saved games are 20
         index=ListBoxGetSelected(14,2); // Get the selected save game
         GetTextBoxText(14,3,text); // Get the typed text
         
         SaveGameSlot(savegameindex[index],text); // Overwrite the selected game
      }
   }

   if (button==1) {
      GUIOff (14);
      game.text_shadow_color = 4;
   }

}
if (interface == 15) {

if (button == 0) {
index = ListBoxGetSelected(15,2);
RestoreGameSlot(savegameindex[index]);
  SetCursorMode(0);
GUIOff(15);
    game.text_shadow_color = 4;
    }
  else if (button == 1) {
     GUIOff(15);

One problem is the things I type to save as don't ad to the list box
So I can't see what I want to load.
Title: Re: save/load GUI
Post by: Gilbert on Fri 31/12/2004 01:22:02
You have to refresh the list, it won't be updated automagically, one way is to do it just after saving (the second is not needed if it's already there in the code for popping up GUI #15):

if (interface==14) {
Ã,  Ã, 
SetMouseCursor(0);
Ã,  Ã, if (button==0) {
Ã,  Ã,  Ã,  // if save is pressed
Ã,  Ã,  Ã,  // Count saved games
Ã,  Ã,  Ã,  index=ListBoxGetNumItems(14,2); // Count saved games
Ã,  Ã,  Ã,  if (index<20) {
Ã,  Ã,  Ã,  Ã,  Ã, GetTextBoxText(14,3,text); // Get the typed text
Ã,  Ã,  Ã,  Ã,  Ã, GUIOff (6);
Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(index,text); // Save game (text as description)
Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else { // if saved games are 20
Ã,  Ã,  Ã,  Ã,  Ã, index=ListBoxGetSelected(14,2); // Get the selected save game
Ã,  Ã,  Ã,  Ã,  Ã, GetTextBoxText(14,3,text); // Get the typed text
Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text); // Overwrite the selected game
Ã,  Ã,  Ã,  }
Ã,  Ã, ListBoxSaveGameList (14,2);
Ã,  Ã, ListBoxSaveGameList (15,2);

Ã,  Ã, }

Ã,  Ã, if (button==1) {
Ã,  Ã,  Ã,  GUIOff (14);
Ã,  Ã,  Ã,  game.text_shadow_color = 4;
Ã,  Ã, }

}
if (interface == 15) {

if (button == 0) {
index = ListBoxGetSelected(15,2);
RestoreGameSlot(savegameindex[index]);
Ã,  SetCursorMode(0);
GUIOff(15);
Ã,  Ã,  game.text_shadow_color = 4;
Ã,  Ã,  }
Ã,  else if (button == 1) {
Ã,  Ã,  Ã, GUIOff(15);
Title: Re: save/load GUI
Post by: Gijs on Fri 31/12/2004 11:48:28
it works perfect! :D
Thank you so much.
one thing though, do I have to put the same script on the on_key_press script?
Title: Re: save/load GUI [SOLVED]
Post by: Gilbert on Mon 03/01/2005 01:40:02
You mean where a GUI was launched? I don't think so, but if you find any related problem, do tell.
Title: Re: save/load GUI [SOLVED]
Post by: Gijs on Mon 03/01/2005 12:45:41
Never mind I solved it.