diff --git a/.gitmodules b/.gitmodules index 023a902..fc91166 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "gta5view"] -path = gta5view -url = https://gitlab.com/Syping/gta5view.git/ -branch = 1.9.x + path = gta5view + url = https://gitlab.com/Syping/gta5view.git/ + branch = 1.8.x diff --git a/README.md b/README.md deleted file mode 100644 index 570c6d6..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## gta5view-cmd - -This project got retired in favor of [ragephoto-cli](https://github.com/Syping/ragephoto-cli). diff --git a/gta5view b/gta5view index 94a263f..f8049c8 160000 --- a/gta5view +++ b/gta5view @@ -1 +1 @@ -Subproject commit 94a263f501df3a6bd3ca6e5794736983c5d08601 +Subproject commit f8049c817804c71c046ee5613d15dda555f5e441 diff --git a/gta5view-cmd.pro b/gta5view-cmd.pro index ba8c3f4..59ba29c 100644 --- a/gta5view-cmd.pro +++ b/gta5view-cmd.pro @@ -25,11 +25,9 @@ TEMPLATE = app CONFIG += console SOURCES += main.cpp \ - gta5view/RagePhoto.cpp \ gta5view/SnapmaticPicture.cpp HEADERS += \ - gta5view/RagePhoto.h \ gta5view/SnapmaticPicture.h INCLUDEPATH += ./gta5view diff --git a/main.cpp b/main.cpp index b24225c..983eaa8 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * gta5view-cmd - gta5view Command Line -* Copyright (C) 2017-2020 Syping +* Copyright (C) 2017-2018 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 @@ -32,11 +32,11 @@ int main(int argc, char *argv[]) QCoreApplication a(argc, argv); QStringList args = a.arguments(); - if (args.length() >= 3) { + if (args.length() >= 3) + { QString format = "jpg"; bool isDefault = true; bool avatarMode = false; - bool eXtendMode = false; bool ignoreORes = false; bool convertToGTA = false; bool customFormat = false; @@ -44,241 +44,238 @@ int main(int argc, char *argv[]) bool keepAspectRatio = true; QMap flags; - if (args.length() >= 4) { - if (args.at(3) == "-pgta") { + if (args.length() >= 4) + { + if (args.at(3) == "-pgta") + { convertToGTA = true; customFormat = false; } - else if (args.at(3) == "-g5e") { + else if (args.at(3) == "-g5e") + { convertToGTA = true; customFormat = true; } - else if (args.at(3) == "-jpg") { + else if (args.at(3) == "-jpg") + { format = "jpg"; convertToGTA = false; } } - if (args.length() >= 5) { - if (args.at(4) == "-a") { + if (args.length() >= 5) + { + if (args.at(4) == "-a") + { isDefault = false; avatarMode = true; } - else if (args.at(4) == "-aX") { - isDefault = false; - avatarMode = true; - eXtendMode = true; - } - else if (args.at(4) == "-p") { + else if (args.at(4) == "-p") + { isDefault = false; avatarMode = false; } - else if (args.at(4) == "-pX") { - isDefault = false; - avatarMode = false; - eXtendMode = true; - } - else if (args.at(4) == "-d") { + else if (args.at(4) == "-d") + { isDefault = true; } - else if (args.at(4) == "-dX") { - isDefault = true; - eXtendMode = true; - } - else if (args.at(4) == "-fs") { + else if (args.at(4) == "-fs") + { convertToGTA = false; formatSwitch = true; } - else if (args.at(4) == "-aiar") { + else if (args.at(4) == "-aiar") + { isDefault = false; avatarMode = true; keepAspectRatio = false; } - else if (args.at(4) == "-aiarX") { - isDefault = false; - avatarMode = true; - eXtendMode = true; - keepAspectRatio = false; - } - else if (args.at(4) == "-akar") { + else if (args.at(4) == "-akar") + { isDefault = false; avatarMode = true; keepAspectRatio = true; } - else if (args.at(4) == "-akarX") { - isDefault = false; - avatarMode = true; - eXtendMode = true; - keepAspectRatio = true; - } - else if (args.at(4) == "-piar") { + else if (args.at(4) == "-piar") + { isDefault = false; avatarMode = false; keepAspectRatio = false; } - else if (args.at(4) == "-piarX") { - isDefault = false; - avatarMode = false; - eXtendMode = true; - keepAspectRatio = false; - } - else if (args.at(4) == "-pkar") { + else if (args.at(4) == "-pkar") + { isDefault = false; avatarMode = false; keepAspectRatio = true; } - else if (args.at(4) == "-pkarX") { - isDefault = false; - avatarMode = false; - eXtendMode = true; - keepAspectRatio = true; - } - else if (args.at(4) == "-diar") { + else if (args.at(4) == "-diar") + { isDefault = true; keepAspectRatio = false; } - else if (args.at(4) == "-diarX") { - isDefault = true; - eXtendMode = true; - keepAspectRatio = false; - } - else if (args.at(4) == "-dkar") { + else if (args.at(4) == "-dkar") + { isDefault = true; keepAspectRatio = true; } - else if (args.at(4) == "-dkarX") { - isDefault = true; - eXtendMode = true; - keepAspectRatio = true; - } - else if (args.at(4) == "-ior") { + else if (args.at(4) == "-ior") + { isDefault = false; ignoreORes = true; keepAspectRatio = false; } - else if (args.at(4) == "-iorX") { - isDefault = false; - ignoreORes = true; - eXtendMode = true; - keepAspectRatio = false; - } - else { + else + { QStringList currentFlagArg = args.at(4).split("="); QString currentFlag = currentFlagArg.at(0).toLower(); - if (currentFlag.at(0) == '-') { + if (currentFlag.left(1) == "-") + { currentFlag.remove(0, 1); - currentFlagArg.removeFirst(); - const QString currentValue = currentFlagArg.join(QString()); + currentFlagArg.removeAt(0); + QString currentValue = currentFlagArg.join(QString()); flags[currentFlag] = currentValue; } } } - if (args.length() >= 6) { + if (args.length() >= 6) + { QStringList flagArgs(args); - for (int argId = 0; argId == 5; argId++) { + for (int argId = 0; argId == 5; argId++) + { flagArgs.removeAt(argId); } - for (const QString &flagArg : flagArgs) { + for (QString flagArg : flagArgs) + { QStringList currentFlagArg = flagArg.split("="); QString currentFlag = currentFlagArg.at(0).toLower(); - if (currentFlag.at(0) == '-') { + if (currentFlag.left(1) == "-") + { currentFlag.remove(0, 1); - currentFlagArg.removeFirst(); - const QString currentValue = currentFlagArg.join(QString()); + currentFlagArg.removeAt(0); + QString currentValue = currentFlagArg.join(QString()); flags[currentFlag] = currentValue; } } } - if (!convertToGTA) { + if (!convertToGTA) + { SnapmaticPicture picture(args.at(1)); - if (picture.readingPicture(false)) { + if (picture.readingPicture(true, false, true)) + { QString filePath = args.at(2); - if (!formatSwitch) { + if (!formatSwitch) + { filePath.replace("", picture.getExportPictureFileName()); filePath.replace("", ".jpg"); - if (!picture.exportPicture(filePath, SnapmaticFormat::JPEG_Format)) { - cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is failed!" << endl; + 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; return 1; } - else { - if (flags.value("output", QString()).toLower() == "exported_filename") { - cout << filePath.toStdString() << endl; + else + { + if (flags.value("output", QString()).toLower() == "exported_filename") + { + cout << filePath.toStdString().c_str() << endl; } - else { - cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is successful!" << endl; + else + { + cout << "gta5view-cmd: Exporting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; } } } - else { + else + { filePath.replace("", picture.getPictureFileName()); - if (customFormat) { + if (customFormat) + { filePath.replace("", ".g5e"); - if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format)) { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is failed!" << endl; + 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; return 1; } - else { - if (flags.value("output", QString()).toLower() == "exported_filename") { - cout << filePath.toStdString() << endl; + else + { + if (flags.value("output", QString()).toLower() == "exported_filename") + { + cout << filePath.toStdString().c_str() << endl; } - else { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is successful!" << endl; + else + { + cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; } } } - else { + else + { filePath.replace("", ""); - if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format)) { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is failed!" << endl; + 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; return 1; } - else { - if (flags.value("output", QString()).toLower() == "exported_filename") { - cout << filePath.toStdString() << endl; + else + { + if (flags.value("output", QString()).toLower() == "exported_filename") + { + cout << filePath.toStdString().c_str() << endl; } - else { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is successful!" << endl; + else + { + cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; } } } } } - else { - cout << "gta5view-cmd: Reading of " << args.at(1).toStdString() << " is failed!" << endl; + else + { + cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl; return 1; } } - else { + else + { SnapmaticPicture picture(":/template.g5e"); - if (picture.readingPicture(false)) { + if (picture.readingPicture(true, false, true)) + { QImage image; QFile imageFile(args.at(1)); - if (!imageFile.open(QFile::ReadOnly)) { - cout << "gta5view-cmd: Reading of " << args.at(1).toStdString() << " is failed!" << endl; + if (!imageFile.open(QFile::ReadOnly)) + { + cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " is failed!" << endl; return 1; } QImageReader imageReader; imageReader.setDecideFormatFromContent(true); imageReader.setDevice(&imageFile); - if (!imageReader.read(&image)) { - cout << "gta5view-cmd: Parsing of " << args.at(1).toStdString() << " is failed!" << endl; + if (!imageReader.read(&image)) + { + cout << "gta5view-cmd: Parsing of " << args.at(1).toStdString().c_str() << " is failed!" << endl; return 1; } - if (!image.isNull()) { - if (!ignoreORes) { + if (!image.isNull()) + { + if (!ignoreORes) + { QSize snapmaticRes(960, 536); QSize avatarRes(470, 470); int avatarZoneX = 145; int avatarZoneY = 66; - if (isDefault) { - if (image.width() == image.height()) { + if (isDefault) + { + if (image.width() == image.height()) + { avatarMode = true; } - else { + else + { avatarMode = false; } } - if (!avatarMode) { + if (!avatarMode) + { QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888); snapmaticImage.fill(Qt::black); QPainter snapmaticPainter(&snapmaticImage); @@ -286,49 +283,59 @@ int main(int argc, char *argv[]) // Picture mode int diffWidth = 0; int diffHeight = 0; - if (keepAspectRatio) { + if (keepAspectRatio) + { image = image.scaled(snapmaticRes, Qt::KeepAspectRatio, Qt::SmoothTransformation); - if (image.width() != snapmaticRes.width()) { + if (image.width() != snapmaticRes.width()) + { diffWidth = snapmaticRes.width() - image.width(); diffWidth = diffWidth / 2; } - else if (image.height() != snapmaticRes.height()) { + else if (image.height() != snapmaticRes.height()) + { diffHeight = snapmaticRes.height() - image.height(); diffHeight = diffHeight / 2; } } - else { + else + { image = image.scaled(snapmaticRes.width(), snapmaticRes.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, image); snapmaticPainter.end(); image = snapmaticImage; } - else { + else + { QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888); snapmaticImage.fill(Qt::black); QPainter snapmaticPainter(&snapmaticImage); // Scale to Avatar Resolution if needed - if (image.width() != avatarRes.width()) { + if (image.width() != avatarRes.width()) + { image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } // Avatar mode int diffWidth = 0; int diffHeight = 0; - if (keepAspectRatio) { + if (keepAspectRatio) + { image = image.scaled(avatarRes, Qt::KeepAspectRatio, Qt::SmoothTransformation); - if (image.width() > image.height()) { + if (image.width() > image.height()) + { diffHeight = avatarRes.height() - image.height(); diffHeight = diffHeight / 2; } - else if (image.width() < image.height()) { + else if (image.width() < image.height()) + { diffWidth = avatarRes.width() - image.width(); diffWidth = diffWidth / 2; } } - else { + else + { image = image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } snapmaticPainter.drawImage(avatarZoneX + diffWidth, avatarZoneY + diffHeight, image); @@ -337,75 +344,95 @@ int main(int argc, char *argv[]) } } - if (picture.setImage(image, eXtendMode)) { + if (picture.setImage(image)) + { int crew = 0; double posX = 0; double posY = 0; double posZ = 0; QStringList players; - if (flags.contains("crew")) { + if (flags.contains("crew")) + { bool crewValid; int crewId = flags["crew"].toInt(&crewValid); - if (crewValid) { + if (crewValid) + { crew = crewId; } } - if (flags.contains("title") && SnapmaticPicture::verifyTitle(flags["title"])) { + if (flags.contains("title") && SnapmaticPicture::verifyTitle(flags["title"])) + { picture.setPictureTitle(flags["title"]); } - else { + else + { avatarMode ? picture.setPictureTitle("Converted Avatar") : picture.setPictureTitle("Converted Picture"); } - if (flags.contains("players")) { + if (flags.contains("players")) + { bool flagValid = true; QString playerFlag = flags["players"]; - if (playerFlag.left(1) == "[" && playerFlag.right(1) == "]") { + if (playerFlag.left(1) == "[" && playerFlag.right(1) == "]") + { playerFlag.remove(0, 1); playerFlag.remove(playerFlag.length() - 1, 1); } const QStringList playersList = playerFlag.split(","); - for (QString player : playersList) { - if (player.left(1) == "\"" && player.right(1) == "\"") { + for (QString player : playersList) + { + if (player.left(1) == "\"" && player.right(1) == "\"") + { player.remove(0, 1); player.remove(player.length() - 1, 1); } bool playerValid; player.toInt(&playerValid); - if (!playerValid) { + if (!playerValid) + { flagValid = false; } } - if (flagValid) { + if (flagValid) + { players = playersList; } } - if (flags.contains("position")) { + if (flags.contains("position")) + { bool flagValid = true; QString positionFlag = flags["position"]; - if (positionFlag.left(1) == "[" && positionFlag.right(1) == "]") { + if (positionFlag.left(1) == "[" && positionFlag.right(1) == "]") + { positionFlag.remove(0, 1); positionFlag.remove(positionFlag.length() - 1, 1); } const QStringList positionsList = positionFlag.split(","); - for (QString position : positionsList) { - if (position.left(1) == "\"" && position.right(1) == "\"") { + for (QString position : positionsList) + { + if (position.left(1) == "\"" && position.right(1) == "\"") + { position.remove(0, 1); position.remove(position.length() - 1, 1); } bool positionValid; position.toDouble(&positionValid); - if (!positionValid) { + if (!positionValid) + { flagValid = false; } } - if (flagValid) { - if (positionsList.length() >= 1) { + if (flagValid) + { + if (positionsList.length() >= 1) + { posX = positionsList.at(0).toDouble(); } - if (positionsList.length() >= 2) { + if (positionsList.length() >= 2) + { posY = positionsList.at(1).toDouble(); } - if (positionsList.length() >= 3) { + if (positionsList.length() >= 3) + { posZ = positionsList.at(2).toDouble(); } } @@ -424,62 +451,76 @@ int main(int argc, char *argv[]) picture.setPictureFileName(QString("PGTA5%1").arg(QString::number(pictureSP.uid))); QString filePath = args.at(2); filePath.replace("", picture.getPictureFileName()); - if (!customFormat) { + if (!customFormat) + { filePath.replace("", ""); - if (!picture.exportPicture(filePath, SnapmaticFormat::PGTA_Format)) { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is failed!" << endl; + 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; return 1; } - else { - if (flags.value("output", QString()).toLower() == "exported_filename") { - cout << filePath.toStdString() << endl; + else + { + if (flags.value("output", QString()).toLower() == "exported_filename") + { + cout << filePath.toStdString().c_str() << endl; } - else { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is successful!" << endl; + else + { + cout << "gta5view-cmd: Converting of " << args.at(1).toStdString().c_str() << " to " << filePath.toStdString().c_str() << " is successful!" << endl; } } } - else { + else + { filePath.replace("", ".g5e"); - if (!picture.exportPicture(filePath, SnapmaticFormat::G5E_Format)) { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is failed!" << endl; + 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; return 1; } - else { - if (flags.value("output", QString()).toLower() == "exported_filename") { - cout << filePath.toStdString() << endl; + else + { + if (flags.value("output", QString()).toLower() == "exported_filename") + { + cout << filePath.toStdString().c_str() << endl; } - else { - cout << "gta5view-cmd: Converting of " << args.at(1).toStdString() << " to " << filePath.toStdString() << " is successful!" << endl; + else + { + 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; return 1; } } - else { - cout << "gta5view-cmd: " << args.at(1).toStdString() << " is invalid image!" << endl; + else + { + cout << "gta5view-cmd: " << args.at(1).toStdString().c_str() << " is invalid image!" << endl; return 1; } } - else { + else + { cout << "gta5view-cmd: Reading of internal template failed!" << endl; return 1; } } } - else { - cout << "gta5view Command Line 0.5.1" << endl << endl; - cout << "Usage: " << args.at(0).toStdString() << " source target -format -mode -flag=value" << endl; - if (args.length() >= 2 && (args.at(1) == "--help" || args.at(1) == "-help")) { + else + { + cout << "gta5view Command Line" << endl << 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")) + { cout << "Convert-only: (auto file name at convert)" << endl; cout << "Convert-only: (auto file extension at convert)" << endl; cout << "Formats: jpg pgta g5e" << endl; cout << "Snapmatic Modes: a p d fs aiar akar piar pkar diar dkar ior" << endl; - cout << "Snapmatic Modes: aX pX dX aiarX akarX piarX pkarX diarX dkarX iorX" << endl; cout << "Snapmatic Flags: crew=int players=int[] position=double[] title=string" << endl; cout << "Global Flags: output=string" << endl; } diff --git a/res/app.rc b/res/app.rc index bbcbdac..3cfc3eb 100644 --- a/res/app.rc +++ b/res/app.rc @@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view-cmd.exe.manifest" #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 0, 5, 1, 0 -PRODUCTVERSION 0, 5, 1, 0 +FILEVERSION 0, 4, 0, 0 +PRODUCTVERSION 0, 4, 0, 0 FILEFLAGSMASK 0x3fL FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 @@ -25,12 +25,12 @@ BEGIN BEGIN VALUE "CompanyName", "Syping" VALUE "FileDescription", "gta5view-cmd" - VALUE "FileVersion", "0.5.1" + VALUE "FileVersion", "0.4.0" VALUE "InternalName", "gta5view-cmd" - VALUE "LegalCopyright", "Copyright © 2017-2020 Syping" + VALUE "LegalCopyright", "Copyright © 2017-2018 Syping" VALUE "OriginalFilename", "gta5view-cmd.exe" VALUE "ProductName", "gta5view-cmd" - VALUE "ProductVersion", "0.5.1" + VALUE "ProductVersion", "0.4.0" END END END