using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace Masters_of_Destruction.UI
public class OptionsWindow : Window
private WindowState wState;
private GameButton btnClose;
private Label lblResolution;
private GameButton btnVideo;
private GameButton btnAudio;
private CheckBox chkEnableSound;
private SlideBar sldMusicVolume;
private Label lblMusicVolume;
private Label lblMusicVolumeValue;
private SlideBar sldSoundVolume;
private Label lblSoundVolume;
private Label lblSoundVolumeValue;
private GameButton btnOK;
private GameButton btnCancel;
private CheckBox chkFullscreen;
wState = WindowState.Head;
BorderColor = Color.White;
TitleFont.Text = "OPTIONS";
WindowRectangle = new Rectangle(Game1.monitor.Viewport.Width / 2 - 200, Game1.monitor.Viewport.Height / 2 - 200, 400, 400);
public override void LoadContent(ContentManager Content)
base.LoadContent(Content);
TitleTexture = Game1.gfx.CreateRectangle(400, 22, new Color(0, 68, 68));
BackgroundTexture = Game1.gfx.CreateRectangle(400, 400, new Color(0, 68, 68));
btnClose = new GameButton();
btnClose.LoadContent(Content);
btnClose.HoverColor = new Color(0, 74, 127);
btnClose.ButtonColor = Color.White;
btnClose.TextColor = new Color(0, 74, 127);
btnClose.TextHoverColor = Color.White;
btnClose.ButtonDownColor = new Color(0, 74, 87);
btnClose.ButtonRectangle = new Rectangle(WindowRectangle.X + (WindowRectangle.Width / 2) - ((WindowRectangle.Width - 200) / 2), WindowRectangle.Y + WindowRectangle.Height - 40, (WindowRectangle.Width - 200), 25);
btnClose.Clicked += new EventHandler(btnClose_Clicked);
btnAudio = new GameButton();
btnAudio.LoadContent(Content);
btnAudio.HoverColor = new Color(0, 74, 127);
btnAudio.ButtonColor = Color.White;
btnAudio.TextColor = new Color(0, 74, 127);
btnAudio.TextHoverColor = Color.White;
btnAudio.ButtonDownColor = new Color(0, 74, 87);
btnAudio.ButtonRectangle = new Rectangle(WindowRectangle.X + (WindowRectangle.Width / 2) - ((WindowRectangle.Width - 100) / 2), WindowRectangle.Y + 60, (WindowRectangle.Width - 100), 25);
btnAudio.Text = "Audio Settings";
btnAudio.Clicked += new EventHandler(btnAudio_Clicked);
btnOK = new GameButton();
btnOK.LoadContent(Content);
btnOK.HoverColor = new Color(0, 74, 127);
btnOK.ButtonColor = Color.White;
btnOK.TextColor = new Color(0, 74, 127);
btnOK.TextHoverColor = Color.White;
btnOK.ButtonDownColor = new Color(0, 74, 87);
btnOK.ButtonRectangle = new Rectangle(btnAudio.ButtonRectangle.X, WindowRectangle.Y + WindowRectangle.Height - 40, btnAudio.ButtonRectangle.Width / 2, 25);
btnCancel = new GameButton();
btnCancel.LoadContent(Content);
btnCancel.HoverColor = new Color(0, 74, 127);
btnCancel.ButtonColor = Color.White;
btnCancel.TextColor = new Color(0, 74, 127);
btnCancel.TextHoverColor = Color.White;
btnCancel.ButtonDownColor = new Color(0, 74, 87);
btnCancel.ButtonRectangle = new Rectangle(btnOK.ButtonRectangle.X + btnOK.ButtonRectangle.Width + (WindowRectangle.Width / btnAudio.ButtonRectangle.Width) , WindowRectangle.Y + WindowRectangle.Height - 40, btnAudio.ButtonRectangle.Width / 2, 25);
btnCancel.Text = "Cancel";
btnCancel.Clicked += new EventHandler(btnCancel_Clicked);
chkEnableSound = new CheckBox(new Rectangle(WindowRectangle.X + 50, WindowRectangle.Y + 50, 200, 22));
chkEnableSound.LoadContent(Content);
chkEnableSound.Text = "Enable Sound";
chkFullscreen = new CheckBox(new Rectangle(WindowRectangle.X + 50, WindowRectangle.Y + 50, 200, 22));
chkFullscreen.LoadContent(Content);
chkFullscreen.Text = "Fullscreen Mode";
sldMusicVolume = new SlideBar(new Rectangle(WindowRectangle.X + 50, WindowRectangle.Y + 125, 200, 30));
sldMusicVolume.LoadContent(Content);
sldMusicVolume.MinValue = 0f;
sldMusicVolume.MaxValue = 100f;
sldMusicVolume.Steps = 10;
sldMusicVolume.SetValue(10);
sldSoundVolume = new SlideBar(new Rectangle(WindowRectangle.X + 50, WindowRectangle.Y + 175, 200, 30));
sldSoundVolume.LoadContent(Content);
sldSoundVolume.MinValue = 0;
sldSoundVolume.MaxValue = 100;
sldSoundVolume.Steps = 10;
sldSoundVolume.SetValue(10);
lblMusicVolume = new Label(new Rectangle(sldMusicVolume.WindowRectangle.X, sldMusicVolume.WindowRectangle.Y - 22, 200, 22));
lblMusicVolume.LoadContent(Content);
lblMusicVolume.Text = "Music Volume";
lblMusicVolumeValue = new Label(new Rectangle(sldMusicVolume.WindowRectangle.X + sldMusicVolume.WindowRectangle.Width + 10, sldMusicVolume.WindowRectangle.Y, 100, 22));
lblMusicVolumeValue.LoadContent(Content);
lblMusicVolumeValue.Text = sldMusicVolume.CurrentValue.ToString() + "%";
lblSoundVolume = new Label(new Rectangle(sldSoundVolume.WindowRectangle.X, sldSoundVolume.WindowRectangle.Y - 22, 200, 22));
lblSoundVolume.LoadContent(Content);
lblSoundVolume.Text = "Sound Volume";
lblResolution = new Label(new Rectangle(WindowRectangle.X + 50, WindowRectangle.Y + 75, 200, 22));
lblResolution.LoadContent(Content);
lblResolution.Text = "Resolution:";
lblSoundVolumeValue = new Label(new Rectangle(sldSoundVolume.WindowRectangle.X + sldSoundVolume.WindowRectangle.Width + 10, sldSoundVolume.WindowRectangle.Y, 100, 22));
lblSoundVolumeValue.LoadContent(Content);
lblSoundVolumeValue.Text = sldSoundVolume.CurrentValue.ToString() + "%";
btnVideo = new GameButton();
btnVideo.LoadContent(Content);
btnVideo.HoverColor = new Color(0, 74, 127);
btnVideo.ButtonColor = Color.White;
btnVideo.TextColor = new Color(0, 74, 127);
btnVideo.TextHoverColor = Color.White;
btnVideo.ButtonDownColor = new Color(0, 74, 87);
btnVideo.ButtonRectangle = new Rectangle(WindowRectangle.X + (WindowRectangle.Width / 2) - ((WindowRectangle.Width - 100) / 2), WindowRectangle.Y + 100, (WindowRectangle.Width - 100), 25);
btnVideo.Text = "Video Settings";
btnVideo.Clicked += new EventHandler(btnVideo_Clicked);
void btnVideo_Clicked(object sender, EventArgs e)
wState = WindowState.Video;
TitleFont.Text = "Video Settings";
void btnCancel_Clicked(object sender, EventArgs e)
wState = WindowState.Head;
wState = WindowState.Head;
TitleFont.Text = "Options";
void btnAudio_Clicked(object sender, EventArgs e)
wState = WindowState.Audio;
TitleFont.Text = "Audio Settings";
void btnClose_Clicked(object sender, EventArgs e)
public override void Unload()
public override void Update(GameTime gameTime)
public override void Draw(SpriteBatch spriteBatch)
private void UpdateHead(GameTime gameTime)
btnAudio.Update(gameTime);
btnVideo.Update(gameTime);
btnClose.Update(gameTime);
private void DrawHead(SpriteBatch spriteBatch)
btnAudio.Draw(spriteBatch);
btnVideo.Draw(spriteBatch);
btnClose.Draw(spriteBatch);
private void UpdateAudio(GameTime gameTime)
chkEnableSound.Update(gameTime);
sldMusicVolume.Update(gameTime);
sldSoundVolume.Update(gameTime);
lblMusicVolume.Update(gameTime);
lblMusicVolumeValue.Text = sldMusicVolume.CurrentValue.ToString() + "%";
lblMusicVolumeValue.Update(gameTime);
lblSoundVolume.Update(gameTime);
lblSoundVolumeValue.Update(gameTime);
lblSoundVolumeValue.Text = sldSoundVolume.CurrentValue.ToString() + "%";
btnCancel.Update(gameTime);
private void DrawAudio(SpriteBatch spriteBatch)
chkEnableSound.Draw(spriteBatch);
sldMusicVolume.Draw(spriteBatch);
sldSoundVolume.Draw(spriteBatch);
lblMusicVolume.Draw(spriteBatch);
lblMusicVolumeValue.Draw(spriteBatch);
lblSoundVolume.Draw(spriteBatch);
lblSoundVolumeValue.Draw(spriteBatch);
btnCancel.Draw(spriteBatch);
private void UpdateVideo(GameTime gameTime)
btnCancel.Update(gameTime);
lblResolution.Update(gameTime);
chkFullscreen.Update(gameTime);
private void DrawVideo(SpriteBatch spriteBatch)
btnCancel.Draw(spriteBatch);
lblResolution.Draw(spriteBatch);
chkFullscreen.Draw(spriteBatch);