How to customize the Default Load Save

Started by Ghostlady, Mon 22/07/2024 00:44:29

Previous topic - Next topic

Ghostlady

I checked both global scripts and do not find any verbiage using buttonsprite in either, other than what is shown above.
Can you show me how to code this check so player would not get an "array index out of bounds" exception if nothing is selected in the listbox?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Snarky

#21
Quote from: Ghostlady on Mon 12/08/2024 18:11:04I checked both global scripts and do not find any verbiage using buttonsprite in either, other than what is shown above.

I assume you mean the script and the header? Well, as said it might also be the script name of a game entity. Or a global variable. But the simplest fix is just to rename the variable.

Quote from: Ghostlady on Mon 12/08/2024 18:11:04Can you show me how to code this check so player would not get an "array index out of bounds" exception if nothing is selected in the listbox?

Well, test it without a safety check first. I'm not sure it's necessary; I don't recall if there's any way for players to make it so nothing is selected. But something like this should work:

Code: ags
  if(lstSaveGamesList.SelectedIndex >= 0)  // Savegame selected in list
  {
    txtNewSaveName.Text = lstSaveGamesList.Items[lstSaveGamesList.SelectedIndex];
    buttonSprite = DynamicSprite.CreateFromSaveGame(lstSaveGamesList.SaveGameSlots[lstSaveGamesList.SelectedIndex], 78, 78);
    if (buttonSprite != null) // If there's a screenshot saved, display it
    {
      btnScrnshot.Visible = true;
      btnScrnshot.NormalGraphic = buttonSprite.Graphic;
    }
    else
      btnScrnshot.Visible = false;
  }
  else // No savegame selected, so hide the screenshot button
  {
    txtNewSaveName.Text = "";
    btnScrnshot.Visible = false;
  }

Ghostlady

Hi, Ok, I got this working, sort of.  The screenshot that displays is the correct room but it is filling up the whole area where the buttons are.  So I can't use the Save, Delete, or Cancel buttons. 
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Khris

#23
First, pick a suitable size for the screenshot. Like an eighth of the game resolution for instance. The size doesn't matter so much as the aspect ratio, obviously. Now resize the button to that, if you haven't already.

Now replace
Code: ags
    buttonSprite = DynamicSprite.CreateFromSaveGame(lstSaveGamesList.SaveGameSlots[lstSaveGamesList.SelectedIndex], 78, 78);
with
Code: ags
    int slot = lstSaveGamesList.SaveGameSlots[lstSaveGamesList.SelectedIndex];
    buttonSprite = DynamicSprite.CreateFromSaveGame(slot, btnScrnshot.Width, btnScrnshot.Height);

(Assigning a larger sprite to a button will not clip it by default. You can turn this on in the button properties but that will simply crop the screenshot. The fix is shrinking the image.)

Ghostlady

#24
Hi, that code definitely corrected the size of the screenshot. 

I am seeing the Save Gui showing up in the screenshot. How do I eliminate that?

Also, the screenshot shows that you can save with a blank name. (Not sure if this really matters)

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Snarky

The screenshot will show the screen as it looks right when you save the game (by calling SaveGameSlot), so you have to hide the GUI (and wait for the screen to update) before you do that. In the A.S.S. module, this is done by:

Code: ags
  gSave.Visible = false;
  mouse.Mode = eModeWalkTo;
  Wait(1);
  SaveGameSlot(totalsaves+1, SL_TEXT);

Your code will likely be a bit different (different text in the SaveGameSlot, for one thing), but apart from perhaps the mouse.Mode line, it should  be essentially equivalent.

Ghostlady

That works perfect for removing the gui on the screenshot. 

I notice that if I save with a screenshot, for example, Dom at letter (see example), then I play some more and save again, Dom at front of house. When I come into Save again, the screenshot displays the last screen that was selected/highlighted on the gui as opposed to the last save.  So anytime I am in the Save function, it will always show the screenshot of the last item I highlighted in the gui. Should it be working like this?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Snarky

Quote from: Ghostlady on Wed 21/08/2024 20:46:31Should it be working like this?

 ??? It's your game. How do you want it to work?

I see two potential purposes of the little screenshot thumbnail on this GUI. One is to show a thumbnail of the slot you will overwrite if you save now. The other is to give a preview of what the thumbnail will look like if you save now.

So showing the thumbnail of the highlighted save makes sense if that's the slot your game will be saved in (and therefore overwrite). To me that would be the intuitive behavior, and is how the A.S.S. module works. But as already discussed, the find_save_slot() function doesn't do that, so showing the selected item's thumbnail arguably makes it even more misleading.

Ghostlady

Since I have separate guis for Save & Load (or restore) can I do something like this for the restore button? I think it makes more sense to see a screenshot of the save you want to restore.  This seems to be working but I had to comment out the first line because there is no txtNewRestoreName.Text like there is for the save. Is it ok to leave this out?

Code: ags
function lstRestoreGamesList_OnSelectionChanged(GUIControl *control)
{
 // txtNewRestoreName.Text = lstRestoreGamesList.Items[lstRestoreGamesList.SelectedIndex];
  int slot = lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex];
  buttonSprite = DynamicSprite.CreateFromSaveGame(slot, btnScrshotR.Width, btnScrshotR.Height); 
  if (buttonSprite != null) {
      btnScrshotR.NormalGraphic = buttonSprite.Graphic; }
}
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

SMF spam blocked by CleanTalk