Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ezekiel000 on Sun 26/08/2012 22:21:58

Title: Custom save/load gui still visible on load
Post by: Ezekiel000 on Sun 26/08/2012 22:21:58
I created my own custom gui for saving/loading but when I restore a saved game the save/load gui is still visible.
How can I get it to save but not hide the gui, but when I load the saved game have the gui not visible?

I'm currently saving with:
Code (AGS) Select
function SaveGame(int slot)
{
  String slot_name;
  slot_name = slot_name.Append(RoomName);
  slot_name = slot_name.Append(", ");
  slot_name = slot_name.Append(Progress);
 
  gSaveload.Visible = false;
  gLabel.Visible = false;
  mouse.Mode = old_mouse_mode;
  SaveGameSlot(slot, slot_name);
  if(slot == 1) sl_slot1_label.Text = slot_name;
  if(slot == 2) sl_slot2_label.Text = slot_name;
  if(slot == 3) sl_slot3_label.Text = slot_name;
  if(slot == 4) sl_slot4_label.Text = slot_name;
  if(slot == 5) sl_slot5_label.Text = slot_name;
  if(slot == 6) sl_slot6_label.Text = slot_name;
  gSaveload.Visible = true;
  old_mouse_mode = mouse.Mode;
  mouse.Mode = eModePointer;
}


And loading with:
Code (AGS) Select
function LoadGame(int slot)
{
  RestoreGameSlot(slot);
  gLabel.Visible = false;
  gSaveload.Visible = false;
}
Title: Re: Custom save/load gui still visible on load
Post by: Khris on Sun 26/08/2012 22:44:44
Both SaveGameSlot and RestoreGameSlot aren't executed until the current function finishes.
In other words, everything in your SaveGame function below SaveGameSlot() is actually executed before the game is saved.

Thus the saved game stores the GUI as being visible, and the LoadGame function turns the GUI invisible, then restores the savegame, thus making it visible again.

I guess you want the GUI to stay visible after the player saved their game, right?
Just use on_event / eEventRestoreGame to turn it off after loading.
(And you can remove all the gSaveload.Visible = false/true; calls from your functions.)
Title: Re: Custom save/load gui still visible on load
Post by: Ezekiel000 on Mon 27/08/2012 09:03:54
Thank you that fixed it.
Title: Re: Custom save/load gui still visible on load
Post by: Miori on Tue 28/08/2012 02:02:17
Thanks too ^_^

Even if I needed a while until I found out how this on_event stuff works XD