mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-01 23:12:35 +00:00
Fix 'Hint' 0x400000 | and Author
This commit is contained in:
parent
c78752ef88
commit
9107c6e8c0
@ -189,9 +189,7 @@ void CheatsPatches::setupUI() {
|
|||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
QString cheatsDir = QString::fromStdString(
|
QString filePath = CHEATS_DIR_QString + "/" + selectedFileName;
|
||||||
Common::FS::GetUserPath(Common::FS::PathType::CheatsDir).string());
|
|
||||||
QString filePath = cheatsDir + "/" + selectedFileName;
|
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
populateFileListCheats();
|
populateFileListCheats();
|
||||||
}
|
}
|
||||||
@ -536,7 +534,7 @@ void CheatsPatches::createFilesJson() {
|
|||||||
jsonFile.close();
|
jsonFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray) {
|
void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray, const QJsonArray& creditsArray) {
|
||||||
QLayoutItem* item;
|
QLayoutItem* item;
|
||||||
while ((item = rightLayout->takeAt(0)) != nullptr) {
|
while ((item = rightLayout->takeAt(0)) != nullptr) {
|
||||||
delete item->widget();
|
delete item->widget();
|
||||||
@ -566,6 +564,9 @@ void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray) {
|
|||||||
cheat.memoryMods.append(memoryMod);
|
cheat.memoryMods.append(memoryMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for the presence of 'hint' field
|
||||||
|
cheat.hasHint = modObject.contains("hint");
|
||||||
|
|
||||||
m_cheats[modName] = cheat;
|
m_cheats[modName] = cheat;
|
||||||
|
|
||||||
if (modType == "checkbox") {
|
if (modType == "checkbox") {
|
||||||
@ -620,20 +621,12 @@ void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set credits label
|
||||||
QLabel* creditsLabel = new QLabel();
|
QLabel* creditsLabel = new QLabel();
|
||||||
QString creditsText = "Author: ";
|
QString creditsText = "Author: ";
|
||||||
QFile file(m_cheatFilePath);
|
if (!creditsArray.isEmpty()) {
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
creditsText += creditsArray[0].toString();
|
||||||
QByteArray jsonData = file.readAll();
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
|
||||||
QJsonObject jsonObject = jsonDoc.object();
|
|
||||||
QJsonArray creditsArray = jsonObject["credits"].toArray();
|
|
||||||
for (const QJsonValue& creditValue : creditsArray) {
|
|
||||||
creditsText += creditValue.toString() + ", ";
|
|
||||||
}
|
|
||||||
if (creditsText.endsWith(", ")) {
|
|
||||||
creditsText.chop(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
creditsLabel->setText(creditsText);
|
creditsLabel->setText(creditsText);
|
||||||
creditsLabel->setAlignment(Qt::AlignLeft);
|
creditsLabel->setAlignment(Qt::AlignLeft);
|
||||||
@ -694,7 +687,8 @@ void CheatsPatches::loadCheats(const QString& filePath) {
|
|||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||||
QJsonObject jsonObject = jsonDoc.object();
|
QJsonObject jsonObject = jsonDoc.object();
|
||||||
QJsonArray modsArray = jsonObject["mods"].toArray();
|
QJsonArray modsArray = jsonObject["mods"].toArray();
|
||||||
addCheatsToLayout(modsArray);
|
QJsonArray creditsArray = jsonObject["credits"].toArray();
|
||||||
|
addCheatsToLayout(modsArray, creditsArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CheatsPatches::loadPatches(const QString& serial) {
|
void CheatsPatches::loadPatches(const QString& serial) {
|
||||||
@ -856,6 +850,9 @@ void CheatsPatches::applyCheat(const QString& modName, bool enabled) {
|
|||||||
std::string offsetStr = memoryMod.offset.toStdString();
|
std::string offsetStr = memoryMod.offset.toStdString();
|
||||||
std::string valueStr = value.toStdString();
|
std::string valueStr = value.toStdString();
|
||||||
|
|
||||||
|
// Determine if the hint field is present
|
||||||
|
bool isHintPresent = m_cheats[modName].hasHint;
|
||||||
|
|
||||||
if (MemoryPatcher::g_eboot_address == 0) {
|
if (MemoryPatcher::g_eboot_address == 0) {
|
||||||
MemoryPatcher::patchInfo addingPatch;
|
MemoryPatcher::patchInfo addingPatch;
|
||||||
addingPatch.modNameStr = modNameStr;
|
addingPatch.modNameStr = modNameStr;
|
||||||
@ -867,7 +864,8 @@ void CheatsPatches::applyCheat(const QString& modName, bool enabled) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryPatcher::PatchMemory(modNameStr, offsetStr, valueStr, true, false);
|
bool isOffset = !isHintPresent;
|
||||||
|
MemoryPatcher::PatchMemory(modNameStr, offsetStr, valueStr, isOffset, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ private:
|
|||||||
void downloadCheats(const QString& url);
|
void downloadCheats(const QString& url);
|
||||||
void downloadPatches();
|
void downloadPatches();
|
||||||
|
|
||||||
void addCheatsToLayout(const QJsonArray& modsArray);
|
void addCheatsToLayout(const QJsonArray& modsArray, const QJsonArray& creditsArray);
|
||||||
void addPatchToLayout(const QString& name, const QString& author, const QString& note,
|
void addPatchToLayout(const QString& name, const QString& author, const QString& note,
|
||||||
const QJsonArray& linesArray, const QString& serial);
|
const QJsonArray& linesArray, const QString& serial);
|
||||||
|
|
||||||
@ -77,6 +77,7 @@ private:
|
|||||||
struct Cheat {
|
struct Cheat {
|
||||||
QString name;
|
QString name;
|
||||||
QString type;
|
QString type;
|
||||||
|
bool hasHint;
|
||||||
QVector<MemoryMod> memoryMods;
|
QVector<MemoryMod> memoryMods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user