/* * ControlsScreen.cs * Authors: Karl Orosz * 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.Input; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using tAC_Engine.Graphics.Entities; using Util; namespace StarJack { class ControlsScreen:GameScreen { public static String TextureDirectory = @"Texture\\"; List mMenuItems = new List(); //int mItemSelected = 0; SpriteBatch mSpriteBatch; SpriteFont mSpriteFont; //public int curWorld; //public int curLevel; //public int curRoom; Entity mBackground; Entity mMenuBackground; InputHandler inputHandler; //The list of the components that this screen will own List mComponents; public ControlsScreen() { } /// /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// public override void Initialize() { Entity.RootDirectory = RootDirectory; mComponents = new List(); inputHandler = GetInputHandler(); inputHandler.Initialize(); inputHandler.BindButton(Keys.Space, Trigger.Activated, (int)SJInputEvent.ExitControlMenu); mBackground = new Entity("Back"); mBackground.TextureName = "Square"; mBackground.Width = 800; mBackground.Height = 600; mBackground.Color = new Color(0, 0, 0, 155); mBackground.X = 0; mBackground.Y = 0; mMenuBackground = new Entity("MenuBack"); mMenuBackground.TextureName = "Controls"; mMenuBackground.X = 80; mMenuBackground.Y = 60; mMenuBackground.Width = 640; mMenuBackground.Height = 480; base.Initialize(); #if DEBUG ShowFPS(); #endif } /// /// LoadContent will be called once per game and is the place to load /// all of your content. /// protected override void LoadContent() { mSpriteBatch = new SpriteBatch(GraphicsDevice); foreach (GameComponent gc in mComponents) { EntitySprite s = gc as EntitySprite; if (s != null) { s.SpriteBatch = mSpriteBatch; } } mSpriteFont = Content.Load(@"Fonts\menufont"); mMenuBackground.LoadContent(Content); mBackground.LoadContent(Content); base.LoadContent(); } /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// protected override void UnloadContent() { } public override void Reinitialize() { inputHandler.Enable(); this.Enabled = true; this.Visible = true; } protected override void Dispose(bool disposing) { //Console.WriteLine("Example menu screen disposing"); if (disposing) { mSpriteBatch.Dispose(); } base.Dispose(disposing); } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. public override void Update(GameTime gameTime) { base.Update(gameTime); while (inputHandler.HasEvent()) { InputEvent e = inputHandler.GetNextEvent(); switch ((SJInputEvent)e.EventCode) { case SJInputEvent.ExitControlMenu: Done(); break; } } } /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. public override void Draw(GameTime gameTime) { base.Draw(gameTime); mSpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.FrontToBack, SaveStateMode.None); mBackground.Draw(mSpriteBatch); mMenuBackground.Draw(mSpriteBatch); mSpriteBatch.End(); } } }