save/load GUI [SOLVED]

Started by Gijs, Tue 28/12/2004 21:39:12

Previous topic - Next topic

Gijs

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

Gijs

It has been more than a day ago when I asked this. :'(
help me out here.

Venus

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

Gijs

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.

Gilbert

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);

Gijs

#5
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?

Gilbert

You mean where a GUI was launched? I don't think so, but if you find any related problem, do tell.

Gijs


SMF spam blocked by CleanTalk