Пример #1
0
        public void Draw(Frame frame, ref ImperativeRenderer renderer)
        {
            renderer.FillRectangle(Bounds.Expand(4, 4), Color.Black * 0.9f);
            renderer.Layer += 1;
            renderer.OutlineRectangle(Bounds.Expand(4, 4), Color.White);
            renderer.Layer += 1;

            int charactersLeft = DisplayedCharacterCount;

            foreach (var s in Strings) {
                int charactersToDraw = Math.Min(charactersLeft, s.Layout.Count);
                if (s.IsMu) {
                    var offset = new Vector2((float)BlippyRNG.NextDouble(-1, 1), (float)BlippyRNG.NextDouble(-1, 1));
                    var scale = (float)BlippyRNG.NextDouble(0.95f, 1.05f);
                    var rotation = (float)BlippyRNG.NextDouble(-0.04f, 0.04f);

                    var dc = s.Layout.DrawCalls.Array[s.Layout.DrawCalls.Offset];
                    dc.Position += offset;
                    dc.ScaleF = scale;
                    dc.Rotation = rotation;
                    dc.MultiplyColor *= (float)BlippyRNG.NextDouble(0.7f, 1.1f);

                    renderer.Draw(ref dc);
                } else {
                    renderer.DrawMultiple(s.Layout.Slice(0, charactersToDraw));
                }
                charactersLeft -= s.Length;
            }

            renderer.Layer += 1;

            if (AdvancePromptVisible) {
                var advancePromptPosition = Bounds.BottomRight;
                advancePromptPosition.Y -= Squared.Util.Arithmetic.PulseSine((float)(Squared.Util.Time.Seconds * 0.66), 0f, 24f);
                renderer.Draw(AdvancePromptIcon, advancePromptPosition, origin: new Vector2(0.85f, 0.8f));
            }

            renderer.Layer += 1;
        }
Пример #2
0
        public void Draw(Frame frame, ref ImperativeRenderer renderer)
        {
            if (HideWhenPaused && Game.Paused)
                return;

            int layerOffset = 0;
            var t = (float)Time.Seconds - OpenedWhen;
            float opacity;

            if (t <= FadeInTime) {
                opacity = MathHelper.Lerp(0.0f, 1.0f, t / FadeInTime);
            } else if (t <= FadeInTime + HoldDuration) {
                opacity = 1.0f;
                layerOffset = 2;
            } else {
                if ((Style & MessageStyle.AutoClose) == MessageStyle.AutoClose) {
                    opacity = MathHelper.Lerp(1.0f, 0.0f, (t - (FadeInTime + HoldDuration)) / FadeOutTime);
                } else {
                    opacity = 1.0f;
                    layerOffset = 2;
                }
            }

            var size = Game.UIText.MeasureString(Text);

            var clippedSize = new Vector2(size.X, size.Y);
            if (clippedSize.X > 1000)
                clippedSize.X = 1000;

            var tl = new Vector2(
                (Game.ViewportWidth - clippedSize.X),
                (Game.ViewportHeight - clippedSize.Y)
            ) * Alignment.GetValueOrDefault(new Vector2(0.5f, 0.5f));
            var br = tl + clippedSize;
            var border = BorderSize;

            var colorInner = new Color(0.0f, 0.0f, 0.0f, BackgroundOpacity * opacity);
            var colorOuter = new Color(0.0f, 0.0f, 0.0f, 0.0f);

            renderer.FillRectangle(new Bounds(tl, br), colorInner);
            renderer.Layer += 1;
            renderer.DrawString(Game.UIText, Text, tl);
        }
Пример #3
0
        public void Draw(Frame frame, ref ImperativeRenderer renderer)
        {
            var size = Measure();
            var pos = new Vector2(Game.ViewportWidth - size.X, Game.ViewportHeight - size.Y) * new Vector2(0.5f, 0.5f);

            pos.X = (float)Math.Floor(pos.X);
            pos.Y = (float)Math.Floor(pos.Y);

            var menuBounds = new Bounds(
                pos - new Vector2(4, 4),
                pos + size + new Vector2(4, 4)
            );

            renderer.FillRectangle(
                menuBounds,
                new Color(0.0f, 0.0f, 0.0f, BackgroundOpacity)
            );
            renderer.Layer += 1;

            renderer.OutlineRectangle(
                menuBounds,
                Color.White
            );

            renderer.Layer += 1;

            for (int i = 0; i < Items.Count; i++) {
                var item = Items[i];
                var itemSize = item.Measure(Game);
                var selected = (i == SelectedIndex);

                item.Draw(Game, ref renderer, pos, itemSize, selected);

                if (selected)
                    DrawCursor(Game, ref renderer, pos, size, itemSize);

                pos.Y += itemSize.Y;
            }

            renderer.Layer += 1;
        }
Пример #4
0
            public void Draw(ref ImperativeRenderer renderer)
            {
                if (Game.InputControls.MouseLocation.HasValue) {
                    var hotspot = State.HitTest(Game.InputControls.MouseLocation.Value).LastOrDefault();
                    if (hotspot == null)
                        return;

                    renderer.FillRectangle(hotspot.Bounds, Color.White * 0.1f);

                    var textLayout = Game.UIText.LayoutString(hotspot.ToString(), null);
                    var offset = ((hotspot.Bounds.Size - textLayout.Size) * 0.5f) + hotspot.Bounds.TopLeft;
                    offset.X = (float)Math.Floor(offset.X);
                    offset.Y = (float)Math.Floor(offset.Y);

                    renderer.DrawMultiple(textLayout, offset + Vector2.One, multiplyColor: Color.Black, sortKey: 0);
                    renderer.DrawMultiple(textLayout, offset, sortKey: 1);
                }
            }