mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-25 12:55:00 +00:00
Cheats/Patches (#493)
* Cheats/Patches Adds the possibility of applying cheats/patches according to the specific game serial+version The logic for adding modifications has not yet been implemented! Interface based on issues/372 https://github.com/shadps4-emu/shadPS4/issues/372 [X]Front-end []Back-end Create a synchronized fork of the cheats/patches repository * Clang Format * separate files The code has been separated into separate files as suggested by georgemoralis. Added the Patch tab, which has not been implemented yet. Added the 'applyCheat' area to apply the modification, not implemented yet... And added LOG_INFO. * reuse * initial implementation of cheat functionality * Update cheats_patches.cpp sets all added buttons to the size of the largest button. and fixes some aesthetic issues. * move eboot_address to module.h fixes the non-qt builds and makes more sense to be there anyway * Patchs menu and fixes adds the possibility to download Patches, it does not modify the memory yet. and some other fixes * MemoryPatcher namespace, activate cheats on start * format * initial patch implementation * format * format again... * convertValueToHex * Fixes Choosing which cheat file to use. And some other fixes * fix bytes16, bytes32, bytes64 type patches If a patch is any of these types we convert it from little endian to big endian * format * format again :( * Implement pattern scanning for mask type patches * add check to stop patches applying to wrong game previously if you added a patch to a game, but closed the window and opened a different game it would still try to apply the patch, this is now fixed * format * Fix 'Hint' 0x400000 | and Author * Management |save checkbox | shadps4 repository MENU - Cheats/Patches Management (implementing Patches) save patches checkbox add shadps4 repository * Load saved patches, miscellaneous fixes * Fix an issue with mask patches not being saved * format + remove debug log * multiple patches | TR translation for cheats/patches * clang * ENABLE_QT_GUI * OK * move memory_patcher to qt_gui * clang * add cheats hu_HU * fix log * Remove the item from the patchesListView if no patches were added (the game has patches, but not for the current version) --------- Co-authored-by: CrazyBloo <CrazyBloo@users.noreply.github.com>
This commit is contained in:
parent
a6a9fff666
commit
614a23b369
35 changed files with 12003 additions and 798 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <QProgressDialog>
|
||||
|
||||
#include "about_dialog.h"
|
||||
#include "cheats_patches.h"
|
||||
#include "common/io_file.h"
|
||||
#include "common/version.h"
|
||||
#include "core/file_format/pkg.h"
|
||||
|
@ -164,7 +165,7 @@ void MainWindow::GetPhysicalDevices() {
|
|||
auto prop = physical_device.getProperties();
|
||||
QString name = QString::fromUtf8(prop.deviceName, -1);
|
||||
if (prop.apiVersion < Vulkan::TargetVulkanApiVersion) {
|
||||
name += " * Unsupported Vulkan Version";
|
||||
name += tr(" * Unsupported Vulkan Version");
|
||||
}
|
||||
m_physical_devices.push_back(name);
|
||||
}
|
||||
|
@ -317,6 +318,83 @@ void MainWindow::CreateConnects() {
|
|||
Config::setTableMode(2);
|
||||
});
|
||||
|
||||
// Cheats/Patches Download.
|
||||
connect(ui->downloadCheatsPatchesAct, &QAction::triggered, this, [this]() {
|
||||
QDialog* panelDialog = new QDialog(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(panelDialog);
|
||||
QPushButton* downloadAllCheatsButton =
|
||||
new QPushButton(tr("Download Cheats For All Installed Games"), panelDialog);
|
||||
QPushButton* downloadAllPatchesButton =
|
||||
new QPushButton(tr("Download Patches For All Games"), panelDialog);
|
||||
|
||||
layout->addWidget(downloadAllCheatsButton);
|
||||
layout->addWidget(downloadAllPatchesButton);
|
||||
|
||||
panelDialog->setLayout(layout);
|
||||
|
||||
connect(downloadAllCheatsButton, &QPushButton::clicked, this, [this, panelDialog]() {
|
||||
QEventLoop eventLoop;
|
||||
int pendingDownloads = 0;
|
||||
|
||||
auto onDownloadFinished = [&]() {
|
||||
if (--pendingDownloads <= 0) {
|
||||
eventLoop.quit();
|
||||
}
|
||||
};
|
||||
|
||||
for (const GameInfo& game : m_game_info->m_games) {
|
||||
QString empty = "";
|
||||
QString gameSerial = QString::fromStdString(game.serial);
|
||||
QString gameVersion = QString::fromStdString(game.version);
|
||||
|
||||
CheatsPatches* cheatsPatches =
|
||||
new CheatsPatches(empty, empty, empty, empty, empty, nullptr);
|
||||
connect(cheatsPatches, &CheatsPatches::downloadFinished, onDownloadFinished);
|
||||
|
||||
pendingDownloads += 3;
|
||||
|
||||
cheatsPatches->downloadCheats("wolf2022", gameSerial, gameVersion, false);
|
||||
cheatsPatches->downloadCheats("GoldHEN", gameSerial, gameVersion, false);
|
||||
cheatsPatches->downloadCheats("shadPS4", gameSerial, gameVersion, false);
|
||||
}
|
||||
eventLoop.exec();
|
||||
|
||||
QMessageBox::information(
|
||||
nullptr, tr("Download Complete"),
|
||||
tr("You have downloaded cheats for all the games you have installed."));
|
||||
|
||||
panelDialog->accept();
|
||||
});
|
||||
connect(downloadAllPatchesButton, &QPushButton::clicked, this, [this, panelDialog]() {
|
||||
QEventLoop eventLoop;
|
||||
int pendingDownloads = 0;
|
||||
|
||||
auto onDownloadFinished = [&]() {
|
||||
if (--pendingDownloads <= 0) {
|
||||
eventLoop.quit();
|
||||
}
|
||||
};
|
||||
|
||||
QString empty = "";
|
||||
CheatsPatches* cheatsPatches =
|
||||
new CheatsPatches(empty, empty, empty, empty, empty, nullptr);
|
||||
connect(cheatsPatches, &CheatsPatches::downloadFinished, onDownloadFinished);
|
||||
|
||||
pendingDownloads += 2;
|
||||
|
||||
cheatsPatches->downloadPatches("GoldHEN", false);
|
||||
cheatsPatches->downloadPatches("shadPS4", false);
|
||||
|
||||
eventLoop.exec();
|
||||
QMessageBox::information(
|
||||
nullptr, tr("Download Complete"),
|
||||
QString(tr("Patches Downloaded Successfully!") + "\n" +
|
||||
tr("All Patches available for all games have been downloaded.")));
|
||||
panelDialog->accept();
|
||||
});
|
||||
panelDialog->exec();
|
||||
});
|
||||
|
||||
// Dump game list.
|
||||
connect(ui->dumpGameListAct, &QAction::triggered, this, [&] {
|
||||
QString filePath = qApp->applicationDirPath().append("/GameList.txt");
|
||||
|
@ -468,7 +546,7 @@ void MainWindow::RefreshGameTable() {
|
|||
m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false);
|
||||
statusBar->clearMessage();
|
||||
int numGames = m_game_info->m_games.size();
|
||||
QString statusMessage = "Games: " + QString::number(numGames);
|
||||
QString statusMessage = tr("Games: ") + QString::number(numGames);
|
||||
statusBar->showMessage(statusMessage);
|
||||
}
|
||||
|
||||
|
@ -519,7 +597,8 @@ void MainWindow::BootGame() {
|
|||
int nFiles = fileNames.size();
|
||||
|
||||
if (nFiles > 1) {
|
||||
QMessageBox::critical(nullptr, "Game Boot", QString("Only one file can be selected!"));
|
||||
QMessageBox::critical(nullptr, tr("Game Boot"),
|
||||
QString(tr("Only one file can be selected!")));
|
||||
} else {
|
||||
std::filesystem::path path(fileNames[0].toStdString());
|
||||
#ifdef _WIN64
|
||||
|
@ -542,7 +621,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
QDir game_dir(QString::fromStdString(extract_path.string()));
|
||||
if (game_dir.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("PKG Extraction");
|
||||
msgBox.setWindowTitle(tr("PKG Extraction"));
|
||||
if (pkgType.contains("PATCH")) {
|
||||
psf.open("", pkg.sfo);
|
||||
QString pkg_app_version = QString::fromStdString(psf.GetString("APP_VER"));
|
||||
|
@ -551,23 +630,24 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
double appD = game_app_version.toDouble();
|
||||
double pkgD = pkg_app_version.toDouble();
|
||||
if (pkgD == appD) {
|
||||
msgBox.setText(
|
||||
QString("Patch detected!\nPKG and Game versions match!: %1\nWould you like "
|
||||
"to overwrite?")
|
||||
.arg(pkg_app_version));
|
||||
msgBox.setText(QString(tr("Patch detected!\nPKG and Game versions match!: "
|
||||
"%1\nWould you like ") +
|
||||
tr("to overwrite?"))
|
||||
.arg(pkg_app_version));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
} else if (pkgD < appD) {
|
||||
msgBox.setText(QString("Patch detected!\nPKG Version %1 is older "
|
||||
"than installed version!: %2\nWould you like "
|
||||
"to overwrite?")
|
||||
msgBox.setText(QString(tr("Patch detected!\nPKG Version %1 is older ") +
|
||||
tr("than installed version!: %2\nWould you like ") +
|
||||
tr("to overwrite?"))
|
||||
.arg(pkg_app_version, game_app_version));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
} else {
|
||||
msgBox.setText(QString("Patch detected!\nGame is installed: %1\nWould you like "
|
||||
"to install Patch: %2?")
|
||||
.arg(game_app_version, pkg_app_version));
|
||||
msgBox.setText(
|
||||
QString(tr("Patch detected!\nGame is installed: %1\nWould you like ") +
|
||||
tr("to install Patch: %2?"))
|
||||
.arg(game_app_version, pkg_app_version));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
}
|
||||
|
@ -578,8 +658,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
msgBox.setText(QString("Game already installed\n%1\nWould you like to overwrite?")
|
||||
.arg(QString::fromStdString(extract_path.string())));
|
||||
msgBox.setText(
|
||||
QString(tr("Game already installed\n%1\nWould you like to overwrite?"))
|
||||
.arg(QString::fromStdString(extract_path.string())));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
int result = msgBox.exec();
|
||||
|
@ -592,15 +673,15 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
} else {
|
||||
// Do nothing;
|
||||
if (pkgType.contains("PATCH")) {
|
||||
QMessageBox::information(this, "PKG Extraction",
|
||||
"PKG is a patch, please install the game first!");
|
||||
QMessageBox::information(this, tr("PKG Extraction"),
|
||||
tr("PKG is a patch, please install the game first!"));
|
||||
return;
|
||||
}
|
||||
// what else?
|
||||
}
|
||||
|
||||
if (!pkg.Extract(file, extract_path, failreason)) {
|
||||
QMessageBox::critical(this, "PKG ERROR", QString::fromStdString(failreason));
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason));
|
||||
} else {
|
||||
int nfiles = pkg.GetNumberOfFiles();
|
||||
|
||||
|
@ -610,9 +691,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
}
|
||||
|
||||
QProgressDialog dialog;
|
||||
dialog.setWindowTitle("PKG Extraction");
|
||||
dialog.setWindowTitle(tr("PKG Extraction"));
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
QString extractmsg = QString("Extracting PKG %1/%2").arg(pkgNum).arg(nPkg);
|
||||
QString extractmsg = QString(tr("Extracting PKG %1/%2")).arg(pkgNum).arg(nPkg);
|
||||
dialog.setLabelText(extractmsg);
|
||||
dialog.setAutoClose(true);
|
||||
dialog.setRange(0, nfiles);
|
||||
|
@ -622,8 +703,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
if (pkgNum == nPkg) {
|
||||
QString path = QString::fromStdString(Config::getGameInstallDir());
|
||||
QMessageBox extractMsgBox(this);
|
||||
extractMsgBox.setWindowTitle("Extraction Finished");
|
||||
extractMsgBox.setText(QString("Game successfully installed at %1").arg(path));
|
||||
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
|
||||
extractMsgBox.setText(
|
||||
QString(tr("Game successfully installed at %1")).arg(path));
|
||||
extractMsgBox.addButton(QMessageBox::Ok);
|
||||
extractMsgBox.setDefaultButton(QMessageBox::Ok);
|
||||
connect(&extractMsgBox, &QMessageBox::buttonClicked, this,
|
||||
|
@ -644,7 +726,8 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
dialog.exec();
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(this, "PKG ERROR", "File doesn't appear to be a valid PKG file");
|
||||
QMessageBox::critical(this, tr("PKG ERROR"),
|
||||
tr("File doesn't appear to be a valid PKG file"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue