// 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;
}
-
-ActorContainer Builder::GetTopLevelActors() const
-{
- // deprecated function.
- return ActorContainer();
-}
-
-Animation Builder::GetAnimation( const std::string &name ) const
-{
- // deprecated
- return Animation();
-}
-
void Builder::SetupTask( RenderTask& task, const TreeNode& node, const Replacement& constant )
{
const Stage& stage = Stage::GetCurrent();
return ret;
}
-Font Builder::GetFont( const std::string& name ) const
-{
- // deprecated function.
- Font font;
- return font;
-}
-
-TextStyle Builder::GetTextStyle( const std::string& name ) const
-{
- // deprecated
- return TextStyle();
-}
-
-Image Builder::GetImage( const std::string& name) const
-{
- // deprecated function.
- return Image();
-}
-
-Actor Builder::GetActor( const std::string &name ) const
-{
- // deprecated function.
- return Actor();
-}
-
void Builder::AddActors( Actor toActor )
{
// 'stage' is the default/by convention section to add from
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 )
{