From 7fe0f626171e386fe26370760f6fad6c0793279e Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 15 May 2009 15:13:17 +0000 Subject: [PATCH] Win32 - Recent ROM menu - if a recent rom doesn't exist it will now prompt the user if he wants to remove the item. --- desmume/src/windows/main.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index f354f0b20..cf9200d05 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -718,6 +718,29 @@ void UpdateRecentRoms(char* filename) UpdateRecentRomsMenu(); } +void RemoveRecentRom(std::string filename) +{ + + vector::iterator x; + vector::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(); }