//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DW.Menus.GameScreens { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using DW.Menus; using DW.Globals; using System.Xml; using DW.Stream; #endregion /// /// Generic game screen, used for all game screens except pause and game over /// public class Generic : Screen { /// /// Loading Screen constructor. /// public Generic(XmlNode node) : base(((Enums.MenuState)Enum.Parse(typeof(Enums.MenuState), node.Attributes["EnumMS"].Value, true))) { this.texturePath = node.Attributes["bgTex"].Value; this.drawRectangle.Width = int.Parse(node.Attributes["drawRectangleWidth"].Value); this.drawRectangle.Height = int.Parse(node.Attributes["drawRectangleHeight"].Value); this.drawRectangle.X = int.Parse(node.Attributes["drawRectangleX"].Value); this.drawRectangle.Y = int.Parse(node.Attributes["drawRectangleY"].Value); if (this.drawRectangle.Equals(Renderer.Dimensions.CLIENTBOUNDS) == false) { this.drawRectangle = Renderer.Dimensions.CLIENTBOUNDS; } this.backgroundAlpha = float.Parse(node.Attributes["bgAlpha"].Value); this.menuState = (Enums.MenuState)Enum.Parse(typeof(Enums.MenuState), node.Attributes["EnumMS"].Value, true); this.eState = (Enums.EngineState)Enum.Parse(typeof(Enums.EngineState), node.Attributes["EnumES"].Value, true); this.hasSprites = bool.Parse(node.Attributes["hasSprites"].Value); this.hasMenu = bool.Parse(node.Attributes["hasMenu"].Value); SetBackground(Renderer.content.Load(texturePath)); List xmlList = new List(); //Instantiate the GameMenu - if no menu, 0,0, else menu if (!hasMenu) { menu = new ScreenMenu("", 0, 0); } else if (node.NextSibling.Name == "MEItem") { menu = new ScreenMenu(node.NextSibling.Attributes["name"].Value, 400, 50); menu.SetDrawMenuTitle(bool.Parse(node.NextSibling.Attributes["showMenuTitle"].Value)); foreach (XmlNode childNode in node.NextSibling.ChildNodes) { XmlNode xmlNode = childNode; xmlList.Add(xmlNode); } foreach (XmlNode thisNode in xmlList) { if (thisNode.Name == "Option") { menu.AddOption(thisNode.Attributes["label"].Value, thisNode.Attributes["a1"].Value, thisNode.Attributes["a2"].Value, thisNode.Attributes["a3"].Value, thisNode.Attributes["a4"].Value); } if (thisNode.Name == "Label") { menu.AddLabel(thisNode.Attributes["label"].Value); } else if (thisNode.Name == "Value") { menu.AddValueInput( thisNode.Attributes["label"].Value, int.Parse(thisNode.Attributes["a1"].Value), int.Parse(thisNode.Attributes["a2"].Value), int.Parse(thisNode.Attributes["a3"].Value), int.Parse(thisNode.Attributes["a4"].Value) ); } } menu.SetFont(Renderer.SystemFonts.Arial); } if (hasSprites) { // load additional sprites here } xmlList.Clear(); } /// /// Draw this menu screen /// /// Sprite Batch public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); if (this.eState == Enums.EngineState.GAME_MODE) { DW.Globals.Statics.engineState = Enums.EngineState.GAME_MODE; } } } }