This commit is contained in:
SamGondelman 2019-02-21 12:12:09 -08:00 committed by sabrina-shanman
parent 162573bc63
commit 7fc9a3fdb6

View file

@ -28,20 +28,20 @@ JSBaker::JSBaker(const QUrl& jsURL, const QString& bakedOutputDir) :
void JSBaker::bake() { void JSBaker::bake() {
qCDebug(js_baking) << "JS Baker " << _jsURL << "bake starting"; qCDebug(js_baking) << "JS Baker " << _jsURL << "bake starting";
// once our texture is loaded, kick off a the processing // once our script is loaded, kick off a the processing
connect(this, &JSBaker::originalScriptLoaded, this, &JSBaker::processScript); connect(this, &JSBaker::originalScriptLoaded, this, &JSBaker::processScript);
if (_jsURL.isEmpty()) { if (_jsURL.isEmpty()) {
// first load the texture (either locally or remotely) // first load the script (either locally or remotely)
loadScript(); loadScript();
} else { } else {
// we already have a texture passed to us, use that // we already have a script passed to us, use that
emit originalScriptLoaded(); emit originalScriptLoaded();
} }
} }
void JSBaker::loadScript() { void JSBaker::loadScript() {
// check if the texture is local or first needs to be downloaded // check if the script is local or first needs to be downloaded
if (_jsURL.isLocalFile()) { if (_jsURL.isLocalFile()) {
// load up the local file // load up the local file
QFile localScript(_jsURL.toLocalFile()); QFile localScript(_jsURL.toLocalFile());
@ -78,14 +78,14 @@ void JSBaker::handleScriptNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender()); auto requestReply = qobject_cast<QNetworkReply*>(sender());
if (requestReply->error() == QNetworkReply::NoError) { if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(js_baking) << "Downloaded texture" << _jsURL; qCDebug(js_baking) << "Downloaded script" << _jsURL;
// store the original texture so it can be passed along for the bake // store the original script so it can be passed along for the bake
_originalScript = requestReply->readAll(); _originalScript = requestReply->readAll();
emit originalScriptLoaded(); emit originalScriptLoaded();
} else { } else {
// add an error to our list stating that this texture could not be downloaded // add an error to our list stating that this script could not be downloaded
handleError("Error downloading " + _jsURL.toString() + " - " + requestReply->errorString()); handleError("Error downloading " + _jsURL.toString() + " - " + requestReply->errorString());
} }
} }
@ -139,7 +139,10 @@ bool JSBaker::bakeJS(const QByteArray& inputFile, QByteArray& outputFile) {
in >> currentCharacter; in >> currentCharacter;
qDebug() << "boop" << inputFile;
while (!in.atEnd()) { while (!in.atEnd()) {
qDebug() << "boop2" << currentCharacter << nextCharacter << previousCharacter;
in >> nextCharacter; in >> nextCharacter;
if (currentCharacter == '\r') { if (currentCharacter == '\r') {
@ -228,6 +231,8 @@ bool JSBaker::bakeJS(const QByteArray& inputFile, QByteArray& outputFile) {
out << currentCharacter; out << currentCharacter;
} }
qDebug() << "boop3" << outputFile;
// Successful bake. Return true // Successful bake. Return true
return true; return true;
} }