Esempio n. 1
0
        public void LoadContent(string AnimationFile)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(FileManager.ContentFolder + AnimationFile);

            if (xmlDoc.SelectSingleNode("Animation/File") != null)
            {
                string TexturePath = xmlDoc.SelectSingleNode("/Animation/File").Attributes.GetNamedItem("Location").Value;
                SpriteSheet = StreamTexture.LoadTextureFromStream(Graphics, TexturePath);
            }

            if (xmlDoc.SelectSingleNode("Animation/SingleSpriteSize") != null)
            {
                SingleSpriteSize = new Vector2(int.Parse(xmlDoc.SelectSingleNode("Animation/SingleSpriteSize").Attributes.GetNamedItem("Width").Value),
                                               int.Parse(xmlDoc.SelectSingleNode("Animation/SingleSpriteSize").Attributes.GetNamedItem("Height").Value));
            }

            foreach (XmlNode SequenceNode in xmlDoc.SelectNodes("Animation/Sequence"))
            {
                List <Frame> Frames = new List <Frame>();

                foreach (XmlNode FrameNode in SequenceNode.ChildNodes)
                {
                    Frames.Add(new Frame(int.Parse(FrameNode.Attributes.GetNamedItem("Index").Value), int.Parse(FrameNode.Attributes.GetNamedItem("Length").Value)));
                }

                Sequences.Add(new Sequence(int.Parse(SequenceNode.Attributes.GetNamedItem("Row").Value), SequenceNode.Attributes.GetNamedItem("Name").Value, Frames));
            }
        }
Esempio n. 2
0
        void LoadCursorTexture(string StyleFilePath, string TextBoxNodeNameInXml)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(FileManager.ContentFolder + StyleFilePath);

            if (xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures") != null)
            {
                Cursor      = StreamTexture.LoadTextureFromStream(Graphics, xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures/CursorTexture").Attributes.GetNamedItem("Path").Value);
                CursorColor = new Color(int.Parse(xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures/CursorTextureColor").Attributes.GetNamedItem("Red").Value),
                                        int.Parse(xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures/CursorTextureColor").Attributes.GetNamedItem("Green").Value),
                                        int.Parse(xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures/CursorTextureColor").Attributes.GetNamedItem("Blue").Value),
                                        int.Parse(xmlDoc.SelectSingleNode(TextBoxNodeNameInXml + "/Textures/CursorTextureColor").Attributes.GetNamedItem("Alpha").Value));
            }
        }
Esempio n. 3
0
 public void LoadContent(string TextureLocation)
 {
     Texture = StreamTexture.LoadTextureFromStream(Graphics, TextureLocation);
 }
Esempio n. 4
0
 public void LoadContent(string TexturePath)
 {
     texture = StreamTexture.LoadTextureFromStream(Graphics, TexturePath);
 }
Esempio n. 5
0
 /// <summary>
 /// Load mouse cursor icon from disk drive.
 /// </summary>
 /// <param name="Content"></param>
 public static void LoadContent(SpriteBatch spriteBatch)
 {
     MouseCursor.spriteBatch = spriteBatch;
     NormalMouseTexture      = StreamTexture.LoadTextureFromStream(Graphics, "Content/MouseCursor.png");
     ColumnResizerTexture    = StreamTexture.LoadTextureFromStream(Graphics, "Content/ColumnCursor.png");
 }
Esempio n. 6
0
        void LoadStyleFile(Stream ContentStream, string XmlPath, string ComponentNodeNameInXml, bool LoadFromArchive)
        {
            XmlDocument xmlDoc = new XmlDocument();

            if (LoadFromArchive)
            {
                xmlDoc.Load(ContentStream);
                ContentStream.Dispose();
                FileManager.Dispose();
            }
            else
            {
                xmlDoc.Load(FileManager.ContentFolder + XmlPath);
            }

            if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures") != null)
            {
                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTexture") != null)
                {
                    NormalComponentTexture = new ComponentTexture();

                    if (LoadFromArchive)
                    {
                        MemoryStream TextureStream;
                        try
                        {
                            string TexturePath = xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTexture").Attributes.GetNamedItem("Path").Value;
                            TextureStream = FileManager.GetFileMemoryStreamFromArchive(TexturePath);
                            NormalComponentTexture.OriginalTexture = Texture2D.FromStream(Graphics.GraphicsDevice, TextureStream);

                            if (ContentStream == null)
                            {
                                throw new Exception("Could not find file \"" + FileManager.ContentFolder + FileManager.SourceArchiveFileName + "/" + XmlPath + "\"");
                            }
                            else if (TextureStream == null)
                            {
                                throw new Exception("Could not find file \"" + FileManager.ContentFolder + FileManager.SourceArchiveFileName + "/" + TexturePath + "\"");
                            }
                        }
                        catch (Exception ex) { throw ex; }

                        TextureStream.Dispose();
                        FileManager.Dispose();
                    }
                    else
                    {
                        NormalComponentTexture.OriginalTexture = StreamTexture.LoadTextureFromStream(Graphics, xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTexture").Attributes.GetNamedItem("Path").Value);
                    }

                    NormalComponentTexture.Color = new Color(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTextureColor").Attributes.GetNamedItem("Red").Value),
                                                             int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTextureColor").Attributes.GetNamedItem("Green").Value),
                                                             int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTextureColor").Attributes.GetNamedItem("Blue").Value),
                                                             int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/NormalTextureColor").Attributes.GetNamedItem("Alpha").Value));

                    NormalComponentTexture.Initialize(Graphics);
                }

                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTexture") != null)
                {
                    HoveredComponentTexture = new ComponentTexture();

                    if (LoadFromArchive)
                    {
                        MemoryStream TextureStream;
                        try
                        {
                            string TexturePath = xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTexture").Attributes.GetNamedItem("Path").Value;
                            TextureStream = FileManager.GetFileMemoryStreamFromArchive(TexturePath);
                            HoveredComponentTexture.OriginalTexture = Texture2D.FromStream(Graphics.GraphicsDevice, TextureStream);

                            if (TextureStream == null)
                            {
                                throw new Exception("Could not find file \"" + FileManager.ContentFolder + FileManager.SourceArchiveFileName + "/" + TexturePath + "\"");
                            }
                        }
                        catch (Exception ex) { throw ex; }

                        TextureStream.Dispose();
                        FileManager.Dispose();
                    }
                    else
                    {
                        HoveredComponentTexture.OriginalTexture = StreamTexture.LoadTextureFromStream(Graphics, xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTexture").Attributes.GetNamedItem("Path").Value);
                    }

                    HoveredComponentTexture.Color = new Color(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTextureColor").Attributes.GetNamedItem("Red").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTextureColor").Attributes.GetNamedItem("Green").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTextureColor").Attributes.GetNamedItem("Blue").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/HoveredTextureColor").Attributes.GetNamedItem("Alpha").Value));

                    HoveredComponentTexture.Initialize(Graphics);
                }

                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTexture") != null)
                {
                    PressedComponentTexture = new ComponentTexture();

                    if (LoadFromArchive)
                    {
                        MemoryStream TextureStream;
                        try
                        {
                            string TexturePath = xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTexture").Attributes.GetNamedItem("Path").Value;
                            TextureStream = FileManager.GetFileMemoryStreamFromArchive(TexturePath);
                            PressedComponentTexture.OriginalTexture = Texture2D.FromStream(Graphics.GraphicsDevice, TextureStream);

                            if (TextureStream == null)
                            {
                                throw new Exception("Could not find file \"" + FileManager.ContentFolder + FileManager.SourceArchiveFileName + "/" + TexturePath + "\"");
                            }
                        }
                        catch (Exception ex) { throw ex; }

                        TextureStream.Dispose();
                        FileManager.Dispose();
                    }
                    else
                    {
                        PressedComponentTexture.OriginalTexture = StreamTexture.LoadTextureFromStream(Graphics, xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTexture").Attributes.GetNamedItem("Path").Value);
                    }

                    PressedComponentTexture.Color = new Color(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTextureColor").Attributes.GetNamedItem("Red").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTextureColor").Attributes.GetNamedItem("Green").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTextureColor").Attributes.GetNamedItem("Blue").Value),
                                                              int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Textures/PressedTextureColor").Attributes.GetNamedItem("Alpha").Value));

                    PressedComponentTexture.Initialize(Graphics);
                }
            }

            if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Rendering") != null)
            {
                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Rendering").Attributes.GetNamedItem("Mode").Value == "None Scalable")
                {
                    if (NormalComponentTexture != null)
                    {
                        NormalComponentTexture.RendererMode = ComponentTexture.RenderMode.NoneScalable;
                    }

                    if (HoveredComponentTexture != null)
                    {
                        HoveredComponentTexture.RendererMode = ComponentTexture.RenderMode.NoneScalable;
                    }

                    if (PressedComponentTexture != null)
                    {
                        PressedComponentTexture.RendererMode = ComponentTexture.RenderMode.NoneScalable;
                    }
                }
                else if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Rendering").Attributes.GetNamedItem("Mode").Value == "Scalable")
                {
                    if (NormalComponentTexture != null)
                    {
                        NormalComponentTexture.RendererMode = ComponentTexture.RenderMode.Scalable;
                    }

                    if (HoveredComponentTexture != null)
                    {
                        HoveredComponentTexture.RendererMode = ComponentTexture.RenderMode.Scalable;
                    }

                    if (PressedComponentTexture != null)
                    {
                        PressedComponentTexture.RendererMode = ComponentTexture.RenderMode.Scalable;
                    }
                }
                else if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Rendering").Attributes.GetNamedItem("Mode").Value == "Scalable RealTime")
                {
                    if (NormalComponentTexture != null)
                    {
                        NormalComponentTexture.RendererMode = ComponentTexture.RenderMode.ScalableRealTime;
                    }

                    if (HoveredComponentTexture != null)
                    {
                        HoveredComponentTexture.RendererMode = ComponentTexture.RenderMode.ScalableRealTime;
                    }

                    if (PressedComponentTexture != null)
                    {
                        PressedComponentTexture.RendererMode = ComponentTexture.RenderMode.ScalableRealTime;
                    }
                }
            }

            if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions") != null)
            {
                borderThickness = new BorderThickness(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/BorderThickness").Attributes.GetNamedItem("Top").Value),
                                                      int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/BorderThickness").Attributes.GetNamedItem("Right").Value),
                                                      int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/BorderThickness").Attributes.GetNamedItem("Bottom").Value),
                                                      int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/BorderThickness").Attributes.GetNamedItem("Left").Value));

                CornerSize = new Vector2(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/CornerSize").Attributes.GetNamedItem("X").Value),
                                         int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/CornerSize").Attributes.GetNamedItem("Y").Value));


                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/DefaultSize") != null)
                {
                    if (Size.X <= 0 || Size.Y <= 0)
                    {
                        DefaultSize = new Vector2(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/DefaultSize").Attributes.GetNamedItem("X").Value),
                                                  int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Dimensions/DefaultSize").Attributes.GetNamedItem("Y").Value));
                    }
                }
            }

            if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text") != null)
            {
                string alignment = "";

                // if (LoadFromArchive)
                //fontRenderer.LoadContentFromArchive(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/Font").Attributes.GetNamedItem("Path").Value);
                //else
                fontRenderer.LoadContent(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/Font").Attributes.GetNamedItem("Path").Value);

                if (xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultText") != null)
                {
                    if (String.IsNullOrEmpty(Text))
                    {
                        Text = xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultText").Attributes.GetNamedItem("Value").Value;
                    }
                }

                if (TextAlignment == Alignment.Default)
                {
                    alignment = xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultAlignment").Attributes.GetNamedItem("Value").Value;

                    if (alignment.ToLowerInvariant() == "left")
                    {
                        TextAlignment = Alignment.Left;
                    }

                    if (alignment.ToLowerInvariant() == "center")
                    {
                        TextAlignment = Alignment.Center;
                    }

                    if (alignment.ToLowerInvariant() == "right")
                    {
                        TextAlignment = Alignment.Right;
                    }
                }

                TextOffsetPosition = new Vector2(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/OffsetPosition").Attributes.GetNamedItem("X").Value),
                                                 int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/OffsetPosition").Attributes.GetNamedItem("Y").Value));

                if (TextColor == null)
                {
                    TextColor = new Color(int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultTextColor").Attributes.GetNamedItem("Red").Value),
                                          int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultTextColor").Attributes.GetNamedItem("Green").Value),
                                          int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultTextColor").Attributes.GetNamedItem("Blue").Value),
                                          int.Parse(xmlDoc.SelectSingleNode(ComponentNodeNameInXml + "/Text/DefaultTextColor").Attributes.GetNamedItem("Alpha").Value));
                }
            }
        }
 public void LoadContent()
 {
     NormalTexture   = StreamTexture.LoadTextureFromStream(graphics, "UnitNormal.png");
     HoveredTexture  = StreamTexture.LoadTextureFromStream(graphics, "UnitHovered.png");
     SelectedTexture = StreamTexture.LoadTextureFromStream(graphics, "UnitSelected.png");
 }
Esempio n. 8
0
 public void LoadContent()
 {
     OriginalTexture = StreamTexture.LoadTextureFromStream(Graphics, "MouseRectangle.png");
 }