Example #1
0
 public UIButtonAppearance(SpriteFont font, Color textColor, RichImage image, Color fillColor)
 {
     this.font      = font;
     this.textColor = textColor;
     this.image     = image;
     this.fillColor = fillColor;
 }
Example #2
0
        public static UIButtonStyle GetDefaultStyle(ContentManager Content)
        {
            SpriteFont font         = Content.Load <SpriteFont>("Arial");
            RichImage  normalImage  = new RichImage(new RichImageLayer_Texture(Content.Load <Texture2D>("button3d"), Color.White, "stretched9grid", 0, Rotation90.None));
            RichImage  hoverImage   = new RichImage(new RichImageLayer_Texture(Content.Load <Texture2D>("button3d_hover"), Color.White, "stretched9grid", 0, Rotation90.None));
            RichImage  pressedImage = new RichImage(new RichImageLayer_Texture(Content.Load <Texture2D>("button3d_pressed"), Color.White, "stretched9grid", 0, Rotation90.None));

            return(new UIButtonStyle(
                       new UIButtonAppearance(font, Color.Black, normalImage, Color.White),
                       new UIButtonAppearance(font, Color.Black, hoverImage, Color.White),
                       new UIButtonAppearance(font, Color.Black, pressedImage, Color.White, new Vector2(0, 1)),
                       new UIButtonAppearance(font, Color.Black, normalImage, Color.Gray)
                       ));
        }
Example #3
0
        public static void DrawTooltip(SpriteBatch spriteBatch, SpriteFont font, RichImage bg, List <string> text, Vector2 origin, Align align)
        {
            float lineHeight = 0;
            float maxWidth   = 0;

            foreach (string s in text)
            {
                Vector2 lineSize = font.MeasureString(s);
                if (lineSize.X > maxWidth)
                {
                    maxWidth = lineSize.X;
                }
                if (lineSize.Y > lineHeight)
                {
                    lineHeight = lineSize.Y;
                }
            }

            Vector2 padding = new Vector2(4, 2);

            if (align == Align.RIGHT)
            {
                origin.X -= (maxWidth + padding.X * 2);
            }
            else if (align == Align.CENTER)
            {
                origin.X -= (int)((maxWidth + padding.X * 2) / 2);
            }

            bg.Draw(spriteBatch, new Rectangle((int)origin.X, (int)origin.Y, (int)(maxWidth + padding.X * 2), (int)(text.Count * lineHeight + padding.Y * 2)));
            Vector2 stringPos = origin + new Vector2(padding.X, padding.Y);

            foreach (string s in text)
            {
                spriteBatch.DrawString(font, s, stringPos, Color.Black);
                stringPos = new Vector2(stringPos.X, stringPos.Y + lineHeight);
            }
        }
Example #4
0
 public static void Draw(this SpriteBatch spriteBatch, RichImage image, Rectangle rect, Color col)
 {
     image.Draw(spriteBatch, rect, col);
 }
Example #5
0
 public void Add(RichImage image)
 {
     layers.Add(new RichImageLayer_Image(image, Rotation90.None));
 }
Example #6
0
 public RichImageLayer_Image(RichImage aImage, Rotation90 aRotation)
 {
     image    = aImage;
     rotation = aRotation;
 }