From 54f537719671a51573dcfa205f5b1fa66e028fdc Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 3 Jun 2013 00:42:19 +0200 Subject: [PATCH] PluginScreen progress --- UI/MenuScreens.cpp | 15 +++++++--- UI/NativeApp.cpp | 4 +-- UI/PluginScreen.cpp | 69 +++++++++++++++++++-------------------------- UI/PluginScreen.h | 19 ++----------- native | 2 +- 5 files changed, 46 insertions(+), 63 deletions(-) diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 16e90863dc..92638c7ae5 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -61,8 +61,10 @@ namespace MainWindow { #include "Core/SaveState.h" #include "Core/HLE/sceUtility.h" -#include "MenuScreens.h" -#include "EmuScreen.h" +#include "UI/MenuScreens.h" +#include "UI/EmuScreen.h" +#include "UI/PluginScreen.h" + #include "GameInfoCache.h" #include "android/jni/TestRunner.h" @@ -98,7 +100,7 @@ static const uint32_t colors[4] = { 0xC0FFFFFF, }; -static void DrawBackground(float alpha) { +void DrawBackground(float alpha) { static float xbase[100] = {0}; static float ybase[100] = {0}; static int last_dp_xres = 0; @@ -669,7 +671,12 @@ void AudioScreen::render() { if (Atrac3plus_Decoder::IsInstalled()) { UICheckBox(GEN_ID, x, y += stride, a->T("Enable Atrac3+"), ALIGN_TOPLEFT, &g_Config.bEnableAtrac3plus); } - + + VLinear vlinear(30, 300, 20); + if (UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) { + screenManager()->push(new PluginScreen()); + } + UIEnd(); } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index ed587c67db..8cb64c98ae 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -355,10 +355,10 @@ void NativeInitGraphics() { // If first run and can't autoinstall, let's send the user to the atrac3plus download screen. if (Atrac3plus_Decoder::CanAutoInstall()) { Atrac3plus_Decoder::DoAutoInstall(); - } else if ((true || g_Config.bFirstRun) && !Atrac3plus_Decoder::IsInstalled()) { - screenManager->switchScreen(new PluginScreen()); } else { screenManager->switchScreen(new LogoScreen(boot_filename)); + if ((true || g_Config.bFirstRun) && !Atrac3plus_Decoder::IsInstalled()) + screenManager->push(new PluginScreen()); } } else { // Go directly into the game. diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index d6565e3f93..9b87394ea1 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -24,33 +24,14 @@ #include "ui/view.h" #include "ui/viewgroup.h" #include "ui/ui_context.h" +#include "UI/ui_atlas.h" #include "Core/HW/atrac3plus.h" -void UIScreen::update(InputState &input) { - if (!root_) { - CreateViews(); - } +void DrawBackground(float alpha); - if (orientationChanged_) { - delete root_; - root_ = 0; - CreateViews(); - } - - UpdateViewHierarchy(input, root_); -} - -void UIScreen::render() { - UI::LayoutViewHierarchy(*screenManager()->getUIContext(), root_); - - screenManager()->getUIContext()->Begin(); - root_->Draw(*screenManager()->getUIContext()); - screenManager()->getUIContext()->End(); - screenManager()->getUIContext()->Flush(); -} - -void UIScreen::touch(const TouchInput &touch) { - root_->Touch(touch); +void PluginScreen::DrawBackground() +{ + ::DrawBackground(1.0f); } PluginScreen::PluginScreen() { @@ -68,18 +49,13 @@ void PluginScreen::CreateViews() { Margins textMargins(20,17); - root_->Add(new TextView(0, "Audio decoding support", ALIGN_HCENTER, 1.0f, new LinearLayoutParams(textMargins))); + root_->Add(new TextView(UBUNTU48, "Audio decoding support", ALIGN_HCENTER, 1.0f, new LinearLayoutParams(textMargins))); ViewGroup *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0)); root_->Add(scroll); - tvDescription_ = scroll->Add(new TextView(0, - "Would you like to install Atrac3+ decoding support by Mai?\n" - "This is required for audio in many games.\n" - "Note that there may be legality issues around non-clean-room\n" - "reverse engineered code in the US and some other countries.\n" - "Choose \"More Information\" for more info.\n", ALIGN_LEFT, 1.0f, new LinearLayoutParams(textMargins))); + tvDescription_ = scroll->Add(new TextView(0, "Looking for download...", ALIGN_LEFT, 1.0f, new LinearLayoutParams(textMargins))); progress_ = root_->Add(new ProgressBar()); progress_->SetVisibility(V_GONE); @@ -87,9 +63,10 @@ void PluginScreen::CreateViews() { ViewGroup *buttonBar = new LinearLayout(ORIENT_HORIZONTAL); root_->Add(buttonBar); - buttonBack_ = new Button(c->T("Back")); - buttonBar->Add(buttonBack_); + buttonBack_ = new Button(c->T("Back"), new LinearLayoutParams(1.0)); + buttonBar->Add(buttonBack_)->OnClick.Add(std::bind(&UIScreen::OnBack, this, placeholder::_1)); buttonDownload_ = new Button(c->T("Download"), new LinearLayoutParams(1.0)); + buttonDownload_->SetEnabled(false); buttonBar->Add(buttonDownload_)->OnClick.Add(std::bind(&PluginScreen::OnDownload, this, placeholder::_1)); buttonBar->Add(new Button(c->T("More Information"), new LinearLayoutParams(1.0)))->OnClick.Add(std::bind(&PluginScreen::OnInformation, this, placeholder::_1)); } @@ -120,6 +97,18 @@ void PluginScreen::update(InputState &input) { at3plusdecoderUrl_ = root->getString(abi.c_str(), ""); if (at3plusdecoderUrl_.empty()) { buttonDownload_->SetEnabled(false); + } else { + buttonDownload_->SetEnabled(true); + + const char *notInstalledText = "Would you like to install Atrac3+ decoding support by Mai?\n" + "This is required for audio in many games.\n" + "Note that there may be legality issues around non-clean-room\n" + "reverse engineered code in the US and some other countries.\n" + + "Choose \"More Information\" for more info.\n"; + + const char *reInstallText = "Would you like to redownload Atrac3+ decoding support by Mai?\n"; + tvDescription_->SetText(Atrac3plus_Decoder::IsInstalled() ? reInstallText : notInstalledText); } } json_.reset(); @@ -134,14 +123,16 @@ void PluginScreen::update(InputState &input) { if (result == 200) { // Yay! tvDescription_->SetText("Mai Atrac3plus plugin downloaded and installed.\n" - "Please press Continue."); + "Please press Back."); buttonDownload_->SetVisibility(UI::V_GONE); } else { - char codeStr[8]; + char codeStr[18]; sprintf(codeStr, "%i", result); tvDescription_->SetText(std::string("Failed to download (") + codeStr + ").\nPlease try again later."); buttonDownload_->SetEnabled(true); } + + at3plusdecoder_.reset(); } } @@ -149,15 +140,13 @@ UI::EventReturn PluginScreen::OnDownload(UI::EventParams &e) { buttonDownload_->SetEnabled(false); std::string destination = Atrac3plus_Decoder::GetInstalledFilename(); - at3plusdecoder_ = downloader_.StartDownload(at3plusdecoderUrl_, destination); - // No decoder available for this arch - // #error Unable to identify architecture return UI::EVENT_DONE; } - UI::EventReturn PluginScreen::OnInformation(UI::EventParams &e) { + LaunchBrowser("http://www.ppsspp.org/at3plusdecoder.html"); return UI::EVENT_DONE; -} \ No newline at end of file +} + diff --git a/UI/PluginScreen.h b/UI/PluginScreen.h index 54fc26e5d2..23bfcaca64 100644 --- a/UI/PluginScreen.h +++ b/UI/PluginScreen.h @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #pragma once + #include #include #include @@ -23,26 +24,11 @@ #include "ui/screen.h" #include "ui/ui.h" #include "ui/viewgroup.h" +#include "ui/ui_screen.h" #include "file/file_util.h" #include "net/http_client.h" -class UIScreen : public Screen { -public: - UIScreen() : Screen(), root_(0), orientationChanged_(false) {} - ~UIScreen() { delete root_; } - - virtual void update(InputState &input); - virtual void render(); - virtual void touch(const TouchInput &touch); - -protected: - virtual void CreateViews() = 0; - - UI::ViewGroup *root_; - bool orientationChanged_; -}; - class PluginScreen : public UIScreen { public: PluginScreen(); @@ -51,6 +37,7 @@ public: protected: virtual void CreateViews(); + virtual void DrawBackground(); private: UI::EventReturn OnDownload(UI::EventParams &e); diff --git a/native b/native index 244af95e8a..08f17083d7 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 244af95e8acbb94890065b60c7fe384e2709eca3 +Subproject commit 08f17083d71cd410b6cb625b574ec98457ef0dec