add RDR 2 photo import and remove savegame import

This commit is contained in:
Syping 2023-10-03 23:21:16 +02:00
parent 8f8ef469d4
commit 9c0cc39b4f
3 changed files with 5 additions and 112 deletions

View file

@ -550,16 +550,16 @@ fileDialogPreOpen: //Work?
for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) { for (const QByteArray &imageFormat : QImageReader::supportedImageFormats()) {
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " "; imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
} }
QString importableFormatsStr = QString("*.g5e SGTA5* PGTA5*"); QString importableFormatsStr = QString("*.g5e PGTA5*");
if (!imageFormatsStr.trimmed().isEmpty()) { if (!imageFormatsStr.trimmed().isEmpty()) {
importableFormatsStr = QString("*.g5e%1SGTA5* PGTA5*").arg(imageFormatsStr); importableFormatsStr = QString("*.g5e%1PGTA5*").arg(imageFormatsStr);
} }
QStringList filters; QStringList filters;
filters << tr("All importable files (%1)").arg(importableFormatsStr); filters << tr("All importable files (%1)").arg(importableFormatsStr);
filters << tr("GTA V Export (%1)").arg("*.g5e"); 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("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 image files (%1)").arg(imageFormatsStr.trimmed());
filters << tr("All files (%1)").arg("**"); filters << tr("All files (%1)").arg("**");
fileDialog.setNameFilters(filters); fileDialog.setNameFilters(filters);
@ -680,41 +680,6 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
return false; 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)) { else if (isSupportedImageFile(selectedFileName)) {
SnapmaticPicture *picture = new SnapmaticPicture(); SnapmaticPicture *picture = new SnapmaticPicture();
picture->initialise(photoFormat); picture->initialise(photoFormat);
@ -883,10 +848,8 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
} }
else { else {
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
SavegameData *savegame = new SavegameData(selectedFile);
if (picture->readingPicture()) { if (picture->readingPicture()) {
bool success = importSnapmaticPicture(picture, notMultiple); bool success = importSnapmaticPicture(picture, notMultiple);
delete savegame;
if (!success) if (!success)
delete picture; delete picture;
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -910,44 +873,14 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
Telemetry->push(TelemetryCategory::PersonalData, jsonDocument); 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 #endif
return success; return success;
} }
else { else {
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
qDebug() << "ImportError SnapmaticPicture" << picture->getLastStep(); qDebug() << "ImportError SnapmaticPicture" << picture->getLastStep();
qDebug() << "ImportError SavegameData" << savegame->getLastStep();
#endif #endif
delete picture; 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+"\"")); if (notMultiple) QMessageBox::warning(this, tr("Import..."), tr("Can't import %1 because file format can't be detected").arg("\""+selectedFileName+"\""));
return false; 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() void ProfileInterface::profileWidgetSelected()
{ {
if (selectedWidgts == 0) { if (selectedWidgts == 0) {

View file

@ -131,7 +131,6 @@ private:
bool importImage(QImage *snapmaticImage, QDateTime importDateTime); bool importImage(QImage *snapmaticImage, QDateTime importDateTime);
bool importFilesProgress(QStringList selectedFiles); bool importFilesProgress(QStringList selectedFiles);
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true); bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted); void pictureLoaded(SnapmaticPicture *picture, bool inserted);
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false); void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false);

View file

@ -565,10 +565,11 @@ fileDialogPreOpen:
fileDialog.setWindowTitle(tr("Open File...")); fileDialog.setWindowTitle(tr("Open File..."));
QStringList filters; 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 Export (%1)").arg("*.g5e");
filters << ProfileInterface::tr("GTA V Savegames files (%1)").arg("SGTA5*"); filters << ProfileInterface::tr("GTA V Savegames files (%1)").arg("SGTA5*");
filters << ProfileInterface::tr("GTA V Snapmatic files (%1)").arg("PGTA5*"); 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("RDR 2 Photo files (%1)").arg("PRDR3*");
filters << ProfileInterface::tr("All files (%1)").arg("**"); filters << ProfileInterface::tr("All files (%1)").arg("**");
fileDialog.setNameFilters(filters); fileDialog.setNameFilters(filters);