Delete/Overwrite SaveGames

Started by Cyberion, Wed 22/09/2004 15:18:14

Previous topic - Next topic

Cyberion

Can anyone help me with the script to overwrite/delete savegames.


I've created custom Save/Load GUI, but whenever i save my games it keeps saving it with the same names, i mean if i saved the game "save01", than i'm trying to save the game using the same name, it will write one more "save01" file. So i will have 2 Save01 files in my list box.

What i want is to Overwrite it. Whenever you type the same name, it will overwrite the old one.

And also i've created the delete button on my Gui in order to select teh save games and delete them.

i used

DeleteSaveSlot(savegameindex[index]);

in order to delete the selected file, but nothing seems to work. I've even tried to put "1" instead of savegameindex[index] in order to delete the first slot, but it doesn't work as well.
Do i need to write anything else into it? here is the code from the save gui without DeleteSaveSlot(savegameindex[index]);:


if (interface==5) { // if save interface
   
   if (button==3) {
   index=ListBoxGetNumItems(5,2); 
   if (index<20) {    
   GetTextBoxText(5,0,text);
   InterfaceOff(5);
   SaveGameSlot(index+1,text);
   SetDefaultCursor(); }

   else {
   index=ListBoxGetSelected(5,2);
   GetTextBoxText(5,0,text);
   InterfaceOff(5);
   SaveGameSlot(savegameindex[index],text);
   SetDefaultCursor(); }
}

if (button==1) {
InterfaceOff(5);
SetDefaultCursor();}

}



teh bottun numbe for the delete button is "4". So any help there?

Ashen

#1
About the Delete button, this should work (does for me, anyway):
Code: ags

Ã,  if (button == 4) {
Ã,  Ã,  if (ListBoxGetSelected (5,2) != -1) {// if a savegame is selected
Ã,  Ã,  Ã,  int slot = ListBoxGetSelected (5,2);
Ã,  Ã,  Ã,  DeleteSaveSlot (slot);
Ã,  Ã,  Ã,  ListBoxSaveGameList(5, 2);
Ã,  Ã,  }
Ã,  }

But, you might want to add a confirmation GUI ("Are you sure you want to delete this save game?"), to avoid annoying accidents.

I'll work on the Overwrite thing.
EDIT: corrected ListBoxGetSelected - I typed it in notepad, so I didn't have autocomplete.
Still trying to sort the overwrite thing - I kind of had it working, but it was buggy at best. There's probably a really simple way, and I'm just making things hard on myself.
I know what you're thinking ... Don't think that.

Cyberion

thx, it worked, but in the strange way.

What i mean is this:

when you have only 1 save game, it won't delete anything, and when you have several savegames and you select any of it, sometimes it deletes it, sometimes it deletes the savegame that is below.

For example:

savegames:

1
2
3
4

when i select to delete 3, it will delete it, so i have:

1
2
4

when i select 2 to delete, it deletes number 4...

any idea why?


P.S. do not forget to correct "int slot = ListBoxgetSelected (5,2);" into "int slot=ListBoxGetSelected (5,2);" ;)

Goot

I just wrote this really long post and then hit the back button on the mouse and killed it. Well, here I go again. The thing isn't working because the list item number is different from the save slot number. The list is ordered depending on when the slots were last saved into. Also, the first item on a list is 0. You need to make a function like savegameindex[] which goes from slot to item on list:

int use;
function get_index(int slot){
use=0;
while(use<20){
if(use==savegameslot[slot]){
return slot;
return;
}
use++;
}
return -1;
}

Try that. It worked for me.

Scorpiorus

Here is an example of the save/load GUI I have just made:

Save/Load dialog GUI example [ver1.0]
http://www.geocities.com/scorpiorus82/saveloadgui_v1_0.zip (copy and paste to the address bar)

It demonstrates a basic GUI with the save, load and delete buttons.

In order to add a new slot a textbox must be clicked on (i.e. have a focus).

Hope it helps :)

Cyberion

thx, i'll check it later.......

but probably i'll stick to the non-dialog version ;)

Cyberion

btw Scor are you Russian? and if so, is your native city Moscow? Because i'm Russian as well ;)

Scorpiorus

Quotethanks, i'll check it later.......
No problem, you're welcome! Let me know if it works as expected. ;)

Quote from: Cyberion on Thu 23/09/2004 19:12:20
btw Scor are you Russian? and if so, is your native city Moscow? Because i'm Russian as well ;)
Yep, I'm from Moscow. Looking at the AGS world map I'd say there aren't many Russians here so I'm glad to see you in the forums. :)

Cyberion

 good to know that one of the best plug'ins developers for AGS is russian mate ;) heheheh.

I'm living in moscow as well. Working as a marketer and studing in INYAZ. (for others Moscow State Linguistic University).

http://www.agsforums.com/yabb/index.php?topic=16840.0

any help if you would have any spare time would be greatly appretiated ;) hehe so far this is this damn delete button ;)

Cyb

SMF spam blocked by CleanTalk