/*
* CSModePanel.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.Graphics;
using Microsoft.Xna.Framework;
using Util;
namespace ColonySim.GUI
{
///
/// Panel for selecting between the two selectable modes,
/// Selection and Deletion.
///
class CSModePanel : GUIRadioContainer
{
#region Enums
///
/// Enumeration of the available modes that can be clicked to be
/// selected.
///
public enum Modes
{
SELECTION,
DELETION
}
#endregion
#region Fields
// Our current mode
Modes mCurrentMode;
// The button for selecting Selection
GUIButton mSelectionButton;
// The button for selecting Deletion
GUIButton mDeletionButton;
// The background
Texture2D mBackground;
#endregion
#region Properties
///
/// The currently selected mode.
///
public Modes CurrentMode
{
get { return mCurrentMode; }
}
#endregion
public CSModePanel()
{
mSelectionButton = new GUIButton();
mDeletionButton = new GUIButton();
// Add the buttons
this.Add(mSelectionButton);
this.Add(mDeletionButton);
}
#region Initialize
///
/// Initialize our content.
///
public override void Initialize()
{
mSelectionButton.Size = new Vector2(Size.X - 6, Size.Y / 2 - 9);
mSelectionButton.Position = new Vector2(Position.X + 3, Position.Y + 3);
mSelectionButton.ButtonPressed += new EventHandler(mSelectionButton_ButtonPressed);
mDeletionButton.Size = new Vector2(Size.X - 6, Size.Y / 2 - 9);
mDeletionButton.Position = new Vector2(Position.X + 3, mSelectionButton.Bounds.Bottom + 3);
mDeletionButton.ButtonPressed += new EventHandler(mDeletionButton_ButtonPressed);
base.Initialize();
}
///
/// Load our content.
///
public override void LoadContent()
{
// Get our background
mBackground = mParentScreen.Content.Load(@"Textures\ResourceBar");
// Get our buttons' textures
mSelectionButton.ButtonUp = mParentScreen.Content.Load(@"Textures\GUI\SelectionUp");
mSelectionButton.ButtonDown = mParentScreen.Content.Load(@"Textures\GUI\SelectionDown");
mDeletionButton.ButtonUp = mParentScreen.Content.Load(@"Textures\GUI\DeletionUp");
mDeletionButton.ButtonDown = mParentScreen.Content.Load(@"Textures\GUI\DeletionDown");
// Base call
base.LoadContent();
}
#endregion
#region Event Handling
public event EventHandler ModeChanged;
void mDeletionButton_ButtonPressed(object sender, EventArgs e)
{
mCurrentMode = Modes.DELETION;
//Invoke Event
if (ModeChanged != null)
ModeChanged.Invoke(this, EventArgs.Empty);
}
void mSelectionButton_ButtonPressed(object sender, EventArgs e)
{
mCurrentMode = Modes.SELECTION;
//Invoke Event
if (ModeChanged != null)
ModeChanged.Invoke(this, EventArgs.Empty);
}
#endregion
#region Draw
///
/// Draw this with a background
///
///
public override void Draw(GameTime gameTime)
{
// If we have a background
if (mBackground != null)
{
// Draw our background
Batch.Draw(mBackground, Bounds, Color.White);
}
// Draw the rest
base.Draw(gameTime);
}
#endregion
}
}