Esempio n. 1
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            string text = Text;

            if (WordWrap)
            {
                text = DwarfGUI.WrapLines(Text, LocalBounds, TextFont);
            }

            if (Truncate)
            {
                Vector2 measure  = Datastructures.SafeMeasure(TextFont, text);
                Vector2 wMeasure = Datastructures.SafeMeasure(TextFont, "W");
                if (measure.X > GlobalBounds.Width)
                {
                    int numLetters = GlobalBounds.Width / (int)wMeasure.X;
                    text = Text.Substring(0, Math.Min(numLetters, Text.Length)) + "...";
                }
            }

            if (StrokeColor.A > 0)
            {
                Drawer2D.DrawAlignedStrokedText(batch, text, TextFont, TextColor, StrokeColor, Alignment, GlobalBounds);
            }
            else
            {
                Drawer2D.DrawAlignedText(batch, text, TextFont, TextColor, Alignment, GlobalBounds);
            }
            base.Render(time, batch);
        }
Esempio n. 2
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            string text = Text;

            if (WordWrap)
            {
                text = DwarfGUI.WrapLines(Text, LocalBounds, TextFont);
            }

            Drawer2D.DrawAlignedStrokedText(batch, text, TextFont, TextColor, StrokeColor, Alignment, GlobalBounds);
            base.Render(time, batch);
        }
Esempio n. 3
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            if (!IsVisible)
            {
                return;
            }
            Rectangle rectToDraw = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, GUI.Skin.TileHeight);

            GUI.Skin.RenderProgressBar(rectToDraw, Value, Tint, batch);
            Drawer2D.DrawAlignedStrokedText(batch, Message, GUI.DefaultFont, MessageColor, MessageStroke, Drawer2D.Alignment.Center, GlobalBounds);
            base.Render(time, batch);
        }
Esempio n. 4
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            if (!IsVisible)
            {
                return;
            }
            Drawer2D.Alignment alignment = DrawButton ? Drawer2D.Alignment.Center : Drawer2D.Alignment.Left;
            if (DrawButton)
            {
                GUI.Skin.RenderButton(GlobalBounds, batch);
            }

            //Drawer2D.DrawRect(GlobalBounds, Color.White, Color.Black, 1.0f);
            if (IsMouseOver)
            {
                Drawer2D.DrawAlignedStrokedText(batch, Label, GUI.DefaultFont, HoverColor, TextStrokeColor, alignment, GlobalBounds);
            }
            else
            {
                if (!IsToggled || Mode == SelectionMode.ButtonList)
                {
                    Drawer2D.DrawAlignedStrokedText(batch, Label, GUI.DefaultFont, TextColor, TextStrokeColor, alignment, GlobalBounds);
                }
                else
                {
                    Drawer2D.DrawAlignedStrokedText(batch, Label, GUI.DefaultFont, ToggledColor, TextStrokeColor, alignment, GlobalBounds);
                }
            }

            if (Texture != null)
            {
                batch.Draw(Texture, new Vector2(GlobalBounds.Top, GlobalBounds.Left - 10), TextureBounds, Color.White, 0.0f, Vector2.Zero, Vector2.Zero, SpriteEffects.None, 0);
            }

            base.Render(time, batch);
        }
Esempio n. 5
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            if (!IsVisible)
            {
                return;
            }

            Rectangle globalBounds = GlobalBounds;
            Color     imageColor   = Color.White;
            Color     textColor    = TextColor;
            Color     strokeColor  = GUI.DefaultStrokeColor;

            if (IsLeftPressed)
            {
                imageColor = PressedTint;
                textColor  = PressedTextColor;
            }
            else if (IsMouseOver)
            {
                imageColor = HoverTint;
                textColor  = HoverTextColor;
            }

            if (CanToggle && IsToggled)
            {
                imageColor = ToggleTint;
            }

            imageColor.A = Transparency;

            Rectangle imageBounds = GetImageBounds();

            switch (Mode)
            {
            case ButtonMode.ImageButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButtonFrame(imageBounds, batch);
                }
                Rectangle bounds = imageBounds;
                if (Image != null && Image.Image != null)
                {
                    batch.Draw(Image.Image, bounds, Image.SourceRect, imageColor);
                }

                Drawer2D.DrawAlignedText(batch, Text, TextFont, textColor, Drawer2D.Alignment.Under | Drawer2D.Alignment.Center, new Rectangle(bounds.X + 2, bounds.Y + 4, bounds.Width, bounds.Height), true);
                if (IsToggled)
                {
                    Drawer2D.DrawRect(batch, GetImageBounds(), Color.White, 2);
                }
                break;

            case ButtonMode.PushButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButton(GlobalBounds, batch);
                }
                Drawer2D.DrawAlignedStrokedText(batch, Text,
                                                TextFont,
                                                textColor, strokeColor, Drawer2D.Alignment.Center, GlobalBounds, true);
                break;

            case ButtonMode.ToolButton:
                if (DrawFrame)
                {
                    GUI.Skin.RenderButton(GlobalBounds, batch);
                }
                if (Image != null && Image.Image != null)
                {
                    Rectangle imageRect   = GetImageBounds();
                    Rectangle alignedRect = Drawer2D.Align(GlobalBounds, imageRect.Width, imageRect.Height, Drawer2D.Alignment.Left);
                    alignedRect.X += 5;
                    batch.Draw(Image.Image, alignedRect, Image.SourceRect, imageColor);
                }
                Drawer2D.DrawAlignedStrokedText(batch, Text, TextFont, textColor, strokeColor, Drawer2D.Alignment.Center, GlobalBounds, true);

                if (IsToggled)
                {
                    Drawer2D.DrawRect(batch, GetImageBounds(), Color.White, 2);
                }

                break;

            case ButtonMode.TabButton:
                GUI.Skin.RenderTab(GlobalBounds, batch, IsToggled ? Color.White : Color.LightGray);
                Drawer2D.DrawAlignedStrokedText(batch, Text,
                                                TextFont,
                                                textColor, strokeColor, Drawer2D.Alignment.Top, new Rectangle(GlobalBounds.X, GlobalBounds.Y + 2, GlobalBounds.Width, GlobalBounds.Height), true);
                break;
            }

            base.Render(time, batch);
        }