Add a launch button to the homebrew store.
This commit is contained in:
parent
adb2ebe87f
commit
d04a99b39f
2 changed files with 30 additions and 1 deletions
30
UI/Store.cpp
30
UI/Store.cpp
|
@ -20,6 +20,7 @@
|
||||||
#include "ext/vjson/json.h"
|
#include "ext/vjson/json.h"
|
||||||
|
|
||||||
#include "i18n/i18n.h"
|
#include "i18n/i18n.h"
|
||||||
|
#include "ui/screen.h"
|
||||||
#include "ui/ui_context.h"
|
#include "ui/ui_context.h"
|
||||||
#include "ui/viewgroup.h"
|
#include "ui/viewgroup.h"
|
||||||
#include "gfx_es2/draw_buffer.h"
|
#include "gfx_es2/draw_buffer.h"
|
||||||
|
@ -27,6 +28,8 @@
|
||||||
#include "Common/Log.h"
|
#include "Common/Log.h"
|
||||||
#include "Common/StringUtils.h"
|
#include "Common/StringUtils.h"
|
||||||
#include "Core/Config.h"
|
#include "Core/Config.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "UI/EmuScreen.h"
|
||||||
#include "UI/Store.h"
|
#include "UI/Store.h"
|
||||||
|
|
||||||
const std::string storeBaseUrl = "http://store.ppsspp.org/";
|
const std::string storeBaseUrl = "http://store.ppsspp.org/";
|
||||||
|
@ -194,10 +197,13 @@ public:
|
||||||
|
|
||||||
virtual void Update(const InputState &input_state);
|
virtual void Update(const InputState &input_state);
|
||||||
|
|
||||||
|
UI::Event OnClickLaunch;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateViews();
|
void CreateViews();
|
||||||
UI::EventReturn OnInstall(UI::EventParams &e);
|
UI::EventReturn OnInstall(UI::EventParams &e);
|
||||||
UI::EventReturn OnUninstall(UI::EventParams &e);
|
UI::EventReturn OnUninstall(UI::EventParams &e);
|
||||||
|
UI::EventReturn OnLaunchClick(UI::EventParams &e);
|
||||||
|
|
||||||
bool IsGameInstalled() {
|
bool IsGameInstalled() {
|
||||||
return g_GameManager.IsGameInstalled(entry_.file);
|
return g_GameManager.IsGameInstalled(entry_.file);
|
||||||
|
@ -227,6 +233,7 @@ void ProductView::CreateViews() {
|
||||||
installButton_ = nullptr;
|
installButton_ = nullptr;
|
||||||
Add(new TextView(st->T("Already Installed")));
|
Add(new TextView(st->T("Already Installed")));
|
||||||
Add(new Button(st->T("Uninstall")))->OnClick.Handle(this, &ProductView::OnUninstall);
|
Add(new Button(st->T("Uninstall")))->OnClick.Handle(this, &ProductView::OnUninstall);
|
||||||
|
Add(new Button(st->T("Launch Game")))->OnClick.Handle(this, &ProductView::OnLaunchClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add star rating, comments etc?
|
// Add star rating, comments etc?
|
||||||
|
@ -272,6 +279,19 @@ UI::EventReturn ProductView::OnUninstall(UI::EventParams &e) {
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI::EventReturn ProductView::OnLaunchClick(UI::EventParams &e) {
|
||||||
|
std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
|
||||||
|
std::string path = pspGame + entry_.file;
|
||||||
|
#ifdef _WIN32
|
||||||
|
path = ReplaceAll(path, "\\", "/");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UI::EventParams e2;
|
||||||
|
e2.s = path;
|
||||||
|
// Insta-update - here we know we are already on the right thread.
|
||||||
|
OnClickLaunch.Trigger(e2);
|
||||||
|
return UI::EVENT_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
StoreScreen::StoreScreen() : loading_(true), connectionError_(false) {
|
StoreScreen::StoreScreen() : loading_(true), connectionError_(false) {
|
||||||
StoreFilter noFilter;
|
StoreFilter noFilter;
|
||||||
|
@ -401,7 +421,15 @@ UI::EventReturn StoreScreen::OnGameSelected(UI::EventParams &e) {
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
|
|
||||||
productPanel_->Clear();
|
productPanel_->Clear();
|
||||||
productPanel_->Add(new ProductView(item->GetEntry()));
|
ProductView *productView = new ProductView(item->GetEntry());
|
||||||
|
productView->OnClickLaunch.Handle(this, &StoreScreen::OnGameLaunch);
|
||||||
|
productPanel_->Add(productView);
|
||||||
|
return UI::EVENT_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
UI::EventReturn StoreScreen::OnGameLaunch(UI::EventParams &e) {
|
||||||
|
std::string path = e.s;
|
||||||
|
screenManager()->switchScreen(new EmuScreen(path));
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ protected:
|
||||||
UI::EventReturn OnGameSelected(UI::EventParams &e);
|
UI::EventReturn OnGameSelected(UI::EventParams &e);
|
||||||
UI::EventReturn OnCategorySelected(UI::EventParams &e);
|
UI::EventReturn OnCategorySelected(UI::EventParams &e);
|
||||||
UI::EventReturn OnRetry(UI::EventParams &e);
|
UI::EventReturn OnRetry(UI::EventParams &e);
|
||||||
|
UI::EventReturn OnGameLaunch(UI::EventParams &e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetFilter(const StoreFilter &filter);
|
void SetFilter(const StoreFilter &filter);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue