mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #3636 from kaienfr/fix_recent_gamelist
Update recent games list & remove redundant recent games from ini file
This commit is contained in:
commit
f24a7c83f5
6 changed files with 46 additions and 10 deletions
|
@ -99,8 +99,12 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
|
|||
std::string fileName;
|
||||
|
||||
sprintf(keyName,"FileName%d",i);
|
||||
if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) break;
|
||||
recentIsos.push_back(fileName);
|
||||
if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) {
|
||||
// just skip it to get the next key
|
||||
}
|
||||
else {
|
||||
recentIsos.push_back(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
||||
|
@ -273,12 +277,15 @@ 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 +405,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 (cleanedRecent[j]==recentIsos[i])
|
||||
break; // skip if found redundant
|
||||
if (j==cleanedRecent.size()-1){ // add if no redundant found
|
||||
cleanedRecent.push_back(recentIsos[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recentIsos = cleanedRecent;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2013- PPSSPP Project.
|
||||
// Copyright (c) 2013- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -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,12 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1550,6 +1550,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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue