Drawable for a {@link Subtexture}
Наследование: IDrawable
Пример #1
0
        /// <summary>
        /// Returns a registered subtexture drawable. If no subtexture drawable is found but a Subtexture exists with the name, a
        /// subtexture drawable is created from the Subtexture and stored in the skin
        /// </summary>
        /// <returns>The subtexture drawable.</returns>
        /// <param name="name">Name.</param>
        public SubtextureDrawable getSubtextureDrawable(string name)
        {
            var subtextureDrawable = get <SubtextureDrawable>(name);

            if (subtextureDrawable != null)
            {
                return(subtextureDrawable);
            }

            var subtexture = get <Subtexture>(name);

            if (subtexture != null)
            {
                subtextureDrawable = new SubtextureDrawable(subtexture);
                add <SubtextureDrawable>(name, subtextureDrawable);
            }

            return(subtextureDrawable);
        }
Пример #2
0
        /// <summary>
        /// Returns a registered drawable. If no drawable is found but a Subtexture/NinePatchSubtexture exists with the name, then the
        /// appropriate drawable is created and stored in the skin. If name is a color a PrimitiveDrawable will be created and stored.
        /// </summary>
        /// <returns>The drawable.</returns>
        /// <param name="name">Name.</param>
        public IDrawable getDrawable(string name)
        {
            var drawable = get <IDrawable>(name);

            if (drawable != null)
            {
                return(drawable);
            }

            // Check for explicit registration of ninepatch, subtexture or tiled drawable
            drawable = get <SubtextureDrawable>(name);
            if (drawable != null)
            {
                return(drawable);
            }

            drawable = get <NinePatchDrawable>(name);
            if (drawable != null)
            {
                return(drawable);
            }

            drawable = get <TiledDrawable>(name);
            if (drawable != null)
            {
                return(drawable);
            }

            drawable = get <PrimitiveDrawable>(name);
            if (drawable != null)
            {
                return(drawable);
            }

            // still nothing. check for a NinePatchSubtexture or a Subtexture and create a new drawable if we find one
            var ninePatchSubtexture = get <NinePatchSubtexture>(name);

            if (ninePatchSubtexture != null)
            {
                drawable = new NinePatchDrawable(ninePatchSubtexture);
                add <NinePatchDrawable>(name, drawable as NinePatchDrawable);
                return(drawable);
            }

            var subtexture = get <Subtexture>(name);

            if (subtexture != null)
            {
                drawable = new SubtextureDrawable(subtexture);
                add <SubtextureDrawable>(name, drawable as SubtextureDrawable);
                return(drawable);
            }

            // finally, we will check if name is a Color and create a PrimitiveDrawable if it is
            if (has <Color>(name))
            {
                var color = get <Color>(name);
                drawable = new PrimitiveDrawable(color);
                add <PrimitiveDrawable>(name, drawable as PrimitiveDrawable);
                return(drawable);
            }

            return(null);
        }