Exemple #1
0
 /// <summary>
 /// Set the Texture that the Graphic is using (if it is using one.)
 /// </summary>
 /// <param name="atlasTexture">The AtlasTexture to use.</param>
 public void SetTexture(AtlasTexture atlasTexture)
 {
     Texture              = atlasTexture.Texture;
     AtlasRegion          = atlasTexture.Region;
     TextureRegion.Width  = atlasTexture.Width;
     TextureRegion.Height = atlasTexture.Height;
     NeedsUpdate          = true;
 }
Exemple #2
0
        /// <summary>
        /// Add another atlas to the collection of textures.  Duplicate names will destroy this.
        /// </summary>
        /// <param name="source">The relative path to the data file.  The png should be in the same directory.</param>
        public Atlas Add(string source)
        {
            var xml = new XmlDocument();

            xml.Load(source);

            var atlas = xml.GetElementsByTagName("TextureAtlas");

            var imagePath = Path.GetDirectoryName(source) + "/";

            if (imagePath == "/")
            {
                imagePath = "";
            }

            foreach (XmlElement a in xml.GetElementsByTagName("TextureAtlas"))
            {
                foreach (XmlElement e in xml.GetElementsByTagName("SubTexture"))
                {
                    var name       = e.AttributeString("name");
                    var uniqueName = true;

                    foreach (var atest in subtextures.Values)
                    {
                        if (atest.Name == name)
                        {
                            uniqueName = false;
                            break;
                        }
                    }

                    if (uniqueName)
                    {
                        var atext = new AtlasTexture();
                        atext.X           = e.AttributeInt("x");
                        atext.Y           = e.AttributeInt("y");
                        atext.Width       = e.AttributeInt("width");
                        atext.Height      = e.AttributeInt("height");
                        atext.FrameHeight = e.AttributeInt("frameHeight", atext.Height);
                        atext.FrameWidth  = e.AttributeInt("frameWidth", atext.Width);
                        atext.FrameX      = e.AttributeInt("frameX", 0);
                        atext.FrameY      = e.AttributeInt("frameY", 0);
                        atext.Name        = name;
                        atext.Source      = imagePath + a.AttributeString("imagePath");
                        atext.Texture     = new Texture(atext.Source);
                        subtextures.Add(e.AttributeString("name"), atext);
                    }
                }
            }
            return(this);
        }
Exemple #3
0
 /// <summary>
 /// Create a new Decals object using an AtlasTexture.
 /// </summary>
 /// <param name="texture"></param>
 public Decals(AtlasTexture texture)
 {
     SetTexture(texture);
     Initialize();
 }
Exemple #4
0
 /// <summary>
 /// Create a new Spritemap from an AtlasTexture.
 /// </summary>
 /// <param name="texture">The AtlasTexture to use for the sprite sheet.</param>
 /// <param name="width">The width of a cell on the sprite sheet.</param>
 /// <param name="height">The height of a cell on the sprite sheet.</param>
 public Spritemap(AtlasTexture texture, int width, int height) : base(texture)
 {
     Initialize(width, height);
 }
Exemple #5
0
 /// <summary>
 /// Create a new NineSlice with an AtlasTexture.
 /// </summary>
 /// <param name="texture">The AtlasTexture to use.</param>
 /// <param name="width">The width of the NineSlice panel.</param>
 /// <param name="height">The height of the NineSlice panel.</param>
 /// <param name="fillRect">The rectangle to determine the stretched areas.</param>
 public NineSlice(AtlasTexture texture, int width, int height, Rectangle?fillRect = null)
     : base()
 {
     SetTexture(texture);
     Initialize(texture.Name + ".png", width, height, fillRect);
 }
Exemple #6
0
 /// <summary>
 /// Create a new ImageSet from an AtlasTexture.
 /// </summary>
 /// <param name="texture">The AtlasTexture to use for the image sheet.</param>
 /// <param name="width">The width of each cell on the image sheet.</param>
 /// <param name="height">The height of each cell on the image sheet.</param>
 public ImageSet(AtlasTexture texture, int width, int height) : base(texture)
 {
     Initialize(width, height);
 }
Exemple #7
0
 /// <summary>
 /// Creates a new Image using an AtlasTexture.
 /// </summary>
 /// <param name="texture">The AtlasTexture to use.</param>
 public Image(AtlasTexture texture) : base()
 {
     SetTexture(texture);
     Initialize();
 }
Exemple #8
0
 /// <summary>
 /// Create a new Particle.
 /// </summary>
 /// <param name="x">The x position.</param>
 /// <param name="y">The y position.</param>
 /// <param name="texture"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public Particle(float x, float y, AtlasTexture texture, int width = 0, int height = 0)
     : base(x, y)
 {
     Image = new ImageSet(texture, width, height);
 }
Exemple #9
0
 /// <summary>
 /// Create a new set of Vertices using an AtlasTexture.
 /// </summary>
 /// <param name="texture">The AtlasTexture to use.</param>
 /// <param name="vertices">The Verts to use.</param>
 public Vertices(AtlasTexture texture, params Vert[] vertices)
     : this(vertices) {
     SetTexture(texture);
     Initialize(vertices);
 }