Skip to content

Commit 896f55b

Browse files
committed
Fix trophy key not updating after save, crash after decryption
1 parent 235edde commit 896f55b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

modules/TrophyManager.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath, QWidget* par
2525
<< "Type"
2626
<< "PID";
2727

28-
RefreshValues(trophyPath);
28+
if (!RefreshValues(trophyPath))
29+
return;
2930
PopulateTrophyWidget(trophyPath);
3031

3132
ui->UnlockButton->setFocus();
3233
ui->TrophyIDBox->addItems(trpId);
3334
ui->TrophyIDBox->setCurrentIndex(0);
35+
3436
TrophyIDChanged();
3537
UpdateStats();
3638

@@ -156,6 +158,7 @@ void TrophyViewer::TrophyIDChanged() {
156158
void TrophyViewer::UpdateStats() {
157159
int UnlockedCount = 0;
158160
int LockedCount = 0;
161+
159162
for (const auto& i : trpUnlocked) {
160163
if (i == "locked")
161164
LockedCount = LockedCount + 1;
@@ -342,7 +345,7 @@ void TrophyViewer::LockAllTrophies() {
342345
QMessageBox::information(this, "Trophies Reset", "All trophies locked");
343346
}
344347

345-
void TrophyViewer::RefreshValues(QString title) {
348+
bool TrophyViewer::RefreshValues(QString title) {
346349
trpId.clear();
347350
trpHidden.clear();
348351
trpUnlocked.clear();
@@ -358,19 +361,19 @@ void TrophyViewer::RefreshValues(QString title) {
358361
Common::PathToQString(trophyDirQt, trophyDir);
359362

360363
QDir dir(trophyDirQt);
361-
if (!dir.exists()) {
364+
QFileInfoList dirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
365+
if (!dir.exists() || dirList.isEmpty()) {
362366
std::filesystem::path path = Common::PathFromQString(gameTrpPath_);
363-
if (!trp.Extract(path, title.toStdString()))
367+
if (!trp.Extract(path, title.toStdString())) {
364368
QMessageBox::warning(this, "Error",
365369
"Error extracting trophy files, a Trophy Key may be required "
366370
"(check shadPS4 settings)");
367-
this->close();
368-
return;
371+
QWidget::close();
372+
return false;
373+
}
369374
}
370-
QFileInfoList dirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
371-
if (dirList.isEmpty())
372-
return;
373375

376+
dirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
374377
for (const QFileInfo& dirInfo : dirList) {
375378
QString fileName = dirInfo.fileName();
376379
QString trpDir = trophyDirQt + "/" + fileName;
@@ -389,7 +392,8 @@ void TrophyViewer::RefreshValues(QString title) {
389392
QString xmlPath = trpDir + "/Xml/TROP.XML";
390393
QFile file(xmlPath);
391394
if (!file.open(QFile::ReadOnly | QFile::Text)) {
392-
return;
395+
QMessageBox::warning(this, "Error", "Error opening file");
396+
return false;
393397
}
394398

395399
QXmlStreamReader reader(&file);
@@ -420,6 +424,7 @@ void TrophyViewer::RefreshValues(QString title) {
420424
}
421425
}
422426
}
427+
return true;
423428
}
424429

425430
TrophyViewer::~TrophyViewer() {

modules/TrophyManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private slots:
4040
void PopulateTrophyWidget(QString title);
4141
void SetTableItem(QTableWidget* parent, int row, int column, QString str);
4242
void UpdateStats();
43-
void RefreshValues(QString title);
43+
bool RefreshValues(QString title);
4444

4545
QTableWidget* tableWidget;
4646
QTabWidget* tabWidget = nullptr;

settings/ShadSettings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <QProcess>
1414
#include <QStandardPaths>
1515

16+
#include "LauncherSettings.h"
1617
#include "ShadSettings.h"
1718
#include "formatting.h"
1819
#include "modules/Common.h"
@@ -325,6 +326,8 @@ void ShadSettings::SaveSettings() {
325326
data["Settings"]["consoleLanguage"] =
326327
languageIndexes[ui->consoleLanguageComboBox->currentIndex()];
327328

329+
Config::TrophyKey = ui->trophyKeyLineEdit->text().toStdString();
330+
328331
std::ofstream file(Common::GetShadUserDir() / "config.toml", std::ios::binary);
329332
file << data;
330333
file.close();

0 commit comments

Comments
 (0)