public void LoadDataFromXMLDocument(string filename)
 {
     XmlDocument document = new XmlDocument();
     document.Load(filename);
     XmlNode node3 = document.FirstChild.NextSibling.ChildNodes.Item(0);
     for (int i = 0; i < node3.ChildNodes.Count; i++)
     {
         Font font;
         Microsoft.Xna.Framework.Graphics.Color color;
         XmlNode node4 = node3.ChildNodes.Item(i);
         OptionStyle style = new OptionStyle {
             Name = node4.Attributes.GetNamedItem("Name").Value
         };
         XmlNode node = node4.ChildNodes.Item(0);
         style.TitleTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("FileName").Value);
         style.TitleWidth = int.Parse(node.Attributes.GetNamedItem("TitleWidth").Value);
         style.TitleHeight = int.Parse(node.Attributes.GetNamedItem("TitleHeight").Value);
         style.TitleMargin = int.Parse(node.Attributes.GetNamedItem("Margin").Value);
         StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
         style.TitleText = new FreeText(this.graphicsDevice, font, color);
         style.TitleText.Position = StaticMethods.LoadRectangleFromXMLNode(node);
         style.TitleText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
         node = node4.ChildNodes.Item(1);
         style.OptionTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("FileName").Value);
         style.OptionSelectedTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("Selected").Value);
         style.ItemHeight = int.Parse(node.Attributes.GetNamedItem("ItemHeight").Value);
         style.Margin = int.Parse(node.Attributes.GetNamedItem("Margin").Value);
         node = node4.ChildNodes.Item(2);
         StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
         style.OptionTextList = new FreeTextList(this.graphicsDevice, font, color);
         style.OptionTextList.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
         this.optionDialog.Styles.Add(style.Name, style);
     }
 }
Exemplo n.º 2
0
 internal void SetStyle(string style)
 {
     OptionStyle style2 = null;
     this.Styles.TryGetValue(style, out style2);
     if (style2 != null)
     {
         this.TitleTexture = style2.TitleTexture;
         this.TitleWidth = style2.TitleWidth;
         this.TitleHeight = style2.TitleHeight;
         this.TitleMargin = style2.TitleMargin;
         this.TitleText = style2.TitleText;
         this.OptionTextList = style2.OptionTextList;
         this.ItemHeight = style2.ItemHeight;
         this.Margin = style2.Margin;
         this.OptionTexture = style2.OptionTexture;
         this.OptionSelectedTexture = style2.OptionSelectedTexture;
     }
 }
Exemplo n.º 3
0
        public void LoadDataFromXMLDocument(string filename)
        {
            XmlDocument document = new XmlDocument();
            string      xml      = Platform.Current.LoadText(filename);

            document.LoadXml(xml);
            XmlNode node3 = document.FirstChild.NextSibling.ChildNodes.Item(0);

            for (int i = 0; i < node3.ChildNodes.Count; i++)
            {
                Font font;
                Microsoft.Xna.Framework.Color color;
                XmlNode     node4 = node3.ChildNodes.Item(i);
                OptionStyle style = new OptionStyle {
                    Name = node4.Attributes.GetNamedItem("Name").Value
                };
                XmlNode node = node4.ChildNodes.Item(0);
                style.TitleTexture = CacheManager.GetTempTexture(@"Content\Textures\GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("FileName").Value);
                style.TitleWidth   = int.Parse(node.Attributes.GetNamedItem("TitleWidth").Value);
                style.TitleHeight  = int.Parse(node.Attributes.GetNamedItem("TitleHeight").Value);
                style.TitleMargin  = int.Parse(node.Attributes.GetNamedItem("Margin").Value);
                StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
                style.TitleText          = new FreeText(font, color);
                style.TitleText.Position = StaticMethods.LoadRectangleFromXMLNode(node);
                style.TitleText.Align    = (TextAlign)Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
                node = node4.ChildNodes.Item(1);
                style.OptionTexture         = CacheManager.GetTempTexture(@"Content\Textures\GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("FileName").Value);
                style.OptionSelectedTexture = CacheManager.GetTempTexture(@"Content\Textures\GameComponents\OptionDialog\Data\" + node.Attributes.GetNamedItem("Selected").Value);
                style.ItemHeight            = int.Parse(node.Attributes.GetNamedItem("ItemHeight").Value);
                style.Margin = int.Parse(node.Attributes.GetNamedItem("Margin").Value);
                node         = node4.ChildNodes.Item(2);
                StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
                style.OptionTextList       = new FreeTextList(font, color);
                style.OptionTextList.Align = (TextAlign)Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
                this.optionDialog.Styles.Add(style.Name, style);
            }
        }