/*
* CSTickerMessage.cs
* Authors: Bradley R. Blankenship
* 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 tAC_Engine.GUI;
namespace ColonySim.GUI
{
///
/// Represents a ticker that is displayed to the player whenever messages
/// need to be displayed about character actions.
///
class CSTickerMessage : GUILabel
{
#region Fields
// The amount of time the ticker should display for
float mDisplayTime = 0.0f;
// The amount of time we have displayed for
float mCurrentTime = 0.0f;
#endregion
#region Properties
///
/// Allow access to the amount of time to display a message.
///
public float DisplayTime
{
get { return mDisplayTime; }
set { mDisplayTime = value; }
}
#endregion
#region Update
///
/// Update the ticker.
///
///
public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
// Base update
base.Update(gameTime);
// Get the amount of time that has elapsed
mCurrentTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
// If it's greater than us, kill us
if (mCurrentTime > mDisplayTime && mDisplayTime != -1)
{
// Disable and make us invisible
Visible = false;
}
}
#endregion
#region Behavior
///
/// Displays the ticker with the given message.
///
/// The current message for the ticker.
public void DisplayTicker(string pMessage)
{
// Set our text
Text = pMessage;
// reset our counter
mCurrentTime = 0.0f;
// Set us to be visible
Visible = true;
}
#endregion
}
}