| using System; |
| using System.Collections.Generic; |
| using System.Text; |
| |
| using System.Windows.Forms; |
| |
| using Microsoft.Xna; |
| using Microsoft.Xna.Framework; |
| using Microsoft.Xna.Framework.Graphics; |
| |
| namespace BugColony |
| { |
| /// <summary> |
| /// Anything that can be manipulated with the mouse |
| /// </summary> |
| public class BaseButton |
| { |
| #region Properties |
| public bool MouseHover; |
| public Rectangle Area = GetBounds(); |
| |
| private static Rectangle GetBounds() |
| { |
| Rectangle r = new Rectangle(); |
| r.X = (int)Position.X; |
| r.Y = (int)Position.Y; |
| |
| if (PrimaryImage != null) |
| { |
| r.Width = PrimaryImage.Width; |
| r.Height = PrimaryImage.Height; |
| } |
| return r; |
| } |
| /// <summary> |
| /// Where the button is located |
| /// </summary> |
| public static Vector2 Position; |
| /// <summary> |
| /// Base image for normal display |
| /// </summary> |
| public static Texture2D PrimaryImage; |
| /// <summary> |
| /// Image for mouse over. |
| /// </summary> |
| public static Texture2D SecondaryImage; |
| /// <summary> |
| /// Images for when a click image is needed. |
| /// Sounds funny yea i made that *** up. |
| /// </summary> |
| public static Texture2D ThirdaryImage; |
| #endregion |
|
| #region Assemblies |
| /// <summary> |
| /// Button has no images WTF? |
| /// </summary> |
| public BaseButton() |
| { |
| } |
| /// <summary> |
| /// Button with only one image (no mouse over function) |
| /// </summary> |
| /// <param name="tex1">Base Image for button</param> |
| public BaseButton(Texture2D tex1) |
| { |
| PrimaryImage = tex1; |
| } |
| /// <summary> |
| /// Mouse with 2 images supporting mouse over feature. |
| /// </summary> |
| /// <param name="tex1">Base image for button</param> |
| /// <param name="tex2">Mouse over image</param> |
| public BaseButton(Texture2D tex1, Texture2D tex2) |
| { |
| PrimaryImage = tex1; |
| SecondaryImage = tex2; |
| } |
| /// <summary> |
| /// Mouse supporting mouse over and click imaging. |
| /// </summary> |
| /// <param name="tex1">Base image for button</param> |
| /// <param name="tex2">Mouse ove image</param> |
| /// <param name="tex3">Click image.</param> |
| public BaseButton(Texture2D tex1, Texture2D tex2, Texture2D tex3) |
| { |
| PrimaryImage = tex1; |
| SecondaryImage = tex2; |
| ThirdaryImage = tex3; |
| } |
| public bool MouseOver() |
| { |
| if (MyMouse.m_Position.X >= Position.X && MyMouse.m_Position.X <= Position.X + Area.Width && MyMouse.m_Position.Y >= Position.Y && MyMouse.m_Position.Y <= Position.Y + Area.Height) |
| return true; |
| |
| return false; |
| } |
| #endregion |
| |
| public virtual void ShowImage(Game1 game) |
| { |
| Area = GetBounds(); |
| bool mouse = MouseOver(); |
| //if (PrimaryImage != null) |
| //game.spriteBatch.Draw(PrimaryImage, Position, mouse ? Color.Red : Color.White); |
| |
| game.spriteBatch.Draw(PrimaryImage, Position, Color.White); |
| } |
| |
| public virtual void OnClick(Game1 game) |
| { |
| } |
| } |
| } |
| |