Fix homebrew store button to work even after changing grid layouts (it lost its click handler)

This commit is contained in:
Henrik Rydgård 2020-05-17 14:57:12 +02:00
parent 90071fd868
commit 7c8bcb2ee4
2 changed files with 15 additions and 27 deletions

View File

@ -628,7 +628,6 @@ void GameBrowser::Refresh() {
lastScale_ = g_Config.fGameGridScale; lastScale_ = g_Config.fGameGridScale;
lastLayoutWasGrid_ = *gridStyle_; lastLayoutWasGrid_ = *gridStyle_;
homebrewStoreButton_ = nullptr;
// Kill all the contents // Kill all the contents
Clear(); Clear();
@ -785,9 +784,7 @@ void GameBrowser::Refresh() {
if (browseFlags_ & BrowseFlags::HOMEBREW_STORE) { if (browseFlags_ & BrowseFlags::HOMEBREW_STORE) {
Add(new Spacer()); Add(new Spacer());
homebrewStoreButton_ = Add(new Choice(mm->T("DownloadFromStore", "Download from the PPSSPP Homebrew Store"), new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT))); Add(new Choice(mm->T("DownloadFromStore", "Download from the PPSSPP Homebrew Store"), new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT)))->OnClick.Handle(this, &GameBrowser::OnHomebrewStore);
} else {
homebrewStoreButton_ = nullptr;
} }
if (!lastText_.empty() && gameButtons.empty()) { if (!lastText_.empty() && gameButtons.empty()) {
@ -908,7 +905,12 @@ UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) {
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
MainScreen::MainScreen() : highlightProgress_(0.0f), prevHighlightProgress_(0.0f), backFromStore_(false), lockBackgroundAudio_(false) { UI::EventReturn GameBrowser::OnHomebrewStore(UI::EventParams &e) {
screenManager_->push(new StoreScreen());
return UI::EVENT_DONE;
}
MainScreen::MainScreen() {
System_SendMessage("event", "mainscreen"); System_SendMessage("event", "mainscreen");
SetBackgroundAudioGame(""); SetBackgroundAudioGame("");
lastVertical_ = UseVerticalLayout(); lastVertical_ = UseVerticalLayout();
@ -918,7 +920,6 @@ MainScreen::~MainScreen() {
SetBackgroundAudioGame(""); SetBackgroundAudioGame("");
} }
void MainScreen::CreateViews() { void MainScreen::CreateViews() {
// Information in the top left. // Information in the top left.
// Back button to the bottom left. // Back button to the bottom left.
@ -974,11 +975,6 @@ void MainScreen::CreateViews() {
mm->T("How to get homebrew & demos", "How to get homebrew && demos"), "https://www.ppsspp.org/gethomebrew.html", mm->T("How to get homebrew & demos", "How to get homebrew && demos"), "https://www.ppsspp.org/gethomebrew.html",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
Choice *hbStore = tabHomebrew->HomebrewStoreButton();
if (hbStore) {
hbStore->OnClick.Handle(this, &MainScreen::OnHomebrewStore);
}
scrollAllGames->Add(tabAllGames); scrollAllGames->Add(tabAllGames);
gameBrowsers_.push_back(tabAllGames); gameBrowsers_.push_back(tabAllGames);
scrollHomebrew->Add(tabHomebrew); scrollHomebrew->Add(tabHomebrew);
@ -1323,11 +1319,6 @@ UI::EventReturn MainScreen::OnCredits(UI::EventParams &e) {
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
UI::EventReturn MainScreen::OnHomebrewStore(UI::EventParams &e) {
screenManager()->push(new StoreScreen());
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnSupport(UI::EventParams &e) { UI::EventReturn MainScreen::OnSupport(UI::EventParams &e) {
#ifdef __ANDROID__ #ifdef __ANDROID__
LaunchBrowser("market://details?id=org.ppsspp.ppssppgold"); LaunchBrowser("market://details?id=org.ppsspp.ppssppgold");

View File

@ -53,8 +53,6 @@ public:
UI::Event OnHoldChoice; UI::Event OnHoldChoice;
UI::Event OnHighlight; UI::Event OnHighlight;
UI::Choice *HomebrewStoreButton() { return homebrewStoreButton_; }
void FocusGame(const std::string &gamePath); void FocusGame(const std::string &gamePath);
void SetPath(const std::string &path); void SetPath(const std::string &path);
void Draw(UIContext &dc) override; void Draw(UIContext &dc) override;
@ -81,14 +79,14 @@ private:
UI::EventReturn PinToggleClick(UI::EventParams &e); UI::EventReturn PinToggleClick(UI::EventParams &e);
UI::EventReturn GridSettingsClick(UI::EventParams &e); UI::EventReturn GridSettingsClick(UI::EventParams &e);
UI::EventReturn OnRecentClear(UI::EventParams &e); UI::EventReturn OnRecentClear(UI::EventParams &e);
UI::EventReturn OnHomebrewStore(UI::EventParams &e);
UI::ViewGroup *gameList_ = nullptr; UI::ViewGroup *gameList_ = nullptr;
PathBrowser path_; PathBrowser path_;
bool *gridStyle_; bool *gridStyle_ = nullptr;
BrowseFlags browseFlags_; BrowseFlags browseFlags_;
std::string lastText_; std::string lastText_;
std::string lastLink_; std::string lastLink_;
UI::Choice *homebrewStoreButton_ = nullptr;
std::string focusGamePath_; std::string focusGamePath_;
bool listingPending_ = false; bool listingPending_ = false;
float lastScale_ = 1.0f; float lastScale_ = 1.0f;
@ -131,21 +129,20 @@ protected:
UI::EventReturn OnExit(UI::EventParams &e); UI::EventReturn OnExit(UI::EventParams &e);
UI::EventReturn OnDownloadUpgrade(UI::EventParams &e); UI::EventReturn OnDownloadUpgrade(UI::EventParams &e);
UI::EventReturn OnDismissUpgrade(UI::EventParams &e); UI::EventReturn OnDismissUpgrade(UI::EventParams &e);
UI::EventReturn OnHomebrewStore(UI::EventParams &e);
UI::EventReturn OnAllowStorage(UI::EventParams &e); UI::EventReturn OnAllowStorage(UI::EventParams &e);
UI::LinearLayout *upgradeBar_; UI::LinearLayout *upgradeBar_ = nullptr;
UI::TabHolder *tabHolder_; UI::TabHolder *tabHolder_ = nullptr;
std::string restoreFocusGamePath_; std::string restoreFocusGamePath_;
std::vector<GameBrowser *> gameBrowsers_; std::vector<GameBrowser *> gameBrowsers_;
std::string highlightedGamePath_; std::string highlightedGamePath_;
std::string prevHighlightedGamePath_; std::string prevHighlightedGamePath_;
float highlightProgress_; float highlightProgress_ = 0.0f;
float prevHighlightProgress_; float prevHighlightProgress_ = 0.0f;
bool backFromStore_; bool backFromStore_ = false;
bool lockBackgroundAudio_; bool lockBackgroundAudio_ = false;
bool lastVertical_; bool lastVertical_;
bool confirmedTemporary_ = false; bool confirmedTemporary_ = false;