Add a launch button to the homebrew store.

This commit is contained in:
Unknown W. Brackets 2015-07-04 09:05:17 -07:00
parent adb2ebe87f
commit d04a99b39f
2 changed files with 30 additions and 1 deletions

View file

@ -20,6 +20,7 @@
#include "ext/vjson/json.h"
#include "i18n/i18n.h"
#include "ui/screen.h"
#include "ui/ui_context.h"
#include "ui/viewgroup.h"
#include "gfx_es2/draw_buffer.h"
@ -27,6 +28,8 @@
#include "Common/Log.h"
#include "Common/StringUtils.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "UI/EmuScreen.h"
#include "UI/Store.h"
const std::string storeBaseUrl = "http://store.ppsspp.org/";
@ -194,10 +197,13 @@ public:
virtual void Update(const InputState &input_state);
UI::Event OnClickLaunch;
private:
void CreateViews();
UI::EventReturn OnInstall(UI::EventParams &e);
UI::EventReturn OnUninstall(UI::EventParams &e);
UI::EventReturn OnLaunchClick(UI::EventParams &e);
bool IsGameInstalled() {
return g_GameManager.IsGameInstalled(entry_.file);
@ -227,6 +233,7 @@ void ProductView::CreateViews() {
installButton_ = nullptr;
Add(new TextView(st->T("Already Installed")));
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?
@ -272,6 +279,19 @@ UI::EventReturn ProductView::OnUninstall(UI::EventParams &e) {
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) {
StoreFilter noFilter;
@ -401,7 +421,15 @@ UI::EventReturn StoreScreen::OnGameSelected(UI::EventParams &e) {
return UI::EVENT_DONE;
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;
}