//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Engine.Menus.GameScreens { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; using DarkWynter.Engine.Menus; using DWGame.Globals; using System.Xml; using DW.Stream; #endregion /// /// Displayed while loading game. /// public class GenericGameScreen : GameScreen { /// /// Loading Screen constructor. /// public GenericGameScreen(XmlNode node) : base(((Enums_Engine.MenuState)Enum.Parse(typeof(Enums_Engine.MenuState), node.Attributes["EnumMS"].Value))) { this.backgroundTexturePath = 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_Engine.MenuState)Enum.Parse(typeof(Enums_Engine.MenuState), node.Attributes["EnumMS"].Value); this.eState = (Enums_Engine.EngineState)Enum.Parse(typeof(Enums_Engine.EngineState), node.Attributes["EnumES"].Value); this.hasSprites = bool.Parse(node.Attributes["hasSprites"].Value); this.hasMenu = bool.Parse(node.Attributes["hasMenu"].Value); SetBackground(Renderer.content.Load(backgroundTexturePath)); List xmlList = new List(); //Instantiate the GameMenu - if no menu, 0,0, else menu if (!hasMenu) { menu = new GameMenu("", 0, 0); } else if (node.NextSibling.Name == "MEItem") { menu = new GameMenu(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.AddMenuOption(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_Engine.EngineState.GAME_MODE) { DWGame.Globals.Statics.engineState = Enums_Engine.EngineState.GAME_MODE; } } } }