diff --git a/PictureDialog.cpp b/PictureDialog.cpp
index 5d81780..5b607d4 100755
--- a/PictureDialog.cpp
+++ b/PictureDialog.cpp
@@ -57,7 +57,8 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
// Showing error if reading error
if (!readOk)
{
- QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep())); return;
+ QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
+ return;
}
if (picture->isPicOk())
diff --git a/SavegameData.cpp b/SavegameData.cpp
index 1be7c37..cd6a435 100755
--- a/SavegameData.cpp
+++ b/SavegameData.cpp
@@ -1,6 +1,108 @@
+/*****************************************************************************
+* gta5sync GRAND THEFT AUTO V SYNC
+* Copyright (C) 2016 Syping Gaming Team
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*****************************************************************************/
+
#include "SavegameData.h"
+#include
-SavegameData::SavegameData(QObject *parent) : QObject(parent)
+SavegameData::SavegameData(QString fileName, QObject *parent) : QObject(parent), savegameFileName(fileName)
{
+ // PARSE INT INIT - DO NOT CHANGE THIS VALUES
+ savegameHeaderLength = 260;
+ verificationValue = QString::fromLatin1("00000001");
+ // INIT SAVEGAME
+ savegameStr = "";
+ savegameOk = 0;
+}
+
+bool SavegameData::readingSavegame()
+{
+ // Start opening file
+ // lastStep is like currentStep
+
+ QFile *saveFile = new QFile(savegameFileName);
+ if (!saveFile->open(QFile::ReadOnly))
+ {
+ lastStep = "1;/1,OpenFile," + convertDrawStringForLog(savegameFileName);
+ return false;
+ }
+
+ // Reading Savegame Header
+ if (!saveFile->isReadable())
+ {
+ lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(savegameFileName) + ",1,NOHEADER";
+ return false;
+ }
+ QByteArray savegameHeaderLine = saveFile->read(savegameHeaderLength);
+ if (QString::fromLatin1(savegameHeaderLine.left(4).toHex()) == verificationValue)
+ {
+ savegameStr = getSavegameDataString(savegameHeaderLine);
+ if (savegameStr.length() >= 1)
+ {
+ savegameOk = true;
+ }
+ }
+
+ return savegameOk;
+}
+
+QString SavegameData::getSavegameDataString(QByteArray savegameHeader)
+{
+ QByteArray savegameUsefulBytes = savegameHeader.left(savegameHeaderLength);
+ savegameUsefulBytes.replace(QByteArray::fromHex("00"),"");
+ savegameUsefulBytes.replace(QByteArray::fromHex("01"),"");
+ return QString::fromLatin1(savegameUsefulBytes);
+}
+
+bool SavegameData::readingSavegameFromFile(QString fileName)
+{
+ if (fileName != "")
+ {
+ savegameFileName = fileName;
+ return readingSavegame();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+QString SavegameData::convertDrawStringForLog(QString inputStr)
+{
+ return inputStr.replace("&","&u;").replace(",","&c;");
+}
+
+QString SavegameData::convertLogStringForDraw(QString inputStr)
+{
+ return inputStr.replace("&c;",",").replace("&u;","&");
+}
+
+bool SavegameData::isSavegameOk()
+{
+ return savegameOk;
+}
+
+QString SavegameData::getSavegameStr()
+{
+ return savegameStr;
+}
+
+QString SavegameData::getLastStep()
+{
+ return lastStep;
}
diff --git a/SavegameData.h b/SavegameData.h
index 85aaa22..4f9f058 100755
--- a/SavegameData.h
+++ b/SavegameData.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+* gta5sync GRAND THEFT AUTO V SYNC
+* Copyright (C) 2016 Syping Gaming Team
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*****************************************************************************/
+
#ifndef SAVEGAMEDATA_H
#define SAVEGAMEDATA_H
@@ -7,11 +25,25 @@ class SavegameData : public QObject
{
Q_OBJECT
public:
- explicit SavegameData(QObject *parent = 0);
+ explicit SavegameData(QString fileName = "", QObject *parent = 0);
+ bool readingSavegameFromFile(QString fileName);
+ bool readingSavegame();
+ bool isSavegameOk();
+ QString getLastStep();
+ QString getSavegameStr();
-signals:
+private:
+ QString getSavegameDataString(QByteArray savegameHeader);
+ QString convertDrawStringForLog(QString inputStr);
+ QString convertLogStringForDraw(QString inputStr);
+ QString savegameFileName;
+ QString savegameStr;
+ QString lastStep;
+ bool savegameOk;
-public slots:
+ // PARSE INT
+ QString verificationValue;
+ int savegameHeaderLength;
};
-#endif // SAVEGAMEDATA_H
\ No newline at end of file
+#endif // SAVEGAMEDATA_H
diff --git a/SavegameDialog.cpp b/SavegameDialog.cpp
new file mode 100755
index 0000000..6e75c26
--- /dev/null
+++ b/SavegameDialog.cpp
@@ -0,0 +1,34 @@
+#include "SavegameDialog.h"
+#include "ui_SavegameDialog.h"
+
+#include
+
+SavegameDialog::SavegameDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::SavegameDialog)
+{
+ ui->setupUi(this);
+ savegameLabStr = ui->labSavegameText->text();
+}
+
+SavegameDialog::~SavegameDialog()
+{
+ delete ui;
+}
+
+void SavegameDialog::setSavegameData(SavegameData *savegame, bool readOk)
+{
+ // Showing error if reading error
+ if (!readOk)
+ {
+ QMessageBox::warning(this,tr("Savegame Viewer"),tr("Failed at %1").arg(savegame->getLastStep()));
+ return;
+ }
+
+ ui->labSavegameText->setText(savegameLabStr.arg(savegame->getSavegameStr()));
+}
+
+void SavegameDialog::on_cmdClose_clicked()
+{
+ this->close();
+}
diff --git a/SavegameDialog.h b/SavegameDialog.h
new file mode 100755
index 0000000..deec5e1
--- /dev/null
+++ b/SavegameDialog.h
@@ -0,0 +1,27 @@
+#ifndef SAVEGAMEDIALOG_H
+#define SAVEGAMEDIALOG_H
+
+#include "SavegameData.h"
+#include
+
+namespace Ui {
+class SavegameDialog;
+}
+
+class SavegameDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit SavegameDialog(QWidget *parent = 0);
+ void setSavegameData(SavegameData *savegame, bool readOk);
+ ~SavegameDialog();
+
+private slots:
+ void on_cmdClose_clicked();
+
+private:
+ Ui::SavegameDialog *ui;
+ QString savegameLabStr;
+};
+
+#endif // SAVEGAMEDIALOG_H
diff --git a/SavegameDialog.ui b/SavegameDialog.ui
new file mode 100755
index 0000000..a72159d
--- /dev/null
+++ b/SavegameDialog.ui
@@ -0,0 +1,65 @@
+
+
+ SavegameDialog
+
+
+
+ 0
+ 0
+ 400
+ 100
+
+
+
+ Savegame Viewer
+
+
+ -
+
+
+ <span style=" font-weight:600;">Savegame</span><br><br>%1
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 3
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Close
+
+
+
+
+
+
+
+
+
+
diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp
index 4df482e..111ea18 100755
--- a/SnapmaticPicture.cpp
+++ b/SnapmaticPicture.cpp
@@ -23,10 +23,9 @@
#include
#include
#include
-#include
#include
-SnapmaticPicture::SnapmaticPicture(QObject *parent, QString fileName) : QObject(parent)
+SnapmaticPicture::SnapmaticPicture(QString fileName, QObject *parent) : QObject(parent), picFileName(fileName)
{
// PARSE INT INIT - DO NOT CHANGE THIS VALUES
snapmaticHeaderLength = 278;
@@ -38,7 +37,6 @@ SnapmaticPicture::SnapmaticPicture(QObject *parent, QString fileName) : QObject(
// INIT PIC
cachePicture = QPixmap(0,0);
- picFileName = "";
pictureStr = "";
lastStep = "";
picOk = 0;
@@ -51,12 +49,6 @@ SnapmaticPicture::SnapmaticPicture(QObject *parent, QString fileName) : QObject(
jsonLocZ = 0;
jsonCrewID = 0;
jsonPlyrsList = QStringList();
-
- // SET PIC FILENAME
- if (fileName != "")
- {
- picFileName = fileName;
- }
}
bool SnapmaticPicture::readingPicture()
diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h
index f81c292..8496583 100755
--- a/SnapmaticPicture.h
+++ b/SnapmaticPicture.h
@@ -29,11 +29,10 @@ class SnapmaticPicture : public QObject
{
Q_OBJECT
public:
- explicit SnapmaticPicture(QObject *parent = 0, QString fileName = "");
+ explicit SnapmaticPicture(QString fileName = "", QObject *parent = 0);
bool readingPictureFromFile(QString fileName);
bool readingPicture();
void setPixmap(QPixmap pixmap);
- void resetValues();
bool isPicOk();
QPixmap getPixmap();
QString getLastStep();
diff --git a/gta5sync.pro b/gta5sync.pro
index e491737..8c12db5 100755
--- a/gta5sync.pro
+++ b/gta5sync.pro
@@ -31,7 +31,8 @@ SOURCES += main.cpp\
ProfileDatabase.cpp \
DatabaseThread.cpp \
CrewDatabase.cpp \
- SavegameData.cpp
+ SavegameData.cpp \
+ SavegameDialog.cpp
HEADERS += \
SnapmaticPicture.h \
@@ -39,10 +40,12 @@ HEADERS += \
ProfileDatabase.h \
DatabaseThread.h \
CrewDatabase.h \
- SavegameData.h
+ SavegameData.h \
+ SavegameDialog.h
FORMS += \
- PictureDialog.ui
+ PictureDialog.ui \
+ SavegameDialog.ui
RESOURCES +=
diff --git a/main.cpp b/main.cpp
index 4f4fb70..1bad84c 100755
--- a/main.cpp
+++ b/main.cpp
@@ -19,8 +19,10 @@
#include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include "DatabaseThread.h"
+#include "SavegameDialog.h"
#include "PictureDialog.h"
#include "CrewDatabase.h"
+#include "SavegameData.h"
#include
#include
#include
@@ -47,6 +49,12 @@ int main(int argc, char *argv[])
arg1 = reworkedArg;
selectedAction = "showpic";
}
+ else if (currentArg.left(9) == "-showsgd=" && selectedAction == "")
+ {
+ reworkedArg = currentArg.remove(0,9);
+ arg1 = reworkedArg;
+ selectedAction = "showsgd";
+ }
else if (selectedAction == "")
{
QFile argumentFile(currentArg);
@@ -58,15 +66,14 @@ int main(int argc, char *argv[])
}
}
- CrewDatabase *crewDB = new CrewDatabase();
- ProfileDatabase *profileDB = new ProfileDatabase();
- DatabaseThread *threadDB = new DatabaseThread(crewDB);
- QObject::connect(threadDB, SIGNAL(playerNameFound(int,QString)), profileDB, SLOT(setPlayerName(int,QString)));
-
if (selectedAction == "showpic")
{
+ CrewDatabase *crewDB = new CrewDatabase();
+ ProfileDatabase *profileDB = new ProfileDatabase();
+ DatabaseThread *threadDB = new DatabaseThread(crewDB);
PictureDialog *picDialog = new PictureDialog(profileDB);
SnapmaticPicture picture;
+
bool readOk = picture.readingPictureFromFile(arg1);
picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog->setSnapmaticPicture(&picture, readOk);
@@ -75,12 +82,29 @@ int main(int argc, char *argv[])
if (crewID != 0) { crewDB->addCrew(crewID); }
if (!readOk) { return 1; }
+ QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(on_playerNameUpdated()));
threadDB->start();
+
picDialog->show();
return a.exec();
}
+ else if (selectedAction == "showsgd")
+ {
+ SavegameDialog *savegameDialog = new SavegameDialog();
+ SavegameData savegame;
+
+ bool readOk = savegame.readingSavegameFromFile(arg1);
+ savegameDialog->setWindowFlags(savegameDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
+ savegameDialog->setSavegameData(&savegame, readOk);
+
+ if (!readOk) { return 1; }
+
+ savegameDialog->show();
+
+ return a.exec();
+ }
return 0;
}