gta5view/RagePhoto.h

111 lines
3.6 KiB
C
Raw Normal View History

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:
enum class JsonFormat : quint8 {
Original = 0,
Compact = 1,
Indented = 2,
};
enum class ExportFormat : quint32 {
2020-11-09 02:13:06 +01:00
G5E1P = 0x454C0010U,
G5E2P = 0x01000032U,
G5E2S = 0x02000032U,
G5E3P = 0x01000033U,
G5E3S = 0x02000033U,
Undefined = 0,
};
enum class PhotoFormat : quint32 {
G5EX = 0x45354700U,
2020-11-08 03:50:06 +01:00
GTA5 = 0x01000000U,
RDR2 = 0x04000000U,
Undefined = 0,
2020-11-08 03:50:06 +01:00
};
explicit RagePhoto();
explicit RagePhoto(const QByteArray &data);
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);
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);
bool setJsonData(const QByteArray &data);
2020-11-15 12:29:33 +01:00
bool setPhotoBuffer(quint32 size, bool moveOffsets = true);
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);
const QJsonObject jsonObject();
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();
quint32 photoBuffer();
quint32 photoSize();
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:
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);
PhotoFormat p_photoFormat;
2020-11-08 03:50:06 +01:00
QJsonObject p_jsonObject;
QByteArray p_fileData;
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;
quint32 p_descBuffer;
2020-11-08 03:50:06 +01:00
quint32 p_descOffset;
quint32 p_endOfFile;
quint32 p_headerSum;
quint32 p_jsonBuffer;
2020-11-08 03:50:06 +01:00
quint32 p_jsonOffset;
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