/* * PopupInfoBox.cs * Authors: * 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. */ using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace tAC_Engine.Graphics.Entities { /// /// Defines a pop up info box to display variou information about an object /// public class PopupInfoBox : PopupSprite { #region Fields // The list of strings which provide information for the pop up box List mInfoStrings = new List(); // The reference to the current sprite font to use for rendering text SpriteFont mSpriteFont; #endregion #region Properties /// /// Gets the list of strings which provide information for the pop up box /// public List InfoStrings { get { return mInfoStrings; } } /// /// Gets/Sets the reference to the current sprite font to use for rendering text /// public SpriteFont SpriteFont { get { return mSpriteFont; } set { mSpriteFont = value; } } #endregion #region creation /// /// Constructor for the pop up info box /// /// Reference to the current content manager /// Path name to the texture to use /// The position of the center of the pop up info box /// The amount of time the pop up box will last for /// Reference to the sprite font used to render the text string public PopupInfoBox(ContentManager pContent, string pTexturePath, Vector2 pCenter, float pTime, SpriteFont pFont) :base(pContent, pTexturePath, pCenter, pTime) { mSpriteFont = pFont; } #endregion #region Render /// /// Renders the pop up info box /// /// Time that has passed in game public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) { base.Draw(gameTime); Vector2 stringPosition = new Vector2(this.Position.X + 5, this.Position.Y + 5); if (Visible && !GettingLarger && !GettingSmaller) { SpriteBatch.Begin(); foreach (string s in mInfoStrings) { // If it's not null if (s != null) { this.SpriteBatch.DrawString(mSpriteFont, s, stringPosition, Color.White); stringPosition.Y += mSpriteFont.MeasureString(s).Y; } } SpriteBatch.End(); } } #endregion #region List Management /// /// Adds a string to the list of strings in the pop up info box /// /// The string to add public void AddInfoString(string pStringToAdd) { mInfoStrings.Add(pStringToAdd); } /// /// Clears the list of strings in the pop up info box /// public void ClearInfoStrings() { mInfoStrings.Clear(); } #endregion } }