Save and Restore GUI

Started by Reven, Sun 12/03/2006 14:46:51

Previous topic - Next topic

Peder 🚀

Ok, so, I checked the help file but couldent find anything about it, tried to search the forums to but couldent find anything (might be just me being crap at searching...)

well anyway, my question goes as this:

on my save and restore GUIs I got 4 "slots" (4 buttons with the numbers, 1, 2, 3 and 4 on) these are buttons, and what I wants is if there is a saved game on slot 1, I wants the button in the save gui to change image so it has a red number. (green when its no saving on the slot)
and in the load gui I wants it to change the picture to one with a green number if it is a saved game on that slot.
There I also want to disable the buttons with the slot numbers that there is no saving on.

I hope all this makes sence....

Ashen

#1
You can use GetSaveSlotDescription(slot,string) (or Game.GetSaveSlotDescription(slot) in 2.71+) to check if the slot exists - returns 0 (2.7 and earlier) or null (2.71+) if no slot.

So, you could use that when you turn the Save/Load GUI on to set the button image, e.g.(2.7 code):
Code: ags

string temp;
if (GetSaveSlotDescription(1,temp == 0) {// No savegame, so green number
  btnSave1.NormalGraphic = GreenNum1; 
  btnSave1.Enabled = false;
}
else {// Savegame, so red number
  btnSave1.NormalGraphic = RedNum1; 
  btnSave1.Enabled = true;
}
if (GetSaveSlotDescription(2,temp == 0) {
  btnSave2.NormalGraphic = GreenNum2; 
  btnSave2.Enabled = false;
}
else {
  btnSave2.NormalGraphic = RedNum2; 
  btnSave2.Enabled = true;
}
// Etc..

(Might've got colours & enabled/disabled the wrong way 'round, but you get the idea.)

EDIT: corrected Graphic to NormalGraphic.
I know what you're thinking ... Don't think that.

Peder 🚀

Quote from: Ashen on Sun 12/03/2006 15:06:39
You can use GetSaveSlotDescription(slot,string) (or Game.GetSaveSlotDescription(slot) in 2.71+) to check if the slot exists - returns 0 (2.7 and earlier) or null (2.71+) if no slot.

So, you could use that when you turn the Save/Load GUI on to set the button image, e.g.(2.7 code):
Code: ags

string temp;
if (GetSaveSlotDescription(1,temp == 0) {// No savegame, so green number
Ã,  btnSave1.Graphic = GreenNum1; 
Ã,  btnSave1.Enabled = false;
}
else {// Savegame, so red number
Ã,  btnSave1.Graphic = RedNum1; 
Ã,  btnSave1.Enabled = true;
}
if (GetSaveSlotDescription(2,temp == 0) {
Ã,  btnSave2.Graphic = GreenNum2; 
Ã,  btnSave2.Enabled = false;
}
else {
Ã,  btnSave2.Graphic = RedNum2; 
Ã,  btnSave2.Enabled = true;
}
// Etc..

(Might've got colours & enabled/disabled the wrong way 'round, but you get the idea.)

Thanks, Ill try it out right away! :)

Peder 🚀

umm.  :-[

so , Ive edited the code to so with right values etc..

now, where do I put it? :-[

Ashen

Quote from: Mewhen you turn the Save/Load GUI on

So, it depends. As standard, there's the buttons on the ICONBAR GUI, and F5/F7 (set in on_key_press). Since you're making your own GUIs, though, you might have other ways set.

If you've more than one way, the easiest thing would be to put it all in a function, and call that when you want to turn the GUI on (as is done by default, with   show_inventory_window()).
I know what you're thinking ... Don't think that.

Peder 🚀

#5
Quote from: Ashen on Sun 12/03/2006 16:02:43
Quote from: Mewhen you turn the Save/Load GUI on

So, it depends. As standard, there's the buttons on the ICONBAR GUI, and F5/F7 (set in on_key_press). Since you're making your own GUIs, though, you might have other ways set.

If you've more than one way, the easiest thing would be to put it all in a function, and call that when you want to turn the GUI on (as is done by default, withÃ,  Ã, show_inventory_window()).

Iam all lost now.. I been trying putting it in my function "show_save_window" but when I just add what you wrote (to try) it says "type 'string' is no longer supported; use String instead.

I havent done much scripting like this before so I dont really get why you put in "string" and "temp" ??

Here is my code for the save GUI:
Code: ags
string temp;
//Slot 1Ã,  
if (GetSaveSlotDescription(1, temp == 0)
{// Empty slot
saveslot1.Graphic = 86; }

else {// Used slot
saveslot1.Graphic = 72; }

//Slot 2
if (GetSaveSlotDescription(2, temp == 0)
{// Empty slot
saveslot2.Graphic = 87;Ã,  }

else {// Used slot
saveslot3.Graphic = 74;Ã,  }

//Slot 3
if (GetSaveSlotDescription(3, temp == 0)
{// Empty slot
saveslot3.Graphic = 88;Ã,  }

else {// Used slot
saveslot3.Graphic = 76;Ã,  }

//Slot 4
if (GetSaveSlotDescription(4, temp == 0)
{// Empty slot
saveslot4.Graphic = 89;Ã,  }

else {// Used slot
saveslot4.Graphic = 78;Ã,  }

and, does it work to just put the numbers of the images I wants to be used or?

Ashen

#6
Because I'm still using V2.7 so that's what that code's in, but it sound like you're using 2.71 (or even a 2.72 beta?). You'll need to change it to using String instead of string (note the capitalisation), and change the GetSaveSlotDescription(..) commands as well.

Look up the Upgrading to 2.71 and GetSaveSlotDescription(..) manual entries for more details.
I know what you're thinking ... Don't think that.

Peder 🚀

Quote from: Ashen on Sun 12/03/2006 16:45:23
Because I'm still using V2.7 so that's what that code's in, but it sound like you're using 2.71 (or even a 2.71 beta?). You'll need to change it to using String instead of string (note the capitalisation), and change the GetSaveSlotDescription(..) commands as well.

Look up the Upgrading to 2.71 and GetSaveSlotDescription(..) manual entries for more details.

ok, thanks, Ill have a look!

Peder 🚀

Ok, it worked with this:
Code: ags
//Slot 1 
if (Game.GetSaveSlotDescription(1) == null )
{// Empty slot
saveslot1.NormalGraphic = 86; }

else {// Used slot
saveslot1.NormalGraphic = 72; }

//Slot 2 
if (Game.GetSaveSlotDescription(2) == null )
{// Empty slot
saveslot2.NormalGraphic = 87;  }

else {// Used slot
saveslot2.NormalGraphic = 74;  }

//Slot 3
if (Game.GetSaveSlotDescription(3) == null )
{// Empty slot
saveslot3.NormalGraphic = 88;  }

else {// Used slot
saveslot3.NormalGraphic = 76;  }

//Slot 4
if (Game.GetSaveSlotDescription(4) == null )
{// Empty slot
saveslot4.NormalGraphic = 89;  }

else {// Used slot
saveslot4.NormalGraphic = 78;  }


Thanks for the help! :)

SMF spam blocked by CleanTalk