Made requested changes to OvenCLI constructor

This commit is contained in:
seefo 2017-06-07 10:35:20 -07:00
parent a3d2fa2630
commit 99e9e10882
3 changed files with 13 additions and 9 deletions

View file

@ -19,11 +19,10 @@
#include "FBXBaker.h"
#include "TextureBaker.h"
BakerCLI::BakerCLI(Oven* parent) : QObject() {
BakerCLI::BakerCLI(Oven* parent) : QObject(parent) {
}
void BakerCLI::bakeFile(const QString inputFilename, const QString outputPath) {
QUrl inputUrl(inputFilename);
void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
// if the URL doesn't have a scheme, assume it is a local file
if (inputUrl.scheme() != "http" && inputUrl.scheme() != "https" && inputUrl.scheme() != "ftp") {
@ -33,11 +32,11 @@ void BakerCLI::bakeFile(const QString inputFilename, const QString outputPath) {
static const QString MODEL_EXTENSION { ".fbx" };
// check what kind of baker we should be creating
bool isFBX = inputFilename.endsWith(MODEL_EXTENSION, Qt::CaseInsensitive);
bool isFBX = inputUrl.toDisplayString().endsWith(MODEL_EXTENSION, Qt::CaseInsensitive);
bool isSupportedImage = false;
for (QByteArray format : QImageReader::supportedImageFormats()) {
isSupportedImage |= inputFilename.endsWith(format, Qt::CaseInsensitive);
isSupportedImage |= inputUrl.toDisplayString().endsWith(format, Qt::CaseInsensitive);
}
// create our appropiate baker

View file

@ -21,7 +21,7 @@ class BakerCLI : public QObject {
public:
BakerCLI(Oven* parent);
void bakeFile(const QString inputFilename, const QString outputPath);
void bakeFile(QUrl inputUrl, const QString outputPath);
private slots:
void handleFinishedBaker();

View file

@ -58,9 +58,14 @@ Oven::Oven(int argc, char* argv[]) :
setupFBXBakerThread();
// check if we were passed any command line arguments that would tell us just to run without the GUI
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
BakerCLI* cli = new BakerCLI(this);
cli->bakeFile(parser.value(CLI_INPUT_PARAMETER), parser.value(CLI_OUTPUT_PARAMETER));
if (parser.isSet(CLI_INPUT_PARAMETER) || parser.isSet(CLI_OUTPUT_PARAMETER)) {
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
BakerCLI* cli = new BakerCLI(this);
cli->bakeFile(parser.value(CLI_INPUT_PARAMETER), parser.value(CLI_OUTPUT_PARAMETER));
} else {
parser.showHelp();
QApplication::quit();
}
} else {
// setup the GUI
_mainWindow = new OvenMainWindow;