Custom restore gui

Started by piraatlife4me, Fri 06/02/2004 22:23:09

Previous topic - Next topic

piraatlife4me

Hey Agsers I am in need of your wisdom.
Does anyone know if there is a thread posted regarding custom save and load guis? If so where is it? I am looking around and I am seeing a lot of stuff about custom inventory but not much about custom save/restore guis.
Thanks
Daniel
Winebarger

Proskrito


Ytterbium

Quote from: Proskrito on Fri 06/02/2004 22:53:07
There is a tutorial about save and load guis in the GAC page:
http://atticwindow.adventuredevelopers.com/tutorials.php?id=1

Wow...isn't that highly coherent and understandable.


</sarcasm>

Currently in production: Septigon

piraatlife4me

Yeah thanks for the tip! This is kind of a weird save and restore gui. It is missing buttons such as load game and save game? Do you happen to know of know of any others?

Proskrito

#4
QuoteWow...isn't that highly coherent and understandable.
mmhh??
QuoteYeah thanks for the tip! This is kind of a weird save and restore gui. It is missing buttons such as load game and save game? Do you happen to know of know of any others?
Well, its using the listboxes themsesves as load and save buttons. (the 'enter' key works as a click also), so it loads the savegame when you click on its name in the listbox, and saves the game when you press enter after typing the name. (i think)
To make it save and load games by pressing a button:
make 2 more buttons:
- a 'save' one in the save gui  -> object 4
- a 'load' one in the load gui -> object 2

the code would only change the following: (look the arrows)
Code: ags
function interface_click(int interface, int button) { if (interface==0) {
// if Restore interface
if (button==1) {            
// if cancel is pressed
InterfaceOff(0); }
// Close interface
if (button==2) { <---------------------------- 'load' button
//if load is pressed
index=ListBoxGetSelected(0,0);
// get the selected game
RestoreGameSlot(savegameindex[index]);}
// restore the game
}
}   if (interface==1) {
// if save interface
if (button==4) { <---------------------------- 'Save' button
// if save is pressed 
index=ListBoxGetNumItems(1,3);
// Count saved games 
if (ind...........


I think it should work if i didnt make any mistakes.

Pumaman

Quote from: Ytterbium on Sat 07/02/2004 04:05:02
Wow...isn't that highly coherent and understandable.

</sarcasm>

Rather than smugly criticising things that people have put together in their own time and out of the goodness of their hearts, perhaps you'd like to contribute something yourself.

piraatlife4me

I'm really sorry if it sounded that way. I really did'nt mean to crticize anyone I think it is all great and really interesting. I was just a little confused because mine has buttons on it. I 'm sorry about that! My poor choice of wording the question.
Daniel
Winebarger

Ytterbium

Quote from: Pumaman on Sat 07/02/2004 18:14:18
Quote from: Ytterbium on Sat 07/02/2004 04:05:02
Wow...isn't that highly coherent and understandable.

</sarcasm>

Rather than smugly criticising things that people have put together in their own time and out of the goodness of their hearts, perhaps you'd like to contribute something yourself.


Sorry, it's just that I can't really understand that tutorial at all. Usually the definition of "tutorial" is something more step-by-step oriented.

Currently in production: Septigon

piraatlife4me

Hey Proskrito! I really appreciate the help. I have everything in my gui set up the way you showed me but the problem is it won't show my restored games for some reason.  I can get the game to save because I am finding saved game files in the compilied folder for my game. For some apparent reason they are not showing up in the list box for the restore game gui.  Do you know of any thing else that I might not be doing right?

Scorpiorus

You have to call the ListBoxSaveGameList (int gui, int object) function in order to display the saves in a listbox on a gui. It's usually called just before GUIOn(LOAD_GUI).


piraatlife4me

Scorpious saves the day....again!
Thanks! I swear you're a genius, that was my problem the whole time.
Thanks buddy!
Daniel
Winebarger

meowy

Hope it's okay to add to someone's thread with more questions.  I followed the link someone posted up there:
http://atticwindow.adventuredevelopers.com/tutorials.php?id=1

That lesson sort of makes sense.  I figured out where to put everything but the first two bits.

Where does this stuff go on my Global script file?



string text;

int index;



Every where I put it, it makes various errors.  Usually something about undefined index that's mentioned further in the script.

I've tried putting it at the top of the file, inside the () on various function lines, just randomly dropping it here or there.. and so far I haven't found the right spot haha
- meowy

a-v-o

Put it before the first use of these variables OUTSIDE any function, like below:

function abc ()
{
// function body  
}

string text;
int index;

function uses_text ()
{
StrCopy (text, "Hello");
}

meowy

Thank you!  No more errors now when I try to save the editing off :)

I've got a nice blue restore and blue save window.  On the save window, clicking "cancel" actually closes it out.  On the restore one, I cannot get the cancel button to work argh.

Also it won't save games either.. and I'm not sure if the restor window works yet.. so aggravating.

All I did with that tutorial from that site was change the first number in each of the sections to match with the right GUI#.  They used 0 and 1, and I use 4 and 5 because of other GUI's already being set up.

No idea what's wrong.
- meowy

meowy

Okay I fought with it some more and I give up.. I can't see what's wrong.  Here's the list of what GUI bits are what number and the script.  It saves off now at least.

Is there another section I need to mess with?  Can anyone tell me what I messed up, please?



I downloaded the RON interface template.  I can't get it to save games off though.  Did I mess something up somewhere?  I only changed the first # in the (#,#) to match my UI numbers..  I think that's all I touched haha

Here's what I have
SAVE (Is GUI 3)

object 0 is label
object 1 is text box (for entering saved game name)
object 2 is a label too
object 3 is the list box
object 4 is cancel button
object 5 is okay button


Here's the script that was already there

if (interface == SAVE) {         // if save interface
   if (button == 3) {
     ListBoxGetItemText(SAVE, 3, ListBoxGetSelected(SAVE, 3), text);
     SetTextBoxText(SAVE, 1, text);
     index = 21;
   }
   if (button == 1 || button == 5) {
     GetTextBoxText(SAVE,1,text);       // Get the typed text
     if (StrCaseComp(text, "") != 0) {    // If text not empty
       InterfaceOff(SAVE);         // Close interface
       SetDefaultCursor();
       if (index < 20)   {         // if less than 20
         index = ListBoxGetNumItems(SAVE,3);
         SaveGameSlot(index+1,text);       // Save game (text as description)
       }
       else {               // if saved games are 20
         index = ListBoxGetSelected(SAVE,3);   // Get the selected save game
         SaveGameSlot(savegameindex[index],text);  // Overwrite the selected game
       }
     }
   }
   if (button == 4) {
     InterfaceOff(SAVE);         // if cancel is pressed close interface
     SetDefaultCursor();
   }
 }



Then since I cannot save a game off, I don't know if the LOAD interface works either hrm.  (It's GUI 4)

object 0 is the list box
object 1 is cancel button
object 2 is label
object 3 is the okay button


 if (interface == LOAD) {
   if (button == 1) {             // if cancel is pressed
     InterfaceOff(LOAD);              // Close interface
     SetDefaultCursor();
   }
   else if (button == 3) {
     index = ListBoxGetSelected(LOAD,0);   // else get the selected game
     RestoreGameSlot(savegameindex[index]);    // restore the game
   }
 }



Okay then in Global I have this stuff

function on_key_press(int keycode) {
 // called when a key is pressed. keycode holds the key's ASCII code
 if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
 if (keycode==17)  GUIOn(QUITGUI);   // Ctrl-Q
 if (keycode==363) GUIOn(SAVE);   // F5
 if (keycode==365) GUIOn(LOAD);  // F7
 if (keycode==367) RestartGame();  // F9
 if (keycode==434) SaveScreenShot("jammie.bmp");  // F12
 if (keycode==9)   show_inventory_window();  // Tab, show inventory

 if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
 if (keycode==22)  Debug(1,0);  // Ctrl-V, version
 if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
 if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room

if (keycode==363) {
// Press F5

SetTextBoxText(3,1,"");
// Clear Text box

ListBoxSaveGameList(3,3);
// Fill List Box with saved games

index=ListBoxGetNumItems(3,3);
// Count how many saved games there are          

if (index>19){
// If saved games 20 (maximum)

Display("You must overwrite a previous saved game");
// Display warning

}

InterfaceOn(3);
// Bring Save interface on              

}



if (keycode==365) {
// Press F7

ListBoxSaveGameList(4,0);
// Fill List box with saved games  

InterfaceOn(4);
// Bring restore Interface on


 }
}


Then below that last bit of } } is the Quit GUI I made.

- meowy

Pumaman

Looks reasonable enough. Can you see if any  agssave.*  files are created in the game folder when you press save?

Does the save window disappear when you press the save button?

meowy

Yeah.. it saves to .001, then if I try to save another game, it's still saving as .001.  Even saving from two different rooms didn't make a difference.

There's nothing on the restore window though.


If it helps, here's what's in the Compiled folder right now:

acsetup.cfg
febcat (the thing to click to start the game)
winsetup
agssave.001

and a screenshot


Ooh.. just thought of something, will it matter if I'm in debug mode or not?
- meowy

Scorpiorus

Try replacing the saving part with:

...
if (button == 1 || button == 5) {

   GetTextBoxText(SAVE,1,text);       // Get the typed text
   if (StrCaseComp(text, "") != 0) {    // If text not empty
      InterfaceOff(SAVE);         // Close interface
      SetDefaultCursor();
      if (index < 19)   {         // if less than 20

         index = ListBoxGetNumItems(SAVE,3);
         SaveGameSlot(index,text);       // Save game (text as description)
      }
      else {               // if saved games are 20
         index = ListBoxGetSelected(SAVE,3);   // Get the selected save game
         SaveGameSlot(savegameindex[index],text); // Overwrite the selected game
      }
   }
}
...

Also, to display saved games put:

...
if (keycode==365) { // F7
  ListBoxSaveGameList (LOAD, 0); // will add a list with saved games
 GUIOn(LOAD);
}
...

How does it go?

meowy

Thank you :)  Still having troubles though.



 if (interface == SAVE) {         // if save interface
   if (button == 3) {
     ListBoxGetItemText(SAVE, 3, ListBoxGetSelected(SAVE, 3), text);
     SetTextBoxText(SAVE, 1, text);
     index = 21;
   }
if (button == 1 || button == 5) {

  GetTextBoxText(SAVE,1,text); // Get the typed text
  if (StrCaseComp(text, "") != 0) { // If text not empty
     InterfaceOff(SAVE); // Close interface
     SetDefaultCursor();
     if (index < 19) { // if less than 20

        index = ListBoxGetNumItems(SAVE,3);
        SaveGameSlot(index,text); // Save game (text as description)
     }
     else { // if saved games are 20
        index = ListBoxGetSelected(SAVE,3); // Get the selected save game
        SaveGameSlot(savegameindex[index],text); // Overwrite the selected game
     }
  }
}
   if (button == 4) {
     InterfaceOff(SAVE);         // if cancel is pressed close interface
     SetDefaultCursor();
   }
 }

 if (interface == LOAD) {
   if (button == 1) {             // if cancel is pressed
     InterfaceOff(LOAD);              // Close interface
     SetDefaultCursor();
   }
   else if (button == 3) {
     index = ListBoxGetSelected(LOAD,0);   // else get the selected game
     RestoreGameSlot(savegameindex[index]);    // restore the game
   }
 }


That is what I have now.

Now the load screen just resets the game it seems.  Still no saved games listed there though, but if I hit 'okay' Cat just pops back to the starting spot in the door and the music starts over.  Even though there's one sitting in the compiled folder.   I even checked to be sure that my font colors were actually readable.. I have them at black/white so it's readable.

The saved game screen.. is there supposed to be a list of all my saved games there?  There isn't any if there should be.  I have that text contrasted white on black too, but it's just a black box.  

Yeah, it's definetly reseting the game.  I changed Cat to start in room 3 this time, then did the Load ui, and it just popped the room back to starting point.  I'm saving each time with a different name.  random letters usually, but there is only one saved game file in the compiled folder.

Seems like I'm forgetting to mention something but I can't remember what *laughs*   Thanks for the help so far :):)  By the time we get this working, I'll be a pro at making save/load ui's I think hahaha


When I save the script off there are no errors when I save the whole deal off to test it, if that helps any? haha
- meowy

Scorpiorus

#19
QuoteThe saved game screen.. is there supposed to be a list of all my saved games there? There isn't any if there should be. I have that text contrasted white on black too, but it's just a black box.
Ah sure, that's the problem. AGS adds a new save depending on how many is already listed in the listbox. If there are saved games displayed it creates a new save with a number SAVES_LISTED + 1. But since there is no save games the SAVES_LISTED is actually 0. So it save to the slot number 1. :)

Adjust your on_mouse_click function:

function on_key_press(int keycode) {
Ã, Ã, Ã, // called when a key is pressed. keycode holds the key's ASCII code
Ã, Ã, Ã, if (IsGamePaused() == 1) keycode=0; // game paused, so don't react to keypresses
Ã, Ã, Ã, if (keycode==17) GUIOn(QUITGUI); // Ctrl-Q
//Ã, Ã, Ã, if (keycode==363) GUIOn(SAVE); // F5
//Ã, Ã, Ã, if (keycode==365) GUIOn(LOAD); // F7
Ã, Ã, Ã, if (keycode==367) RestartGame(); // F9
Ã, Ã, Ã, if (keycode==434) SaveScreenShot("jammie.bmp"); // F12
Ã, Ã, Ã, if (keycode==9) show_inventory_window(); // Tab, show inventory

Ã, Ã, Ã, if (keycode==19) Debug(0,0); // Ctrl-S, give all inventory
Ã, Ã, Ã, if (keycode==22) Debug(1,0); // Ctrl-V, version
Ã, Ã, Ã, if (keycode==1) Debug(2,0); // Ctrl-A, show walkable areas
Ã, Ã, Ã, if (keycode==24) Debug(3,0); // Ctrl-X, teleport to room

Ã, Ã, Ã, if (keycode==363) {Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Press F5

Ã, Ã, Ã, Ã, Ã, Ã, SetTextBoxText(SAVE,1,"");Ã, Ã, Ã, Ã, Ã, Ã, // Clear Text box
Ã, Ã, Ã, Ã, Ã, Ã, ListBoxSaveGameList(SAVE,3);Ã, Ã, Ã, // Fill List Box with saved games
Ã, Ã, Ã, Ã, Ã, Ã, index=ListBoxGetNumItems(SAVE,3);Ã, Ã, Ã, // Count how many saved games there are
Ã, Ã, Ã, Ã, Ã, Ã, if (index>19) {Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // If saved games 20 (maximum)

Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Display("You must overwrite a previous saved game"); // Display warning
Ã, Ã, Ã, Ã, Ã, Ã, }

Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOn(SAVE);Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Bring Save interface on

Ã, Ã, Ã, }



Ã, Ã, Ã, if (keycode==365) {Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Press F7
Ã, Ã, Ã, Ã, Ã, Ã, ListBoxSaveGameList(LOAD,0);Ã, Ã, Ã, // Fill List box with saved games
Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOn(LOAD);Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, // Bring restore Interface on

Ã, Ã, Ã, }

}

So pressing F5 shows the SAVE GUI whereas F7 displays the LOAD one.

In any case already saved games need to be listed on the save GUI, otherwise the save code wouldn't work properly.

EDIT: btw, the code assumes you use F5/F7 to bring up the save/load guis. If you also display them on pressing some GUI button you can't just put GUIOn(SAVE)/GUIOn(LOAD) there as these commands don't list the saved games. You need the same script as the one from on_mouse_click() function, i.e.:

to display the SAVE GUI

SetTextBoxText(SAVE,1,"");      // Clear Text box
     ListBoxSaveGameList(SAVE,3);   // Fill List Box with saved games
     index=ListBoxGetNumItems(SAVE,3);   // Count how many saved games there are
     if (index>19) {         // If saved games 20 (maximum)
        Display("You must overwrite a previous saved game"); // Display warning
     }
     GUIOn(SAVE);         // Bring Save interface on


to display the LOAD GUI:

     ListBoxSaveGameList(LOAD,0);   // Fill List box with saved games
     GUIOn(LOAD);         // Bring restore Interface on

SMF spam blocked by CleanTalk