Accept textures as list or json

This commit is contained in:
Zach Pomerantz 2016-03-24 19:40:02 -07:00
parent caf2595e13
commit 413c3b88cf

View file

@ -113,14 +113,18 @@ QVariantMap RenderableModelEntityItem::parseTexturesToMap(QString textures) {
return _originalTexturesMap;
}
QString jsonTextures = "{\"" + textures.replace(":\"", "\":\"").replace(",\n", ",\"") + "}";
// Legacy: a ,\n-delimited list of filename:"texturepath"
if (*textures.cbegin() != '{') {
textures = "{\"" + textures.replace(":\"", "\":\"").replace(",\n", ",\"") + "}";
}
QJsonParseError error;
QJsonDocument texturesAsJson = QJsonDocument::fromJson(jsonTextures.toUtf8(), &error);
QJsonDocument texturesJson = QJsonDocument::fromJson(textures.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << _textures;
return _originalTexturesMap;
}
QJsonObject texturesAsJsonObject = texturesAsJson.object();
return texturesAsJsonObject.toVariantMap();
return texturesJson.object().toVariantMap();
}
void RenderableModelEntityItem::remapTextures() {