Merge pull request #3836 from shenweip/patch-ui

Add "Remove From Recent" function,more convenient for the users.
This commit is contained in:
Henrik Rydgård committed 2013-09-21 09:15:51 -07:00
commit 3fafb3d291
2 files changed
+25

No files matched your search

+23
View File
@@ -30,6 +30,7 @@
#include "UI/MiscScreens.h"
#include "UI/MainScreen.h"
#include "Core/Host.h"
#include "Core/Config.h"
void GameScreen::CreateViews() {
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
@@ -70,6 +71,9 @@ void GameScreen::CreateViews() {
if (host->CanCreateShortcut()) {
rightColumnItems->Add(new Choice(ga->T("Create Shortcut")))->OnClick.Handle(this, &GameScreen::OnCreateShortcut);
}
if (isRecentGame(gamePath_)) {
rightColumnItems->Add(new Choice(ga->T("Remove From Recent")))->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent);
}
UI::SetFocusedView(play);
}
@@ -196,3 +200,22 @@ UI::EventReturn GameScreen::OnCreateShortcut(UI::EventParams &e) {
}
return UI::EVENT_DONE;
}
bool GameScreen::isRecentGame(std::string gamePath) {
for (auto it = g_Config.recentIsos.begin(); it != g_Config.recentIsos.end(); ++it) {
if (!strcmp((*it).c_str(),gamePath.c_str()))
return true;
}
return false;
}
UI::EventReturn GameScreen::OnRemoveFromRecent(UI::EventParams &e) {
for (auto it = g_Config.recentIsos.begin(); it != g_Config.recentIsos.end(); ++it) {
if (!strcmp((*it).c_str(),gamePath_.c_str())) {
g_Config.recentIsos.erase(it);
screenManager()->switchScreen(new MainScreen());
return UI::EVENT_DONE;
}
}
return UI::EVENT_DONE;
}
+2
View File
@@ -37,6 +37,7 @@ protected:
virtual void DrawBackground(UIContext &dc);
void CallbackDeleteSaveData(bool yes);
void CallbackDeleteGame(bool yes);
bool isRecentGame(std::string gamePath);
private:
// Event handlers
@@ -46,6 +47,7 @@ private:
UI::EventReturn OnDeleteGame(UI::EventParams &e);
UI::EventReturn OnSwitchBack(UI::EventParams &e);
UI::EventReturn OnCreateShortcut(UI::EventParams &e);
UI::EventReturn OnRemoveFromRecent(UI::EventParams &e);
std::string gamePath_;