Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: NiksterG on Sat 21/03/2009 04:50:07

Title: Custom Save / Load GUI in AGS 3.1.2
Post by: NiksterG on Sat 21/03/2009 04:50:07
Hey everyone, it's been a  while since I last posted here. Doubt anyone remembers me, but that's okay.  ::)

EDIT: Never mind, I figured it out myself, after an hour of brain-frying madness. You can now ignore this post. (though it seems that's what you were doing anyway... :P)

Anyway, I am having a lot of difficulty with a custom save/load GUI. I decided, after tinkering with my old (and broken) game, I would just upgrade it to AGS 3.1. Unfortunately for me, I can't figure out a lot of the new functions.  :-\

I got the Restore Game GUI to work (at least I think so... I haven't been able to save yet) but the Save Game dialog is messing me up. Basically, what I've got is a text box, a list box, and an OK button. What supposed to happen is when the player clicks on the list box and selects an item, that text goes into the text box. If the player presses save, that slot is overridden. I think I got this part to work.

What I can't figure out is how to get it to save for the first slot, since SaveGameSlot needs an index to save to. I don't want to put it at 0, because that might override the slot at the top, but the TopItem property doesn't return -1 if there is no top item - it returns 0! So I can't put an if statement to check if TopItem is nonexistant.

I know there's a custom save/load GUI module floating around here somewhere, but I'd rather get the experience doing it myself. I already feel like I cheated a little by downloading strazer's KeyboardMovement module.  :-[

Any help, guys?
Thanks,
Niksterg

PS here's the code:


//global script file
function btnSaveGameCancel_OnClick(GUIControl *control, MouseButton button)
{
        gSaveGame.Visible = false;
}
function SaveGameList_OnSelectionChange(GUIControl *control)
{
tbSaveGameText.Text = SaveGameList.Items[SaveGameList.GetItemAtLocation(mouse.x, mouse.y)];
}

function tbSaveGameText_OnActivate(GUIControl *control)
{
int i = SaveGameList.SelectedIndex;
if (i == -1)
i = SaveGameList.TopItem + 1;
SaveGameSlot(SaveGameList.SaveGameSlots[i], tbSaveGameText.Text);
}

function btnSaveGameOk_OnClick(GUIControl *control, MouseButton button)
{
tbSaveGameText_OnActivate(control);
}
Title: Re: Custom Save / Load GUI in AGS 3.1.2
Post by: Trent R on Sun 22/03/2009 07:33:32
For anyone else interested, there is a useful tutorial on the wiki (http://www.americangirlscouts.org/agswiki/Creating_Custom_Save_and_Load_Dialogs) that should work with the 3.0 code (although I think there may be one or two changes, but they shouldn't change the functionality.


~Trent