Custom SAVELOAD GUI errors and quriks

Started by ZZjZmoz, Mon 04/07/2005 18:17:09

Previous topic - Next topic

ZZjZmoz

I'm making a customized save game dialog for my new game ShipLife (Details @ www.stunninginteractive.com), which I've affectionately named SAVELOAD GUI v1.0.



Each of the buttons (except cancel) has a rollover graphic displaying what it does.

The coding for the SAVELOAD GUI is, as of now, as follows:

Code: ags

function repeatedly_execute() {
Ã,  lstSaveLoadSavelist.FillSaveGameList();
}


Code: ags

//SAVELOAD GUI (in progress)
function txtSaveLoadSaveName_Activate(){
Ã,  lstSaveLoadSavelist.SelectedIndex = -1;
}

function lstSaveLoadSavelist_SelectionChanged(){
Ã,  string text;
Ã,  lstSaveLoadSavelist.GetItemText(lstSaveLoadSavelist.SelectedIndex, text);
Ã,  txtSaveLoadSaveName.SetText(text);
}

function btnSaveLoadUp_Click(GUIControl *control, MouseButton button) {
Ã,  if (lstSaveLoadSavelist.TopItem == 0){
Ã,  Ã,  Display("No more entries.");
Ã,  }else{
Ã,  Ã,  lstSaveLoadSavelist.TopItem = lstSaveLoadSavelist.TopItem - 1;
Ã,  }
}

function btnSaveLoadDown_Click(GUIControl *control, MouseButton button) {
Ã,  
	if (lstSaveLoadSavelist.TopItem == lstSaveLoadSavelist.ItemCount) {
Ã,  Ã,  Display("No more entries.");
Ã,  }else{
		lstSaveLoadSavelist.TopItem = lstSaveLoadSavelist.TopItem + 1;
Ã,  }
}

function btnSaveLoadSave_Click(GUIControl *control, MouseButton button) {Ã,  
// save your game
Ã,  string strSaveName;
Ã,  int intIndex;
Ã,  int intEndIndex;
Ã,  
Ã,  intIndex = lstSaveLoadSavelist.SelectedIndex;
Ã,  intEndIndex = lstSaveLoadSavelist.ItemCount + 1;
Ã,  txtSaveLoadSaveName.GetText(strSaveName);
Ã,  
Ã,  if (StrComp("", strSaveName) == 0){
Ã,  Ã,  Display("ERROR: No save name input!");
Ã,  }else{
Ã,  Ã,  if (intIndex == -1){
Ã,  Ã,  Ã,  if (lstSaveLoadSavelist.ItemCount < 20){
Ã,  Ã,  Ã,  Ã,  SaveGameSlot(intEndIndex, strSaveName);
Ã,  Ã,  Ã,  }else{
Ã,  Ã,  Ã,  Ã,  Display("ERROR: No more space.");
Ã,  Ã,  Ã,  }
Ã,  Ã,  }else{
Ã,  Ã,  Ã,  SaveGameSlot(intIndex, strSaveName);
Ã,  Ã,  }
Ã,  txtSaveLoadSaveName.SetText("");
Ã,  lstSaveLoadSavelist.SelectedIndex = -1;
Ã,  }
}

function btnSaveLoadLoad_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  if (lstSaveLoadSavelist.SelectedIndex == -1){
Ã,  Ã,  Display("ERROR: Invalid slot selection.");
Ã,  }else{
Ã,  Ã,  string savename;
Ã,  Ã,  lstSaveLoadSavelist.GetItemText(lstSaveLoadSavelist.SelectedIndex, savename);
Ã,  Ã,  Display("Deleted index is %s", savename);
Ã,  }
}

function btnSaveLoadDelete_Click(GUIControl *control, MouseButton button) {

Ã,  if (lstSaveLoadSavelist.SelectedIndex == -1){
Ã,  Ã,  Display("ERROR: Cannot delete selection.");
Ã,  }else{
Ã,  Ã,  DeleteSaveSlot(lstSaveLoadSavelist.SelectedIndex);
Ã,  }
}

function btnSaveLoadClose_Click(GUIControl *control, MouseButton button) {
Ã,  gSaveload.Visible = false;
}


The load and delete buttons are still being worked on. However, when I refresh the save list with the most recent selection of save games, when I put it in repeatedly_execute, the list refreshes fine but it won't let me make any other selection besides the first one, and if I put it in the btnSaveLoadSave function, it doesn't refresh correctly. Also, new games are supposed to be added when lstSaveLoadSavelist.SelectedIndex == -1, but that seems to be malfunctioning. The up and down buttons seem to be functioning correctly, but when I try to load, it says "Deleted index is (filename)", and delete just doesn't seem to work when there is only one selected file. I'm confused beyond belief. Does anyone have a solution to all these problems (besides SaveGameDialog(), of courseÃ,  :))?

Much thanks in advance. ;D

Released Late August 2007

GarageGothic

Well, the first error is to put the FillSaveGameList command in repeatedly execute. Just run it once when the save window is opened (and if you keep it open after a save, run it again on saving).

ZZjZmoz

I've tried that. I put it in the repeatedly_execute section because it didn't seem to work when I did:

function btnSaveGameSave_Click(){
lstSaveGameSaveList.FillSaveGameList();
  //save game code
lstSaveGameSaveList.FillSaveGameList();
}

oh well, might as well try it again.

Released Late August 2007

GarageGothic

No, in the save function it should only run AFTER you've saved. I think that the problem is that filling the list messes with the current selection.
So you should only fill it 1) when opening the save gui and 2) after saving, in case the gui stays on screen.

ZZjZmoz

well, I tried it, and it still doesn't work. hmm... :-\. This is very interesting. It should refresh normally, but it seems to only refresh after I hit the button and save a new file, in which the old file appears and the new one doesn't appear until the NEXT time I save. I have no clue why this is happening...

Released Late August 2007

Pumaman

The refresh issue is because of this from the manual:

"NOTE: The game will not be saved immediately; instead, it will be saved when the script function finishes executing."

Therefore if you refresh after the SaveGameSlot call, the game won't actually have been saved yet.

You'll have to use a rather messy workaround of setting a global variable to 1 to indicate that a refresh is needed, and then doing it in repeatedly_execute if the variable is 1.

SMF spam blocked by CleanTalk