/* * CSResourceLabel.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; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace ColonySim.GUI { /// /// Represents a specialized label that contains two labels for the /// use of identifying resources. /// class CSResourceLabel : GUIContainer { #region Fields // The resource we're tracking ResourceCode mResource; // The label for our resource icon GUILabel mResourceIcon = new GUILabel(); // The label for the amount of a given resource GUILabel mResourceAmount = new GUILabel(); #endregion #region Properties /// /// Allow getting and setting of the Icon for the resource. /// public Texture2D ResourceIcon { get { return mResourceIcon.Background; } set { mResourceIcon.Background = value; } } /// /// Allow getting and setting of the amount of the resource being /// shown. /// public string ResourceAmount { get { return mResourceAmount.Text; } set { mResourceAmount.Text = value; } } /// /// Allow getting and setting of the resource this label looks over. /// public ResourceCode Resource { get { return mResource; } set { mResource = value; ToolTipText = mResource.ToString(); } } #endregion #region Constructs /// /// Base /// public CSResourceLabel() { // Add the two labels this.Add(mResourceIcon); this.Add(mResourceAmount); } #endregion #region Initialization /// /// Initialize the label values, based on what's available. /// public override void Initialize() { // Base call base.Initialize(); } /// /// Loads content, or unlaods content for the labels. /// public override void LoadContent() { // Load the content base.LoadContent(); // Kill the background for the text label mResourceAmount.Background = null; mResourceAmount.TextColor = Color.White; } /// /// Resize the labels. /// public override void Resize() { // base call base.Resize(); // Resize the icon mResourceIcon.Size = new Vector2(24, 24); mResourceIcon.Position = Position; // Resize the label mResourceAmount.Font = ParentScreen.Content.Load(@"Fonts\InformationPanelFont"); mResourceAmount.Size = new Vector2(Size.X - 6, Size.Y); mResourceAmount.Position = new Vector2(mResourceIcon.Bounds.Right + 3, Position.Y); } #endregion } }