Exemple #1
0
 private static Vector2 GetTextureSize(Vector2 size, ImageSettings image, Texture2D buttonTexture)
 {
     if (buttonTexture != null)
     {
         if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Horizontal)
         {
             size.X = size.X + buttonTexture.Width;
             size.Y = buttonTexture.Height > size.Y ? buttonTexture.Height : size.Y;
         }
         else if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Vertical)
         {
             size.X = buttonTexture.Width > size.X ? buttonTexture.Width : size.X;
             size.Y = size.Y + buttonTexture.Height;
         }
     }
     return(size);
 }
Exemple #2
0
 private static Vector2 GetHorizontalTextureRectangle(Vector2 imageOffset, ref Rectangle sliderRect, ImageSettings image, Texture2D buttonTexture)
 {
     if (buttonTexture != null)
     {
         if (image.ImagePositioning == ButtonAreaImagePositioningEnum.ValueHorizontalSlider)
         {
             sliderRect = new Rectangle((int)imageOffset.X, (int)imageOffset.Y, buttonTexture.Width, buttonTexture.Height);
         }
         if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Horizontal)
         {
             imageOffset.X = imageOffset.X + buttonTexture.Width;
         }
         else if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Vertical)
         {
             imageOffset.Y = imageOffset.Y + buttonTexture.Height;
         }
     }
     return(imageOffset);
 }
Exemple #3
0
 protected virtual Vector2 DrawTexture(SpriteBatch spriteBatch, Vector2 offset, Vector2 position, Vector2 imageOffset, ImageSettings image, Texture2D buttonTexture, int currentHorizontalValue, int currentVerticalValue, int borderLeft, int borderRight)
 {
     if (buttonTexture != null)
     {
         if (image.ImagePositioning == ButtonAreaImagePositioningEnum.Unmovable)
         {
             spriteBatch.Draw(buttonTexture, position + offset + imageOffset, Color.White);
         }
         else
         {
             Rectangle sliderPartVisible = new Rectangle(0, 0, buttonTexture.Width, buttonTexture.Height);
             if (image.ImagePositioning == ButtonAreaImagePositioningEnum.ValueHorizontalSlider)
             {
                 int sliderWidth = (buttonTexture.Width - (borderLeft + borderRight)) * currentHorizontalValue / 100 + borderLeft + borderRight;
                 sliderPartVisible = new Rectangle(buttonTexture.Width - sliderWidth, 0, sliderWidth, buttonTexture.Height);
             }
             else if (image.ImagePositioning == ButtonAreaImagePositioningEnum.ValueVerticalSlider)
             {
                 sliderPartVisible = new Rectangle(0, buttonTexture.Height * (100 - currentVerticalValue) / 100, buttonTexture.Width, buttonTexture.Height * currentVerticalValue / 100);
             }
             spriteBatch.Draw(buttonTexture, position + offset + imageOffset, sliderPartVisible, Color.White);
         }
         if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Horizontal)
         {
             imageOffset.X = imageOffset.X + buttonTexture.Width;
         }
         else if (image.ImageStackDirection == ButtonAreaImageStackDirectionEnum.Vertical)
         {
             imageOffset.Y = imageOffset.Y + buttonTexture.Height;
         }
     }
     return(imageOffset);
 }