More refactoring of installzip code

This commit is contained in:
Henrik Rydgård committed 2024-09-04 17:08:26 +02:00
1 parent 472a812ff5
commit db550fc433
4 files changed
+87 -54

No files matched your search

+9 -5
View File
@@ -50,10 +50,9 @@ void InstallZipScreen::CreateViews() {
std::string shortFilename = zipPath_.GetFilename();
// TODO: Do in the background?
ZipFileInfo zipInfo{};
DetectZipFileContents(zipPath_, &zipInfo); // Even if this fails, it sets zipInfo->contents.
DetectZipFileContents(zipPath_, &zipFileInfo_); // Even if this fails, it sets zipInfo->contents.
if (zipInfo.contents == ZipFileContents::ISO_FILE || zipInfo.contents == ZipFileContents::PSP_GAME_DIR) {
if (zipFileInfo_.contents == ZipFileContents::ISO_FILE || zipFileInfo_.contents == ZipFileContents::PSP_GAME_DIR) {
std::string_view question = iz->T("Install game from ZIP file?");
leftColumn->Add(new TextView(question, ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
leftColumn->Add(new TextView(shortFilename, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
@@ -67,7 +66,7 @@ void InstallZipScreen::CreateViews() {
rightColumnItems->Add(new CheckBox(&deleteZipFile_, iz->T("Delete ZIP file")));
returnToHomebrew_ = true;
} else if (zipInfo.contents == ZipFileContents::TEXTURE_PACK) {
} else if (zipFileInfo_.contents == ZipFileContents::TEXTURE_PACK) {
std::string_view question = iz->T("Install textures from ZIP file?");
leftColumn->Add(new TextView(question, ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
leftColumn->Add(new TextView(shortFilename, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
@@ -102,7 +101,12 @@ bool InstallZipScreen::key(const KeyInput &key) {
}
UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams &params) {
if (g_GameManager.InstallGameOnThread(zipPath_, zipPath_, deleteZipFile_)) {
ZipFileTask task;
task.url = zipPath_;
task.fileName = zipPath_;
task.deleteAfter = deleteZipFile_;
task.zipFileInfo = zipFileInfo_;
if (g_GameManager.InstallZipOnThread(task)) {
installStarted_ = true;
if (installChoice_) {
installChoice_->SetEnabled(false);