Custom Save/Restore GUI in AGS
Moderators: adeyke, VampD3, eriqchang, Angelus3K
Custom Save/Restore GUI in AGS
I've looked everywhere trying to understand how to make one of these. The help file is nonexistent on this part, and the AGS-heads at the forums are no help either. I've found two threads on the subject at BIGBLUECUP, but after a week of trying to decipher them and coming up empty, I'm deferring to those who've done it before.
So what the hell do I do??? I want GUIs that allow you to Save, Restore, and Delete your save games, and if possible tell you when you've reached the limit of Saves you can have. I've found the ListBox.FillSaveGameList(); command, but I don't know how or where in the code to execute it. HELP!!!
So what the hell do I do??? I want GUIs that allow you to Save, Restore, and Delete your save games, and if possible tell you when you've reached the limit of Saves you can have. I've found the ListBox.FillSaveGameList(); command, but I don't know how or where in the code to execute it. HELP!!!
-
- Defense Minister Status
- Posts: 736
- Joined: Tue Sep 17, 2002 2:54 pm
- Location: Kolding, Denmark
- Contact:
A quick search turned up this page: http://atticwindow.adventuredevelopers. ... estore.php
Not sure if it helps you further or if you've already seen it, but hopefully it can help you a bit further, even if it isn't too verbose.
Not sure if it helps you further or if you've already seen it, but hopefully it can help you a bit further, even if it isn't too verbose.
Here you go:
Add this to your global script, near the beginning.
Add this to your global script, near the beginning.
and then, add this to your interface:string text;
int index;
function Save() {
SetMouseCursor(6);
SetTextBoxText(SAVE,1,""); // Clear Text box
ListBoxSaveGameList(SAVE,3); // Fill List Box with saved games
index = ListBoxGetNumItems(SAVE,3); // Count how many saved games there are
if (index > 19) // If saved games 20 (maximum)
DisplayMessage(990); // Display warning
index = 0;
InterfaceOn(SAVE); // Bring Save interface on
}
function Load() {
SetMouseCursor(6);
ListBoxSaveGameList(LOAD,0); // Fill List box with saved games
InterfaceOn(LOAD); // Bring restore Interface on
}
You'll also need to create 2 GUIS titled "LOAD" and "SAVE", and set up a text box, a list box and some buttons. Just match all the numbers up accordingly, seeing as I merely just posted the scripts from my game.if (interface == SAVE) { // if save interface
if (button == 3) {
ListBoxGetItemText(SAVE, 3, ListBoxGetSelected(SAVE, 3), text);
SetTextBoxText(SAVE, 1, text);
index = 21;
}
if (button == 1 || button == 5) {
GetTextBoxText(SAVE,1,text); // Get the typed text
if (StrCaseComp(text, "") != 0) { // If text not empty
InterfaceOff(SAVE); // Close interface
SetDefaultCursor();
if (index < 20) { // if less than 20
index = ListBoxGetNumItems(SAVE,3);
SaveGameSlot(index+1,text); // Save game (text as description)
}
else { // if saved games are 20
index = ListBoxGetSelected(SAVE,3); // Get the selected save game
SaveGameSlot(savegameindex[index],text); // Overwrite the selected game
}
}
}
if (button == 4) {
InterfaceOff(SAVE); // if cancel is pressed close interface
InterfaceOn(ICONBAR);
SetDefaultCursor();
}
}
if (interface == LOAD) {
if (button == 1) { // if cancel is pressed
InterfaceOff(LOAD); // Close interface
SetDefaultCursor();
}
else if (button == 3) {
index = ListBoxGetSelected(LOAD,0); // else get the selected game
RestoreGameSlot(savegameindex[index]); // restore the game
}
}
Could you do me a quick favor and tell me which pieces of code are defined by me? For example, do I really type in "string text" or do I type in "string mygamesavelist" or something like that?
EDIT: Do you have an update on the code for AGS 2.71? A lot of stuff is different with it now. I'm doing my best to convert it all, but I'd like to make sure I'm doing the right thing.
EDIT: Do you have an update on the code for AGS 2.71? A lot of stuff is different with it now. I'm doing my best to convert it all, but I'd like to make sure I'm doing the right thing.
Well, my best advice is to look for the "Reality on the Norm" template on Google. If you can't find it, I'll upload it somewhere and give you the link, seeing as it has the scripts and everything you need.
EDIT: I'll retype my script for you in the meantime, but you're going to have to fill me in on your GUI names, your label and button numbers, etc.
EDIT: I'll retype my script for you in the meantime, but you're going to have to fill me in on your GUI names, your label and button numbers, etc.
ALL RIIIIGHT! After much beating my head over my keyboard, I got the Save GUI to function properly!!!!!! w00t! It currently saves a game! Of course, it's yet to be able to delete savegames and I'm not sure if the "Savegame directory is full" scenario works or not, but all in its time!
Now, I need to find out exactly how to get it to replace the save if it's the same name. I've got two saves named "crazymans" and that's hella confusing.
Here's my code, in all its AGS 2.71 glory!
Where Control is my Control Panel GUI, Savegame is my Save GUI, SaveList is my Save Game List Box, SaveText is my Save Game Text Box, and Iconbar is my Icon Bar:
Now, I need to find out exactly how to get it to replace the save if it's the same name. I've got two saves named "crazymans" and that's hella confusing.
Here's my code, in all its AGS 2.71 glory!
Where Control is my Control Panel GUI, Savegame is my Save GUI, SaveList is my Save Game List Box, SaveText is my Save Game Text Box, and Iconbar is my Icon Bar:
I kept thinking that, since it's an object-based script now, I just have to create what happens when those objects are activated, and then it became a matter of figuring out which commands suited what I wanted to happen. I've still got light years to go before I sleep, but the fact that it's functional is amazing right now.int saves;
#sectionstart SaveButton_Click//SAVE BUTTON IN THE CONTROL PANEL GUI
function SaveButton_Click(GUIControl *control, MouseButton button)
{gControl.Visible = false;
gSavegame.Centre();
gSavegame.Visible = true;
saves = (SaveList.ItemCount);
if (saves > 19) {
DisplayMessage(990);
}
}
#sectionend SaveButton_Click//SAVE BUTTON IN THE CONTROL PANEL GUI
#sectionstart CancelSaveButton_Click // DO NOT EDIT OR REMOVE THIS LINE
function CancelSaveButton_Click(GUIControl *control, MouseButton button) {
gSavegame.Visible = false;
gIconbar.Visible = true;
}
#sectionend CancelSaveButton_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart SaveList_SelectionChanged // DO NOT EDIT OR REMOVE THIS LINE
function SaveList_SelectionChanged(GUIControl *control) {
SaveList.FillSaveGameList();
}
#sectionend SaveList_SelectionChanged // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart SaveText_Activate // DO NOT EDIT OR REMOVE THIS LINE
function SaveText_Activate(GUIControl *control) {
}
#sectionend SaveText_Activate // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart SavegameButton_Click // DO NOT EDIT OR REMOVE THIS LINE
function SavegameButton_Click(GUIControl *control, MouseButton button) {
SaveGameSlot(saves, SaveText.Text);
String input = SaveText.Text;
saves = (SaveList.ItemCount);
SaveList.AddItem(input);
gSavegame.Visible = false;
gIconbar.Visible = true;
}
#sectionend SavegameButton_Click // DO NOT EDIT OR REMOVE THIS LINE
That's all I do, save and then try to load. I don't think it keeps permanent saves unless you actually compile it like you're going to release it.
But yeah, I save and then try to load and the damn screen's not there.
Right now, I'm trying to get the GUI to work where if you save a game with the same name as another savegame that it'll replace that save (in the typical Sierra fashion). This is what I've got:
But yeah, I save and then try to load and the damn screen's not there.
Right now, I'm trying to get the GUI to work where if you save a game with the same name as another savegame that it'll replace that save (in the typical Sierra fashion). This is what I've got:
Unfortunately, when I try to run that code it just tells me that ListBox.Items has an "invalid index specified." I've tried moving it around but I don't know what to do on this one.#sectionstart SavegameButton_Click // DO NOT EDIT OR REMOVE THIS LINE
function SavegameButton_Click(GUIControl *control, MouseButton button) {
saves = (SaveList.ItemCount);
String input = SaveText.Text;
String item = SaveList.Items[SaveList.SelectedIndex];
if (input.CompareTo(item) == 0) { // i.e. strings match
SaveGameSlot (SaveList.SelectedIndex, SaveText.Text);
}
else {
SaveGameSlot(saves, SaveText.Text);
SaveList.AddItem(input);
}
gSavegame.Visible = false;
gIconbar.Visible = true;
}
#sectionend SavegameButton_Click // DO NOT EDIT OR REMOVE THIS LINE