mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-20 18:34:58 +00:00
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:
parent
29ad2eca62
commit
a588bc5da8
10 changed files with 135 additions and 12 deletions
|
@ -68,6 +68,18 @@ public:
|
|||
|
||||
menu.addMenu(copyMenu);
|
||||
|
||||
// "Delete..." submenu.
|
||||
QMenu* deleteMenu = new QMenu(tr("Delete..."), widget);
|
||||
QAction* deleteGame = new QAction(tr("Delete Game"), widget);
|
||||
QAction* deleteUpdate = new QAction(tr("Delete Update"), widget);
|
||||
QAction* deleteDLC = new QAction(tr("Delete DLC"), widget);
|
||||
|
||||
deleteMenu->addAction(deleteGame);
|
||||
deleteMenu->addAction(deleteUpdate);
|
||||
deleteMenu->addAction(deleteDLC);
|
||||
|
||||
menu.addMenu(deleteMenu);
|
||||
|
||||
// Show menu.
|
||||
auto selected = menu.exec(global_pos);
|
||||
if (!selected) {
|
||||
|
@ -82,7 +94,13 @@ public:
|
|||
|
||||
if (selected == &openSfoViewer) {
|
||||
PSF psf;
|
||||
if (psf.Open(std::filesystem::path(m_games[itemID].path) / "sce_sys" / "param.sfo")) {
|
||||
QString game_update_path;
|
||||
Common::FS::PathToQString(game_update_path, m_games[itemID].path.concat("-UPDATE"));
|
||||
std::filesystem::path game_folder_path = m_games[itemID].path;
|
||||
if (std::filesystem::exists(Common::FS::PathFromQString(game_update_path))) {
|
||||
game_folder_path = Common::FS::PathFromQString(game_update_path);
|
||||
}
|
||||
if (psf.Open(game_folder_path / "sce_sys" / "param.sfo")) {
|
||||
int rows = psf.GetEntries().size();
|
||||
QTableWidget* tableWidget = new QTableWidget(rows, 2);
|
||||
tableWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -269,6 +287,55 @@ public:
|
|||
.arg(QString::fromStdString(m_games[itemID].size));
|
||||
clipboard->setText(combinedText);
|
||||
}
|
||||
|
||||
if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC) {
|
||||
bool error = false;
|
||||
QString folder_path, game_update_path;
|
||||
Common::FS::PathToQString(folder_path, m_games[itemID].path);
|
||||
Common::FS::PathToQString(game_update_path, m_games[itemID].path.concat("-UPDATE"));
|
||||
QString message_type = tr("Game");
|
||||
if (selected == deleteUpdate) {
|
||||
if (!Config::getSeparateUpdateEnabled()) {
|
||||
QMessageBox::critical(
|
||||
nullptr, tr("Error"),
|
||||
QString(tr("This feature requires the 'Enable Separate Update Folder' "
|
||||
"config option "
|
||||
"to work. If you want to use this feature, please enable it.")));
|
||||
error = true;
|
||||
} else if (!std::filesystem::exists(m_games[itemID].path.concat("-UPDATE"))) {
|
||||
QMessageBox::critical(nullptr, tr("Error"),
|
||||
QString(tr("This game has no update to delete!")));
|
||||
error = true;
|
||||
} else {
|
||||
folder_path = game_update_path;
|
||||
message_type = tr("Update");
|
||||
}
|
||||
} else if (selected == deleteDLC) {
|
||||
std::filesystem::path addon_path =
|
||||
Config::getAddonInstallDir() /
|
||||
Common::FS::PathFromQString(folder_path).parent_path().filename();
|
||||
if (!std::filesystem::exists(addon_path)) {
|
||||
QMessageBox::critical(nullptr, tr("Error"),
|
||||
QString(tr("This game has no DLC to delete!")));
|
||||
error = true;
|
||||
} else {
|
||||
folder_path = QString::fromStdString(addon_path.string());
|
||||
message_type = tr("DLC");
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
QString gameName = QString::fromStdString(m_games[itemID].name);
|
||||
QDir dir(folder_path);
|
||||
QMessageBox::StandardButton reply = QMessageBox::question(
|
||||
nullptr, QString(tr("Delete %1")).arg(message_type),
|
||||
QString(tr("Are you sure you want to delete %1's %2 directory?"))
|
||||
.arg(gameName, message_type),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (reply == QMessageBox::Yes) {
|
||||
dir.removeRecursively();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue