// Instances a box decorator.
Decorator* DecoratorTiledBoxInstancer::InstanceDecorator(const String& ROCKET_UNUSED(name), const PropertyDictionary& properties)
{
	DecoratorTiled::Tile tiles[9];
	String texture_names[9];
	String rcss_paths[9];

	GetTileProperties(tiles[0], texture_names[0], rcss_paths[0], properties, "top-left-image");
	GetTileProperties(tiles[1], texture_names[1], rcss_paths[1], properties, "top-right-image");
	GetTileProperties(tiles[2], texture_names[2], rcss_paths[2], properties, "bottom-left-image");
	GetTileProperties(tiles[3], texture_names[3], rcss_paths[3], properties, "bottom-right-image");
	GetTileProperties(tiles[4], texture_names[4], rcss_paths[4], properties, "left-image");
	GetTileProperties(tiles[5], texture_names[5], rcss_paths[5], properties, "right-image");
	GetTileProperties(tiles[6], texture_names[6], rcss_paths[6], properties, "top-image");
	GetTileProperties(tiles[7], texture_names[7], rcss_paths[7], properties, "bottom-image");
	GetTileProperties(tiles[8], texture_names[8], rcss_paths[8], properties, "center-image");

	DecoratorTiledBox* decorator = new DecoratorTiledBox();

	decorator->GetColorMultiplier() = properties.GetProperty("color-multiplier")->value.Get< Colourb >();

	if (decorator->Initialise(tiles, texture_names, rcss_paths))
		return decorator;

	decorator->RemoveReference();
	ReleaseDecorator(decorator);
	return NULL;
}
// Instances a decorator given the property tag and attributes from the RCSS file.
Rocket::Core::Decorator* DecoratorInstancerDefender::InstanceDecorator(const Rocket::Core::String& ROCKET_UNUSED(name), const Rocket::Core::PropertyDictionary& properties)
{
	const Rocket::Core::Property* image_source_property = properties.GetProperty("image-src");
	Rocket::Core::String image_source = image_source_property->Get< Rocket::Core::String >();

	DecoratorDefender* decorator = new DecoratorDefender();
	if (decorator->Initialise(image_source, image_source_property->source))
		return decorator;

	decorator->RemoveReference();
	ReleaseDecorator(decorator);
	return NULL;
}
// Instances a box decorator.
Decorator* DecoratorTiledImageInstancer::InstanceDecorator(const String& ROCKET_UNUSED(name), const PropertyDictionary& properties)
{
	DecoratorTiled::Tile tile;
	String texture_name;
	String rcss_path;

	GetTileProperties(tile, texture_name, rcss_path, properties, "image");

	DecoratorTiledImage* decorator = new DecoratorTiledImage();
	if (decorator->Initialise(tile, texture_name, rcss_path))
		return decorator;

	decorator->RemoveReference();
	ReleaseDecorator(decorator);
	return NULL;
}
// Instances a decorator given the property tag and attributes from the RCSS file.
Rocket::Core::Decorator* DecoratorInstancerStarfield::InstanceDecorator(const Rocket::Core::String& ROCKET_UNUSED(name), const Rocket::Core::PropertyDictionary& properties)
{
	int num_layers = Rocket::Core::Math::RealToInteger(properties.GetProperty("num-layers")->Get< float >());
	Rocket::Core::Colourb top_colour = properties.GetProperty("top-colour")->Get< Rocket::Core::Colourb >();
	Rocket::Core::Colourb bottom_colour = properties.GetProperty("bottom-colour")->Get< Rocket::Core::Colourb >();
	float top_speed = properties.GetProperty("top-speed")->Get< float >();
	float bottom_speed = properties.GetProperty("bottom-speed")->Get< float >();
	int top_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("top-density")->Get< float >());
	int bottom_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("bottom-density")->Get< float >());

	DecoratorStarfield* decorator = new DecoratorStarfield();
	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))
		return decorator;

	decorator->RemoveReference();
	ReleaseDecorator(decorator);
	return NULL;
}
// Instances a box decorator.
Decorator* DecoratorTiledVerticalInstancer::InstanceDecorator(const String& ROCKET_UNUSED(name), const PropertyDictionary& properties)
{
	DecoratorTiled::Tile tiles[3];
	String texture_names[3];
	String rcss_paths[3];

	GetTileProperties(tiles[0], texture_names[0], rcss_paths[0], properties, "top-image");
	GetTileProperties(tiles[1], texture_names[1], rcss_paths[1], properties, "bottom-image");
	GetTileProperties(tiles[2], texture_names[2], rcss_paths[2], properties, "center-image");

	DecoratorTiledVertical* decorator = new DecoratorTiledVertical();
	if (decorator->Initialise(tiles, texture_names, rcss_paths))
		return decorator;

	decorator->RemoveReference();
	ReleaseDecorator(decorator);
	return NULL;
}