Win32 - Recent ROM menu - if a recent rom doesn't exist it will now prompt the user if he wants to remove the item.

This commit is contained in:
adelikat 2009-05-15 15:13:17 +00:00
parent 4fa564f062
commit 7fe0f62617
1 changed files with 34 additions and 0 deletions

View File

@ -718,6 +718,29 @@ void UpdateRecentRoms(char* filename)
UpdateRecentRomsMenu();
}
void RemoveRecentRom(std::string filename)
{
vector<string>::iterator x;
vector<string>::iterator theMatch;
bool match = false;
for (x = RecentRoms.begin(); x < RecentRoms.end(); ++x)
{
if (filename == *x)
{
//We have a match
match = true; //Flag that we have a match
theMatch = x; //Hold on to the iterator (Note: the loop continues, so if for some reason we had a duplicate (which wouldn't happen under normal circumstances, it would pick the last one in the list)
}
}
//----------------------------------------------------------------
//If there was a match, remove it
if (match)
RecentRoms.erase(theMatch);
UpdateRecentRomsMenu();
}
void GetRecentRoms()
{
//This function retrieves the recent ROMs stored in the .ini file
@ -2259,6 +2282,17 @@ void OpenRecentROM(int listNum)
{
romloaded = TRUE;
}
else
//Rom failed to load, ask the user how to handle it
{
string str = "Could not open ";
str.append(filename);
str.append("\n\nRemove from list?");
if (MessageBox(MainWindow->getHWnd(), str.c_str(), "File error", MB_YESNO) == IDYES)
{
RemoveRecentRom(RecentRoms[listNum]);
}
}
NDS_UnPause();
}