From 29bbb826a108faf749824c16f9c13e75ab32e647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Nov 2013 13:02:08 +0100 Subject: [PATCH] Put the store button on the homebrew tab. Make it look slightly less awful. --- UI/MainScreen.cpp | 38 +++++++++++++++++++++++++++----------- UI/Store.cpp | 27 +++++++++++++++++++-------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 15b7ea0bc3..ecd2a224f7 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -234,13 +234,19 @@ void GameButton::Draw(UIContext &dc) { dc.RebindTexture(); } +enum GameBrowserFlags { + FLAG_HOMEBREWSTOREBUTTON = 1 +}; + + class GameBrowser : public UI::LinearLayout { public: - GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = 0); + GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, int flags = 0, UI::LayoutParams *layoutParams = 0); UI::Event OnChoice; UI::Event OnHoldChoice; + UI::Choice *HomebrewStoreButton() { return homebrewStoreButton_; } private: void Refresh(); @@ -257,10 +263,12 @@ private: bool allowBrowsing_; std::string lastText_; std::string lastLink_; + int flags_; + UI::Choice *homebrewStoreButton_; }; -GameBrowser::GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams) - : LinearLayout(UI::ORIENT_VERTICAL, layoutParams), gameList_(0), path_(path), gridStyle_(gridStyle), allowBrowsing_(allowBrowsing), lastText_(lastText), lastLink_(lastLink) { +GameBrowser::GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle, std::string lastText, std::string lastLink, int flags, UI::LayoutParams *layoutParams) + : LinearLayout(UI::ORIENT_VERTICAL, layoutParams), gameList_(0), path_(path), gridStyle_(gridStyle), allowBrowsing_(allowBrowsing), lastText_(lastText), lastLink_(lastLink), flags_(flags) { using namespace UI; Refresh(); } @@ -306,6 +314,7 @@ UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) { void GameBrowser::Refresh() { using namespace UI; + homebrewStoreButton_ = 0; // Kill all the contents Clear(); @@ -392,6 +401,11 @@ void GameBrowser::Refresh() { b->OnHoldClick.Handle(this, &GameBrowser::GameButtonHoldClick); } + if (flags_ & FLAG_HOMEBREWSTOREBUTTON) { + Add(new Spacer()); + homebrewStoreButton_ = Add(new Choice("Download from the PPSSPP Homebrew Store", new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT))); + } + if (!lastText_.empty() && gameButtons.empty()) { Add(new Spacer()); Add(new Choice(lastText_, new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT)))->OnClick.Handle(this, &GameBrowser::LastClick); @@ -451,15 +465,18 @@ void MainScreen::CreateViews() { ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); GameBrowser *tabRecentGames = new GameBrowser( - "!RECENT", false, &g_Config.bGridView1, "", "", + "!RECENT", false, &g_Config.bGridView1, "", "", 0, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, true, &g_Config.bGridView2, - m->T("How to get games"), "http://www.ppsspp.org/getgames.html", + m->T("How to get games"), "http://www.ppsspp.org/getgames.html", 0, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); GameBrowser *tabHomebrew = new GameBrowser(GetSysDirectory(DIRECTORY_GAME), false, &g_Config.bGridView3, m->T("How to get homebrew & demos", "How to get homebrew && demos"), "http://www.ppsspp.org/gethomebrew.html", + FLAG_HOMEBREWSTOREBUTTON, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); + tabHomebrew->HomebrewStoreButton()->OnClick.Handle(this, &MainScreen::OnHomebrewStore); + scrollRecentGames->Add(tabRecentGames); scrollAllGames->Add(tabAllGames); scrollHomebrew->Add(tabHomebrew); @@ -516,7 +533,6 @@ void MainScreen::CreateViews() { #endif rightColumnItems->Add(new Choice(m->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings); rightColumnItems->Add(new Choice(m->T("Credits")))->OnClick.Handle(this, &MainScreen::OnCredits); - rightColumnItems->Add(new Choice(m->T("Homebrew Store")))->OnClick.Handle(this, &MainScreen::OnHomebrewStore); #ifndef __SYMBIAN32__ rightColumnItems->Add(new Choice(m->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg); #endif @@ -885,10 +901,10 @@ void UmdReplaceScreen::CreateViews() { ScrollView *scrollAllGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); GameBrowser *tabRecentGames = new GameBrowser( - "!RECENT", false, &g_Config.bGridView1, "", "", + "!RECENT", false, &g_Config.bGridView1, "", "", 0, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); - GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, true, &g_Config.bGridView2, - m->T("How to get games"), "http://www.ppsspp.org/getgames.html", + GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, true, &g_Config.bGridView2, + m->T("How to get games"), "http://www.ppsspp.org/getgames.html", 0, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); scrollRecentGames->Add(tabRecentGames); @@ -912,8 +928,8 @@ void UmdReplaceScreen::CreateViews() { } root_ = new LinearLayout(ORIENT_HORIZONTAL); - root_->Add(leftColumn); - root_->Add(rightColumn); + root_->Add(leftColumn); + root_->Add(rightColumn); } void UmdReplaceScreen::update(InputState &input) { diff --git a/UI/Store.cpp b/UI/Store.cpp index d234e3ef8b..0dbee972fc 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -177,16 +177,26 @@ void StoreScreen::ParseListing(std::string json) { void StoreScreen::CreateViews() { using namespace UI; + + root_ = new LinearLayout(ORIENT_VERTICAL); + + // Top bar + LinearLayout *topBar = root_->Add(new LinearLayout(ORIENT_HORIZONTAL)); + topBar->Add(new Button("Back"))->OnClick.Handle(this, &UIScreen::OnBack); + topBar->Add(new TextView("PPSSPP Homebrew Store")); + UI::Drawable solid(0xFFbd9939); + topBar->SetBG(solid); + + LinearLayout *content; if (connectionError_ || loading_) { - root_ = new LinearLayout(ORIENT_VERTICAL); - root_->Add(new TextView(loading_ ? "Loading.." : "Connection Error")); - root_->Add(new Button("Retry"))->OnClick.Handle(this, &StoreScreen::OnRetry); - root_->Add(new Button("Back"))->OnClick.Handle(this, &UIScreen::OnBack); + content = new LinearLayout(ORIENT_VERTICAL); + content->Add(new TextView(loading_ ? "Loading.." : "Connection Error")); + content->Add(new Button("Retry"))->OnClick.Handle(this, &StoreScreen::OnRetry); + content->Add(new Button("Back"))->OnClick.Handle(this, &UIScreen::OnBack); } else { - root_ = new LinearLayout(ORIENT_HORIZONTAL); + content = new LinearLayout(ORIENT_HORIZONTAL); ScrollView *leftScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(0.5f)); - root_->Add(new Button("Back"))->OnClick.Handle(this, &UIScreen::OnBack); - root_->Add(leftScroll); + content->Add(leftScroll); LinearLayout *scrollItemView = new LinearLayout(ORIENT_VERTICAL); leftScroll->Add(scrollItemView); std::vector entries = FilterEntries(); @@ -196,8 +206,9 @@ void StoreScreen::CreateViews() { // TODO: Similar apps, etc etc productPanel_ = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(0.5f)); - root_->Add(productPanel_); + content->Add(productPanel_); } + root_->Add(content); } std::vector StoreScreen::FilterEntries() {