Skip to content

Commit

Permalink
Move clear game list to new menu
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 committed Mar 2, 2020
1 parent e3c130d commit d8405b6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
9 changes: 0 additions & 9 deletions UI/GameSettingsScreen.cpp
Expand Up @@ -722,9 +722,6 @@ void GameSettingsScreen::CreateViews() {
#endif

systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP")));
if (g_Config.iMaxRecent > 0)
systemSettings->Add(new Choice(sy->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);

const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png";
const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg";
if (File::Exists(bgPng) || File::Exists(bgJpg)) {
Expand Down Expand Up @@ -988,12 +985,6 @@ UI::EventReturn GameSettingsScreen::OnSavePathOther(UI::EventParams &e) {

#endif

UI::EventReturn GameSettingsScreen::OnClearRecents(UI::EventParams &e) {
g_Config.recentIsos.clear();
OnRecentChanged.Trigger(e);
return UI::EVENT_DONE;
}

UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) {
const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png";
const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg";
Expand Down
2 changes: 0 additions & 2 deletions UI/GameSettingsScreen.h
Expand Up @@ -36,7 +36,6 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
void onFinish(DialogResult result) override;
void sendMessage(const char *message, const char *value) override;
std::string tag() const override { return "settings"; }
UI::Event OnRecentChanged;

protected:
void CreateViews() override;
Expand Down Expand Up @@ -86,7 +85,6 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
UI::EventReturn OnChangeNickname(UI::EventParams &e);
UI::EventReturn OnChangeproAdhocServerAddress(UI::EventParams &e);
UI::EventReturn OnChangeMacAddress(UI::EventParams &e);
UI::EventReturn OnClearRecents(UI::EventParams &e);
UI::EventReturn OnChangeBackground(UI::EventParams &e);
UI::EventReturn OnFullscreenChange(UI::EventParams &e);
UI::EventReturn OnDisplayLayoutEditor(UI::EventParams &e);
Expand Down
59 changes: 34 additions & 25 deletions UI/MainScreen.cpp
Expand Up @@ -861,6 +861,25 @@ UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::GridSettingsClick(UI::EventParams &e) {
auto sy = GetI18NCategory("System");
auto gridSettings = new GridSettingsScreen(sy->T("Games list settings"));
gridSettings->OnRecentChanged.Handle(this, &GameBrowser::OnRecentClear);
if (e.v)
gridSettings->SetPopupOrigin(e.v);

screenManager_->push(gridSettings);
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) {
screenManager_->RecreateAllViews();
if (host) {
host->UpdateUI();
}
return UI::EVENT_DONE;
}

MainScreen::MainScreen() : highlightProgress_(0.0f), prevHighlightProgress_(0.0f), backFromStore_(false), lockBackgroundAudio_(false) {
System_SendMessage("event", "mainscreen");
SetBackgroundAudioGame("");
Expand Down Expand Up @@ -1267,27 +1286,7 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
}

UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
auto gameSettings = new GameSettingsScreen("", "");
gameSettings->OnRecentChanged.Handle(this, &MainScreen::OnRecentChange);
screenManager()->push(gameSettings);
return UI::EVENT_DONE;
}

UI::EventReturn MainScreen::OnRecentChange(UI::EventParams &e) {
RecreateViews();
if (host) {
host->UpdateUI();
}
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::GridSettingsClick(UI::EventParams &e) {
auto sy = GetI18NCategory("System");
auto *gridSettings = new GridSettingsScreen(sy->T("Games list settings"));
if (e.v)
gridSettings->SetPopupOrigin(e.v);

screenManager_->push(gridSettings);
screenManager()->push(new GameSettingsScreen("", ""));
return UI::EVENT_DONE;
}

Expand Down Expand Up @@ -1456,7 +1455,6 @@ void GridSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f));
LinearLayout *items = new LinearLayout(ORIENT_VERTICAL);

items->Add(new ItemHeader(sy->T("View style")));
items->Add(new CheckBox(&g_Config.bGridView1, sy->T("Display Recent on a grid")));
items->Add(new CheckBox(&g_Config.bGridView2, sy->T("Display Games on a grid")));
items->Add(new CheckBox(&g_Config.bGridView3, sy->T("Display Homebrew on a grid")));
Expand All @@ -1465,9 +1463,14 @@ void GridSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
items->Add(new Choice(sy->T("Increase size")))->OnClick.Handle(this, &GridSettingsScreen::GridPlusClick);
items->Add(new Choice(sy->T("Decrease size")))->OnClick.Handle(this, &GridSettingsScreen::GridMinusClick);

items->Add(new ItemHeader(sy->T("Extra info")));
items->Add(new CheckBox(&g_Config.bShowIDOnGameIcon, sy->T("Show ID on game selection screen")));
items->Add(new CheckBox(&g_Config.bShowRegionOnGameIcon, sy->T("Show region flag on game selection screen")));
items->Add(new ItemHeader(sy->T("Display Extra Info")));
items->Add(new CheckBox(&g_Config.bShowIDOnGameIcon, sy->T("Show ID")));
items->Add(new CheckBox(&g_Config.bShowRegionOnGameIcon, sy->T("Show region flag")));

if (g_Config.iMaxRecent > 0) {
items->Add(new ItemHeader(sy->T("Clear Recent")));
items->Add(new Choice(sy->T("Clear Recent Games List")))->OnClick.Handle(this, &GridSettingsScreen::OnRecentClearClick);
}

scroll->Add(items);
parent->Add(scroll);
Expand All @@ -1482,3 +1485,9 @@ UI::EventReturn GridSettingsScreen::GridMinusClick(UI::EventParams &e) {
g_Config.fGameGridScale = std::max(g_Config.fGameGridScale/1.25f, MIN_GAME_GRID_SCALE);
return UI::EVENT_DONE;
}

UI::EventReturn GridSettingsScreen::OnRecentClearClick(UI::EventParams &e) {
g_Config.recentIsos.clear();
OnRecentChanged.Trigger(e);
return UI::EVENT_DONE;
}
4 changes: 3 additions & 1 deletion UI/MainScreen.h
Expand Up @@ -80,6 +80,7 @@ class GameBrowser : public UI::LinearLayout {
UI::EventReturn HomeClick(UI::EventParams &e);
UI::EventReturn PinToggleClick(UI::EventParams &e);
UI::EventReturn GridSettingsClick(UI::EventParams &e);
UI::EventReturn OnRecentClear(UI::EventParams &e);

UI::ViewGroup *gameList_ = nullptr;
PathBrowser path_;
Expand Down Expand Up @@ -123,7 +124,6 @@ class MainScreen : public UIScreenWithBackground {
// Event handlers
UI::EventReturn OnLoadFile(UI::EventParams &e);
UI::EventReturn OnGameSettings(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);
Expand Down Expand Up @@ -173,10 +173,12 @@ class GridSettingsScreen : public PopupScreen {
public:
GridSettingsScreen(std::string label) : PopupScreen(label) {}
void CreatePopupContents(UI::ViewGroup *parent) override;
UI::Event OnRecentChanged;

private:
UI::EventReturn GridPlusClick(UI::EventParams &e);
UI::EventReturn GridMinusClick(UI::EventParams &e);
UI::EventReturn OnRecentClearClick(UI::EventParams &e);
const float MAX_GAME_GRID_SCALE = 3.0;
const float MIN_GAME_GRID_SCALE = 0.8;
};

0 comments on commit d8405b6

Please sign in to comment.