I include a year ago a function(like in the manual) with load the screenshot from a save game and bring it on a button on my save/load gui. I didn`t change the code but now I see that it didn`t work anymore. I can change the button.normalimage only whis a sprite from the manager and not whis the dynamic sprite from the savegame. if i try it, the button vanished. but the sprite from the game is loaded, because i can bring it on the screen whis RawDrawImage(0,0,Sprite.Graphic)
what is the problem ????
please help me, here is my function:
function update_Slot () {
DynamicSprite *Sprite = DynamicSprite.CreateFromSaveGame(lstSave.SelectedIndex, 80, 60);
if (Sprite != null)
{
btnScrnshot.ClipImage = true;
btnScrnshot.Clickable = false;
btnScrnshot.NormalGraphic = Sprite.Graphic;
Display("%d: %d*%d", lstSave.SelectedIndex, Sprite.Width, Sprite.Height);
RawDrawImage(0,0,Sprite.Graphic);
}
else
btnScrnshot.NormalGraphic = 189;
txtSavegameSlot.Text = lstSave.Items[lstSave.SelectedIndex].Copy();
SetGlobalInt(7, lstSave.SelectedIndex);
}
Sounds like the same trouble as here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=29943.0).
Declare the DynamicSprite outside the function. Otherwise, the spritre is deleted when the function ends, and the button "vanishes" (or is set to not having a graphic, at least). Once it's been RawDraw-n, it's part of the background so the sprite itself is no longer needed - as I understand it - which is why RawDrawImage works but the Button doesn't.
Basically:
DynamicSprite *Sprite;
function update_Slot () {
Sprite = DynamicSprite.CreateFromSaveGame(lstSave.SelectedIndex, 80, 60);
// Etc.
// Everything else as it is.
}
Should work.
Hang on, what's the .Copy() doing on this line:
txtSavegameSlot.Text = lstSave.Items[lstSave.SelectedIndex].Copy();
It won't cause any problems, but like the manual says it's kind of redundant. Just this should do the same thing:
txtSavegameSlot.Text = lstSave.Items[lstSave.SelectedIndex];
Oh, one other thing - you might want to use lstSave.SaveGameSlots[lstSave.SelectedIndex] instead of lstSave.SelectedIndex. Unless you're using a completely custom system, the order of the games in the ListBox isn't necessarily the same as their slot number. (They're sorted in terms of last saved, if you used ListBox.FillSaveGameList.)
thanks if I use
DynamicSprite *Sprite;
function .....
it works.
I yused the system that the game is saved with the same slot as in the listbox and order the listbox on startup, so it is not a bug. and the RawDrawImage(0,0,Sprite.Graphic) was to debug
But i wonder about the bug, because the saveloadgui works a long time and i didn't modify anything I coud remember