added savegame viewer
This commit is contained in:
parent
69494fc100
commit
c126840e4c
10 changed files with 304 additions and 25 deletions
|
@ -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())
|
||||
|
|
104
SavegameData.cpp
104
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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SavegameData.h"
|
||||
#include <QFile>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#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
|
||||
#endif // SAVEGAMEDATA_H
|
||||
|
|
34
SavegameDialog.cpp
Executable file
34
SavegameDialog.cpp
Executable file
|
@ -0,0 +1,34 @@
|
|||
#include "SavegameDialog.h"
|
||||
#include "ui_SavegameDialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
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();
|
||||
}
|
27
SavegameDialog.h
Executable file
27
SavegameDialog.h
Executable file
|
@ -0,0 +1,27 @@
|
|||
#ifndef SAVEGAMEDIALOG_H
|
||||
#define SAVEGAMEDIALOG_H
|
||||
|
||||
#include "SavegameData.h"
|
||||
#include <QDialog>
|
||||
|
||||
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
|
65
SavegameDialog.ui
Executable file
65
SavegameDialog.ui
Executable file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SavegameDialog</class>
|
||||
<widget class="QDialog" name="SavegameDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Savegame Viewer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vlSavegameDialog">
|
||||
<item>
|
||||
<widget class="QLabel" name="labSavegameText">
|
||||
<property name="text">
|
||||
<string><span style=" font-weight:600;">Savegame</span><br><br>%1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vsSavegameDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>3</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlButtons">
|
||||
<item>
|
||||
<spacer name="hsButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -23,10 +23,9 @@
|
|||
#include <QJsonArray>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
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()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 +=
|
||||
|
||||
|
|
34
main.cpp
34
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 <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue