@@ -25,12 +25,14 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath, QWidget* par
25
25
<< " Type"
26
26
<< " PID" ;
27
27
28
- RefreshValues (trophyPath);
28
+ if (!RefreshValues (trophyPath))
29
+ return ;
29
30
PopulateTrophyWidget (trophyPath);
30
31
31
32
ui->UnlockButton ->setFocus ();
32
33
ui->TrophyIDBox ->addItems (trpId);
33
34
ui->TrophyIDBox ->setCurrentIndex (0 );
35
+
34
36
TrophyIDChanged ();
35
37
UpdateStats ();
36
38
@@ -156,6 +158,7 @@ void TrophyViewer::TrophyIDChanged() {
156
158
void TrophyViewer::UpdateStats () {
157
159
int UnlockedCount = 0 ;
158
160
int LockedCount = 0 ;
161
+
159
162
for (const auto & i : trpUnlocked) {
160
163
if (i == " locked" )
161
164
LockedCount = LockedCount + 1 ;
@@ -342,7 +345,7 @@ void TrophyViewer::LockAllTrophies() {
342
345
QMessageBox::information (this , " Trophies Reset" , " All trophies locked" );
343
346
}
344
347
345
- void TrophyViewer::RefreshValues (QString title) {
348
+ bool TrophyViewer::RefreshValues (QString title) {
346
349
trpId.clear ();
347
350
trpHidden.clear ();
348
351
trpUnlocked.clear ();
@@ -358,19 +361,19 @@ void TrophyViewer::RefreshValues(QString title) {
358
361
Common::PathToQString (trophyDirQt, trophyDir);
359
362
360
363
QDir dir (trophyDirQt);
361
- if (!dir.exists ()) {
364
+ QFileInfoList dirList = dir.entryInfoList (QDir::Dirs | QDir::NoDotAndDotDot);
365
+ if (!dir.exists () || dirList.isEmpty ()) {
362
366
std::filesystem::path path = Common::PathFromQString (gameTrpPath_);
363
- if (!trp.Extract (path, title.toStdString ()))
367
+ if (!trp.Extract (path, title.toStdString ())) {
364
368
QMessageBox::warning (this , " Error" ,
365
369
" Error extracting trophy files, a Trophy Key may be required "
366
370
" (check shadPS4 settings)" );
367
- this ->close ();
368
- return ;
371
+ QWidget::close ();
372
+ return false ;
373
+ }
369
374
}
370
- QFileInfoList dirList = dir.entryInfoList (QDir::Dirs | QDir::NoDotAndDotDot);
371
- if (dirList.isEmpty ())
372
- return ;
373
375
376
+ dirList = dir.entryInfoList (QDir::Dirs | QDir::NoDotAndDotDot);
374
377
for (const QFileInfo& dirInfo : dirList) {
375
378
QString fileName = dirInfo.fileName ();
376
379
QString trpDir = trophyDirQt + " /" + fileName;
@@ -389,7 +392,8 @@ void TrophyViewer::RefreshValues(QString title) {
389
392
QString xmlPath = trpDir + " /Xml/TROP.XML" ;
390
393
QFile file (xmlPath);
391
394
if (!file.open (QFile::ReadOnly | QFile::Text)) {
392
- return ;
395
+ QMessageBox::warning (this , " Error" , " Error opening file" );
396
+ return false ;
393
397
}
394
398
395
399
QXmlStreamReader reader (&file);
@@ -420,6 +424,7 @@ void TrophyViewer::RefreshValues(QString title) {
420
424
}
421
425
}
422
426
}
427
+ return true ;
423
428
}
424
429
425
430
TrophyViewer::~TrophyViewer () {
0 commit comments