Merge pull request #7470 from zzmp/fix/tex-json

Accept textures as list or json
This commit is contained in:
Chris Collins 2016-03-25 10:05:12 -07:00
commit 2a85170a46

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() {