Arrows on Save/Restore Gui and Deleting Funny Business [Solved]

Started by Elessar, Thu 21/06/2007 04:38:22

Previous topic - Next topic

Elessar

I've looked for a topic that covers this but couldn't find one. I've got custom save and restore dialogs working, but I don't know how to implement the up/down arrows for scrolling through the list. It seems like it should be obvious, but I can't figure it out.




And one thing that was puzzling me:
When deleting items from the dialog, I had the code:
Code: ags
DeleteSaveSlot(SavedGames.SaveGameSlots[SavedGames.SelectedIndex]);
SavedGames.RemoveItem(SavedGames.SelectedIndex);


But when I tested it by saving games with the names 1, 2, 3, 2 (again), 4 and then deleteing them all, 3 appeared when I opened up the dialog again. Any idea why? I've replaced it with the following code, and it now works, it's just not as elegant.
Code: ags
DeleteSaveSlot(SavedGames.SaveGameSlots[SavedGames.SelectedIndex]);
GUIOff(8);
SavedGames.FillSaveGameList();
GUIOn(8);

GarageGothic

#1
Just use the buttons to change the SelectedIndex:

For the up arrow:
Code: ags
if (SavedGames.SelectedIndex > 0) SavedGames.SelectedIndex--; //make sure that we can't go higher than the newest save


For down arrow:
Code: ags
if (SavedGames.SelectedIndex < SavedGames.ItemCount - 1) SavedGames.SelectedIndex++; //make sure that we can't go beyond the last save



As for the second problem, FillSaveGameList() is always the correct way to update the list. Why do you need to turn the GUI off and on again while doing so?

Elessar

I knew there must be some easy solution! Thanks! :D

Yeah, it turns out I don't need to turn off the Gui first. The only reason I had that in there was that I found out that I had to call FillSaveGameList() before starting up the Gui, otherwise the games didn't show up. So I assumed I would have to turn the GUI off and on again before the list would refresh.

Khris

Just for reference:
GUIOff()/GUIOn() (obsolete, use gName.Visible=true/false) will only change the visibility of the GUI and don't have any effect on the contents.

SMF spam blocked by CleanTalk