Separate Updates from Game Folder (#1026)

* separate updates implementation

* clang format

clang format

clang format

clang format

clang hates me

work please

* hotfix: check for sfo file instead of the folder

* tiny change

* refactor

* forgot to change this over

* add review changes

* use operator
This commit is contained in:
ElBread3 2024-10-15 10:49:42 -05:00 committed by GitHub
parent 29ad2eca62
commit a588bc5da8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 135 additions and 12 deletions

View file

@ -676,10 +676,17 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
InstallDirSelect ids;
ids.exec();
auto game_install_dir = ids.getSelectedDirectory();
auto extract_path = game_install_dir / pkg.GetTitleID();
auto game_folder_path = game_install_dir / pkg.GetTitleID();
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
bool use_game_update = pkgType.contains("Patch") && Config::getSeparateUpdateEnabled();
auto game_update_path = use_game_update
? game_install_dir / (std::string(pkg.GetTitleID()) + "-UPDATE")
: game_folder_path;
if (!std::filesystem::exists(game_update_path)) {
std::filesystem::create_directory(game_update_path);
}
QString gameDirPath;
Common::FS::PathToQString(gameDirPath, extract_path);
Common::FS::PathToQString(gameDirPath, game_folder_path);
QDir game_dir(gameDirPath);
if (game_dir.exists()) {
QMessageBox msgBox;
@ -715,7 +722,11 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
return;
}
psf.Open(extract_path / "sce_sys" / "param.sfo");
std::filesystem::path sce_folder_path =
std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo")
? game_update_path / "sce_sys" / "param.sfo"
: game_folder_path / "sce_sys" / "param.sfo";
psf.Open(sce_folder_path);
QString game_app_version;
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
game_app_version = QString::fromStdString(std::string{*app_ver});
@ -764,7 +775,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
addonMsgBox.setDefaultButton(QMessageBox::No);
int result = addonMsgBox.exec();
if (result == QMessageBox::Yes) {
extract_path = addon_extract_path;
game_update_path = addon_extract_path;
} else {
return;
}
@ -775,12 +786,14 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
msgBox.setDefaultButton(QMessageBox::No);
int result = msgBox.exec();
if (result == QMessageBox::Yes) {
extract_path = addon_extract_path;
game_update_path = addon_extract_path;
} else {
return;
}
}
} else {
QString gameDirPath;
Common::FS::PathToQString(gameDirPath, game_folder_path);
msgBox.setText(QString(tr("Game already installed") + "\n" + gameDirPath + "\n" +
tr("Would you like to overwrite?")));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
@ -801,8 +814,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
}
// what else?
}
if (!pkg.Extract(file, extract_path, failreason)) {
if (!pkg.Extract(file, game_update_path, failreason)) {
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
} else {
int nfiles = pkg.GetNumberOfFiles();