mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
More GameManager improvements.
This commit is contained in:
parent
aca0f35bdf
commit
66c3f31ff9
@ -30,6 +30,7 @@
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Util/GameManager.h"
|
||||
@ -116,9 +117,10 @@ void GameManager::Update() {
|
||||
return;
|
||||
}
|
||||
// Game downloaded to temporary file - install it!
|
||||
InstallGameOnThread(fileName, true);
|
||||
InstallGameOnThread(curDownload_->url(), fileName, true);
|
||||
} else {
|
||||
ERROR_LOG(HLE, "Expected HTTP status code 200, got status code %i. Install cancelled, deleting partial file.", curDownload_->ResultCode());
|
||||
ERROR_LOG(HLE, "Expected HTTP status code 200, got status code %d. Install cancelled, deleting partial file '%s'",
|
||||
curDownload_->ResultCode(), fileName.c_str());
|
||||
File::Delete(fileName.c_str());
|
||||
}
|
||||
curDownload_.reset();
|
||||
@ -203,7 +205,7 @@ ZipFileContents DetectZipFileContents(struct zip *z, ZipFileInfo *info) {
|
||||
}
|
||||
}
|
||||
|
||||
bool GameManager::InstallGame(std::string fileName, bool deleteAfter) {
|
||||
bool GameManager::InstallGame(std::string url, std::string fileName, bool deleteAfter) {
|
||||
if (installInProgress_) {
|
||||
ERROR_LOG(HLE, "Cannot have two installs in progress at the same time");
|
||||
return false;
|
||||
@ -214,9 +216,11 @@ bool GameManager::InstallGame(std::string fileName, bool deleteAfter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isRawISO = false; // TODO: Make it possible to pass in this information.
|
||||
if (isRawISO) {
|
||||
return InstallRawISO(fileName, fileName);
|
||||
// Examine the URL to guess out what we're installing.
|
||||
if (endsWithNoCase(url, ".cso") || endsWithNoCase(url, ".iso")) {
|
||||
// It's a raw ISO or CSO file. We just copy it to the destination.
|
||||
std::string shortFilename = GetFilenameFromPath(url);
|
||||
return InstallRawISO(fileName, shortFilename, deleteAfter);
|
||||
}
|
||||
|
||||
I18NCategory *sy = GetI18NCategory("System");
|
||||
@ -414,18 +418,23 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, std::string
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameManager::InstallGameOnThread(std::string zipFile, bool deleteAfter) {
|
||||
bool GameManager::InstallGameOnThread(std::string url, std::string fileName, bool deleteAfter) {
|
||||
if (installInProgress_) {
|
||||
return false;
|
||||
}
|
||||
installThread_.reset(new std::thread(std::bind(&GameManager::InstallGame, this, zipFile, deleteAfter)));
|
||||
installThread_.reset(new std::thread(std::bind(&GameManager::InstallGame, this, url, fileName, deleteAfter)));
|
||||
installThread_->detach();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameManager::InstallRawISO(std::string file, std::string originalName) {
|
||||
bool GameManager::InstallRawISO(std::string file, std::string originalName, bool deleteAfter) {
|
||||
std::string destPath = g_Config.currentDirectory + "/" + originalName;
|
||||
File::Copy(file, destPath);
|
||||
// TODO: To save disk space, we should probably attempt a move first.
|
||||
if (File::Copy(file, destPath)) {
|
||||
if (deleteAfter) {
|
||||
File::Delete(file.c_str());
|
||||
}
|
||||
}
|
||||
installProgress_ = 1.0f;
|
||||
installInProgress_ = false;
|
||||
installError_ = "";
|
||||
|
@ -66,13 +66,13 @@ public:
|
||||
}
|
||||
|
||||
// Only returns false if there's already an installation in progress.
|
||||
bool InstallGameOnThread(std::string zipFile, bool deleteAfter);
|
||||
bool InstallGameOnThread(std::string url, std::string tempFileName, bool deleteAfter);
|
||||
|
||||
private:
|
||||
bool InstallGame(std::string zipfile, bool deleteAfter);
|
||||
bool InstallGame(std::string url, std::string tempFileName, bool deleteAfter);
|
||||
bool InstallMemstickGame(struct zip *z, std::string zipFile, std::string pspGame, int numFiles, int stripChars, bool deleteAfter);
|
||||
bool InstallZippedISO(struct zip *z, int isoFileIndex, std::string zipfile, bool deleteAfter);
|
||||
bool InstallRawISO(std::string zipFile, std::string originalName);
|
||||
bool InstallRawISO(std::string zipFile, std::string originalName, bool deleteAfter);
|
||||
void InstallDone();
|
||||
bool ExtractFile(struct zip *z, int file_index, std::string outFilename, size_t *bytesCopied, size_t allBytes);
|
||||
|
||||
|
@ -81,7 +81,7 @@ bool InstallZipScreen::key(const KeyInput &key) {
|
||||
}
|
||||
|
||||
UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams ¶ms) {
|
||||
if (g_GameManager.InstallGameOnThread(zipPath_, deleteZipFile_)) {
|
||||
if (g_GameManager.InstallGameOnThread(zipPath_, zipPath_, deleteZipFile_)) {
|
||||
installStarted_ = true;
|
||||
installChoice_->SetEnabled(false);
|
||||
}
|
||||
|
13
UI/Store.cpp
13
UI/Store.cpp
@ -284,13 +284,16 @@ void ProductView::Update() {
|
||||
}
|
||||
|
||||
UI::EventReturn ProductView::OnInstall(UI::EventParams &e) {
|
||||
std::string zipUrl;
|
||||
std::string fileUrl;
|
||||
if (entry_.downloadURL.empty()) {
|
||||
// Construct the URL, easy to predict from our server
|
||||
zipUrl = storeBaseUrl + "files/" + entry_.file + ".zip";
|
||||
std::string shortName = entry_.file;
|
||||
if (shortName.find('.') == std::string::npos)
|
||||
shortName += ".zip";
|
||||
fileUrl = storeBaseUrl + "files/" + shortName;
|
||||
} else {
|
||||
// Use the provided URL, for external hosting.
|
||||
zipUrl = entry_.downloadURL;
|
||||
fileUrl = entry_.downloadURL;
|
||||
}
|
||||
if (installButton_) {
|
||||
installButton_->SetEnabled(false);
|
||||
@ -298,8 +301,8 @@ UI::EventReturn ProductView::OnInstall(UI::EventParams &e) {
|
||||
if (cancelButton_) {
|
||||
cancelButton_->SetVisibility(UI::V_VISIBLE);
|
||||
}
|
||||
INFO_LOG(SYSTEM, "Triggering install of %s", zipUrl.c_str());
|
||||
g_GameManager.DownloadAndInstall(zipUrl);
|
||||
INFO_LOG(SYSTEM, "Triggering install of '%s'", fileUrl.c_str());
|
||||
g_GameManager.DownloadAndInstall(fileUrl);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user