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; 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; QJsonParseError error;
QJsonDocument texturesAsJson = QJsonDocument::fromJson(jsonTextures.toUtf8(), &error); QJsonDocument texturesJson = QJsonDocument::fromJson(textures.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) { if (error.error != QJsonParseError::NoError) {
qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << _textures; qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << _textures;
return _originalTexturesMap;
} }
QJsonObject texturesAsJsonObject = texturesAsJson.object(); return texturesJson.object().toVariantMap();
return texturesAsJsonObject.toVariantMap();
} }
void RenderableModelEntityItem::remapTextures() { void RenderableModelEntityItem::remapTextures() {