I trying to make a save/load gui in a blank game but I can’t get the save name to appear on the list.
I tried the wiki version and I tried copy the default one but I can’t get it to work. I tried searching here but the most versions are for older versions of AGS.
My version is 3.2.1.
This is my code
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
int totalSaves = lstSaveGames.ItemCount;//number of saves on list
String saveName = txtSaveName.Text; //holds value of txtSaveName textbox
//Check for a save name.If none tell them to enter one, else go on
if(saveName=="")
{
Display("Please enter a name for your save.");
return;
}
//if there is no saved games yet, just save it
if(lstSaveGames.SelectedIndex ==-1)
{
gSaveGame.Visible=false;
SaveGameSlot(totalSaves+1, saveName);
}
else
{
int checkSave=0; //runs through the list and checks for double entries
while (checkSave!=totalSaves)
{
if(saveName == lstSaveGames.Items[checkSave]) //one matches, so overwrite it.
{
//if so overwite the selscted game
gSaveGame.Visible=false;
SaveGameSlot(savegameindex[checkSave],saveName);
return;
}
checkSave++;
}
//if we've made it here, there is no match so just save it to a new slot.
if(totalSaves <20)
{
gSaveGame.Visible=false;
SaveGameSlot(totalSaves+1,saveName);
}
else
{
Display("The maximum number of saved games has been reached; overwrite or delete some old ones.");
}
}
}
Hope someone can help or I guess I have to start over i a default game. :-[
Hi
After making your gui and putting in buttons for save and load:
Maybe you are looking to put in more than is generally required and I may be off course here but i use this with a new GUI with buttons coded:
show_save_game_dialog();
This brings up the Save box..
Its the same for the Load box:
show_restore_game_dialog();
As I said, maybe I'm off course in what you actually want to achieve. Possibly the bit about double entrys? Apart from that do you really need to override AGS Load / Save scripts?
barefoot
I have a save button on my main gui that brings up the save gui.
That is working, however it is coded:
function btn_save_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible=true;
mouse.UseModeGraphic(eModeWait);
}
Do you think change it to "show dialog" would help with the text box?
It depends if your new GUI is visible all the time or if you make it visible at certain times..
Why would it have eModeWait? (baffling)
My code for this is:
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
int i = 0;
while (i < lstSaveGamesList.ItemCount)
{
if (lstSaveGamesList.Items[i] == txtNewSaveName.Text)
{
gameSlotToSaveInto = lstSaveGamesList.SaveGameSlots[i];
}
i++;
}
SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
close_save_game_dialog();
}
Mmm.. perhaps elaborate a bit more..
I started with the same as you but that didnt work for me. Hmm maybe I have to start over.
Just create a new GUI with Buttons for save and Load (customise at will or just customise original )..
and script to new GUI buttons
show_save_game_dialog();
show_restore_game_dialog();
QuitGame(1); // 0 or 1
Apart from that... it works for me...
Thanks for trying to help me. Its not really what I have problem with but I going to start again and try to find where I went wrong.
My problem is that the saves dont show in the text box.
Check that text colour is NOT the same as the GUI colour.
Perhaps make sure its text label has"Bring to front" so its above Gui
barefoot
You need this to put the savegames into the listbox:
http://www.adventuregamestudio.co.uk/manual/ListBox.FillSaveGameList.htm
Thanks barefoot, not a bad idea but not this time :)
Thanks Khris, its working now.
Glad you got there in the end.. and thanks Khris :=
I just want to point out that what you said about using "Bring to front" to make sure the label is above the GUI doesn't make any sense at all seeing as controls are always drawn on top of their owning GUI. The "Bring to front"/"send to back" options/functions apply to the ordering of the controls themselves.