예제 #1
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            renderer.DrawChars(BackgroundText, Width, Height, FormatBack, Dialog, Position.Transform * baseTransform, cursorPos);
            var offset = GetBackgroundWidth() - GetForegroundWidth();

            renderer.DrawChars(ForegroundText, Width, Height, FormatFront, Dialog, Matrix.CreateTranslation(offset, 0, 0) * Position.Transform * baseTransform, cursorPos);
        }
예제 #2
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            var sprite   = SpriteLoader.Instance.AddSprite("content/ui_slider_bar");
            var cursor   = SpriteLoader.Instance.AddSprite("content/cursor");
            var barSlide = BarSlide();
            int bars     = (int)Math.Round(BarCount * barSlide);

            if (bars <= 0 && barSlide > 0)
            {
                bars = 1;
            }
            if (bars >= BarCount - 1 && barSlide < 1)
            {
                bars = BarCount - 1;
            }
            renderer.Scene.PushSpriteBatch(transform: Position.Transform * baseTransform);
            if (barSlide > 0)
            {
                renderer.Scene.DrawSprite(cursor, 0, new Vector2(0, 0), SpriteEffects.FlipHorizontally, 0);
            }
            for (int i = 0; i < BarCount; i++)
            {
                renderer.Scene.DrawSprite(sprite, 0, new Vector2(16 + i * 5 - 1, 0), SpriteEffects.None, i < bars ? Color.White : Color.Gray, 0);
            }
            if (barSlide < 1)
            {
                renderer.Scene.DrawSprite(cursor, 0, new Vector2(16 + BarCount * 5 - 1, 0), SpriteEffects.None, 0);
            }
            renderer.Scene.PopSpriteBatch();
        }
예제 #3
0
 public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
 {
     var charOffset = Vector2.Zero;
     var color      = Color.White;
     var border     = Color.Black; //TODO: formatting
     //renderer.DrawCharLine(charOffset + new Vector2(0, 15), (int)Width, color, border);
     //renderer.DrawCharLine(charOffset + new Vector2(0, 8), (int)Width, color, border);
 }
예제 #4
0
 public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
 {
     if (Selected())
     {
         renderer.Scene.PushSpriteBatch(transform: Position.Transform * baseTransform);
         renderer.Scene.DrawSprite(Sprite, 0, new Vector2(Width / 2, Height / 2) - Sprite.Middle, SpriteEffects.None, 0);
         renderer.Scene.PopSpriteBatch();
     }
 }
예제 #5
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            renderer.Scene.PushSpriteBatch(transform: Position.Transform * baseTransform);
            renderer.DrawAreaDebug(Vector2.Zero, new Vector2(Width, Height));
            float yOffset = 0;

            foreach (var element in Contents)
            {
                element.Draw(this, baseTransform, renderer, cursorPos + new Vector2(0, yOffset));
                element.IncrementPosition(ref cursorPos);
                yOffset += element.Height;
            }
            renderer.Scene.PopSpriteBatch();
        }
예제 #6
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            var par = Format.GetParams(cursorPos);

            par = Dialog.Transform(par, cursorPos);
            Color   color  = par.Color;
            Vector2 offset = par.Offset;
            Vector2 scale  = par.Scale;
            float   angle  = par.Angle;

            renderer.Scene.PushSpriteBatch(transform: Matrix.CreateTranslation(-8, -8, 0) * Matrix.CreateScale(scale.X, scale.Y, 0) * Matrix.CreateRotationZ(angle) * Matrix.CreateTranslation(8, 8, 0) * Position.Transform * baseTransform);
            if (color.A > 0)
            {
                Symbol.DrawIcon(renderer.Scene, offset, par, 0);
            }
            renderer.Scene.PopSpriteBatch();
        }
예제 #7
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            float offset      = 0;
            float alignOffset = 0;

            renderer.Scene.PushSpriteBatch(transform: Position.Transform * baseTransform);
            renderer.DrawAreaDebug(Vector2.Zero, new Vector2(Width, Height));
            int i = 0;

            foreach (var element in Contents)
            {
                element.Draw(this, baseTransform, renderer, cursorPos + new Vector2(offset + alignOffset, 0));
                element.IncrementPosition(ref cursorPos);
                offset += element.Width + (i < Contents.Count - 1 ? ColumnConfigs.Padding : 0);
                i++;
            }
            renderer.Scene.PopSpriteBatch();
        }
예제 #8
0
        public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
        {
            float offsetX = (Width - GetWidth()) * 1f;

            switch (Alignment)
            {
            case (LineAlignment.Left):
                offsetX = 0;
                break;

            case (LineAlignment.Center):
                offsetX *= 0.5f;
                break;

            case (LineAlignment.Right):
                break;
            }

            renderer.DrawChars(Text, Width, Height, Format, Dialog, Position.Transform * baseTransform * Matrix.CreateTranslation(offsetX, 0, 0), cursorPos);
        }
예제 #9
0
        public virtual void Draw(FontRenderer fontRenderer, int x, int y, float openCoeff)
        {
            if (openCoeff <= 0)
            {
                return;
            }

            var   rectInterior = new Rectangle(new Point(x, y), Size());
            float openResize   = MathHelper.Lerp(-0.5f, 0.0f, openCoeff);

            rectInterior.Inflate(rectInterior.Width * openResize, rectInterior.Height * openResize);

            var minWidth = rectInterior.Width * 2 / 3;

            fontRenderer.Scene.DrawUI(ContentSprite, rectInterior, Color.White);
            if (!Label.IsEmpty() && openCoeff >= 1)
            {
                var       width        = (int)MathHelper.Clamp(Label.GetContentWidth() + 8, minWidth, rectInterior.Width);
                Rectangle rectExterior = new Rectangle(rectInterior.X + (rectInterior.Width - width) / 2, rectInterior.Y - 20, width, 16);
                fontRenderer.Scene.DrawUI(LabelSprite, rectExterior, Color.White);
                Label.Draw(new Vector2(rectExterior.X, rectExterior.Y), fontRenderer);
            }
        }
예제 #10
0
 public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
 {
     renderer.DrawChars(Text, Width, Height, Format, Dialog, Position.Transform * baseTransform, cursorPos);
 }
예제 #11
0
 public void Draw(TextPosition position, FontRenderer renderer)
 {
     Draw(position.Position, renderer, position.Transform);
 }
예제 #12
0
 public void Draw(Vector2 position, FontRenderer renderer, Matrix?transform = null)
 {
     SetPosition(position, transform);
     renderer.ResetDebug();
     Root.Draw(null, TextPosition.Transform * Matrix.CreateTranslation(TextPosition.Position.X, TextPosition.Position.Y, 0), renderer, new TextCursorPosition());
 }
예제 #13
0
 public override void Draw(FontRenderer fontRenderer, int x, int y, float openCoeff)
 {
     base.Draw(fontRenderer, x, y, openCoeff);
     Content.Draw(new Vector2(x, y), fontRenderer);
 }
예제 #14
0
 public Scene(Game game)
 {
     Game         = game;
     FontRenderer = new FontRenderer(this);
 }