#region Using Statements
using System;
using System.Collections.Generic;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using DarkWynter.Stream;
#endregion
namespace DarkWynter.Engine.UserInterface
{
///
/// Base class for all types.
///
public class ScreenObject
{
///
/// Text string drawn to HUD.
///
public string text;
///
/// Position of HUD element.
///
public Vector2 position = new Vector2();
///
/// Width of HUD element.
///
public int width;
///
/// Height of HUD element.
///
public int height;
///
/// Color of text element.
///
public Color color;
///
/// Type of HUD element.
///
public DisplayType type = DisplayType.BASE;
///
/// Visibility of HUD element.
///
public bool visible = true;
};
#region Children of ScreenObject
///
/// Indicates what type of Heads Up Display element this is.
///
public enum DisplayType
{
///
/// A string of text.
///
TEXT,
///
/// A numerical value.
///
VALUE,
///
/// An image.
///
IMAGE,
///
/// Default.
///
BASE
};
///
/// Used to display Text.
///
public class TextDisplay : ScreenObject
{
///
/// Text display constructor.
///
public TextDisplay()
{
type = DisplayType.TEXT;
}
}
///
/// Used to display Values.
///
public class ValueDisplay : ScreenObject
{
///
/// Numerical value drawn to HUD.
///
public float value;
///
/// Value display constructor.
///
public ValueDisplay()
{
type = DisplayType.VALUE;
}
}
///
/// Used to display Images.
///
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.
///
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... i.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;
}
}
///
/// Used to display image sequences
///
public class ImageSpinner : ScreenObject
{
///
/// Array of images
///
public ImageDisplay[] images;
///
/// Index of active image
///
public int activeIndex;
///
/// Constructor
///
/// Size of Image Display
public ImageSpinner(int size)
{
this.activeIndex = 0;
this.images = new ImageDisplay[size];
}
///
/// Add an image to our array
///
/// Image
/// Location
public void addImage(ImageDisplay val, int slot)
{
images[slot] = val;
}
///
/// Iterate to next image
///
public void next()
{
if (this.images.Length <= this.activeIndex + 1)
{
this.activeIndex = 0;
}
else
{
this.activeIndex++;
}
}
///
/// Iterate to previous image
///
public void prev()
{
if (this.activeIndex == 0)
{
this.activeIndex = this.images.Length - 1;
}
else
{
this.activeIndex--;
}
}
}
#endregion
}