Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: trevbot on Thu 17/04/2025 07:46:41

Title: "show_restore_game_dialog()" (and presumably save as well) not being called?
Post by: trevbot on Thu 17/04/2025 07:46:41
Hi! I'm having a little trouble with the following function - it doesn't appear to be called anywhere?

function show_restore_game_dialog()
{
  System.Log(eLogInfo,  "Showing restore dialog.");
  lstRestoreGamesList.FillSaveGameList();
  open_gui(gRestoreGame);
}

I'm using the default Save/Restore GUIs, and I noticed that when I save everything appears to work as expected, but when I open the restore GUI, no save file is listed. My understanding was that the above function is what populates the list in the restore GUI, so I put the LogInfo line in there to see when the function was called. It appears it never is.

I started this project years ago and am just coming back to it recently, so I'm not 100% sure what I did when I set it up, but I'm quite sure I didn't do anything specifically with the save/restore functionality. I'm using the default gSaveGame and gRestoreGame GUIs, so I figured "show_restore_game_dialog()" would be called when they open? I thought maybe there was an event for "on open" or something, but can't find such a thing.

Would love a nudge in the right direction.  :smiley:
Title: Re: "show_restore_game_dialog()" (and presumably save as well) not being called?
Post by: Khris on Thu 17/04/2025 07:56:03
This function is a custom one, not one of the engine ones like repeatedly_execute(). It is thus never called by the engine.
In the Sierra template it is called when you click the restore game button, and in on_key_press when a F7 keypress is handled:

function btnIconLoad_Click(GUIControl *control, MouseButton button)
{
  show_restore_game_dialog();
}

You can find these spots by right clicking the declaration and selecting "Find all usages".
Title: Re: "show_restore_game_dialog()" (and presumably save as well) not being called?
Post by: trevbot on Thu 17/04/2025 08:45:58
Thanks!

So, I'm using the BASS template I believe (left click interact, right click look). Any idea where would be an appropriate place to make the call?

(I'm assuming there isn't a way to set up an event like I would for a button click. Would I want to call this from the click event that opens the restore GUI?)
Title: Re: "show_restore_game_dialog()" (and presumably save as well) not being called?
Post by: Khris on Thu 17/04/2025 11:02:14
Quote from: trevbot on Thu 17/04/2025 08:45:58Would I want to call this from the click event that opens the restore GUI?

...yes, but that is kind of the wrong question. The correct way to use the function is to go to wherever you've put
  gRestoreGame.Visible = true;and instead call
  show_restore_game_dialog();
The BASS template (and others) have a bunch of convenience functions. If you got rid of all of them, you'd end up with having to manually add
  lstRestoreGamesList.FillSaveGameList();
  TwoClickHandler.Close();
  mouse.UseModeGraphic(eModeWalkto);
  gRestoreGame.Visible = true;
each time you want to let the user load a game.

The custom function show_restore_game_dialog (and also open_gui) was added by the creator(s) of the template so you don't have to deal with all that. You just add your button or your keyboard shortcut, call show_restore_game_dialog() in the handler code and that's it.
Title: Re: "show_restore_game_dialog()" (and presumably save as well) not being called?
Post by: trevbot on Thu 17/04/2025 18:42:56
Thanks! You just opened up a lot here for me.

I'll definitely look into the functions available in the BASS template. Sounds like it will make my life a lot easier on future projects.

I've learned a lot about programming over the years so picking up this project I abandoned years ago sometimes feels like it was handed to me by a random stranger!  :grin: