I've tweaked my game's Save/Restore GUI code slightly to prevent the name of the previously saved/restored game from always showing up in the GUI's text box, but I think I may have broken something, since one of the testers for my game reported being unable to load a previously saved game. I haven't run into this problem myself, but I still wanted to try to fix it.
I don't know if anyone is able to help me with this since the code is pretty messy, but I figured I might as well ask if anyone notices any obvious problems. (Also: I'm using Joe Carl's GUI, which uses Spanish names for a lot of the buttons that I never bothered changing -- sorry about that.)
Overwrite button:
Code: ags
Save button:
Code: ags
Restore button:
Code: ags
Confirm delete button:
Code: ags
Thank you very much in advance!
I don't know if anyone is able to help me with this since the code is pretty messy, but I figured I might as well ask if anyone notices any obvious problems. (Also: I'm using Joe Carl's GUI, which uses Spanish names for a lot of the buttons that I never bothered changing -- sorry about that.)
Overwrite button:
#sectionstart overwriteSI_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
function overwriteSI_btn_Click(GUIControl *control, MouseButton button) {
int p = 0;
while(p<partidas.ItemCount){
if((partidas.ItemCount>p)&&(partidas.Items[p]==guardar.Text)){
gOverwrite.Visible=false;
gSaverestore.Visible=false;
SaveGameSlot(partidas.SaveGameSlots[p], guardar.Text);
partidas.FillSaveGameList();
guardar.Text="";
gIcons.Visible=true;
Display("Game saved!");
if (player.Room==39 || player.Room==40 || player.Room==41 || player.Room==112) { //no walk!
mouse.Mode=eModeLookat;
mouse.UseModeGraphic(eModeLookat);
}
if (player.Room==80 && gPuzzle1.Visible==true) {
if (mouse.Mode==eModeTouch) mouse.UseModeGraphic(eModePointer);
}
else {
mouse.Mode=eModeWalkto;
mouse.UseModeGraphic(eModeWalkto);
}
return;
}
p++;
}
}
#sectionend overwriteSI_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
Save button:
#sectionstart savegame_Click // DO NOT EDIT OR REMOVE THIS LINE
function savegame_Click(GUIControl *control, MouseButton button) {
int totalSaves = partidas.ItemCount; //number of saves on list
String saveName = guardar.Text; //holds value of txtSaveName
if (saveName==""){
Display("Please enter a name.");
return;
}
// If there is no saved games yet, just save it.
if (partidas.SelectedIndex == -1)
{
gSaverestore.Visible=false;
SaveGameSlot(temp_savegame_index, guardar.Text); ///replaced 2nd item (temp_savegame) with guardar.Text. i hope this works
//SaveGameSlot(partidas.ItemCount+1, guardar.Text);
partidas.FillSaveGameList();
guardar.Text="";
Display("Game saved.");
gIcons.Visible=true;
}
else
{
int checkSave = 0; //runs through the list and checks for double entries
while (checkSave != totalSaves)
{
if (saveName == partidas.Items[checkSave]) // one matches, so overwrite it.
{
// If so, overwrite the selected save game
temp_savegame_index = savegameindex[checkSave];
temp_savename = saveName;
gOverwrite.Visible=true;
gIcons.Visible=false;
return;
}
checkSave++;
}
// There is no match, just save to a new slot.
if (totalSaves < 49)
{
gSaverestore.Visible = false;
SaveGameSlot(totalSaves+1, saveName);
Display ("Game saved!");
gIcons.Visible=true;
guardar.Text="";
}
else
{
Display("You have reached the maximum number of saves![Either delete or overwrite an old save if you[want to create a new one.");
guardar.Text="";
return;
}
}
if (player.Room==39 || player.Room==40 || player.Room==41 || player.Room==112) { //no walk!
mouse.Mode=eModeLookat;
mouse.UseModeGraphic(eModeLookat);
}
if (player.Room==80 && gPuzzle1.Visible==true) {
if (mouse.Mode==eModeTouch) mouse.UseModeGraphic(eModePointer);
}
else {
if (cliff_hiding==false && chu_timer_on==false) {
mouse.Mode=eModeWalkto;
mouse.UseModeGraphic(eModeWalkto);
}
else { //if hiding
mouse.Mode=eModeLookat;
mouse.UseModeGraphic(eModeLookat);
}
}
return;
int p = 0;
while(p<=partidas.ItemCount){
if(guardar==partidas.Items[p]) {
//overwrite open
temp_savegame_index = savegameindex[p];
temp_savename = guardar;
gOverwrite.Visible=true;
gIcons.Visible=false;
return;
}
p++;
}
if (p>49) {
Display("You have reached the maximum number of saves![Either delete or overwrite an old save if you[want to create a new one.");
return;
}
}
#sectionend savegame_Click // DO NOT EDIT OR REMOVE THIS LINE
Restore button:
#sectionstart restoregame_Click // DO NOT EDIT OR REMOVE THIS LINE
function restoregame_Click(GUIControl *control, MouseButton button) {
if(partidas.ItemCount!=0){
int index = partidas.SelectedIndex;
RestoreGameSlot(partidas.SaveGameSlots[index]);
partidas.FillSaveGameList();
savegame.Enabled=true;
guardar.Enabled=true;
cerrar.Enabled=true;
guardar.Text="";
// SetGameOption(OPT_WHENGUIDISABLED, 2);
}
else Display("No game to load!");
}
#sectionend restoregame_Click // DO NOT EDIT OR REMOVE THIS LINE
Confirm delete button:
function del_yes_OnClick(GUIControl *control, MouseButton button)
{
//delete-yes
if(partidas.ItemCount>=1){
int index = partidas.SelectedIndex;
DeleteSaveSlot(partidas.SaveGameSlots[index]);
partidas.FillSaveGameList();
guardar.Text="";
}
gDelete.Visible=false;
}
Thank you very much in advance!