implemented the special drawable interface.
This commit is contained in:
		@@ -9,7 +9,7 @@ using System.Xml.Serialization;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace RecrownedAthenaeum.DataTypes
 | 
					namespace RecrownedAthenaeum.DataTypes
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class NinePatch
 | 
					    public class NinePatch : ISpecialDrawable
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public Color color;
 | 
					        public Color color;
 | 
				
			||||||
        public Rectangle textureRegion;
 | 
					        public Rectangle textureRegion;
 | 
				
			||||||
@@ -38,7 +38,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            color = Color.White;
 | 
					            color = Color.White;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Draw(SpriteBatch batch, Rectangle destination)
 | 
					        public void Draw(SpriteBatch spriteBatch, Rectangle destination)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Rectangle sourceRectangle;
 | 
					            Rectangle sourceRectangle;
 | 
				
			||||||
            Rectangle drawnRectangle;
 | 
					            Rectangle drawnRectangle;
 | 
				
			||||||
@@ -57,7 +57,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //2x1
 | 
					            //2x1
 | 
				
			||||||
            drawnRectangle.X = destination.X + a;
 | 
					            drawnRectangle.X = destination.X + a;
 | 
				
			||||||
@@ -72,7 +72,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //3x1
 | 
					            //3x1
 | 
				
			||||||
            drawnRectangle.X = destination.X + destination.Width - b;
 | 
					            drawnRectangle.X = destination.X + destination.Width - b;
 | 
				
			||||||
@@ -87,7 +87,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //1x2
 | 
					            //1x2
 | 
				
			||||||
            drawnRectangle.X = destination.X;
 | 
					            drawnRectangle.X = destination.X;
 | 
				
			||||||
@@ -102,7 +102,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //2x2
 | 
					            //2x2
 | 
				
			||||||
            drawnRectangle.X = destination.X + a;
 | 
					            drawnRectangle.X = destination.X + a;
 | 
				
			||||||
@@ -117,7 +117,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //3x2
 | 
					            //3x2
 | 
				
			||||||
            drawnRectangle.X = destination.X + destination.Width - b;
 | 
					            drawnRectangle.X = destination.X + destination.Width - b;
 | 
				
			||||||
@@ -132,7 +132,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //1x3
 | 
					            //1x3
 | 
				
			||||||
            drawnRectangle.X = destination.X;
 | 
					            drawnRectangle.X = destination.X;
 | 
				
			||||||
@@ -147,7 +147,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //2x3
 | 
					            //2x3
 | 
				
			||||||
            drawnRectangle.X = destination.X + a;
 | 
					            drawnRectangle.X = destination.X + a;
 | 
				
			||||||
@@ -162,7 +162,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //3x3
 | 
					            //3x3
 | 
				
			||||||
            drawnRectangle.X = destination.X + destination.Width - b;
 | 
					            drawnRectangle.X = destination.X + destination.Width - b;
 | 
				
			||||||
@@ -177,7 +177,13 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            sourceRectangle.X += textureRegion.X;
 | 
					            sourceRectangle.X += textureRegion.X;
 | 
				
			||||||
            sourceRectangle.Y += textureRegion.Y;
 | 
					            sourceRectangle.Y += textureRegion.Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            batch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
					            spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.color = color;
 | 
				
			||||||
 | 
					            Draw(spriteBatch, destination);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
        private Texture2D texture;
 | 
					        private Texture2D texture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Dictionary<string, TextureAtlasRegion> dictionaryOfRegions = new Dictionary<string, TextureAtlasRegion>();
 | 
					        private Dictionary<string, TextureAtlasRegion> dictionaryOfRegions = new Dictionary<string, TextureAtlasRegion>();
 | 
				
			||||||
 | 
					        public TextureAtlasRegion this[string name] { get { if (name != null && dictionaryOfRegions.ContainsKey(name)) return dictionaryOfRegions[name]; else return null; } }
 | 
				
			||||||
        public TextureAtlas(Texture2D texture, TextureAtlasRegion[] regions)
 | 
					        public TextureAtlas(Texture2D texture, TextureAtlasRegion[] regions)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.texture = texture;
 | 
					            this.texture = texture;
 | 
				
			||||||
@@ -57,7 +57,7 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
            return dictionaryOfRegions[name].AsTexture2D(graphicsDevice);
 | 
					            return dictionaryOfRegions[name].AsTexture2D(graphicsDevice);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public class TextureAtlasRegion : IComparable<TextureAtlasRegion>, IDisposable
 | 
					        public class TextureAtlasRegion : IComparable<TextureAtlasRegion>, ISpecialDrawable, IDisposable
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            public readonly string name;
 | 
					            public readonly string name;
 | 
				
			||||||
            public readonly Rectangle sourceRectangle;
 | 
					            public readonly Rectangle sourceRectangle;
 | 
				
			||||||
@@ -82,7 +82,13 @@ namespace RecrownedAthenaeum.DataTypes
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            public void Draw(SpriteBatch batch, Rectangle destination, Color color, float rotation, Vector2 origin)
 | 
					            public void Draw(SpriteBatch batch, Rectangle destination, Color color, float rotation, Vector2 origin)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                batch.Draw(atlasTexture, destination, sourceRectangle, color, rotation, origin, SpriteEffects.None, 0f);
 | 
					                if (ninepatch != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ninepatch.Draw(batch, destination);
 | 
				
			||||||
 | 
					                } else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    batch.Draw(atlasTexture, destination, sourceRectangle, color, rotation, origin, SpriteEffects.None, 0f);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /// <summary>
 | 
					            /// <summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
using Microsoft.Xna.Framework;
 | 
					using Microsoft.Xna.Framework;
 | 
				
			||||||
using Microsoft.Xna.Framework.Graphics;
 | 
					using Microsoft.Xna.Framework.Graphics;
 | 
				
			||||||
 | 
					using RecrownedAthenaeum.DataTypes;
 | 
				
			||||||
using RecrownedAthenaeum.UI.Modular;
 | 
					using RecrownedAthenaeum.UI.Modular;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace RecrownedAthenaeum.UI.Modular.Modules
 | 
					namespace RecrownedAthenaeum.UI.Modular.Modules
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class Image : UIModule
 | 
					    public class Image : UIModule, ISpecialDrawable
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public float rotation = 0f;
 | 
					        public float rotation = 0f;
 | 
				
			||||||
        public Texture2D Texture { get; set; }
 | 
					        public Texture2D Texture { get; set; }
 | 
				
			||||||
@@ -59,5 +60,14 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
 | 
				
			|||||||
            batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
 | 
					            batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
 | 
				
			||||||
            base.Draw(batch);
 | 
					            base.Draw(batch);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.color = color;
 | 
				
			||||||
 | 
					            this.rotation = rotation;
 | 
				
			||||||
 | 
					            this.origin = origin;
 | 
				
			||||||
 | 
					            bounds = destination;
 | 
				
			||||||
 | 
					            Draw(spriteBatch);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user