Exemplo n.º 1
0
 public DialogParams Transform(DialogParams par, TextCursorPosition pos)
 {
     par = TransformShow(par, pos, ShowSlider.GetSlide(pos));
     par = TransformHighlight(par, pos, HighlightSlider.GetSlide(pos));
     par = TransformHide(par, pos, HideSlider.GetSlide(pos));
     return(par);
 }
Exemplo n.º 2
0
 public void IncrementPosition(ref TextCursorPosition cursorPos)
 {
     foreach (var element in Contents)
     {
         element.IncrementPosition(ref cursorPos);
     }
 }
Exemplo n.º 3
0
 public static DialogParams DefaultParams(TextCursorPosition position) => new DialogParams()
 {
     Color  = Color.White,
     Border = Color.Black,
     Offset = Vector2.Zero,
     Scale  = Vector2.One,
     Angle  = 0,
 };
Exemplo n.º 4
0
 private static DialogParams TransformHide(DialogParams param, TextCursorPosition pos, float slide)
 {
     if (slide >= 1)
     {
         param.Color  = Color.Transparent;
         param.Border = Color.Transparent;
     }
     return(param);
 }
Exemplo n.º 5
0
 private static DialogParams Transform(DialogParams param, TextCursorPosition pos, float slide)
 {
     if (slide <= 0)
     {
         param.Color  = Color.Transparent;
         param.Border = Color.Transparent;
     }
     param.Scale = Vector2.Lerp(new Vector2(3, 3), Vector2.One, slide);
     return(param);
 }
Exemplo n.º 6
0
 private static DialogParams Transform(DialogParams param, TextCursorPosition pos, float slide)
 {
     if (slide <= 0)
     {
         param.Color  = Color.Transparent;
         param.Border = Color.Transparent;
     }
     else
     {
         float angle = Util.RandomNoise(pos.GlobalCharacter) * MathHelper.TwoPi;
         param.Offset = Vector2.Lerp(Util.AngleToVector(angle) * 20, Vector2.Zero, MathHelper.Clamp(slide * 2, 0, 1));
         param.Scale  = Vector2.Lerp(new Vector2(3, 3), Vector2.One, MathHelper.Clamp(slide * 2, 0, 1));
         param.Border = Color.Lerp(Color.Orange.RotateHue(pos.GlobalCharacter / 20f), Color.Black, slide);
     }
     return(param);
 }
Exemplo n.º 7
0
 private DialogParams TransformShow(DialogParams param, TextCursorPosition pos, float slide)
 {
     if (slide <= 0)
     {
         //param.Color = Color.Transparent;
         //param.Border = Color.Transparent;
     }
     else
     {
         float angle = Util.RandomNoise(pos.GlobalCharacter) * MathHelper.TwoPi;
         //param.Offset = Vector2.Lerp(Util.AngleToVector(angle) * 20, Vector2.Zero, MathHelper.Clamp(slide * 2, 0, 1));
         //param.Scale = Vector2.Lerp(new Vector2(3, 3), Vector2.One, MathHelper.Clamp(slide * 2, 0, 1));
         var colorSlide = (float)LerpHelper.ForwardReverse(1, 0, slide);
         param.Border = Color.Lerp(Color.Gold, Color.Black, colorSlide);
     }
     param.Offset = Vector2.Lerp(-pos.Position, Vector2.Zero, (float)LerpHelper.QuadraticOut(0, 1, AppearSlide.Slide));
     return(param);
 }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
0
 public void IncrementPosition(ref TextCursorPosition cursorPos)
 {
     cursorPos.AddCharacters(1);
     cursorPos.IncrementElement();
 }
Exemplo n.º 11
0
 public void Draw(ITextContainer parent, Matrix baseTransform, FontRenderer renderer, TextCursorPosition cursorPos)
 {
     renderer.DrawChars(Text, Width, Height, Format, Dialog, Position.Transform * baseTransform, cursorPos);
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
0
        public float GetSlide(TextCursorPosition pos)
        {
            float n = (CharacterCurrent + Interval.Slide) * Interval.EndTime;

            return(MathHelper.Clamp((n - pos.LocalCharacter * Interval.EndTime) / Lag, 0, 1));
        }
Exemplo n.º 14
0
 public float GetSlide(TextCursorPosition pos)
 {
     return(SliderLag.Slide);
 }
Exemplo n.º 15
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();
     }
 }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
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();
        }
Exemplo n.º 18
0
 public void IncrementPosition(ref TextCursorPosition cursorPos)
 {
     cursorPos.IncrementElement();
 }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        public void DrawChars(IEnumerable <char> chars, float width, float height, TextFormatting format, TextDialog dialog, Matrix transform, TextCursorPosition cursorPos)
        {
            float offset = 0;

            var skew = new Matrix(
                1, 0, 0, 0,
                format.Italic ? -4f / 16 : 0, 1, 0, 0,
                0, 0, 1, 0,
                0, 0, 0, 1
                );
            var skewCenter = Matrix.CreateTranslation(-width / 2, -height / 2, 0) * skew * Matrix.CreateTranslation(width / 2, height / 2, 0);

            Scene.PushSpriteBatch(transform: skewCenter * transform);

            DrawAreaDebug(Vector2.Zero, new Vector2(width, height));
            foreach (var chr in chars)
            {
                var par = format.GetParams(cursorPos + new Vector2(offset, 0));
                DrawChar(chr, new Vector2(offset, 0), format, dialog.Transform(par, cursorPos + new Vector2(offset, 0)));
                cursorPos.AddCharacters(1);
                offset += format.GetCharWidth(chr) + 1;
            }
            Scene.PopSpriteBatch();
        }
Exemplo n.º 21
0
 public void IncrementPosition(ref TextCursorPosition cursorPos)
 {
     cursorPos.AddCharacters(BackgroundText.Length);
     cursorPos.IncrementElement();
 }
Exemplo n.º 22
0
 public static DialogParams TransformIdentity(DialogParams param, TextCursorPosition pos, float slide) => param;
Exemplo n.º 23
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);
        }