From adb2ebe87f8c85fb01d9e5f921f2b408814f75d5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 4 Jul 2015 08:40:40 -0700 Subject: [PATCH] Refresh buttons after installing homebrew. --- Core/Util/GameManager.h | 5 ++++- UI/Store.cpp | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Core/Util/GameManager.h b/Core/Util/GameManager.h index d5053a1446..4265ed4e14 100644 --- a/Core/Util/GameManager.h +++ b/Core/Util/GameManager.h @@ -41,7 +41,10 @@ public: // Returns false if no install is in progress. bool IsInstallInProgress() const { - return installInProgress_; + return installInProgress_ || IsDownloadInProgress(); + } + bool IsDownloadInProgress() const { + return curDownload_.get() != nullptr; } float GetCurrentInstallProgress() const { return installProgress_; diff --git a/UI/Store.cpp b/UI/Store.cpp index 2db234aaed..da715fa465 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -187,7 +187,8 @@ void ProductItemView::Update(const InputState &input_state) { // This is a "details" view of a game. Lets you install it. class ProductView : public UI::LinearLayout { public: - ProductView(const StoreEntry &entry) : LinearLayout(UI::ORIENT_VERTICAL), entry_(entry), installButton_(0) { + ProductView(const StoreEntry &entry) + : LinearLayout(UI::ORIENT_VERTICAL), entry_(entry), installButton_(0), wasInstalled_(false) { CreateViews(); } @@ -198,8 +199,13 @@ private: UI::EventReturn OnInstall(UI::EventParams &e); UI::EventReturn OnUninstall(UI::EventParams &e); + bool IsGameInstalled() { + return g_GameManager.IsGameInstalled(entry_.file); + } + StoreEntry entry_; UI::Button *installButton_; + bool wasInstalled_; }; void ProductView::CreateViews() { @@ -213,10 +219,12 @@ void ProductView::CreateViews() { Add(new TextView(entry_.author)); I18NCategory *st = GetI18NCategory("Store"); - if (!g_GameManager.IsGameInstalled(entry_.file)) { + wasInstalled_ = IsGameInstalled(); + if (!wasInstalled_) { installButton_ = Add(new Button(st->T("Install"))); installButton_->OnClick.Handle(this, &ProductView::OnInstall); } else { + installButton_ = nullptr; Add(new TextView(st->T("Already Installed"))); Add(new Button(st->T("Uninstall")))->OnClick.Handle(this, &ProductView::OnUninstall); } @@ -232,6 +240,12 @@ void ProductView::CreateViews() { } void ProductView::Update(const InputState &input_state) { + if (wasInstalled_ != IsGameInstalled()) { + CreateViews(); + } + if (installButton_) { + installButton_->SetEnabled(!g_GameManager.IsInstallInProgress()); + } View::Update(input_state); }