Use a UI event for clearing recents.

This way it builds on Android, and is cross platform too.
This commit is contained in:
Unknown W. Brackets 2013-09-07 09:44:28 -07:00
parent 26c5ee4a6d
commit f97794136c
6 changed files with 13 additions and 19 deletions

View File

@ -50,7 +50,6 @@ 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;
}
@ -265,7 +264,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
OnRecentChanged.Trigger(e);
return UI::EVENT_DONE;
}
@ -357,12 +356,6 @@ 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;
}

View File

@ -25,11 +25,12 @@
class GameSettingsScreen : public UIDialogScreenWithBackground {
public:
GameSettingsScreen(std::string gamePath, std::string gameID = "")
: gamePath_(gamePath), gameID_(gameID), iAlternateSpeedPercent_(3), enableReports_(false), clearrecentlist_(false) {}
: gamePath_(gamePath), gameID_(gameID), iAlternateSpeedPercent_(3), enableReports_(false) {}
virtual void update(InputState &input);
UI::Event OnLanguageChanged;
UI::Event OnRecentChanged;
protected:
virtual void CreateViews();
@ -64,7 +65,6 @@ private:
bool cap60FPS_;
int iAlternateSpeedPercent_;
bool enableReports_;
bool clearrecentlist_;
};
/*

View File

@ -554,9 +554,6 @@ void MainScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "language")) {
RecreateViews();
}
if (!strcmp(message, "clearrecentlist")){
RecreateViews();
}
}
void MainScreen::update(InputState &input) {
@ -594,6 +591,7 @@ UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
// screenManager()->push(new SettingsScreen());
auto gameSettings = new GameSettingsScreen("", "");
gameSettings->OnLanguageChanged.Handle(this, &MainScreen::OnLanguageChange);
gameSettings->OnRecentChanged.Handle(this, &MainScreen::OnRecentChange);
screenManager()->push(gameSettings);
return UI::EVENT_DONE;
}
@ -606,6 +604,14 @@ UI::EventReturn MainScreen::OnLanguageChange(UI::EventParams &e) {
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnRecentChange(UI::EventParams &e) {
RecreateViews();
if (host) {
host->UpdateUI();
}
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnCredits(UI::EventParams &e) {
screenManager()->push(new CreditsScreen());
return UI::EVENT_DONE;

View File

@ -44,6 +44,7 @@ private:
UI::EventReturn OnLoadFile(UI::EventParams &e);
UI::EventReturn OnGameSettings(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnRecentChange(UI::EventParams &e);
UI::EventReturn OnCredits(UI::EventParams &e);
UI::EventReturn OnSupport(UI::EventParams &e);
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);

View File

@ -1550,11 +1550,6 @@ 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.

View File

@ -12,7 +12,6 @@ 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 {