/* * MenuItem.cs * Authors: Mike Dapiran * Copyright (c) 2007-2008 Cornell University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #region Using Declarations using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; #endregion namespace tAC_Engine.ScreenStates { /// /// Represents a basic menu item for a menu screen. /// public class MenuItem { #region Fields /// /// Tells whether the menu item is selected or not. /// protected bool m_Selected = false; /// /// The color to draw the text as. /// protected Color m_DrawColor; /// /// The text for the given menu item. /// protected string m_Text; /// /// The position, on screen, for the given menu item. /// protected Vector2 m_Position; /// /// The base color for the text. /// protected Color m_BaseColor = Color.White; /// /// The color for when the menu item is selected. /// protected Color m_SelectedColor = Color.Yellow; #endregion #region Properties /// /// Gets/Sets whether the menu item is selected or not. /// public bool Selected { get { return m_Selected; } set { m_Selected = value; if (m_Selected) m_DrawColor = m_SelectedColor; else m_DrawColor = m_BaseColor; } } /// /// Gets/Sets the text for the given menu item. /// public string Text { get { return m_Text; } set { m_Text = value; } } /// /// Gets/Sets the position, on screen, for the given menu item. /// public Vector2 Position { get { return m_Position; } set { m_Position = value; } } /// /// Gets/Sets the base color for the text. /// public Color BaseColor { get { return m_BaseColor; } set { m_BaseColor = value; } } /// /// Gets/Sets the color for when the menu item is selected. /// public Color SelectedColor { get { return m_SelectedColor; } set { m_SelectedColor = value; } } #endregion #region Constructs /// /// The constructos /// /// Text for the given menu. /// The position for the given menu. public MenuItem(string p_Text, Vector2 p_Position) { m_Text = p_Text; m_Position = p_Position; Selected = false; } #endregion #region Draw /// /// Draw's the given menu item. /// /// The sprite batch to draw with. /// The font to use for the drawing. public void Draw(SpriteBatch p_SpriteBatch, SpriteFont p_SpriteFont) { p_SpriteBatch.Begin(); p_SpriteBatch.DrawString(p_SpriteFont, m_Text, m_Position, m_DrawColor); p_SpriteBatch.End(); } #endregion #region Accept /// /// Performs the needed operations for when the menu item has been accepted /// public virtual void Accept() { } #endregion } }