From e5090e36c2237ca1fd0ba33bc0142afdbdb147ae Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 2 Jun 2013 14:38:22 +0200 Subject: [PATCH] More plugin stuff --- Core/HW/atrac3plus.h | 3 ++- UI/PluginScreen.cpp | 21 +++++++++++++++++---- UI/PluginScreen.h | 11 ++++++++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Core/HW/atrac3plus.h b/Core/HW/atrac3plus.h index 8562ee2622..9d2c7cf41f 100644 --- a/Core/HW/atrac3plus.h +++ b/Core/HW/atrac3plus.h @@ -6,7 +6,8 @@ namespace Atrac3plus_Decoder { bool IsInstalled(); bool CanAutoInstall(); bool DoAutoInstall(); - + std::string GetInstalledFilename(); + int Init(); int Shutdown(); diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index 4219ec4076..86217d8526 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -24,9 +24,19 @@ #include "ui/view.h" #include "ui/viewgroup.h" #include "ui/ui_context.h" - +#include "Core/HW/atrac3plus.h" void UIScreen::update(InputState &input) { + if (!root_) { + CreateViews(); + } + + if (orientationChanged_) { + delete root_; + root_ = 0; + CreateViews(); + } + UpdateViewHierarchy(input, root_); } @@ -46,7 +56,9 @@ void UIScreen::touch(const TouchInput &touch) { PluginScreen::PluginScreen() { // Let's start by downloading the json. We'll find out in Update when it's finished. json_ = downloader_.StartDownload("http://www.ppsspp.org/update/at3plusdecoder.json", ""); +} +void PluginScreen::CreateViews() { I18NCategory *c = GetI18NCategory("Plugin"); // Build the UI. @@ -54,7 +66,6 @@ PluginScreen::PluginScreen() { root_ = new LinearLayout(ORIENT_VERTICAL); - Margins textMargins(20,17); tvDescription_ = root_->Add(new TextView(0, "Audio decoding support", ALIGN_HCENTER, 1.0f, new LinearLayoutParams(textMargins))); @@ -64,12 +75,14 @@ PluginScreen::PluginScreen() { "reverse engineered code in the US and some other countries.\n" "Choose \"More Information\" for more info.\n", ALIGN_LEFT, 1.0f, new LinearLayoutParams(1.0, textMargins))); + progress_ = root_->Add(new ProgressBar()); + ViewGroup *buttonBar = new LinearLayout(ORIENT_HORIZONTAL); root_->Add(buttonBar); buttonDownload_ = new Button(c->T("Download"), new LinearLayoutParams(1.0)); - buttonBar->Add(buttonDownload_)->OnClick.Add(std::bind(&PluginScreen::OnDownload, this, p::_1)); - buttonBar->Add(new Button(c->T("More Information"), new LinearLayoutParams(1.0)))->OnClick.Add(std::bind(&PluginScreen::OnInformation, this, p::_1)); + 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)); } void PluginScreen::update(InputState &input) { diff --git a/UI/PluginScreen.h b/UI/PluginScreen.h index 9948f71663..16249a7017 100644 --- a/UI/PluginScreen.h +++ b/UI/PluginScreen.h @@ -29,13 +29,18 @@ class UIScreen : public Screen { public: - UIScreen() : Screen(), root_(0) {} + 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 { @@ -43,6 +48,9 @@ public: PluginScreen(); virtual void update(InputState &input); + +protected: + virtual void CreateViews(); private: UI::EventReturn OnDownload(UI::EventParams &e); @@ -55,4 +63,5 @@ private: // UI widgets that need updating UI::TextView *tvDescription_; UI::Button *buttonDownload_; + UI::ProgressBar *progress_; }; \ No newline at end of file