From 137df18a00bb419bc51d894a4d4e28ad6eaff69f Mon Sep 17 00:00:00 2001 From: kaienfr Date: Thu, 5 Sep 2013 00:04:24 +0200 Subject: [PATCH] Update recent games list & remove redundant recent games from ini file --- Core/Config.cpp | 24 ++++++++++++++++++------ UI/GameSettingsScreen.cpp | 7 +++++++ UI/GameSettingsScreen.h | 3 ++- UI/MainScreen.cpp | 3 +++ Windows/WndMainWindow.cpp | 5 +++++ Windows/WndMainWindow.h | 1 + 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index bb958935c0..3bb174408b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -273,12 +273,13 @@ void Config::Save() { IniFile::Section *recent = iniFile.GetOrCreateSection("Recent"); recent->Set("MaxRecent", iMaxRecent); - for (int i = 0; i < (int)recentIsos.size(); i++) - { + for (int i = 0; i < iMaxRecent; i++) { char keyName[64]; - sprintf(keyName,"FileName%d",i); - recent->Set(keyName,recentIsos[i]); + if (i < recentIsos.size()){ + recent->Set(keyName, recentIsos[i]);} + else{ + recent->Delete(keyName);} // delete the nonexisting FileName } IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); @@ -398,8 +399,19 @@ void Config::AddRecent(const std::string &file) { void Config::CleanRecent() { std::vector cleanedRecent; for (size_t i = 0; i < recentIsos.size(); i++) { - if (File::Exists(recentIsos[i])) - cleanedRecent.push_back(recentIsos[i]); + if (File::Exists(recentIsos[i])){ + // clean the redundant recent games' list. + if (cleanedRecent.size()==0){ // add first one + cleanedRecent.push_back(recentIsos[i]); + } + for (size_t j=0; j