Making Custom Save Game GUI

Started by Ginny, Sat 06/12/2003 21:12:03

Previous topic - Next topic

Ginny

Here's the thing, I've been trying to make this damn Save GUI to work all day, and it keeps acting weird..

here's the script:

// main global script file

string save_text; // text in textbox
int saves; // number of saved games
int selected; // selected list box item
int new_slot = -1; // slot saved as "_new"

//interface_click

   else if (button == 6)  { // save game
     
     SetTextBoxText(6, 3, ""); // clear text box
     ListBoxSaveGameList(6, 4); // fill list box with saved games
     saves = ListBoxGetNumItems(6, 4);
   
     if (saves < 20) {
     
       SaveGameSlot(saves+1, "_new"); // save a slot as "_new"
       ListBoxSaveGameList(6, 4); // fill list box with saved games
       saves = ListBoxGetNumItems(6, 4);
       new_slot = saves; // new slot is the last slot
       }
   
     ListBoxSetSelected(6, 4, saves); // select the last slot
     
     GUIOn(6); // turn on save GUI
   
     }
   
   else if (button == 7) {  // load game

   ListBoxSaveGameList(7, 3); // fill list box with saved games
   saves = ListBoxGetNumItems(7, 3); // number of saves
   ListBoxSetSelected(7, 3, saves); // select last one
   GUIOn(7); // turn on Load GUI
   
     }


//interface_click for Save and Load GUIs (6 and 7)

 if (interface == 6) { // load GUI
   
   if (button == 1) { // Cancel button
     GUIOff(6);
     DeleteSaveSlot(savegameindex[new_slot]); // delete the new slot
     }
   else if ((button == 0) || (button == 3)) { //pressed enter/save button
     if (saves >= 20) { // reached max
       Display("The PlanetX comitee of badgers has forbbiden tourists to save more than 20 times, so you must give up an existing save."); // message
       Display("Ah, rats.");
       }
     
     selected = ListBoxGetSelected(6, 4);
     GetTextBoxText(6, 3, save_text); // get text
     GUIOff(6);
     SaveGameSlot(savegameindex[selected], save_text); // save game to the selected slot
     
     if (selected != new_slot) { // if the "_new" slot wasn't selected
       
       DeleteSaveSlot(savegameindex[new_slot]); // delete it
       
       }
       
    }
}

if (interface == 7) {
 
 if (button == 1) {
   GUIOff(7);
 }
 
 if (button == 0) {
   
   if (saves == 0) {
     
     Display("You have no saved game to load.");
     
     }
   else {
   selected = ListBoxGetSelected(7, 3);
   RestoreGameSlot(savegameindex[selected]); // restore selected game
   }
   }


Now, when I turn on the GUI it has nothing selected, and when I select something and save the game, after 2 saves there are multiple "_new" slots...

Anyone know what the problem is? Thanks for any help,

Ginny.
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Pumaman

#1
List box items are numbered from 0, so you want:

saves = ListBoxGetNumItems(6, 4) - 1;

in order for it to select the last item

Ginny

#2
Hmm, odd, I did try something like this which didn't work out well, and then I believe I read in the manual that both list boxes and save games start with 0. So I removed it. Anyway, trying this now, it still doesn't work properly. There are multiple _new slots which don't get deleted and the wrong slot is overwritten with the new save... I'm puzzled. I've tried changing
selected = ListBoxGetSelected(6, 4);
to
selected = ListBoxGetSelected(6, 4) - 1;
tried changing it to +1, nothing works correctly..

Thanks though, this has helped :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Ishmael

Copy the BlueGUI scripts ;D Find RickJ's sig somewhere, follow the bluesoft link and download BG source...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ginny

I do have BlueGui downloaded, and it's a great GUI, but I did want to solve this myself..However, I'll take a look at the source code and might figure out the problem. My save dialog prolems only occurred when I started messing with the idea of having an option to either save a new game or overwrite one... Hmm, I might have an idea...

Thx TK :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

hello Ginny

QuoteMy save dialog prolems only occurred when I started messing with the idea of having an option to either save a new game or overwrite one...
The next should work:



else if (button == 6) { // save game
         new_slot = -1;
         SetTextBoxText(6, 3, ""); // clear text box
         ListBoxSaveGameList(6, 4); // fill list box with saved games
         saves = ListBoxGetNumItems(6, 4);

         if (saves < 20) {
           
            SaveGameSlot(saves, "_new"); // save a slot as "_new"
            ListBoxSaveGameList(6, 4); // fill list box with saved games
            saves = ListBoxGetNumItems(6, 4);
            new_slot = saves-1; // new slot is the last slot
         }

         ListBoxSetSelected(6, 4, 0); // select the last slot
         
         GUIOn(6); // turn on save GUI

      }      

      else if (button == 7) { // load game

         ListBoxSaveGameList(7, 3); // fill list box with saved games
         ListBoxSetSelected(7, 3, 0/*saves*/); // select last one
         GUIOn(7); // turn on Load GUI

      }
 
 
   }
   
   
   
   


//interface_click for Save and Load GUIs (6 and 7)

   if (interface == 6) { // load GUI

      if (button == 1) { // Cancel button
         GUIOff(6);
         if (new_slot!=-1) DeleteSaveSlot(new_slot); // delete the new slot
      }
      else if ((button == 0) || (button == 3)) { //pressed enter/save button
         if (saves >= 20) { // reached max
            Display("The PlanetX comitee of badgers has forbbiden tourists to save more than 20 times, so you must give up an existing save."); // message
            Display("Ah, rats.");
         }

         selected = ListBoxGetSelected(6, 4);
         GetTextBoxText(6, 3, save_text); // get text
         GUIOff(6);
         SaveGameSlot(savegameindex[selected], save_text); // save game to the selected slot

         if (savegameindex[selected] != new_slot) { // if the "_new" slot wasn't selected
         
            if (new_slot!=-1) DeleteSaveSlot(new_slot); // delete it

         }

      }
   }
   
   

   if (interface == 7) {

      if (button == 1) {
         GUIOff(7);
      }

      if (button == 0) {

         if (saves == 0) {

            Display("You have no saved game to load.");

         }
         else {
            selected = ListBoxGetSelected(7, 3);
            RestoreGameSlot(savegameindex[selected]); // restore selected game
         }
      }
 
 
   }  

~Cheeers  

Ginny

Hmm well I tried it that way and afterwards with some other adjustments, but it keeps giving me trouble... I could of course forget the _new slot idea and just make sure nothing is selected when the GUI turns on, but the only problem would be that if the player accidentally selects something, he/she needs to close the GUI and reopen it to have nothing selected. I could also have a confirmation box for overwriting which would deselect what was selected if the player clicks the "No" button.

heh :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

The only problem I see is that you might have some saves left in the game\compiled folder. What if you delete them all and try the script again.

Meanwhile, I'll test that script making a simple save/load GUI and see what else can be wrong. ;)

~Cheers

Ginny

Nope, I always delete the saved games beofore testing.. Heh, I'll concentrate on the rest of the game for now (MAGS game). Thanks, I really appreciate you trying to solve this for me :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

SMF spam blocked by CleanTalk