Store: Implement progress bar for homebrew installs

This commit is contained in:
Henrik Rydgård 2024-01-22 10:27:44 +01:00
parent bd388fc094
commit c2850ff65a
45 changed files with 72 additions and 51 deletions

View File

@ -302,15 +302,12 @@ bool GameManager::InstallGame(const Path &url, const Path &fileName, bool delete
auto di = GetI18NCategory(I18NCat::DIALOG);
auto sy = GetI18NCategory(I18NCat::SYSTEM);
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 0.0f, 0.0f, 0.1f);
std::string extension = url.GetFileExtension();
// Examine the URL to guess out what we're installing.
if (extension == ".cso" || extension == ".iso") {
// It's a raw ISO or CSO file. We just copy it to the destination.
std::string shortFilename = url.GetFilename();
bool success = InstallRawISO(fileName, shortFilename, deleteAfter);
g_OSD.RemoveProgressBar("install", success, 0.5f);
return success;
}
@ -569,9 +566,12 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const
return true;
};
auto di = GetI18NCategory(I18NCat::DIALOG);
// Create all the directories first in one pass
std::set<Path> createdDirs;
for (int i = 0; i < info.numFiles; i++) {
// Let's count the directories as the first 10%.
const char *fn = zip_get_name(z, i, 0);
std::string zippedName = fn;
if (zippedName.length() < (size_t)info.stripChars) {
@ -597,6 +597,7 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const
allBytes += zstat.size;
}
}
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, info.numFiles, (i + 1) * 0.1f, 0.1f);
}
// Now, loop through again in a second pass, writing files.
@ -620,7 +621,9 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const
createdFiles.push_back(outFilename);
}
}
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 1.0f, 0.1f + (i + 1) / (float)info.numFiles * 0.9f, 0.1f);
}
INFO_LOG(HLE, "Extracted %d files from zip (%d bytes / %d).", info.numFiles, (int)bytesCopied, (int)allBytes);
zip_close(z);
z = nullptr;
@ -631,6 +634,7 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const
}
InstallDone();
ResetInstallError();
g_OSD.RemoveProgressBar("install", true, 0.5f);
return true;
bail:
@ -644,6 +648,7 @@ bail:
File::DeleteDir(iter);
}
SetInstallError(sy->T("Storage full"));
g_OSD.RemoveProgressBar("install", false, 0.5f);
return false;
}
@ -670,6 +675,8 @@ bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const P
return false;
}
auto di = GetI18NCategory(I18NCat::DIALOG);
const size_t blockSize = 1024 * 128;
u8 *buffer = new u8[blockSize];
while (bytesCopied < allBytes) {
@ -680,6 +687,7 @@ bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const P
break;
bytesCopied += readSize;
installProgress_ = (float)bytesCopied / (float)allBytes;
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 1.0f, installProgress_, 0.1f);
}
delete[] buffer;
@ -688,6 +696,7 @@ bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const P
if (bytesCopied < allBytes) {
File::Delete(dest);
g_OSD.RemoveProgressBar("install", false, 0.5f);
SetInstallError(sy->T("Storage full"));
return false;
}
@ -698,6 +707,7 @@ bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const P
}
InstallDone();
ResetInstallError();
g_OSD.RemoveProgressBar("install", true, 0.5f);
return true;
}
@ -718,13 +728,19 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path &
Path outputISOFilename = Path(g_Config.currentDirectory) / fn.substr(nameOffset);
size_t bytesCopied = 0;
bool success = false;
auto di = GetI18NCategory(I18NCat::DIALOG);
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 0.0f, 0.0f, 0.1f);
if (ExtractFile(z, isoFileIndex, outputISOFilename, &bytesCopied, allBytes)) {
INFO_LOG(IO, "Successfully extracted ISO file to '%s'", outputISOFilename.c_str());
success = true;
}
zip_close(z);
if (deleteAfter) {
if (success && deleteAfter) {
File::Delete(zipfile);
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 0.0f, 0.0f, 0.1f);
}
g_OSD.RemoveProgressBar("install", success, 0.5f);
z = 0;
installProgress_ = 1.0f;
@ -755,11 +771,16 @@ bool GameManager::UninstallGameOnThread(const std::string &name) {
bool GameManager::InstallRawISO(const Path &file, const std::string &originalName, bool deleteAfter) {
Path destPath = Path(g_Config.currentDirectory) / originalName;
auto di = GetI18NCategory(I18NCat::DIALOG);
g_OSD.SetProgressBar("install", di->T("Installing..."), 0.0f, 0.0f, 0.0f, 0.1f);
// TODO: To save disk space, we should probably attempt a move first.
if (File::Copy(file, destPath)) {
if (deleteAfter) {
File::Delete(file);
}
g_OSD.RemoveProgressBar("install", true, 0.5f);
} else {
g_OSD.RemoveProgressBar("install", false, 0.5f);
}
installProgress_ = 1.0f;
InstallDone();

View File

@ -311,15 +311,15 @@ void ProductView::CreateViews() {
} else {
installButton_ = nullptr;
speedView_ = nullptr;
Add(new TextView(st->T("Already Installed")));
launchButton_ = new Button(st->T("Launch Game"));
launchButton_->OnClick.Handle(this, &ProductView::OnLaunchClick);
Add(launchButton_);
uninstallButton_ = new Button(st->T("Uninstall"));
Add(uninstallButton_)->OnClick.Add([=](UI::EventParams &e) {
g_GameManager.UninstallGameOnThread(entry_.file);
return UI::EVENT_DONE;
});
launchButton_ = new Button(st->T("Launch Game"));
launchButton_->OnClick.Handle(this, &ProductView::OnLaunchClick);
Add(launchButton_);
Add(new TextView(st->T("Installed")));
}
cancelButton_ = Add(new Button(di->T("Cancel")));

View File

@ -1168,9 +1168,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = ‎مثبتة بالفعل
Connection Error = ‎خطأ في الإتصال
Install = ‎تثبيت
Installed = ‎مثبتة بالفعل
Launch Game = ‎إبدء اللعبة
Loading... = ‎تحميل...
MB = ‎ميجا

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Вече е инсталирано
Connection Error = Грешка при свързването
Install = Инсталирай
Installed = Вече е инсталирано
Launch Game = Launch game
Loading... = Зареждане...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = Cap paràmetre coincideix '%1'
Search term = Search term
[Store]
Already Installed = Ja instal·lat
Connection Error = Error de connexió
Install = Instal·lar
Installed = Ja instal·lat
Launch Game = Iniciar joc
Loading... = Carregant...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Již instalováno
Connection Error = Chyba připojení
Install = Nainstalovat
Installed = Již instalováno
Launch Game = Spustit hru
Loading... = Načítání...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Allerede installeret
Connection Error = Forbindelsesfejl
Install = Installer
Installed = Allerede installeret
Launch Game = Start spil
Loading... = Henter...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = Keine Übereinstimmungen mit '%1'
Search term = Suchbegriff
[Store]
Already Installed = Bereits installiert
Connection Error = Verbindungsfehler
Install = Installieren
Installed = Bereits installiert
Launch Game = Spiel starten
Loading... = Lade...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1176,9 +1176,9 @@ State load undone = State load undone
Untitled PSP game = Untitled PSP game
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1161,9 +1161,9 @@ No settings matched '%1' = Ningún ajuste coincide '%1'
Search term = Buscar término
[Store]
Already Installed = Ya instalado
Connection Error = Error de conexión
Install = Instalar
Installed = Ya instalado
Launch Game = Iniciar juego
Loading... = Cargando...
MB = MB

View File

@ -1162,9 +1162,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Ya instalado
Connection Error = Error de conexión
Install = Instalar
Installed = Ya instalado
Launch Game = Lanzar juego
Loading... = Cargando...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = Ei löytynyt asetuksia hakusanalla '%1'
Search term = Hakusana
[Store]
Already Installed = Jo asennettu
Connection Error = Yhteysvirhe
Install = Asenna
Installed = Jo asennettu
Launch Game = Käynnistä peli
Loading... = Ladataan...
MB = Mt

View File

@ -1151,9 +1151,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Déjà installé
Connection Error = Erreur de connexion
Install = Installer
Installed = Déjà installé
Launch Game = Lancer le jeu
Loading... = Chargement...
MB = Mo

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Xa instalado
Connection Error = Erro de conexión
Install = Instalar
Installed = Xa instalado
Launch Game = Launch game
Loading... = Cargando...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Ήδη εγκατεστημένο
Connection Error = Σφάλμα σύνδεσης
Install = Εγκατάσταση
Installed = Ήδη εγκατεστημένο
Launch Game = Έναρξη παιχνιδιού
Loading... = Φόρτωση...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Već instalirano
Connection Error = Pogreška u spajanju
Install = Instaliraj
Installed = Već instalirano
Launch Game = Pokreni igru
Loading... = Učitavanje...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Már telepítve
Connection Error = Kapcsolódási hiba
Install = Telepítés
Installed = Már telepítve
Launch Game = Játék indítása
Loading... = Töltés...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Sudah terpasang
Connection Error = Kesalahan pada koneksi
Install = Pasang
Installed = Sudah terpasang
Launch Game = Jalankan permainan
Loading... = Memuat...
MB = MB

View File

@ -1161,9 +1161,9 @@ No settings matched '%1' = Nessuna impostazione con corrispondenza: '%1'
Search term = Cerca termine
[Store]
Already Installed = Già installato
Connection Error = Errore di connessione
Install = Installa
Installed = Già installato
Launch Game = Avvia il gioco
Loading... = Caricamento...
MB = MB

View File

@ -1160,9 +1160,9 @@ Clear filter = 検索文字のクリア
Search term = Search term
[Store]
Already Installed = インストール済み
Connection Error = 接続エラー
Install = インストールする
Installed = インストール済み
Launch Game = ゲームを起動する
Loading... = ロードしています...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Mpun terpasang
Connection Error = Galat koneksi
Install = Nginstal
Installed = Mpun terpasang
Launch Game = Bukak Dolanan
Loading... = Nteni...
MB = MB

View File

@ -1152,9 +1152,9 @@ State load undone = 상태 불러오기 취소
Untitled PSP game = 제목 없는 PSP 게임
[Store]
Already Installed = 이미 설치됨
Connection Error = 연결 오류
Install = 설치
Installed = 이미 설치됨
Launch Game = 게임 실행
Loading... = 불러오기 중...
MB = 메가바이트

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = ຕິດຕັ້ງຮຽບຮ້ອຍແລ້ວ
Connection Error = ການເຊື່ອມຕໍ່ລົ້ມເຫຼວ
Install = ຕິດຕັ້ງ
Installed = ຕິດຕັ້ງຮຽບຮ້ອຍແລ້ວ
Launch Game = ເລີ່ມເກມ
Loading... = ກຳລັງໂຫຼດ...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Jau instaliuota
Connection Error = Prisijungimo klaida
Install = Instaliuoti
Installed = Jau instaliuota
Launch Game = Paleisti žaidimą
Loading... = Kraunama...
MB = Megabaitai

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Telah dipasang sebelumnya
Connection Error = Kesalahan Sambungan
Install = Pasang
Installed = Telah dipasang sebelumnya
Launch Game = Launch game
Loading... = Memuatkan...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Al geïnstalleerd
Connection Error = Verbindingsfout
Install = Installeren
Installed = Al geïnstalleerd
Launch Game = Game starten
Loading... = Laden
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already installed
Connection Error = Connection error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1166,9 +1166,9 @@ No settings matched '%1' = Brak wyników dla '%1'
Search term = Wyszukaj frazę
[Store]
Already Installed = Zainstalowane
Connection Error = Błąd połączenia
Install = Zainstaluj
Installed = Zainstalowane
Launch Game = Rozpocznij grę
Loading... = Ładowanie...
MB = MB

View File

@ -1176,9 +1176,9 @@ State load undone = Carregamento do state desfeito
Untitled PSP game = Jogo de PSP sem título
[Store]
Already Installed = Já instalado
Connection Error = Erro de conexão
Install = Instalar
Installed = Já instalado
Launch Game = Iniciar jogo
Loading... = Carregando...
MB = MBs

View File

@ -1178,9 +1178,9 @@ State load undone = Carregamento do estado desfeito
Untitled PSP game = Jogo de PSP sem título
[Store]
Already Installed = Já instalado
Connection Error = Erro de conexão
Install = Instalar
Installed = Já instalado
Launch Game = Iniciar jogo
Loading... = Carregando...
MB = MBs

View File

@ -1161,9 +1161,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Deja instalat
Connection Error = Eroare de conexiune
Install = Instalare
Installed = Deja instalat
Launch Game = Launch game
Loading... = Se încarcă...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = Нет настроек, содержащих '%1'
Search term = Поисковый запрос
[Store]
Already Installed = Уже установлено
Connection Error = Ошибка подключения
Install = Установить
Installed = Уже установлено
Launch Game = Запустить игру
Loading... = Загрузка...
MB = Мб

View File

@ -1161,9 +1161,9 @@ No settings matched '%1' = Inga inställningar matchade '%1'
Search term = Sökterm
[Store]
Already Installed = Redan installerad
Connection Error = Uppkopplingsfel
Install = Installera
Installed = Installerad
Launch Game = Starta spel
Loading... = Laddar...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Already Installed
Connection Error = Connection Error
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB

View File

@ -1164,9 +1164,9 @@ No settings matched '%1' = ไม่มีตั้งค่าที่ตร
Search term = คำที่ต้องการค้นหา
[Store]
Already Installed = ติดตั้งเรียบร้อยแล้ว
Connection Error = การเชื่อมต่อล้มเหลว
Install = ติดตั้ง
Installed = ติดตั้งเรียบร้อยแล้ว
Launch Game = เริ่มเกม
Loading... = กำลังโหลด...
MB = เมกกะไบต์

View File

@ -1161,9 +1161,9 @@ No settings matched '%1' = '%1' ile eşleşen ayar yok
Search term = Search term
[Store]
Already Installed = Zaten yüklü
Connection Error = Bağlantı hatası
Install = Yükle
Installed = Zaten yüklü
Launch Game = Oyunu başlat
Loading... = Yükleniyor...
MB = MB

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Вже встановлено
Connection Error = Помилка підключення
Install = Встановити
Installed = Вже встановлено
Launch Game = Запустити гри
Loading... = Завантаження...
MB = Мб

View File

@ -1160,9 +1160,9 @@ No settings matched '%1' = No settings matched '%1'
Search term = Search term
[Store]
Already Installed = Đã cài rồi
Connection Error = Lỗi kết nối
Install = Cài
Installed = Đã cài rồi
Launch Game = Launch game
Loading... = Đang load...
MB = MB

View File

@ -1153,9 +1153,9 @@ State load undone = 撤销即时存档读取
Untitled PSP game = 无标题的PSP游戏
[Store]
Already Installed = 已安装
Connection Error = 网络错误
Install = 安装
Installed = 已安装
Launch Game = 开始游戏
Loading... = 载入中…
MB = MB

View File

@ -1152,9 +1152,9 @@ State load undone = 存檔載入復原
Untitled PSP game = 未命名 PSP 遊戲
[Store]
Already Installed = 已安裝
Connection Error = 連線錯誤
Install = 安裝
Installed = 已安裝
Launch Game = 啟動遊戲
Loading... = 正在載入…
MB = MB