예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">Game</param>
        /// <param name="bufferManager">Buffer manager</param>
        /// <param name="description">Button description</param>
        public SpriteButton(Scene scene, SpriteButtonDescription description)
            : base(scene, description)
        {
            var spriteDesc = new SpriteDescription()
            {
                Width     = description.Width,
                Height    = description.Height,
                Color     = description.ColorReleased,
                FitScreen = false,
            };

            if (!string.IsNullOrEmpty(description.TextureReleased))
            {
                spriteDesc.Textures = new[] { description.TextureReleased };
                spriteDesc.UVMap    = description.TextureReleasedUVMap;
            }

            this.buttonReleased = new Sprite(scene, spriteDesc);

            if (description.TwoStateButton)
            {
                var spriteDesc2 = new SpriteDescription()
                {
                    Width     = description.Width,
                    Height    = description.Height,
                    Color     = description.ColorPressed,
                    FitScreen = false,
                };

                if (!string.IsNullOrEmpty(description.TexturePressed))
                {
                    spriteDesc2.Textures = new[] { description.TexturePressed };
                    spriteDesc2.UVMap    = description.TexturePressedUVMap;
                }

                this.buttonPressed = new Sprite(scene, spriteDesc2);
            }

            if (description.TextDescription != null)
            {
                this.textDrawer = new TextDrawer(
                    scene,
                    description.TextDescription);
            }

            this.Left = description.Left;
            this.Top  = description.Top;
            this.Text = description.Text;
        }
예제 #2
0
 /// <summary>
 /// Releases used resources
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (left != null)
         {
             left.Dispose();
             left = null;
         }
         if (right != null)
         {
             right.Dispose();
             right = null;
         }
         if (textDrawer != null)
         {
             textDrawer.Dispose();
             textDrawer = null;
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">Game</param>
        /// <param name="bufferManager">Buffer manager</param>
        /// <param name="description">Button description</param>
        public SpriteProgressBar(Scene scene, SpriteProgressBarDescription description)
            : base(scene, description)
        {
            this.ProgressValue = 0;

            this.left = new Sprite(
                scene,
                new SpriteDescription()
            {
                Color     = description.ProgressColor,
                Width     = description.Width,
                Height    = description.Height,
                FitScreen = false,
            });

            this.right = new Sprite(
                scene,
                new SpriteDescription()
            {
                Color     = description.BaseColor,
                Width     = description.Width,
                Height    = description.Height,
                FitScreen = false,
            });

            if (description.TextDescription != null)
            {
                this.textDrawer = new TextDrawer(
                    scene,
                    description.TextDescription);
            }

            this.Left      = description.Left;
            this.Top       = description.Top;
            this.Width     = description.Width;
            this.Height    = description.Height;
            this.Text      = description.Text;
            this.Rectangle = new Rectangle(description.Left, description.Top, description.Width, description.Height);
        }
예제 #4
0
        /// <summary>
        /// Releases used resources
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.buttonReleased != null)
                {
                    this.buttonReleased.Dispose();
                    this.buttonReleased = null;
                }

                if (this.buttonPressed != null)
                {
                    this.buttonPressed.Dispose();
                    this.buttonPressed = null;
                }

                if (this.textDrawer != null)
                {
                    this.textDrawer.Dispose();
                    this.textDrawer = null;
                }
            }
        }