Example #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;
        }
Example #2
0
File: Menu.cs Project: kg/rlms2013
        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;
        }