Update recent games list & remove redundant recent games from ini file

This commit is contained in:
kaienfr committed 2013-09-05 18:23:28 +02:00
1 parent 515874c147
commit 137df18a00
6 files changed
+36 -7

No files matched your search

+18 -6
View File
@@ -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<std::string> 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<cleanedRecent.size();j++){
if ((std::string)cleanedRecent[j]==(std::string)recentIsos[i])
break; // skip if found redundant
if (j==cleanedRecent.size()-1){ // add if no redundant found
cleanedRecent.push_back(recentIsos[i]);
}
}
}
}
recentIsos = cleanedRecent;
}
+7
View File
@@ -48,6 +48,7 @@ namespace MainWindow {
WM_USER_LOG_STATUS_CHANGED = WM_USER + 101,
WM_USER_ATRAC_STATUS_CHANGED = WM_USER + 102,
WM_USER_UPDATE_UI = WM_USER + 103,
WM_USER_RECREATE_RECENTLIST = WM_USER + 104,
};
extern HWND hwndMain;
}
@@ -398,6 +399,7 @@ void GameSettingsScreen::CreateViews() {
UI::EventReturn GameSettingsScreen::OnClearRecents(UI::EventParams &e) {
g_Config.recentIsos.clear();
clearrecentlist_=true; // set true to send clear_recent_list message
return UI::EVENT_DONE;
}
@@ -489,6 +491,11 @@ UI::EventReturn GameSettingsScreen::OnBack(UI::EventParams &e) {
KeyMap::UpdateConfirmCancelKeys();
if (clearrecentlist_){
// clear the recent game list on MainWindow.
PostMessage(MainWindow::hwndMain, MainWindow::WM_USER_RECREATE_RECENTLIST, 0, 0);
clearrecentlist_ = false; }
return UI::EVENT_DONE;
}
+2 -1
View File
@@ -25,7 +25,7 @@
class GameSettingsScreen : public UIDialogScreenWithBackground {
public:
GameSettingsScreen(std::string gamePath, std::string gameID = "")
: gamePath_(gamePath), gameID_(gameID), iAlternateSpeedPercent_(3), enableReports_(false) {}
: gamePath_(gamePath), gameID_(gameID), iAlternateSpeedPercent_(3), enableReports_(false), clearrecentlist_(false) {}
virtual void update(InputState &input);
@@ -64,6 +64,7 @@ private:
bool cap60FPS_;
int iAlternateSpeedPercent_;
bool enableReports_;
bool clearrecentlist_;
};
/*
+3
View File
@@ -554,6 +554,9 @@ void MainScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "language")) {
RecreateViews();
}
if (!strcmp(message, "clearrecentlist")){
RecreateViews();
}
}
void MainScreen::update(InputState &input) {
+5
View File
@@ -1538,6 +1538,11 @@ namespace MainWindow
Update();
break;
case WM_USER_RECREATE_RECENTLIST:
NativeMessageReceived("clearrecentlist", "");
Update();
break;
case WM_MENUSELECT:
// Unfortunately, accelerate keys (hotkeys) shares the same enabled/disabled states
// with corresponding menu items.
+1
View File
@@ -12,6 +12,7 @@ namespace MainWindow
WM_USER_LOG_STATUS_CHANGED = WM_USER + 101,
WM_USER_ATRAC_STATUS_CHANGED = WM_USER + 102,
WM_USER_UPDATE_UI = WM_USER + 103,
WM_USER_RECREATE_RECENTLIST = WM_USER + 104,
};
enum {