// special field 'effect' references the shader effect instances
if(key == "effect")
{
- Actor actor = Actor::DownCast(handle);
- OptionalString s = constant.IsString( keyChild.second );
- if(actor && s)
+ RenderableActor actor = RenderableActor::DownCast(handle);
+ if( actor )
{
- ShaderEffect e = GetShaderEffect(*s, constant);
- actor.SetShaderEffect(e);
+ OptionalString str = constant.IsString( keyChild.second );
+ if( str )
+ {
+ ShaderEffect effect = GetShaderEffect( *str, constant );
+ actor.SetShaderEffect(effect);
+ }
}
else
{
if( Property::INVALID_INDEX == index )
{
- Actor actor = Actor::DownCast(propertyObject);
+ RenderableActor actor = RenderableActor::DownCast(handle);
if( actor )
{
if( ShaderEffect effect = actor.GetShaderEffect() )
}
}
- ApplyProperties( root, node, handle, replacements );
-
- if( actor)
+ if( actor )
{
// add children of all the styles
if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
parent.Add( actor );
}
}
-
+ else
+ {
+ ApplyProperties( root, node, handle, replacements );
+ }
}
else
{
return baseHandle;
}
+BaseHandle Builder::CreateFromJson( const std::string& json )
+{
+ BaseHandle ret;
+
+ // merge in new template, hoping no one else has one named '@temp@'
+ std::string newTemplate =
+ std::string("{\"templates\":{\"@temp@\":") + \
+ json + \
+ std::string("}}");
+
+ if( mParser.Parse(newTemplate) )
+ {
+ Replacement replacement( mReplacementMap );
+ ret = Create( "@temp@", replacement );
+ }
+
+ return ret;
+}
+
+bool Builder::ApplyFromJson( Handle& handle, const std::string& json )
+{
+ bool ret = false;
+
+ // merge new style, hoping no one else has one named '@temp@'
+ std::string newStyle =
+ std::string("{\"styles\":{\"@temp@\":") + \
+ json + \
+ std::string("}}");
+
+ if( mParser.Parse(newStyle) )
+ {
+ Replacement replacement( mReplacementMap );
+ ret = ApplyStyle( "@temp@", handle, replacement );
+ }
+
+ return ret;
+}
+
BaseHandle Builder::Create( const std::string& templateName )
{