2013-12-05 13:14:15 +00:00
|
|
|
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "i18n/i18n.h"
|
|
|
|
#include "ui/ui.h"
|
|
|
|
#include "ui/view.h"
|
|
|
|
#include "ui/viewgroup.h"
|
|
|
|
#include "UI/ui_atlas.h"
|
|
|
|
#include "file/file_util.h"
|
|
|
|
|
2013-12-05 15:04:50 +00:00
|
|
|
#include "Core/Util/GameManager.h"
|
2013-12-05 13:14:15 +00:00
|
|
|
#include "UI/InstallZipScreen.h"
|
2013-12-06 11:29:27 +00:00
|
|
|
#include "UI/MainScreen.h"
|
2013-12-05 13:14:15 +00:00
|
|
|
|
|
|
|
void InstallZipScreen::CreateViews() {
|
|
|
|
using namespace UI;
|
|
|
|
|
|
|
|
FileInfo fileInfo;
|
|
|
|
bool success = getFileInfo(zipPath_.c_str(), &fileInfo);
|
|
|
|
|
|
|
|
I18NCategory *di = GetI18NCategory("Dialog");
|
2013-12-05 16:49:37 +00:00
|
|
|
I18NCategory *iz = GetI18NCategory("InstallZip");
|
2013-12-05 13:14:15 +00:00
|
|
|
|
|
|
|
Margins actionMenuMargins(0, 100, 15, 0);
|
|
|
|
|
|
|
|
root_ = new LinearLayout(ORIENT_HORIZONTAL);
|
|
|
|
|
|
|
|
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
|
|
|
|
root_->Add(leftColumn);
|
|
|
|
|
2013-12-05 16:49:37 +00:00
|
|
|
leftColumn->Add(new TextView(iz->T("Install game from ZIP file?"), ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
|
2013-12-05 13:14:15 +00:00
|
|
|
leftColumn->Add(new TextView(zipPath_, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
|
2013-12-06 11:49:57 +00:00
|
|
|
|
|
|
|
doneView_ = leftColumn->Add(new TextView("", new AnchorLayoutParams(10, 120, NONE, NONE)));
|
2013-12-05 16:49:37 +00:00
|
|
|
progressBar_ = leftColumn->Add(new ProgressBar(new AnchorLayoutParams(10, 200, 200, NONE)));
|
2013-12-05 13:14:15 +00:00
|
|
|
|
|
|
|
ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
|
|
|
|
root_->Add(rightColumnItems);
|
|
|
|
|
2013-12-05 16:49:37 +00:00
|
|
|
installChoice_ = rightColumnItems->Add(new Choice(iz->T("Install")));
|
2013-12-05 13:14:15 +00:00
|
|
|
installChoice_->OnClick.Handle(this, &InstallZipScreen::OnInstall);
|
2013-12-05 16:49:37 +00:00
|
|
|
backChoice_ = rightColumnItems->Add(new Choice(di->T("Back")));
|
|
|
|
backChoice_->OnClick.Handle<UIScreen>(this, &UIScreen::OnOK); // OK so that EmuScreen will handle it right
|
|
|
|
|
|
|
|
rightColumnItems->Add(new CheckBox(&deleteZipFile_, iz->T("Delete ZIP file")));
|
|
|
|
}
|
|
|
|
|
2014-06-15 11:04:59 +00:00
|
|
|
bool InstallZipScreen::key(const KeyInput &key) {
|
2017-03-06 14:43:38 +00:00
|
|
|
// Ignore all key presses during download and installation to avoid user escape
|
|
|
|
if (g_GameManager.GetState() == GameManagerState::IDLE) {
|
2014-06-15 11:04:59 +00:00
|
|
|
return UIScreen::key(key);
|
2013-12-05 16:49:37 +00:00
|
|
|
}
|
2014-06-15 11:04:59 +00:00
|
|
|
return false;
|
2013-12-05 13:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams ¶ms) {
|
2013-12-05 16:49:37 +00:00
|
|
|
if (g_GameManager.InstallGameOnThread(zipPath_, deleteZipFile_)) {
|
|
|
|
installStarted_ = true;
|
|
|
|
installChoice_->SetEnabled(false);
|
2013-12-05 13:14:15 +00:00
|
|
|
}
|
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
|
|
|
|
2017-03-15 05:01:18 +00:00
|
|
|
void InstallZipScreen::update() {
|
2013-12-06 11:49:57 +00:00
|
|
|
I18NCategory *iz = GetI18NCategory("InstallZip");
|
|
|
|
|
2013-12-05 16:49:37 +00:00
|
|
|
using namespace UI;
|
2017-03-06 14:43:38 +00:00
|
|
|
if (g_GameManager.GetState() != GameManagerState::IDLE) {
|
2013-12-05 16:49:37 +00:00
|
|
|
progressBar_->SetVisibility(V_VISIBLE);
|
2017-03-06 14:43:38 +00:00
|
|
|
progressBar_->SetProgress(g_GameManager.GetCurrentInstallProgressPercentage());
|
2013-12-05 16:49:37 +00:00
|
|
|
backChoice_->SetEnabled(false);
|
|
|
|
} else {
|
|
|
|
progressBar_->SetVisibility(V_GONE);
|
|
|
|
backChoice_->SetEnabled(true);
|
2013-12-06 11:49:57 +00:00
|
|
|
std::string err = g_GameManager.GetInstallError();
|
|
|
|
if (!err.empty()) {
|
|
|
|
doneView_->SetText(iz->T(err.c_str()));
|
2013-12-06 14:29:14 +00:00
|
|
|
} else if (installStarted_) {
|
|
|
|
doneView_->SetText(iz->T("Installed!"));
|
|
|
|
MainScreen::showHomebrewTab = true;
|
2013-12-06 11:49:57 +00:00
|
|
|
}
|
2013-12-05 16:49:37 +00:00
|
|
|
}
|
2017-03-15 05:01:18 +00:00
|
|
|
UIScreen::update();
|
2013-12-05 13:14:15 +00:00
|
|
|
}
|