Ejemplo n.º 1
0
        protected virtual void LoadBackdropTexture(XmlNode backdropTextureNode)
        {
            if (backdropTextureNode != null)
            {
                XmlNode nameAttribute       = backdropTextureNode.SelectSingleNode(@"@name");
                XmlNode textureAttribute    = backdropTextureNode.SelectSingleNode(@"@texture");
                XmlNode tileWidthAttribute  = backdropTextureNode.SelectSingleNode(@"@tileWidth");
                XmlNode tileHeightAttribute = backdropTextureNode.SelectSingleNode(@"@tileHeight");
                XmlNode activeAttribute     = backdropTextureNode.SelectSingleNode(@"@active");

                string name    = (nameAttribute != null) ? nameAttribute.Value : "";
                string texture = (textureAttribute != null) ? textureAttribute.Value : "";

                int tileWidth  = 0;
                int tileHeight = 0;

                bool active = false;

                if (tileWidthAttribute != null)
                {
                    Int32.TryParse(tileWidthAttribute.Value, out tileWidth);
                }

                if (tileHeightAttribute != null)
                {
                    Int32.TryParse(tileWidthAttribute.Value, out tileHeight);
                }

                if (activeAttribute != null)
                {
                    active = (activeAttribute.Value.ToLower() == "true") ? true : false;
                }

                if (name.Length > 0 && texture.Length > 0 && tileWidth > 0 && tileHeight > 0)
                {
                    try
                    {
                        Texture2D         backgroundTexture = _panelCreate.UserInterface.Game.Content.Load <Texture2D>(texture);
                        UIBackdropTexture backdropTexture   = new UIBackdropTexture(backgroundTexture, tileWidth, tileHeight);

                        if (!_panelCreate.BackdropTextures.Keys.Contains(name))
                        {
                            _panelCreate.BackdropTextures.Add(name, backdropTexture);
                        }

                        if (active)
                        {
                            _panelCreate.BackdropTexture = backdropTexture;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Texture load failed for the following texture: " + texture, ex);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public UIBackdropTexture GetBackdropTexture(string name)
        {
            UIBackdropTexture backdropTexture = null;

            if (BackdropTextures.Keys.Contains(name))
            {
                backdropTexture = BackdropTextures[name];
            }

            return(backdropTexture);
        }
Ejemplo n.º 3
0
        protected virtual void LoadBackdropTexture(XmlNode backdropTextureNode)
        {
            if (backdropTextureNode != null)
            {
                XmlNode nameAttribute       = backdropTextureNode.SelectSingleNode(@"@name");
                XmlNode textureAttribute    = backdropTextureNode.SelectSingleNode(@"@texture");
                XmlNode tileWidthAttribute  = backdropTextureNode.SelectSingleNode(@"@tileWidth");
                XmlNode tileHeightAttribute = backdropTextureNode.SelectSingleNode(@"@tileHeight");

                string name    = (nameAttribute != null) ? nameAttribute.Value : "";
                string texture = (textureAttribute != null) ? textureAttribute.Value : "";

                if (name.Length > 0 && texture.Length > 0)
                {
                    if (!BackdropTextures.Keys.Contains(name))
                    {
                        int tileWidth  = 0;
                        int tileHeight = 0;

                        if (tileWidthAttribute != null)
                        {
                            if (!Int32.TryParse(tileWidthAttribute.Value, out tileWidth))
                            {
                                tileWidth = 0;
                            }
                        }

                        if (tileHeightAttribute != null)
                        {
                            if (!Int32.TryParse(tileHeightAttribute.Value, out tileHeight))
                            {
                                tileHeight = 0;
                            }
                        }

                        if (name.Length > 0 && texture.Length > 0 && tileWidth > 0 && tileHeight > 0)
                        {
                            Texture2D         backgroundTexture = UserInterface.Game.Content.Load <Texture2D>(texture);
                            UIBackdropTexture backdropTexture   = new UIBackdropTexture(backgroundTexture, tileWidth,
                                                                                        tileHeight);

                            if (!BackdropTextures.Keys.Contains(name))
                            {
                                BackdropTextures.Add(name, backdropTexture);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public virtual UIBackdropTexture GetBackdropTexture(string name)
        {
            UIBackdropTexture backdropTexture = null;

            if (BackdropTextures.Keys.Contains(name))
            {
                backdropTexture = BackdropTextures[name];
            }
            else
            {
                backdropTexture = UserInterface.Theme.GetBackdropTexture(name);
            }

            return(backdropTexture);
        }