change submodule to gta5view

This commit is contained in:
Syping 2018-02-21 12:11:43 +01:00
parent 0c5340919f
commit 8ccfcc20f0
5 changed files with 475 additions and 496 deletions

@ -1 +0,0 @@
Subproject commit 15fd35642534a3f46046a5cc2bf27f41e77b14f5

1
gta5view Submodule

@ -0,0 +1 @@
Subproject commit 12f8430f343b80ad1be717c587329686720f6725

View File

@ -1,6 +1,6 @@
#/***************************************************************************** #/*****************************************************************************
#* gta5view-cmd - gta5view Command Line #* gta5view-cmd - gta5view Command Line
#* Copyright (C) 2017 Syping #* Copyright (C) 2017-2018 Syping
#* #*
#* This program is free software: you can redistribute it and/or modify #* 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 #* it under the terms of the GNU General Public License as published by
@ -25,42 +25,21 @@ TEMPLATE = app
CONFIG += console CONFIG += console
SOURCES += main.cpp \ SOURCES += main.cpp \
gta5sync/SnapmaticPicture.cpp \ gta5view/SnapmaticPicture.cpp \
gta5sync/StringParser.cpp gta5view/StringParser.cpp
HEADERS += \ HEADERS += \
gta5sync/SnapmaticPicture.h \ gta5view/SnapmaticPicture.h \
gta5sync/StringParser.h gta5view/StringParser.h
INCLUDEPATH += ./gta5sync INCLUDEPATH += ./gta5view
# WINDOWS ONLY # WINDOWS ONLY
win32: DEFINES += GTA5SYNC_WIN win32: DEFINES += GTA5SYNC_WIN
# win32: RC_FILE += res/app.rc # win32: RC_FILE += res/app.rc
win32: LIBS += -luser32
win32: CONFIG -= embed_manifest_exe win32: CONFIG -= embed_manifest_exe
# QT4 ONLY STUFF
isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./gta5sync/qjson4
isEqual(QT_MAJOR_VERSION, 4): HEADERS += gta5sync/qjson4/QJsonArray.h \
gta5sync/qjson4/QJsonDocument.h \
gta5sync/qjson4/QJsonObject.h \
gta5sync/qjson4/QJsonParseError.h \
gta5sync/qjson4/QJsonValue.h \
gta5sync/qjson4/QJsonValueRef.h \
gta5sync/qjson4/QJsonParser.h \
gta5sync/qjson4/QJsonRoot.h
isEqual(QT_MAJOR_VERSION, 4): SOURCES += gta5sync/qjson4/QJsonArray.cpp \
gta5sync/qjson4/QJsonDocument.cpp \
gta5sync/qjson4/QJsonObject.cpp \
gta5sync/qjson4/QJsonParseError.cpp \
gta5sync/qjson4/QJsonValue.cpp \
gta5sync/qjson4/QJsonValueRef.cpp \
gta5sync/qjson4/QJsonParser.cpp
RESOURCES += \ RESOURCES += \
res.qrc res.qrc

926
main.cpp
View File

@ -1,463 +1,463 @@
/***************************************************************************** /*****************************************************************************
* gta5view-cmd - gta5view Command Line * gta5view-cmd - gta5view Command Line
* Copyright (C) 2017 Syping * Copyright (C) 2017-2018 Syping
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include "SnapmaticPicture.h" #include "gta5view/SnapmaticPicture.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QImageReader> #include <QImageReader>
#include <QDateTime> #include <QDateTime>
#include <QPainter> #include <QPainter>
#include <QImage> #include <QImage>
#include <QMap> #include <QMap>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
QStringList args = a.arguments(); QStringList args = a.arguments();
if (args.length() >= 3) if (args.length() >= 3)
{ {
QString format = "jpg"; QString format = "jpg";
bool isDefault = true; bool isDefault = true;
bool avatarMode = false; bool avatarMode = false;
bool convertToGTA = false; bool convertToGTA = false;
bool customFormat = false; bool customFormat = false;
bool formatSwitch = false; bool formatSwitch = false;
bool keepAspectRatio = true; bool keepAspectRatio = true;
QMap<QString,QString> flags; QMap<QString,QString> flags;
if (args.length() >= 4) if (args.length() >= 4)
{ {
if (args.at(3) == "-pgta") if (args.at(3) == "-pgta")
{ {
convertToGTA = true; convertToGTA = true;
customFormat = false; customFormat = false;
} }
else if (args.at(3) == "-g5e") else if (args.at(3) == "-g5e")
{ {
convertToGTA = true; convertToGTA = true;
customFormat = true; customFormat = true;
} }
else if (args.at(3) == "-jpg") else if (args.at(3) == "-jpg")
{ {
format = "jpg"; format = "jpg";
convertToGTA = false; convertToGTA = false;
} }
} }
if (args.length() >= 5) if (args.length() >= 5)
{ {
if (args.at(4) == "-a") if (args.at(4) == "-a")
{ {
isDefault = false; isDefault = false;
avatarMode = true; avatarMode = true;
} }
else if (args.at(4) == "-p") else if (args.at(4) == "-p")
{ {
isDefault = false; isDefault = false;
avatarMode = false; avatarMode = false;
} }
else if (args.at(4) == "-d") else if (args.at(4) == "-d")
{ {
isDefault = true; isDefault = true;
} }
else if (args.at(4) == "-aiar") else if (args.at(4) == "-aiar")
{ {
isDefault = false; isDefault = false;
avatarMode = true; avatarMode = true;
keepAspectRatio = false; keepAspectRatio = false;
} }
else if (args.at(4) == "-akar") else if (args.at(4) == "-akar")
{ {
isDefault = false; isDefault = false;
avatarMode = true; avatarMode = true;
keepAspectRatio = true; keepAspectRatio = true;
} }
else if (args.at(4) == "-piar") else if (args.at(4) == "-piar")
{ {
isDefault = false; isDefault = false;
avatarMode = false; avatarMode = false;
keepAspectRatio = false; keepAspectRatio = false;
} }
else if (args.at(4) == "-pkar") else if (args.at(4) == "-pkar")
{ {
isDefault = false; isDefault = false;
avatarMode = false; avatarMode = false;
keepAspectRatio = true; keepAspectRatio = true;
} }
else if (args.at(4) == "-diar") else if (args.at(4) == "-diar")
{ {
isDefault = true; isDefault = true;
keepAspectRatio = false; keepAspectRatio = false;
} }
else if (args.at(4) == "-dkar") else if (args.at(4) == "-dkar")
{ {
isDefault = true; isDefault = true;
keepAspectRatio = true; keepAspectRatio = true;
} }
else if (args.at(4) == "-fs") else if (args.at(4) == "-fs")
{ {
convertToGTA = false; convertToGTA = false;
formatSwitch = true; formatSwitch = true;
} }
} }
if (args.length() >= 6) if (args.length() >= 6)
{ {
QStringList flagArgs(args); QStringList flagArgs(args);
for (int argId = 0; argId == 5; argId++) for (int argId = 0; argId == 5; argId++)
{ {
flagArgs.removeAt(argId); flagArgs.removeAt(argId);
} }
for (QString flagArg : flagArgs) for (QString flagArg : flagArgs)
{ {
QStringList currentFlagArg = flagArg.split("="); QStringList currentFlagArg = flagArg.split("=");
QString currentFlag = currentFlagArg.at(0).toLower(); QString currentFlag = currentFlagArg.at(0).toLower();
if (currentFlag.left(1) == "-") if (currentFlag.left(1) == "-")
{ {
currentFlag.remove(0, 1); currentFlag.remove(0, 1);
currentFlagArg.removeAt(0); currentFlagArg.removeAt(0);
QString currentValue = currentFlagArg.join(QString()); QString currentValue = currentFlagArg.join(QString());
flags[currentFlag] = currentValue; flags[currentFlag] = currentValue;
} }
} }
} }
if (!convertToGTA) if (!convertToGTA)
{ {
SnapmaticPicture picture(args.at(1)); SnapmaticPicture picture(args.at(1));
if (picture.readingPicture(true, false, true)) if (picture.readingPicture(true, false, true))
{ {
QString filePath = args.at(2); QString filePath = args.at(2);
if (!formatSwitch) if (!formatSwitch)
{ {
filePath.replace("<autodef>", picture.getExportPictureFileName()); filePath.replace("<autodef>", picture.getExportPictureFileName());
filePath.replace("<autoext>", ".jpg"); filePath.replace("<autoext>", ".jpg");
if (!picture.exportPicture(filePath, SnapmaticFormat::JPEG_Format)) if (!picture.exportPicture(filePath, SnapmaticFormat::JPEG_Format))
{ {
cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
else else
{ {
if (flags.value("output", QString()).toLower() == "exported_filename") if (flags.value("output", QString()).toLower() == "exported_filename")
{ {
cout << filePath.toStdString().c_str() << endl; cout << filePath.toStdString().c_str() << endl;
} }
else else
{ {
cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl;
} }
} }
} }
else else
{ {
filePath.replace("<autodef>", picture.getPictureFileName()); filePath.replace("<autodef>", picture.getPictureFileName());
if (customFormat) if (customFormat)
{ {
filePath.replace("<autoext>", ".g5e"); filePath.replace("<autoext>", ".g5e");
if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format)) if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format))
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
else else
{ {
if (flags.value("output", QString()).toLower() == "exported_filename") if (flags.value("output", QString()).toLower() == "exported_filename")
{ {
cout << filePath.toStdString().c_str() << endl; cout << filePath.toStdString().c_str() << endl;
} }
else else
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl;
} }
} }
} }
else else
{ {
filePath.replace("<autoext>", ""); filePath.replace("<autoext>", "");
if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format)) if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format))
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
else else
{ {
if (flags.value("output", QString()).toLower() == "exported_filename") if (flags.value("output", QString()).toLower() == "exported_filename")
{ {
cout << filePath.toStdString().c_str() << endl; cout << filePath.toStdString().c_str() << endl;
} }
else else
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl;
} }
} }
} }
} }
} }
else else
{ {
cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
} }
else else
{ {
SnapmaticPicture picture(":/template.g5e"); SnapmaticPicture picture(":/template.g5e");
if (picture.readingPicture(true, false, true)) if (picture.readingPicture(true, false, true))
{ {
QImage image; QImage image;
QFile imageFile(args.at(1)); QFile imageFile(args.at(1));
if (!imageFile.open(QFile::ReadOnly)) if (!imageFile.open(QFile::ReadOnly))
{ {
cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
QImageReader imageReader; QImageReader imageReader;
imageReader.setDecideFormatFromContent(true); imageReader.setDecideFormatFromContent(true);
imageReader.setDevice(&imageFile); imageReader.setDevice(&imageFile);
if (!imageReader.read(&image)) if (!imageReader.read(&image))
{ {
cout << "gta5view-cmd: Parsing of " << args.at(1).toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Parsing of " << args.at(1).toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
if (!image.isNull()) if (!image.isNull())
{ {
QSize snapmaticRes(960, 536); QSize snapmaticRes(960, 536);
QSize avatarRes(470, 470); QSize avatarRes(470, 470);
int avatarZoneX = 145; int avatarZoneX = 145;
int avatarZoneY = 66; int avatarZoneY = 66;
if (isDefault) if (isDefault)
{ {
if (image.width() == image.height()) if (image.width() == image.height())
{ {
avatarMode = true; avatarMode = true;
} }
else else
{ {
avatarMode = false; avatarMode = false;
} }
} }
if (!avatarMode) if (!avatarMode)
{ {
QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888); QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
snapmaticImage.fill(Qt::black); snapmaticImage.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticImage); QPainter snapmaticPainter(&snapmaticImage);
// Picture mode // Picture mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (keepAspectRatio) if (keepAspectRatio)
{ {
image = image.scaled(snapmaticRes, Qt::KeepAspectRatio, Qt::SmoothTransformation); image = image.scaled(snapmaticRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (image.width() != snapmaticRes.width()) if (image.width() != snapmaticRes.width())
{ {
diffWidth = snapmaticRes.width() - image.width(); diffWidth = snapmaticRes.width() - image.width();
diffWidth = diffWidth / 2; diffWidth = diffWidth / 2;
} }
else if (image.height() != snapmaticRes.height()) else if (image.height() != snapmaticRes.height())
{ {
diffHeight = snapmaticRes.height() - image.height(); diffHeight = snapmaticRes.height() - image.height();
diffHeight = diffHeight / 2; diffHeight = diffHeight / 2;
} }
} }
else else
{ {
image = image.scaled(snapmaticRes.width(), snapmaticRes.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); image = image.scaled(snapmaticRes.width(), snapmaticRes.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
} }
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, image); snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, image);
snapmaticPainter.end(); snapmaticPainter.end();
image = snapmaticImage; image = snapmaticImage;
} }
else else
{ {
QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888); QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
snapmaticImage.fill(Qt::black); snapmaticImage.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticImage); QPainter snapmaticPainter(&snapmaticImage);
// Scale to Avatar Resolution if needed // Scale to Avatar Resolution if needed
if (image.width() != avatarRes.width()) if (image.width() != avatarRes.width())
{ {
image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
} }
// Avatar mode // Avatar mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (keepAspectRatio) if (keepAspectRatio)
{ {
image = image.scaled(avatarRes, Qt::KeepAspectRatio, Qt::SmoothTransformation); image = image.scaled(avatarRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (image.width() > image.height()) if (image.width() > image.height())
{ {
diffHeight = avatarRes.height() - image.height(); diffHeight = avatarRes.height() - image.height();
diffHeight = diffHeight / 2; diffHeight = diffHeight / 2;
} }
else if (image.width() < image.height()) else if (image.width() < image.height())
{ {
diffWidth = avatarRes.width() - image.width(); diffWidth = avatarRes.width() - image.width();
diffWidth = diffWidth / 2; diffWidth = diffWidth / 2;
} }
} }
else else
{ {
image = image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); image = image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
} }
snapmaticPainter.drawImage(avatarZoneX + diffWidth, avatarZoneY + diffHeight, image); snapmaticPainter.drawImage(avatarZoneX + diffWidth, avatarZoneY + diffHeight, image);
snapmaticPainter.end(); snapmaticPainter.end();
image = snapmaticImage; image = snapmaticImage;
} }
if (picture.setImage(image)) if (picture.setImage(image))
{ {
int crew = 0; int crew = 0;
QStringList players; QStringList players;
if (flags.contains("crew")) if (flags.contains("crew"))
{ {
bool crewValid; bool crewValid;
int crewId = flags["crew"].toInt(&crewValid); int crewId = flags["crew"].toInt(&crewValid);
if (crewValid) if (crewValid)
{ {
crew = crewId; crew = crewId;
} }
} }
if (flags.contains("title") && SnapmaticPicture::verifyTitle(flags["title"])) if (flags.contains("title") && SnapmaticPicture::verifyTitle(flags["title"]))
{ {
picture.setPictureTitle(flags["title"]); picture.setPictureTitle(flags["title"]);
} }
else else
{ {
avatarMode ? picture.setPictureTitle("Converted Avatar") : picture.setPictureTitle("Converted Picture"); avatarMode ? picture.setPictureTitle("Converted Avatar") : picture.setPictureTitle("Converted Picture");
} }
if (flags.contains("players")) if (flags.contains("players"))
{ {
bool flagValid = true; bool flagValid = true;
QString playerFlag = flags["players"]; QString playerFlag = flags["players"];
if (playerFlag.left(1) == "[" && playerFlag.right(1) == "]") if (playerFlag.left(1) == "[" && playerFlag.right(1) == "]")
{ {
playerFlag.remove(0, 1); playerFlag.remove(0, 1);
playerFlag.remove(playerFlag.length() - 1, 1); playerFlag.remove(playerFlag.length() - 1, 1);
} }
const QStringList playersList = playerFlag.split(","); const QStringList playersList = playerFlag.split(",");
for (QString player : playersList) for (QString player : playersList)
{ {
if (player.left(1) == "\"" && player.right(1) == "\"") if (player.left(1) == "\"" && player.right(1) == "\"")
{ {
player.remove(0, 1); player.remove(0, 1);
player.remove(player.length() - 1, 1); player.remove(player.length() - 1, 1);
} }
bool playerValid; bool playerValid;
player.toInt(&playerValid); player.toInt(&playerValid);
if (!playerValid) if (!playerValid)
{ {
flagValid = false; flagValid = false;
} }
} }
if (flagValid) if (flagValid)
{ {
players = playersList; players = playersList;
} }
} }
SnapmaticProperties pictureSP = picture.getSnapmaticProperties(); SnapmaticProperties pictureSP = picture.getSnapmaticProperties();
pictureSP.uid = QString(QTime::currentTime().toString("HHmmss") + pictureSP.uid = QString(QTime::currentTime().toString("HHmmss") +
QString::number(QDate::currentDate().dayOfYear())).toInt(); QString::number(QDate::currentDate().dayOfYear())).toInt();
pictureSP.createdDateTime = QDateTime::currentDateTime(); pictureSP.createdDateTime = QDateTime::currentDateTime();
pictureSP.createdTimestamp = pictureSP.createdDateTime.toTime_t(); pictureSP.createdTimestamp = pictureSP.createdDateTime.toTime_t();
pictureSP.crewID = crew; pictureSP.crewID = crew;
pictureSP.playersList = players; pictureSP.playersList = players;
picture.setSnapmaticProperties(pictureSP); picture.setSnapmaticProperties(pictureSP);
picture.setPictureFileName(QString("PGTA5%1").arg(QString::number(pictureSP.uid))); picture.setPictureFileName(QString("PGTA5%1").arg(QString::number(pictureSP.uid)));
QString filePath = args.at(2); QString filePath = args.at(2);
filePath.replace("<autodef>", picture.getPictureFileName()); filePath.replace("<autodef>", picture.getPictureFileName());
if (!customFormat) if (!customFormat)
{ {
filePath.replace("<autoext>", ""); filePath.replace("<autoext>", "");
if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format)) if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format))
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
else else
{ {
if (flags.value("output", QString()).toLower() == "exported_filename") if (flags.value("output", QString()).toLower() == "exported_filename")
{ {
cout << filePath.toStdString().c_str() << endl; cout << filePath.toStdString().c_str() << endl;
} }
else else
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl;
} }
} }
} }
else else
{ {
filePath.replace("<autoext>", ".g5e"); filePath.replace("<autoext>", ".g5e");
if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format)) if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format))
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is failed!" << endl;
return 1; return 1;
} }
else else
{ {
if (flags.value("output", QString()).toLower() == "exported_filename") if (flags.value("output", QString()).toLower() == "exported_filename")
{ {
cout << filePath.toStdString().c_str() << endl; cout << filePath.toStdString().c_str() << endl;
} }
else else
{ {
cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl;
} }
} }
} }
} }
else else
{ {
cout << "gta5view-cmd: Editing of Snapmatic Image Stream failed!" << endl; cout << "gta5view-cmd: Editing of Snapmatic Image Stream failed!" << endl;
return 1; return 1;
} }
} }
else else
{ {
cout << "gta5view-cmd: " << args.at(1).toStdString().c_str() << " is invalid image!" << endl; cout << "gta5view-cmd: " << args.at(1).toStdString().c_str() << " is invalid image!" << endl;
return 1; return 1;
} }
} }
else else
{ {
cout << "gta5view-cmd: Reading of internal template failed!" << endl; cout << "gta5view-cmd: Reading of internal template failed!" << endl;
return 1; return 1;
} }
} }
} }
else else
{ {
cout << "gta5view Command Line" << endl << endl; cout << "gta5view Command Line" << endl << endl;
cout << "Usage: " << args.at(0).toStdString().c_str() << " source target -format -mode -flag=value" << endl; cout << "Usage: " << args.at(0).toStdString().c_str() << " source target -format -mode -flag=value" << endl;
if (args.length() >= 2 && (args.at(1) == "--help" || args.at(1) == "-help")) if (args.length() >= 2 && (args.at(1) == "--help" || args.at(1) == "-help"))
{ {
cout << "Convert-only: <autodef> (auto file name at convert)" << endl; cout << "Convert-only: <autodef> (auto file name at convert)" << endl;
cout << "Convert-only: <autoext> (auto file extension at convert)" << endl; cout << "Convert-only: <autoext> (auto file extension at convert)" << endl;
cout << "Formats: jpg pgta g5e" << endl; cout << "Formats: jpg pgta g5e" << endl;
cout << "Snapmatic Modes: a p d fs aiar akar piar pkar diar dkar" << endl; cout << "Snapmatic Modes: a p d fs aiar akar piar pkar diar dkar" << endl;
cout << "Snapmatic Flags: crew=int players=int[] title=string" << endl; cout << "Snapmatic Flags: crew=int players=int[] title=string" << endl;
cout << "Global Flags: output=string" << endl; cout << "Global Flags: output=string" << endl;
} }
return 255; return 255;
} }
return 0; return 0;
} }

10
res.qrc
View File

@ -1,5 +1,5 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file alias="template.g5e">gta5sync/res/template.g5e</file> <file alias="template.g5e">gta5view/res/template.g5e</file>
</qresource> </qresource>
</RCC> </RCC>