Custom Save / Load GUI in AGS 3.1.2

Started by NiksterG, Sat 21/03/2009 04:50:07

Previous topic - Next topic

NiksterG

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:

Code: ags

//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);
}
Check out my games! (Not all made with AGS)

Trent R

For anyone else interested, there is a useful tutorial on the wiki 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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk