- changed 'load game' menu so that it preselects the last used savegame, either for loading or saving.

SVN r2867 (trunk)
This commit is contained in:
Christoph Oelckers 2010-09-29 22:24:55 +00:00
parent 5464676603
commit 024bbeb171

View file

@ -57,6 +57,7 @@ class DLoadSaveMenu : public DListMenu
protected: protected:
static TDeletingArray<FSaveGameNode*> SaveGames; static TDeletingArray<FSaveGameNode*> SaveGames;
static int LastSaved; static int LastSaved;
static int LastAccessed;
int Selected; int Selected;
int TopItem; int TopItem;
@ -115,6 +116,7 @@ IMPLEMENT_CLASS(DLoadSaveMenu)
TDeletingArray<FSaveGameNode*> DLoadSaveMenu::SaveGames; TDeletingArray<FSaveGameNode*> DLoadSaveMenu::SaveGames;
int DLoadSaveMenu::LastSaved = -1; int DLoadSaveMenu::LastSaved = -1;
int DLoadSaveMenu::LastAccessed = -1;
FSaveGameNode *quickSaveSlot; FSaveGameNode *quickSaveSlot;
@ -336,7 +338,7 @@ void DLoadSaveMenu::NotifyNewSave (const char *file, const char *title, bool okF
if (okForQuicksave) if (okForQuicksave)
{ {
if (quickSaveSlot == NULL) quickSaveSlot = node; if (quickSaveSlot == NULL) quickSaveSlot = node;
LastSaved = i; LastAccessed = LastSaved = i;
} }
return; return;
} }
@ -352,7 +354,7 @@ void DLoadSaveMenu::NotifyNewSave (const char *file, const char *title, bool okF
if (okForQuicksave) if (okForQuicksave)
{ {
if (quickSaveSlot == NULL) quickSaveSlot = node; if (quickSaveSlot == NULL) quickSaveSlot = node;
LastSaved = index; LastAccessed = LastSaved = index;
} }
} }
@ -734,10 +736,16 @@ bool DLoadSaveMenu::MenuEvent (int mkey, bool fromcontroller)
{ {
if (Selected != -1) if (Selected != -1)
{ {
int listindex = SaveGames[0]->bNoDelete? Selected-1 : Selected;
remove (SaveGames[Selected]->Filename.GetChars()); remove (SaveGames[Selected]->Filename.GetChars());
UnloadSaveData (); UnloadSaveData ();
Selected = RemoveSaveSlot (Selected); Selected = RemoveSaveSlot (Selected);
ExtractSaveData (Selected); ExtractSaveData (Selected);
if (LastSaved == listindex) LastSaved = -1;
else if (LastSaved > listindex) LastSaved--;
if (LastAccessed == listindex) LastAccessed = -1;
else if (LastAccessed > listindex) LastAccessed--;
} }
return true; return true;
} }
@ -1040,6 +1048,10 @@ DLoadMenu::DLoadMenu(DMenu *parent, FListMenuDescriptor *desc)
: DLoadSaveMenu(parent, desc) : DLoadSaveMenu(parent, desc)
{ {
TopItem = 0; TopItem = 0;
if (LastAccessed != -1)
{
Selected = LastAccessed;
}
ExtractSaveData (Selected); ExtractSaveData (Selected);
} }
@ -1074,6 +1086,7 @@ bool DLoadMenu::MenuEvent (int mkey, bool fromcontroller)
} }
M_ClearMenus(); M_ClearMenus();
BorderNeedRefresh = screen->GetPageCount (); BorderNeedRefresh = screen->GetPageCount ();
LastAccessed = Selected;
return true; return true;
} }
return false; return false;