using System; using System.Collections.Generic; using System.Linq; using System.Text; using DW.UI; using Microsoft.Xna.Framework.Graphics; using System.Xml; using DW.Stream; using Microsoft.Xna.Framework; namespace DW.UI.ScreenObjects { /// /// Used to display Images on the HUD /// public class ImageDisplay : ScreenObject { /// /// Image drawn to HUD. /// Edit by Drew: I changed this so that there is a "Source" property in the image... /// this is used for my health bar. Getters and setters change eachother appropriately. /// References that use Width*Scale in existing code will just be left alone. /// string mName; /// /// Sets the image and defaults the source to the entire image /// public string name { get { return mName; } set { mName = value; } } Texture2D mImage; /// /// Sets the image and defaults the source to the entire image /// public Texture2D image { get { return mImage; } set { mImage = value; Source = new Rectangle(0, 0, image.Width, image.Height); } } /// /// X scale of image. /// public float xScale; /// /// Y scale of image. /// public float yScale; /// /// Contains the size of the image (source/scale) /// This is only different from Texture Dimension * scale when /// the source is changed... playerIndex.e. only on my health bars /// public Rectangle Size; Rectangle mSource; /// /// Changes the Source Rectangle /// public Rectangle Source { get { return mSource; } set { mSource = value; Size = new Rectangle(0, 0, (int)(mSource.Width * xScale), (int)(mSource.Height * yScale)); } } /// /// Image display constructor. /// Scale defaults to 1. /// public ImageDisplay() { xScale = 1.0f; yScale = 1.0f; type = DisplayType.IMAGE; } /// /// Image display constructor. /// Scale defaults to 1. /// public ImageDisplay(XmlNode node) { xScale = 1.0f; yScale = 1.0f; type = DisplayType.IMAGE; name = node.Attributes["nameID"].Value; position = new Vector2(int.Parse(node.Attributes["posX"].Value), int.Parse(node.Attributes["posY"].Value)); visible = bool.Parse(node.Attributes["toDraw"].Value); color = GetColor(node); image = Renderer.content.Load(node.Attributes["texturePath"].Value); } } }