From 9c0cc39b4f76caf33f45af99b2618af2b71527ff Mon Sep 17 00:00:00 2001 From: Syping Date: Tue, 3 Oct 2023 23:21:16 +0200 Subject: [PATCH] add RDR 2 photo import and remove savegame import --- src/ProfileInterface.cpp | 113 ++------------------------------------- src/ProfileInterface.h | 1 - src/UserInterface.cpp | 3 +- 3 files changed, 5 insertions(+), 112 deletions(-) diff --git a/src/ProfileInterface.cpp b/src/ProfileInterface.cpp index dc280f8..3c39586 100644 --- a/src/ProfileInterface.cpp +++ b/src/ProfileInterface.cpp @@ -550,16 +550,16 @@ fileDialogPreOpen: //Work? for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) { imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " "; } - QString importableFormatsStr = QString("*.g5e SGTA5* PGTA5*"); + QString importableFormatsStr = QString("*.g5e PGTA5*"); if (!imageFormatsStr.trimmed().isEmpty()) { - importableFormatsStr = QString("*.g5e%1SGTA5* PGTA5*").arg(imageFormatsStr); + importableFormatsStr = QString("*.g5e%1PGTA5*").arg(imageFormatsStr); } QStringList filters; filters << tr("All importable files (%1)").arg(importableFormatsStr); filters << tr("GTA V Export (%1)").arg("*.g5e"); - filters << tr("GTA V Savegames files (%1)").arg("SGTA5*"); filters << tr("GTA V Snapmatic files (%1)").arg("PGTA5*"); + filters << tr("RDR 2 Photo files (%1)").arg("PRDR3*"); filters << tr("All image files (%1)").arg(imageFormatsStr.trimmed()); filters << tr("All files (%1)").arg("**"); fileDialog.setNameFilters(filters); @@ -680,41 +680,6 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime return false; } } - else if (selectedFileName.left(4) == "SGTA") { - SavegameData *savegame = new SavegameData(selectedFile); - if (savegame->readingSavegame()) { - bool success = importSavegameData(savegame, selectedFile, notMultiple); - if (!success) - delete savegame; -#ifdef GTA5SYNC_TELEMETRY - if (success && notMultiple) { - QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); - telemetrySettings.beginGroup("Telemetry"); - bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); - telemetrySettings.endGroup(); - if (pushUsageData && Telemetry->canPush()) { - QJsonDocument jsonDocument; - QJsonObject jsonObject; - jsonObject["Type"] = "ImportSuccess"; -#if QT_VERSION >= 0x060000 - jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch()); -#else - jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); -#endif - jsonObject["ImportType"] = "Savegame"; - jsonDocument.setObject(jsonObject); - Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); - } - } -#endif - return success; - } - else { - if (notMultiple) QMessageBox::warning(this, tr("Import..."), tr("Failed to read Savegame file")); - delete savegame; - return false; - } - } else if (isSupportedImageFile(selectedFileName)) { SnapmaticPicture *picture = new SnapmaticPicture(); picture->initialise(photoFormat); @@ -883,10 +848,8 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime } else { SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); - SavegameData *savegame = new SavegameData(selectedFile); if (picture->readingPicture()) { bool success = importSnapmaticPicture(picture, notMultiple); - delete savegame; if (!success) delete picture; #ifdef GTA5SYNC_TELEMETRY @@ -910,44 +873,14 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); } } -#endif - return success; - } - else if (savegame->readingSavegame()) { - bool success = importSavegameData(savegame, selectedFile, notMultiple); - delete picture; - if (!success) - delete savegame; -#ifdef GTA5SYNC_TELEMETRY - if (success && notMultiple) { - QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); - telemetrySettings.beginGroup("Telemetry"); - bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); - telemetrySettings.endGroup(); - if (pushUsageData && Telemetry->canPush()) { - QJsonDocument jsonDocument; - QJsonObject jsonObject; - jsonObject["Type"] = "ImportSuccess"; -#if QT_VERSION >= 0x060000 - jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch()); -#else - jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toTime_t()); -#endif - jsonObject["ImportType"] = "Savegame"; - jsonDocument.setObject(jsonObject); - Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); - } - } #endif return success; } else { #ifdef GTA5SYNC_DEBUG qDebug() << "ImportError SnapmaticPicture" << picture->getLastStep(); - qDebug() << "ImportError SavegameData" << savegame->getLastStep(); #endif delete picture; - delete savegame; if (notMultiple) QMessageBox::warning(this, tr("Import..."), tr("Can't import %1 because file format can't be detected").arg("\""+selectedFileName+"\"")); return false; } @@ -1210,46 +1143,6 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa } } -bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPath, bool warn) -{ - QString sgdFileName; - bool foundFree = 0; - int currentSgd = 0; - - while (currentSgd < 15 && !foundFree) { - QString sgdNumber = QString::number(currentSgd); - if (sgdNumber.length() == 1) { - sgdNumber.insert(0, "0"); - } - sgdFileName = "SGTA500" % sgdNumber; - - if (!QFile::exists(profileFolder % "/" % sgdFileName)) { - foundFree = true; - } - currentSgd++; - } - - if (foundFree) { - const QString newSgdPath = profileFolder % "/" % sgdFileName; - if (QFile::copy(sgdPath, newSgdPath)) { - savegame->setSavegameFileName(newSgdPath); - savegameFiles << newSgdPath; - savegameLoaded(savegame, newSgdPath, true); - return true; - } - else { - if (warn) - QMessageBox::warning(this, tr("Import..."), tr("Savegame import failed! Can not copy the file in the profile")); - return false; - } - } - else { - if (warn) - QMessageBox::warning(this, tr("Import..."), tr("Savegame import failed! No Savegame slot is available")); - return false; - } -} - void ProfileInterface::profileWidgetSelected() { if (selectedWidgts == 0) { diff --git a/src/ProfileInterface.h b/src/ProfileInterface.h index 642101a..0046277 100644 --- a/src/ProfileInterface.h +++ b/src/ProfileInterface.h @@ -131,7 +131,6 @@ private: bool importImage(QImage *snapmaticImage, QDateTime importDateTime); bool importFilesProgress(QStringList selectedFiles); bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true); - bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true); void pictureLoaded(SnapmaticPicture *picture, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false); diff --git a/src/UserInterface.cpp b/src/UserInterface.cpp index 5a6dda4..c5c231c 100644 --- a/src/UserInterface.cpp +++ b/src/UserInterface.cpp @@ -565,10 +565,11 @@ fileDialogPreOpen: fileDialog.setWindowTitle(tr("Open File...")); QStringList filters; - filters << ProfileInterface::tr("All profile files (%1)").arg("*.g5e SGTA5* PGTA5* PRDR3*"); + filters << ProfileInterface::tr("All profile files (%1)").arg("*.g5e SGTA5* PGTA5* SRDR3* PRDR3*"); filters << ProfileInterface::tr("GTA V Export (%1)").arg("*.g5e"); filters << ProfileInterface::tr("GTA V Savegames files (%1)").arg("SGTA5*"); filters << ProfileInterface::tr("GTA V Snapmatic files (%1)").arg("PGTA5*"); + filters << ProfileInterface::tr("RDR 2 Savegames files (%1)").arg("SRDR3*"); filters << ProfileInterface::tr("RDR 2 Photo files (%1)").arg("PRDR3*"); filters << ProfileInterface::tr("All files (%1)").arg("**"); fileDialog.setNameFilters(filters);