2020-11-08 03:50:06 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* gta5view Grand Theft Auto V Profile Viewer
|
|
|
|
* Copyright (C) 2020 Syping
|
|
|
|
*
|
|
|
|
* 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 RAGEPHOTO_H
|
|
|
|
#define RAGEPHOTO_H
|
|
|
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class RagePhoto : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-11 07:04:39 +01:00
|
|
|
enum class JsonFormat : quint8 {
|
|
|
|
Original = 0,
|
|
|
|
Compact = 1,
|
|
|
|
Indented = 2,
|
|
|
|
};
|
2020-11-09 01:08:51 +01:00
|
|
|
enum class ExportFormat : quint32 {
|
2020-11-09 02:13:06 +01:00
|
|
|
G5E1P = 0x454C0010U,
|
2020-11-08 18:05:44 +01:00
|
|
|
G5E2P = 0x01000032U,
|
|
|
|
G5E2S = 0x02000032U,
|
|
|
|
G5E3P = 0x01000033U,
|
|
|
|
G5E3S = 0x02000033U,
|
2020-11-09 01:08:51 +01:00
|
|
|
Undefined = 0,
|
2020-11-08 18:05:44 +01:00
|
|
|
};
|
2020-11-09 01:08:51 +01:00
|
|
|
enum class PhotoFormat : quint32 {
|
2020-11-08 18:05:44 +01:00
|
|
|
G5EX = 0x45354700U,
|
2020-11-08 03:50:06 +01:00
|
|
|
GTA5 = 0x01000000U,
|
|
|
|
RDR2 = 0x04000000U,
|
2020-11-09 01:08:51 +01:00
|
|
|
Undefined = 0,
|
2020-11-08 03:50:06 +01:00
|
|
|
};
|
2020-11-11 07:04:39 +01:00
|
|
|
explicit RagePhoto();
|
2020-11-08 18:05:44 +01:00
|
|
|
explicit RagePhoto(const QByteArray &data);
|
2020-11-11 07:04:39 +01:00
|
|
|
explicit RagePhoto(const QString &filePath);
|
2020-11-09 01:23:01 +01:00
|
|
|
explicit RagePhoto(QIODevice *ioDevice);
|
2020-11-08 03:50:06 +01:00
|
|
|
bool isLoaded();
|
|
|
|
bool load();
|
|
|
|
void clear();
|
|
|
|
void setDescription(const QString &description);
|
2020-11-09 01:08:51 +01:00
|
|
|
void setFileData(const QByteArray &data);
|
2020-11-08 03:50:06 +01:00
|
|
|
void setFilePath(const QString &filePath);
|
2020-11-09 01:23:01 +01:00
|
|
|
void setIODevice(QIODevice *ioDevice);
|
2020-11-09 01:08:51 +01:00
|
|
|
bool setJsonData(const QByteArray &data);
|
2020-11-15 12:29:33 +01:00
|
|
|
bool setPhotoBuffer(quint32 size, bool moveOffsets = true);
|
2020-11-09 01:08:51 +01:00
|
|
|
bool setPhotoData(const QByteArray &data);
|
|
|
|
bool setPhotoData(const char *data, int size);
|
|
|
|
void setPhotoFormat(PhotoFormat photoFormat);
|
2020-11-08 03:50:06 +01:00
|
|
|
void setTitle(const QString &title);
|
2020-11-09 01:08:51 +01:00
|
|
|
const QJsonObject jsonObject();
|
2020-11-11 07:04:39 +01:00
|
|
|
const QByteArray jsonData(JsonFormat jsonFormat = JsonFormat::Original);
|
2020-11-08 03:50:06 +01:00
|
|
|
const QByteArray photoData();
|
|
|
|
const QString description();
|
|
|
|
const QString photoString();
|
|
|
|
const QString title();
|
2020-11-09 01:08:51 +01:00
|
|
|
quint32 photoBuffer();
|
2020-11-09 01:42:11 +01:00
|
|
|
quint32 photoSize();
|
2020-11-09 01:08:51 +01:00
|
|
|
PhotoFormat photoFormat();
|
2020-11-09 03:43:46 +01:00
|
|
|
QByteArray save(PhotoFormat photoFormat);
|
|
|
|
void save(QIODevice *ioDevice, PhotoFormat photoFormat);
|
2020-11-08 03:50:06 +01:00
|
|
|
static RagePhoto* loadFile(const QString &filePath);
|
|
|
|
|
|
|
|
private:
|
2020-11-08 18:05:44 +01:00
|
|
|
inline quint32 charToUInt32BE(char *x);
|
|
|
|
inline quint32 charToUInt32LE(char *x);
|
2020-11-08 20:53:43 +01:00
|
|
|
inline void uInt32ToCharBE(quint32 *x, char *y);
|
|
|
|
inline void uInt32ToCharLE(quint32 *x, char *y);
|
2020-11-11 17:58:15 +01:00
|
|
|
inline QByteArray stringToUtf16LE(const QString &string);
|
|
|
|
inline QString utf16LEToString(const QByteArray &data);
|
|
|
|
inline QString utf16LEToString(const char *data, int size);
|
2020-11-09 01:08:51 +01:00
|
|
|
PhotoFormat p_photoFormat;
|
2020-11-08 03:50:06 +01:00
|
|
|
QJsonObject p_jsonObject;
|
2020-11-08 18:05:44 +01:00
|
|
|
QByteArray p_fileData;
|
2020-11-09 01:08:51 +01:00
|
|
|
QByteArray p_jsonData;
|
2020-11-08 03:50:06 +01:00
|
|
|
QByteArray p_photoData;
|
|
|
|
QIODevice *p_ioDevice;
|
|
|
|
QString p_descriptionString;
|
|
|
|
QString p_filePath;
|
|
|
|
QString p_photoString;
|
|
|
|
QString p_titleString;
|
2020-11-11 07:04:39 +01:00
|
|
|
quint32 p_descBuffer;
|
2020-11-08 03:50:06 +01:00
|
|
|
quint32 p_descOffset;
|
|
|
|
quint32 p_endOfFile;
|
2020-11-08 18:05:44 +01:00
|
|
|
quint32 p_headerSum;
|
2020-11-11 07:04:39 +01:00
|
|
|
quint32 p_jsonBuffer;
|
2020-11-08 03:50:06 +01:00
|
|
|
quint32 p_jsonOffset;
|
2020-11-11 07:04:39 +01:00
|
|
|
quint32 p_photoBuffer;
|
|
|
|
quint32 p_titlBuffer;
|
2020-11-08 03:50:06 +01:00
|
|
|
quint32 p_titlOffset;
|
|
|
|
bool p_isLoaded;
|
|
|
|
int p_inputMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RAGEPHOTO_H
|