mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-24 03:16:17 +00:00
code: Remove fpkg code
Signed-off-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
parent
d339b3f7d6
commit
be22674f8c
14 changed files with 31 additions and 2015 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <QKeyEvent>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QProgressDialog>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "about_dialog.h"
|
||||
#include "cheats_patches.h"
|
||||
|
@ -19,7 +20,6 @@
|
|||
#include "common/string_util.h"
|
||||
#include "common/version.h"
|
||||
#include "control_settings.h"
|
||||
#include "core/file_format/pkg.h"
|
||||
#include "core/loader.h"
|
||||
#include "game_install_dialog.h"
|
||||
#include "install_dir_select.h"
|
||||
|
@ -718,7 +718,6 @@ void MainWindow::CreateConnects() {
|
|||
});
|
||||
|
||||
// Package install.
|
||||
connect(ui->bootInstallPkgAct, &QAction::triggered, this, &MainWindow::InstallPkg);
|
||||
connect(ui->bootGameAct, &QAction::triggered, this, &MainWindow::BootGame);
|
||||
connect(ui->gameInstallPathAct, &QAction::triggered, this, &MainWindow::InstallDirectory);
|
||||
|
||||
|
@ -726,15 +725,6 @@ void MainWindow::CreateConnects() {
|
|||
connect(ui->addElfFolderAct, &QAction::triggered, m_elf_viewer.data(),
|
||||
&ElfViewer::OpenElfFolder);
|
||||
|
||||
// Package Viewer.
|
||||
connect(ui->pkgViewerAct, &QAction::triggered, this, [this]() {
|
||||
PKGViewer* pkgViewer = new PKGViewer(
|
||||
m_game_info, this, [this](std::filesystem::path file, int pkgNum, int nPkg) {
|
||||
this->InstallDragDropPkg(file, pkgNum, nPkg);
|
||||
});
|
||||
pkgViewer->show();
|
||||
});
|
||||
|
||||
// Trophy Viewer
|
||||
connect(ui->trophyViewerAct, &QAction::triggered, this, [this]() {
|
||||
if (m_game_info->m_games.empty()) {
|
||||
|
@ -965,22 +955,6 @@ void MainWindow::SaveWindowState() const {
|
|||
this->geometry().width(), this->geometry().height());
|
||||
}
|
||||
|
||||
void MainWindow::InstallPkg() {
|
||||
QFileDialog dialog;
|
||||
dialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
dialog.setNameFilter(tr("PKG File (*.PKG *.pkg)"));
|
||||
if (dialog.exec()) {
|
||||
QStringList fileNames = dialog.selectedFiles();
|
||||
int nPkg = fileNames.size();
|
||||
int pkgNum = 0;
|
||||
for (const QString& file : fileNames) {
|
||||
++pkgNum;
|
||||
std::filesystem::path path = Common::FS::PathFromQString(file);
|
||||
MainWindow::InstallDragDropPkg(path, pkgNum, nPkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::BootGame() {
|
||||
QFileDialog dialog;
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
@ -1004,260 +978,6 @@ void MainWindow::BootGame() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg) {
|
||||
if (Loader::DetectFileType(file) == Loader::FileTypes::Pkg) {
|
||||
std::string failreason;
|
||||
pkg = PKG();
|
||||
if (!pkg.Open(file, failreason)) {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
|
||||
return;
|
||||
}
|
||||
if (!psf.Open(pkg.sfo)) {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"),
|
||||
"Could not read SFO. Check log for details");
|
||||
return;
|
||||
}
|
||||
auto category = psf.GetString("CATEGORY");
|
||||
|
||||
if (!use_for_all_queued || pkgNum == 1) {
|
||||
InstallDirSelect ids;
|
||||
const auto selected = ids.exec();
|
||||
if (selected == QDialog::Rejected) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_install_dir = ids.getSelectedDirectory();
|
||||
delete_file_on_install = ids.deleteFileOnInstall();
|
||||
use_for_all_queued = ids.useForAllQueued();
|
||||
}
|
||||
std::filesystem::path game_install_dir = last_install_dir;
|
||||
|
||||
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
|
||||
bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled();
|
||||
|
||||
// Default paths
|
||||
auto game_folder_path = game_install_dir / pkg.GetTitleID();
|
||||
auto game_update_path = use_game_update ? game_folder_path.parent_path() /
|
||||
(std::string{pkg.GetTitleID()} + "-patch")
|
||||
: game_folder_path;
|
||||
const int max_depth = 5;
|
||||
|
||||
if (pkgType.contains("PATCH")) {
|
||||
// For patches, try to find the game recursively
|
||||
auto found_game = Common::FS::FindGameByID(game_install_dir,
|
||||
std::string{pkg.GetTitleID()}, max_depth);
|
||||
if (found_game.has_value()) {
|
||||
game_folder_path = found_game.value().parent_path();
|
||||
game_update_path = use_game_update ? game_folder_path.parent_path() /
|
||||
(std::string{pkg.GetTitleID()} + "-patch")
|
||||
: game_folder_path;
|
||||
}
|
||||
} else {
|
||||
// For base games, we check if the game is already installed
|
||||
auto found_game = Common::FS::FindGameByID(game_install_dir,
|
||||
std::string{pkg.GetTitleID()}, max_depth);
|
||||
if (found_game.has_value()) {
|
||||
game_folder_path = found_game.value().parent_path();
|
||||
}
|
||||
// If the game is not found, we install it in the game install directory
|
||||
else {
|
||||
game_folder_path = game_install_dir / pkg.GetTitleID();
|
||||
}
|
||||
game_update_path = use_game_update ? game_folder_path.parent_path() /
|
||||
(std::string{pkg.GetTitleID()} + "-patch")
|
||||
: game_folder_path;
|
||||
}
|
||||
|
||||
QString gameDirPath;
|
||||
Common::FS::PathToQString(gameDirPath, game_folder_path);
|
||||
QDir game_dir(gameDirPath);
|
||||
if (game_dir.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("PKG Extraction"));
|
||||
|
||||
std::string content_id;
|
||||
if (auto value = psf.GetString("CONTENT_ID"); value.has_value()) {
|
||||
content_id = std::string{*value};
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no CONTENT_ID");
|
||||
return;
|
||||
}
|
||||
std::string entitlement_label = Common::SplitString(content_id, '-')[2];
|
||||
|
||||
auto addon_extract_path =
|
||||
Config::getAddonInstallDir() / pkg.GetTitleID() / entitlement_label;
|
||||
QString addonDirPath;
|
||||
Common::FS::PathToQString(addonDirPath, addon_extract_path);
|
||||
QDir addon_dir(addonDirPath);
|
||||
|
||||
if (pkgType.contains("PATCH")) {
|
||||
QString pkg_app_version;
|
||||
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
|
||||
pkg_app_version = QString::fromStdString(std::string{*app_ver});
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
|
||||
return;
|
||||
}
|
||||
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});
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
|
||||
return;
|
||||
}
|
||||
double appD = game_app_version.toDouble();
|
||||
double pkgD = pkg_app_version.toDouble();
|
||||
if (pkgD == appD) {
|
||||
msgBox.setText(QString(tr("Patch detected!") + "\n" +
|
||||
tr("PKG and Game versions match: ") + pkg_app_version +
|
||||
"\n" + tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
} else if (pkgD < appD) {
|
||||
msgBox.setText(QString(tr("Patch detected!") + "\n" +
|
||||
tr("PKG Version %1 is older than installed version: ")
|
||||
.arg(pkg_app_version) +
|
||||
game_app_version + "\n" +
|
||||
tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
} else {
|
||||
msgBox.setText(QString(tr("Patch detected!") + "\n" +
|
||||
tr("Game is installed: ") + game_app_version + "\n" +
|
||||
tr("Would you like to install Patch: ") +
|
||||
pkg_app_version + " ?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
}
|
||||
int result = msgBox.exec();
|
||||
if (result == QMessageBox::Yes) {
|
||||
// Do nothing.
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (category == "ac") {
|
||||
if (!addon_dir.exists()) {
|
||||
QMessageBox addonMsgBox;
|
||||
addonMsgBox.setWindowTitle(tr("DLC Installation"));
|
||||
addonMsgBox.setText(QString(tr("Would you like to install DLC: %1?"))
|
||||
.arg(QString::fromStdString(entitlement_label)));
|
||||
|
||||
addonMsgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
addonMsgBox.setDefaultButton(QMessageBox::No);
|
||||
int result = addonMsgBox.exec();
|
||||
if (result == QMessageBox::Yes) {
|
||||
game_update_path = addon_extract_path;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
msgBox.setText(QString(tr("DLC already installed:") + "\n" + addonDirPath +
|
||||
"\n\n" + tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
int result = msgBox.exec();
|
||||
if (result == QMessageBox::Yes) {
|
||||
game_update_path = addon_extract_path;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msgBox.setText(QString(tr("Game already installed") + "\n" + gameDirPath + "\n" +
|
||||
tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
int result = msgBox.exec();
|
||||
if (result == QMessageBox::Yes) {
|
||||
// Do nothing.
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Do nothing;
|
||||
if (pkgType.contains("PATCH") || category == "ac") {
|
||||
QMessageBox::information(
|
||||
this, tr("PKG Extraction"),
|
||||
tr("PKG is a patch or DLC, please install the game first!"));
|
||||
return;
|
||||
}
|
||||
// what else?
|
||||
}
|
||||
if (!pkg.Extract(file, game_update_path, failreason)) {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
|
||||
} else {
|
||||
int nfiles = pkg.GetNumberOfFiles();
|
||||
|
||||
if (nfiles > 0) {
|
||||
QVector<int> indices;
|
||||
for (int i = 0; i < nfiles; i++) {
|
||||
indices.append(i);
|
||||
}
|
||||
|
||||
QProgressDialog dialog;
|
||||
dialog.setWindowTitle(tr("PKG Extraction"));
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
QString extractmsg = QString(tr("Extracting PKG %1/%2")).arg(pkgNum).arg(nPkg);
|
||||
dialog.setLabelText(extractmsg);
|
||||
dialog.setAutoClose(true);
|
||||
dialog.setRange(0, nfiles);
|
||||
|
||||
dialog.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter,
|
||||
dialog.size(), this->geometry()));
|
||||
|
||||
QFutureWatcher<void> futureWatcher;
|
||||
connect(&futureWatcher, &QFutureWatcher<void>::finished, this, [=, this]() {
|
||||
if (pkgNum == nPkg) {
|
||||
QString path;
|
||||
|
||||
// We want to show the parent path instead of the full path
|
||||
Common::FS::PathToQString(path, game_folder_path.parent_path());
|
||||
QIcon windowIcon(
|
||||
Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png")
|
||||
.c_str());
|
||||
|
||||
QMessageBox extractMsgBox(this);
|
||||
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
|
||||
if (!windowIcon.isNull()) {
|
||||
extractMsgBox.setWindowIcon(windowIcon);
|
||||
}
|
||||
extractMsgBox.setText(
|
||||
QString(tr("Game successfully installed at %1")).arg(path));
|
||||
extractMsgBox.addButton(QMessageBox::Ok);
|
||||
extractMsgBox.setDefaultButton(QMessageBox::Ok);
|
||||
connect(&extractMsgBox, &QMessageBox::buttonClicked, this,
|
||||
[&](QAbstractButton* button) {
|
||||
if (extractMsgBox.button(QMessageBox::Ok) == button) {
|
||||
extractMsgBox.close();
|
||||
emit ExtractionFinished();
|
||||
}
|
||||
});
|
||||
extractMsgBox.exec();
|
||||
}
|
||||
if (delete_file_on_install) {
|
||||
std::filesystem::remove(file);
|
||||
}
|
||||
});
|
||||
connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); });
|
||||
connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog,
|
||||
&QProgressDialog::setValue);
|
||||
futureWatcher.setFuture(
|
||||
QtConcurrent::map(indices, [&](int index) { pkg.ExtractFiles(index); }));
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"),
|
||||
tr("File doesn't appear to be a valid PKG file"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::InstallDirectory() {
|
||||
GameInstallDialog dlg;
|
||||
dlg.exec();
|
||||
|
@ -1340,7 +1060,6 @@ QIcon MainWindow::RecolorIcon(const QIcon& icon, bool isWhite) {
|
|||
}
|
||||
|
||||
void MainWindow::SetUiIcons(bool isWhite) {
|
||||
ui->bootInstallPkgAct->setIcon(RecolorIcon(ui->bootInstallPkgAct->icon(), isWhite));
|
||||
ui->bootGameAct->setIcon(RecolorIcon(ui->bootGameAct->icon(), isWhite));
|
||||
ui->shadFolderAct->setIcon(RecolorIcon(ui->shadFolderAct->icon(), isWhite));
|
||||
ui->exitAct->setIcon(RecolorIcon(ui->exitAct->icon(), isWhite));
|
||||
|
@ -1368,7 +1087,6 @@ void MainWindow::SetUiIcons(bool isWhite) {
|
|||
ui->keyboardButton->setIcon(RecolorIcon(ui->keyboardButton->icon(), isWhite));
|
||||
ui->refreshGameListAct->setIcon(RecolorIcon(ui->refreshGameListAct->icon(), isWhite));
|
||||
ui->menuGame_List_Mode->setIcon(RecolorIcon(ui->menuGame_List_Mode->icon(), isWhite));
|
||||
ui->pkgViewerAct->setIcon(RecolorIcon(ui->pkgViewerAct->icon(), isWhite));
|
||||
ui->trophyViewerAct->setIcon(RecolorIcon(ui->trophyViewerAct->icon(), isWhite));
|
||||
ui->configureAct->setIcon(RecolorIcon(ui->configureAct->icon(), isWhite));
|
||||
ui->addElfFolderAct->setIcon(RecolorIcon(ui->addElfFolderAct->icon(), isWhite));
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "game_list_utils.h"
|
||||
#include "main_window_themes.h"
|
||||
#include "main_window_ui.h"
|
||||
#include "pkg_viewer.h"
|
||||
|
||||
class GameListFrame;
|
||||
|
||||
|
@ -36,7 +35,6 @@ public:
|
|||
explicit MainWindow(QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
bool Init();
|
||||
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
|
||||
void InstallDirectory();
|
||||
void StartGame();
|
||||
void PauseGame();
|
||||
|
@ -72,7 +70,6 @@ private:
|
|||
void SetLastUsedTheme();
|
||||
void SetLastIconSizeBullet();
|
||||
void SetUiIcons(bool isWhite);
|
||||
void InstallPkg();
|
||||
void BootGame();
|
||||
void AddRecentFiles(QString filePath);
|
||||
void LoadTranslation();
|
||||
|
@ -89,7 +86,6 @@ private:
|
|||
QActionGroup* m_list_mode_act_group = nullptr;
|
||||
QActionGroup* m_theme_act_group = nullptr;
|
||||
QActionGroup* m_recent_files_group = nullptr;
|
||||
PKG pkg;
|
||||
// Dockable widget frames
|
||||
WindowThemes m_window_themes;
|
||||
GameListUtils m_game_list_utils;
|
||||
|
@ -120,20 +116,6 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
void dropEvent(QDropEvent* event1) override {
|
||||
const QMimeData* mimeData = event1->mimeData();
|
||||
if (mimeData->hasUrls()) {
|
||||
QList<QUrl> urlList = mimeData->urls();
|
||||
int pkgNum = 0;
|
||||
int nPkg = urlList.size();
|
||||
for (const QUrl& url : urlList) {
|
||||
pkgNum++;
|
||||
std::filesystem::path path = Common::FS::PathFromQString(url.toLocalFile());
|
||||
InstallDragDropPkg(path, pkgNum, nPkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
std::filesystem::path last_install_dir = "";
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
class Ui_MainWindow {
|
||||
public:
|
||||
QAction* bootInstallPkgAct;
|
||||
QAction* bootGameAct;
|
||||
QAction* addElfFolderAct;
|
||||
QAction* shadFolderAct;
|
||||
|
@ -27,7 +26,6 @@ public:
|
|||
QAction* gameInstallPathAct;
|
||||
QAction* downloadCheatsPatchesAct;
|
||||
QAction* dumpGameListAct;
|
||||
QAction* pkgViewerAct;
|
||||
QAction* trophyViewerAct;
|
||||
#ifdef ENABLE_UPDATER
|
||||
QAction* updaterAct;
|
||||
|
@ -87,9 +85,6 @@ public:
|
|||
MainWindow->setDockNestingEnabled(true);
|
||||
MainWindow->setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks |
|
||||
QMainWindow::AnimatedDocks | QMainWindow::GroupedDragging);
|
||||
bootInstallPkgAct = new QAction(MainWindow);
|
||||
bootInstallPkgAct->setObjectName("bootInstallPkgAct");
|
||||
bootInstallPkgAct->setIcon(QIcon(":images/file_icon.png"));
|
||||
bootGameAct = new QAction(MainWindow);
|
||||
bootGameAct->setObjectName("bootGameAct");
|
||||
bootGameAct->setIcon(QIcon(":images/play_icon.png"));
|
||||
|
@ -148,9 +143,6 @@ public:
|
|||
dumpGameListAct = new QAction(MainWindow);
|
||||
dumpGameListAct->setObjectName("dumpGameList");
|
||||
dumpGameListAct->setIcon(QIcon(":images/dump_icon.png"));
|
||||
pkgViewerAct = new QAction(MainWindow);
|
||||
pkgViewerAct->setObjectName("pkgViewer");
|
||||
pkgViewerAct->setIcon(QIcon(":images/file_icon.png"));
|
||||
trophyViewerAct = new QAction(MainWindow);
|
||||
trophyViewerAct->setObjectName("trophyViewer");
|
||||
trophyViewerAct->setIcon(QIcon(":images/trophy_icon.png"));
|
||||
|
@ -309,7 +301,6 @@ public:
|
|||
menuBar->addAction(menuView->menuAction());
|
||||
menuBar->addAction(menuSettings->menuAction());
|
||||
menuBar->addAction(menuHelp->menuAction());
|
||||
menuFile->addAction(bootInstallPkgAct);
|
||||
menuFile->addAction(bootGameAct);
|
||||
menuFile->addSeparator();
|
||||
menuFile->addAction(addElfFolderAct);
|
||||
|
@ -345,7 +336,6 @@ public:
|
|||
menuSettings->addAction(menuUtils->menuAction());
|
||||
menuUtils->addAction(downloadCheatsPatchesAct);
|
||||
menuUtils->addAction(dumpGameListAct);
|
||||
menuUtils->addAction(pkgViewerAct);
|
||||
menuUtils->addAction(trophyViewerAct);
|
||||
#ifdef ENABLE_UPDATER
|
||||
menuHelp->addAction(updaterAct);
|
||||
|
@ -361,8 +351,6 @@ public:
|
|||
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "shadPS4", nullptr));
|
||||
addElfFolderAct->setText(
|
||||
QCoreApplication::translate("MainWindow", "Open/Add Elf Folder", nullptr));
|
||||
bootInstallPkgAct->setText(
|
||||
QCoreApplication::translate("MainWindow", "Install Packages (PKG)", nullptr));
|
||||
bootGameAct->setText(QCoreApplication::translate("MainWindow", "Boot Game", nullptr));
|
||||
#ifdef ENABLE_UPDATER
|
||||
updaterAct->setText(
|
||||
|
@ -371,8 +359,6 @@ public:
|
|||
aboutAct->setText(QCoreApplication::translate("MainWindow", "About shadPS4", nullptr));
|
||||
configureAct->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
||||
#if QT_CONFIG(tooltip)
|
||||
bootInstallPkgAct->setToolTip(QCoreApplication::translate(
|
||||
"MainWindow", "Install application from a .pkg file", nullptr));
|
||||
#endif // QT_CONFIG(tooltip)
|
||||
menuRecent->setTitle(QCoreApplication::translate("MainWindow", "Recent Games", nullptr));
|
||||
shadFolderAct->setText(
|
||||
|
@ -404,7 +390,6 @@ public:
|
|||
QCoreApplication::translate("MainWindow", "Download Cheats/Patches", nullptr));
|
||||
dumpGameListAct->setText(
|
||||
QCoreApplication::translate("MainWindow", "Dump Game List", nullptr));
|
||||
pkgViewerAct->setText(QCoreApplication::translate("MainWindow", "PKG Viewer", nullptr));
|
||||
trophyViewerAct->setText(
|
||||
QCoreApplication::translate("MainWindow", "Trophy Viewer", nullptr));
|
||||
mw_searchbar->setPlaceholderText(
|
||||
|
@ -433,4 +418,4 @@ public:
|
|||
|
||||
namespace Ui {
|
||||
class MainWindow : public Ui_MainWindow {};
|
||||
} // namespace Ui
|
||||
} // namespace Ui
|
||||
|
|
|
@ -1,217 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "pkg_viewer.h"
|
||||
|
||||
PKGViewer::PKGViewer(std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent,
|
||||
std::function<void(std::filesystem::path, int, int)> InstallDragDropPkg)
|
||||
: QMainWindow(), m_game_info(game_info_get) {
|
||||
this->resize(1280, 720);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dir_list_std = Config::getPkgViewer();
|
||||
dir_list.clear();
|
||||
for (const auto& str : dir_list_std) {
|
||||
dir_list.append(QString::fromStdString(str));
|
||||
}
|
||||
statusBar = new QStatusBar(treeWidget);
|
||||
this->setStatusBar(statusBar);
|
||||
treeWidget = new QTreeWidget(this);
|
||||
treeWidget->setColumnCount(9);
|
||||
QStringList headers;
|
||||
headers << tr("Name") << tr("Serial") << tr("Installed") << tr("Size") << tr("Category")
|
||||
<< tr("Type") << tr("App Ver") << tr("FW") << tr("Region") << tr("Flags") << tr("Path");
|
||||
treeWidget->setHeaderLabels(headers);
|
||||
treeWidget->header()->setDefaultAlignment(Qt::AlignCenter);
|
||||
treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
treeWidget->setColumnWidth(8, 170);
|
||||
this->setCentralWidget(treeWidget);
|
||||
QMenuBar* menuBar = new QMenuBar(this);
|
||||
menuBar->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
QMenu* fileMenu = menuBar->addMenu(tr("File"));
|
||||
QAction* openFolderAct = new QAction(tr("Open Folder"), this);
|
||||
fileMenu->addAction(openFolderAct);
|
||||
this->setMenuBar(menuBar);
|
||||
CheckPKGFolders(); // Check for new PKG files in existing folders.
|
||||
ProcessPKGInfo();
|
||||
|
||||
connect(openFolderAct, &QAction::triggered, this, &PKGViewer::OpenPKGFolder);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::customContextMenuRequested, this,
|
||||
[=, this](const QPoint& pos) {
|
||||
if (treeWidget->selectedItems().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
m_gui_context_menus.RequestGameMenuPKGViewer(pos, m_full_pkg_list, treeWidget,
|
||||
InstallDragDropPkg);
|
||||
});
|
||||
|
||||
connect(parent, &QWidget::destroyed, this, [this]() { this->deleteLater(); });
|
||||
}
|
||||
|
||||
PKGViewer::~PKGViewer() {}
|
||||
|
||||
void PKGViewer::OpenPKGFolder() {
|
||||
QString folderPath =
|
||||
QFileDialog::getExistingDirectory(this, tr("Open Folder"), QDir::homePath());
|
||||
if (!dir_list.contains(folderPath)) {
|
||||
dir_list.append(folderPath);
|
||||
QDir directory(folderPath);
|
||||
QFileInfoList fileInfoList = directory.entryInfoList(QDir::Files);
|
||||
for (const QFileInfo& fileInfo : fileInfoList) {
|
||||
QString file_ext = fileInfo.suffix();
|
||||
if (fileInfo.isFile() && file_ext == "pkg") {
|
||||
m_pkg_list.append(fileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
std::sort(m_pkg_list.begin(), m_pkg_list.end());
|
||||
ProcessPKGInfo();
|
||||
dir_list_std.clear();
|
||||
for (auto dir : dir_list) {
|
||||
dir_list_std.push_back(dir.toStdString());
|
||||
}
|
||||
Config::setPkgViewer(dir_list_std);
|
||||
} else {
|
||||
// qDebug() << "Folder selection canceled.";
|
||||
}
|
||||
}
|
||||
|
||||
void PKGViewer::CheckPKGFolders() { // Check for new PKG file additions.
|
||||
m_pkg_list.clear();
|
||||
for (const QString& dir : dir_list) {
|
||||
QDir directory(dir);
|
||||
QFileInfoList fileInfoList = directory.entryInfoList(QDir::Files);
|
||||
for (const QFileInfo& fileInfo : fileInfoList) {
|
||||
QString file_ext = fileInfo.suffix();
|
||||
if (fileInfo.isFile() && file_ext == "pkg") {
|
||||
m_pkg_list.append(fileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(m_pkg_list.begin(), m_pkg_list.end());
|
||||
}
|
||||
|
||||
void PKGViewer::ProcessPKGInfo() {
|
||||
treeWidget->clear();
|
||||
map_strings.clear();
|
||||
map_integers.clear();
|
||||
m_pkg_app_list.clear();
|
||||
m_pkg_patch_list.clear();
|
||||
m_full_pkg_list.clear();
|
||||
for (int i = 0; i < m_pkg_list.size(); i++) {
|
||||
std::filesystem::path path = Common::FS::PathFromQString(m_pkg_list[i]);
|
||||
std::string failreason;
|
||||
if (!package.Open(path, failreason)) {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
|
||||
return;
|
||||
}
|
||||
psf.Open(package.sfo);
|
||||
QString title_name = QString::fromStdString(
|
||||
std::string{psf.GetString("TITLE").value_or(std::string{tr("Unknown").toStdString()})});
|
||||
QString title_id = QString::fromStdString(std::string{
|
||||
psf.GetString("TITLE_ID").value_or(std::string{tr("Unknown").toStdString()})});
|
||||
QString app_type = GameListUtils::GetAppType(psf.GetInteger("APP_TYPE").value_or(0));
|
||||
QString app_version = QString::fromStdString(std::string{
|
||||
psf.GetString("APP_VER").value_or(std::string{tr("Unknown").toStdString()})});
|
||||
QString title_category = QString::fromStdString(std::string{
|
||||
psf.GetString("CATEGORY").value_or(std::string{tr("Unknown").toStdString()})});
|
||||
QString pkg_size = GameListUtils::FormatSize(package.GetPkgHeader().pkg_size);
|
||||
pkg_content_flag = package.GetPkgHeader().pkg_content_flags;
|
||||
QString flagss = "";
|
||||
for (const auto& flag : package.flagNames) {
|
||||
if (package.isFlagSet(pkg_content_flag, flag.first)) {
|
||||
if (!flagss.isEmpty())
|
||||
flagss += (", ");
|
||||
flagss += QString::fromStdString(flag.second.data());
|
||||
}
|
||||
}
|
||||
|
||||
QString fw_ = tr("Unknown");
|
||||
if (const auto fw_int_opt = psf.GetInteger("SYSTEM_VER"); fw_int_opt.has_value()) {
|
||||
const u32 fw_int = *fw_int_opt;
|
||||
if (fw_int == 0) {
|
||||
fw_ = "0.00";
|
||||
} else {
|
||||
QString fw = QString::number(fw_int, 16);
|
||||
fw_ = fw.length() > 7 ? QString::number(fw_int, 16).left(3).insert(2, '.')
|
||||
: fw.left(3).insert(1, '.');
|
||||
}
|
||||
}
|
||||
char region = package.GetPkgHeader().pkg_content_id[0];
|
||||
QString pkg_info = "";
|
||||
if (title_category == "gd" && !flagss.contains("PATCH")) {
|
||||
title_category = "App";
|
||||
pkg_info = title_name + ";;" + title_id + ";;" + pkg_size + ";;" + title_category +
|
||||
";;" + app_type + ";;" + app_version + ";;" + fw_ + ";;" +
|
||||
game_list_util.GetRegion(region) + ";;" + flagss + ";;" + m_pkg_list[i];
|
||||
m_pkg_app_list.append(pkg_info);
|
||||
} else {
|
||||
title_category = "Patch";
|
||||
pkg_info = title_name + ";;" + title_id + ";;" + pkg_size + ";;" + title_category +
|
||||
";;" + app_type + ";;" + app_version + ";;" + fw_ + ";;" +
|
||||
game_list_util.GetRegion(region) + ";;" + flagss + ";;" + m_pkg_list[i];
|
||||
m_pkg_patch_list.append(pkg_info);
|
||||
}
|
||||
}
|
||||
std::sort(m_pkg_app_list.begin(), m_pkg_app_list.end());
|
||||
for (int i = 0; i < m_pkg_app_list.size(); i++) {
|
||||
QTreeWidgetItem* treeItem = new QTreeWidgetItem(treeWidget);
|
||||
QStringList pkg_app_ = m_pkg_app_list[i].split(";;");
|
||||
m_full_pkg_list.append(m_pkg_app_list[i]);
|
||||
treeItem->setExpanded(true);
|
||||
treeItem->setText(0, pkg_app_[0]);
|
||||
treeItem->setText(1, pkg_app_[1]);
|
||||
treeItem->setText(3, pkg_app_[2]);
|
||||
treeItem->setTextAlignment(3, Qt::AlignCenter);
|
||||
treeItem->setText(4, pkg_app_[3]);
|
||||
treeItem->setTextAlignment(4, Qt::AlignCenter);
|
||||
treeItem->setText(5, pkg_app_[4]);
|
||||
treeItem->setTextAlignment(5, Qt::AlignCenter);
|
||||
treeItem->setText(6, pkg_app_[5]);
|
||||
treeItem->setTextAlignment(6, Qt::AlignCenter);
|
||||
treeItem->setText(7, pkg_app_[6]);
|
||||
treeItem->setTextAlignment(7, Qt::AlignCenter);
|
||||
treeItem->setText(8, pkg_app_[7]);
|
||||
treeItem->setTextAlignment(8, Qt::AlignCenter);
|
||||
treeItem->setText(9, pkg_app_[8]);
|
||||
treeItem->setText(10, pkg_app_[9]);
|
||||
for (const GameInfo& info : m_game_info->m_games) { // Check if game is installed.
|
||||
if (info.serial == pkg_app_[1].toStdString()) {
|
||||
treeItem->setText(2, QChar(0x2713));
|
||||
treeItem->setTextAlignment(2, Qt::AlignCenter);
|
||||
}
|
||||
}
|
||||
for (const QString& item : m_pkg_patch_list) {
|
||||
QStringList pkg_patch_ = item.split(";;");
|
||||
if (pkg_patch_[1] == pkg_app_[1]) { // check patches with serial.
|
||||
m_full_pkg_list.append(item);
|
||||
QTreeWidgetItem* childItem = new QTreeWidgetItem(treeItem);
|
||||
childItem->setText(0, pkg_patch_[0]);
|
||||
childItem->setText(1, pkg_patch_[1]);
|
||||
childItem->setText(3, pkg_patch_[2]);
|
||||
childItem->setTextAlignment(3, Qt::AlignCenter);
|
||||
childItem->setText(4, pkg_patch_[3]);
|
||||
childItem->setTextAlignment(4, Qt::AlignCenter);
|
||||
childItem->setText(5, pkg_patch_[4]);
|
||||
childItem->setTextAlignment(5, Qt::AlignCenter);
|
||||
childItem->setText(6, pkg_patch_[5]);
|
||||
childItem->setTextAlignment(6, Qt::AlignCenter);
|
||||
childItem->setText(7, pkg_patch_[6]);
|
||||
childItem->setTextAlignment(7, Qt::AlignCenter);
|
||||
childItem->setText(8, pkg_patch_[7]);
|
||||
childItem->setTextAlignment(8, Qt::AlignCenter);
|
||||
childItem->setText(9, pkg_patch_[8]);
|
||||
childItem->setText(10, pkg_patch_[9]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < treeWidget->columnCount() - 2; ++column) {
|
||||
// Resize the column to fit its contents
|
||||
treeWidget->resizeColumnToContents(column);
|
||||
}
|
||||
// Update status bar.
|
||||
statusBar->clearMessage();
|
||||
int numPkgs = m_pkg_list.size();
|
||||
QString statusMessage = QString::number(numPkgs) + " " + tr("Package");
|
||||
statusBar->showMessage(statusMessage);
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "common/io_file.h"
|
||||
#include "core/file_format/pkg.h"
|
||||
#include "core/file_format/pkg_type.h"
|
||||
#include "core/file_format/psf.h"
|
||||
#include "game_info.h"
|
||||
#include "game_list_utils.h"
|
||||
#include "gui_context_menus.h"
|
||||
|
||||
class PKGViewer : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PKGViewer(
|
||||
std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent,
|
||||
std::function<void(std::filesystem::path, int, int)> InstallDragDropPkg = nullptr);
|
||||
~PKGViewer();
|
||||
void OpenPKGFolder();
|
||||
void CheckPKGFolders();
|
||||
void ProcessPKGInfo();
|
||||
|
||||
private:
|
||||
GuiContextMenus m_gui_context_menus;
|
||||
PKG package;
|
||||
PSF psf;
|
||||
PKGHeader pkgheader;
|
||||
PKGEntry entry;
|
||||
PSFHeader header;
|
||||
char pkgTitleID[9];
|
||||
std::vector<u8> pkg;
|
||||
u64 pkgSize = 0;
|
||||
std::unordered_map<std::string, std::string> map_strings;
|
||||
std::unordered_map<std::string, u32> map_integers;
|
||||
|
||||
u32_be pkg_content_flag;
|
||||
std::shared_ptr<GameInfoClass> m_game_info;
|
||||
GameListUtils game_list_util;
|
||||
// Status bar
|
||||
QStatusBar* statusBar;
|
||||
|
||||
std::vector<std::pair<int, QString>> appTypes = {
|
||||
{0, "FULL APP"},
|
||||
{1, "UPGRADABLE"},
|
||||
{2, "DEMO"},
|
||||
{3, "FREEMIUM"},
|
||||
};
|
||||
|
||||
QStringList m_full_pkg_list;
|
||||
QStringList m_pkg_app_list;
|
||||
QStringList m_pkg_patch_list;
|
||||
QStringList m_pkg_list;
|
||||
QStringList dir_list;
|
||||
std::vector<std::string> dir_list_std;
|
||||
QTreeWidget* treeWidget = nullptr;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue