From c8603c01f86becc6509feba35db2ffe3c87f9037 Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Thu, 19 Sep 2013 16:10:31 +0800 Subject: [PATCH] Add "Remove From Recent" funtion,more convenient for the users. --- UI/GameScreen.cpp | 23 +++++++++++++++++++++++ UI/GameScreen.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index ab0beb6957..24edda65f7 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -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; +} \ No newline at end of file diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 4443900e67..8df9d70621 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -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_;