2017-10-09 08:35:48 +02:00
/*****************************************************************************
2023-01-27 20:09:43 +01:00
* gta5view Grand Theft Auto V Profile Viewer
* Copyright ( C ) 2016 - 2023 Syping
2017-10-09 08:35:48 +02:00
*
* 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 SNAPMATICPICTURE_H
# define SNAPMATICPICTURE_H
2023-02-20 15:22:30 +01:00
# ifdef RAGEPHOTO_USE_ABI_WRAPPER
# include <RagePhotoA.h>
typedef RagePhotoA RagePhoto ;
# else
# include <RagePhoto.h>
# endif
2017-10-09 08:35:48 +02:00
# include <QStringList>
2023-01-27 20:09:43 +01:00
# include <QJsonObject>
2017-10-09 08:35:48 +02:00
# include <QDateTime>
# include <QObject>
# include <QString>
# include <QImage>
2023-02-27 14:17:50 +01:00
enum class SnapmaticFormat : int32_t { Auto_Format = 0 , PGTA5_Format = 1 , PRDR3_Format = 2 , JPEG_Format = 3 , G5E_Format = 4 , Unknown_Format = - 1 } ;
2023-01-27 20:09:43 +01:00
enum G5EExportFormat : uint32_t {
G5E1P = 0x454C0010UL ,
G5E2P = 0x01000032UL ,
G5E2S = 0x02000032UL ,
G5E3P = 0x01000033UL ,
G5E3S = 0x02000033UL ,
} ;
enum G5EPhotoFormat : uint32_t {
G5EX = 0x45354700UL ,
} ;
2017-10-09 08:35:48 +02:00
struct SnapmaticProperties {
struct SnapmaticLocation {
QString area ;
double x ;
double y ;
double z ;
2021-02-15 23:12:44 +01:00
bool isCayoPerico ;
2017-10-09 08:35:48 +02:00
} ;
int uid ;
int crewID ;
2017-11-22 14:59:40 +01:00
int streetID ;
2017-10-09 08:35:48 +02:00
QStringList playersList ;
uint createdTimestamp ;
QDateTime createdDateTime ;
bool isMeme ;
bool isMug ;
bool isSelfie ;
bool isFromDirector ;
bool isFromRSEditor ;
SnapmaticLocation location ;
} ;
class SnapmaticPicture : public QObject
{
Q_OBJECT
public :
explicit SnapmaticPicture ( const QString & fileName = " " , QObject * parent = 0 ) ;
~ SnapmaticPicture ( ) ;
void reset ( ) ;
bool preloadFile ( ) ;
2020-11-09 01:42:11 +01:00
bool readingPictureFromFile ( const QString & fileName , bool cacheEnabled = false ) ;
bool readingPicture ( bool cacheEnabled = false ) ;
2017-12-12 04:45:46 +01:00
bool isPicOk ( ) ; // Please use isPictureOk instead
2017-10-09 08:35:48 +02:00
void clearCache ( ) ;
2023-02-27 14:17:50 +01:00
const QImage getImage ( ) ;
const QByteArray getPictureStream ( ) ;
const QString getLastStep ( bool readable = true ) ;
const QString getPictureStr ( ) ;
const QString getPictureTitl ( ) ;
const QString getPictureSortStr ( ) ;
const QString getPictureFileName ( ) ;
const QString getPictureFilePath ( ) ;
const QString getExportPictureFileName ( ) ;
const QString getOriginalPictureFileName ( ) ;
const QString getOriginalPictureFilePath ( ) ;
2020-11-15 13:15:16 +01:00
bool setImage ( const QImage & picture , bool eXtendMode = false ) ;
2017-12-12 04:45:46 +01:00
bool setPictureTitl ( const QString & newTitle ) ; // Please use setPictureTitle instead
bool setPictureStream ( const QByteArray & streamArray ) ;
2017-10-09 08:35:48 +02:00
void updateStrings ( ) ;
void emitUpdate ( ) ;
2017-12-17 13:03:43 +01:00
void emitCustomSignal ( const QString & signal ) ;
2017-10-09 08:35:48 +02:00
// FILE MANAGEMENT
bool exportPicture ( const QString & fileName , SnapmaticFormat format = SnapmaticFormat : : Auto_Format ) ;
2023-02-27 14:17:50 +01:00
void setPicFileName ( const QString & picFileName ) ;
void setPicFilePath ( const QString & picFilePath ) ;
bool deletePicFile ( ) ;
2017-10-09 08:35:48 +02:00
// JSON
bool isJsonOk ( ) ;
2023-02-27 14:17:50 +01:00
const QString getJsonStr ( ) ;
2017-10-09 08:35:48 +02:00
SnapmaticProperties getSnapmaticProperties ( ) ;
2017-12-12 04:45:46 +01:00
bool setSnapmaticProperties ( SnapmaticProperties properties ) ;
2023-02-27 14:17:50 +01:00
bool setJsonStr ( const QString & jsonStr , bool updateProperties = false ) ;
2017-10-09 08:35:48 +02:00
// VISIBILITY
2023-02-27 14:17:50 +01:00
bool isHidden ( ) ;
bool isVisible ( ) ;
2017-10-09 08:35:48 +02:00
bool setPictureHidden ( ) ;
bool setPictureVisible ( ) ;
2017-12-12 04:45:46 +01:00
// ALTERNATIVES (MORE DEVELOPER FRIENDLY FUNCTION CALLS)
2023-02-27 14:17:50 +01:00
inline QString getJsonString ( ) { return getJsonStr ( ) ; }
inline QString getPictureJson ( ) { return getJsonStr ( ) ; }
inline QString getPictureTitle ( ) { return getPictureTitl ( ) ; }
inline uint32_t getPictureSize ( ) { return ragePhoto ( ) - > jpegSize ( ) ; }
inline QString getPictureString ( ) { return getPictureStr ( ) ; }
inline bool setJsonString ( const QString & jsonString , bool updateProperties = false ) { return setJsonStr ( jsonString , updateProperties ) ; } // Please use setPictureJson instead
inline bool setPictureJson ( const QString & json , bool updateProperties = false ) { return setJsonStr ( json , updateProperties ) ; }
inline bool setPictureTitle ( const QString & title ) { return setPictureTitl ( title ) ; }
inline void setPictureFileName ( const QString & fileName ) { return setPicFileName ( fileName ) ; }
inline void setPictureFilePath ( const QString & filePath ) { return setPicFilePath ( filePath ) ; }
inline bool deletePictureFile ( ) { return deletePicFile ( ) ; }
inline bool isPictureOk ( ) { return isPicOk ( ) ; }
inline bool isPictureHidden ( ) { return isHidden ( ) ; }
inline bool isPictureVisible ( ) { return isVisible ( ) ; }
inline bool setHidden ( ) { return setPictureHidden ( ) ; }
inline bool setVisible ( ) { return setPictureVisible ( ) ; }
2017-12-12 04:45:46 +01:00
2017-10-09 08:35:48 +02:00
// PREDEFINED PROPERTIES
2020-08-25 17:29:41 +02:00
static QSize getSnapmaticResolution ( ) ;
2017-10-09 08:35:48 +02:00
2017-11-22 20:23:36 +01:00
// SNAPMATIC FORMAT
SnapmaticFormat getSnapmaticFormat ( ) ;
void setSnapmaticFormat ( SnapmaticFormat format ) ;
bool isFormatSwitched ( ) ;
2017-10-09 08:35:48 +02:00
// VERIFY CONTENT
static bool verifyTitle ( const QString & title ) ;
2018-05-24 22:32:00 +02:00
// STRING OPERATIONS
2023-01-27 20:09:43 +01:00
static QString parseTitleString ( const QByteArray & commitBytes ) ;
2018-05-24 22:32:00 +02:00
static QString convertDrawStringForLog ( const QString & inputStr ) ;
static QString convertLogStringForDraw ( const QString & inputStr ) ;
2020-11-15 12:29:33 +01:00
// RAGEPHOTO
RagePhoto * ragePhoto ( ) ;
2017-10-09 08:35:48 +02:00
private :
QImage cachePicture ;
QString picExportFileName ;
QString picFileName ;
QString picFilePath ;
QString pictureStr ;
QString lastStep ;
QString sortStr ;
bool picOk ;
bool cacheEnabled ;
2017-11-22 20:23:36 +01:00
bool isFormatSwitch ;
2023-01-27 20:09:43 +01:00
bool isPreLoaded ;
2017-10-09 08:35:48 +02:00
// JSON
void parseJsonContent ( ) ;
bool jsonOk ;
2017-12-12 04:45:46 +01:00
SnapmaticProperties localProperties ;
2023-01-27 20:09:43 +01:00
QJsonObject jsonObject ;
2017-10-09 08:35:48 +02:00
// VERIFY CONTENT
static bool verifyTitleChar ( const QChar & titleChar ) ;
2020-11-09 01:08:51 +01:00
// RAGEPHOTO
2020-11-15 12:29:33 +01:00
RagePhoto p_ragePhoto ;
2020-11-09 01:08:51 +01:00
2017-10-09 08:35:48 +02:00
signals :
2017-12-17 13:03:43 +01:00
void customSignal ( QString signal ) ;
2017-10-09 08:35:48 +02:00
void preloaded ( ) ;
void updated ( ) ;
void loaded ( ) ;
public slots :
} ;
# endif // SNAPMATICPICTURE_H