예제 #1
0
        public void Draw(AdvancedDrawBatch batch)
        {
            if (!Enabled)
            {
                return;
            }

            Color normalColor     = Color.LightBlue;
            Color errorColor      = Color.Red;
            Color backgroundColor = Color.Black;

            int offset = Math.Max(1, _height / 10);

            _display.Reset(new Point(offset, offset));

            if (_right > 0)
            {
                Matrix matrix;

                matrix = Matrix.CreateRotationZ(MathHelper.PiOver2) * Matrix.CreateTranslation(new Vector3(_right, 0, 0));
                batch.PushTransform(matrix);
            }

            batch.BeginPrimitive(PrimitiveType.TriangleList, null);
            batch.PushVertex(new Vector2(0, 0), backgroundColor);
            batch.PushVertex(new Vector2(0, _height), backgroundColor);
            batch.PushVertex(new Vector2(6000, 0), backgroundColor);

            batch.PushVertex(new Vector2(0, _height), backgroundColor);
            batch.PushVertex(new Vector2(6000, 0), backgroundColor);
            batch.PushVertex(new Vector2(6000, _height), backgroundColor);

            int   lastMaxFrameFill = (int)(100 * _maxFrame / (_targetFrameTime)) - 100;
            Color color;

            lastMaxFrameFill = Math.Min(99, lastMaxFrameFill);

            _stringBuilder.Clear();
            _stringBuilder.AppendFormat("{0,-2} ", (int)_minFps);
            color = (_maxFrame > _minFrameTime) ? errorColor : normalColor;
            _display.Draw(batch, _stringBuilder, color);

            _stringBuilder.Clear();
            _stringBuilder.AppendFormat("{0,-2} ", (int)_fps);
            color = _fps < (1 / _minFrameTime) ? errorColor : normalColor;
            _display.Draw(batch, _stringBuilder, color);

            _stringBuilder.Clear();
            _stringBuilder.AppendFormat("{0,-2} ", Math.Max(0, lastMaxFrameFill));
            color = (_maxFrame > _minFrameTime) ? errorColor : normalColor;
            _display.Draw(batch, _stringBuilder, color);

            for (int idx = 0; idx < _counters.Count; ++idx)
            {
                var counter = _counters[idx];

                float frameTime         = counter.Value;
                int   lastUpdatePercent = float.IsNaN(frameTime) ? -1 : (int)(100 * frameTime / (_targetFrameTime));
                lastUpdatePercent = Math.Min(99, lastUpdatePercent);

                _stringBuilder.Clear();

                if (lastUpdatePercent < 0)
                {
                    _stringBuilder.AppendFormat("{1}{0,-2} ", "-", (char)(idx + 'A'));
                }
                else
                {
                    _stringBuilder.AppendFormat("{1}{0,-2} ", lastUpdatePercent, (char)(idx + 'A'));
                }

                color = (lastUpdatePercent > counter.MaxFill) ? errorColor : normalColor;
                _display.Draw(batch, _stringBuilder, color);
            }

            if (_right > 0)
            {
                batch.PopTransform();
            }
        }
예제 #2
0
        void Draw(AdvancedDrawBatch batch, int code, Color color)
        {
            Color c = Color.Black;

            batch.BeginPrimitive(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, null);

            Color offColor = color * 0.15f;

            // a
            c = (code & 0x01) != 0 ? color : offColor;

            PushVertex(batch, 2, 2, ref c);
            PushVertex(batch, 3, 1, ref c);
            PushVertex(batch, 3, 3, ref c);

            PushVertex(batch, 8, 2, ref c);
            PushVertex(batch, 7, 1, ref c);
            PushVertex(batch, 7, 3, ref c);

            PushVertex(batch, 3, 1, ref c);
            PushVertex(batch, 3, 3, ref c);
            PushVertex(batch, 7, 1, ref c);

            PushVertex(batch, 3, 3, ref c);
            PushVertex(batch, 7, 1, ref c);
            PushVertex(batch, 7, 3, ref c);

            // b
            c = (code & 0x02) != 0 ? color : offColor;

            PushVertex(batch, 8, 2, ref c);
            PushVertex(batch, 9, 3, ref c);
            PushVertex(batch, 7, 3, ref c);

            PushVertex(batch, 8, 8, ref c);
            PushVertex(batch, 9, 7, ref c);
            PushVertex(batch, 7, 7, ref c);

            PushVertex(batch, 7, 3, ref c);
            PushVertex(batch, 9, 3, ref c);
            PushVertex(batch, 7, 7, ref c);

            PushVertex(batch, 9, 3, ref c);
            PushVertex(batch, 7, 7, ref c);
            PushVertex(batch, 9, 7, ref c);

            // c
            c = (code & 0x04) != 0 ? color : offColor;

            PushVertex(batch, 8, 8, ref c);
            PushVertex(batch, 9, 9, ref c);
            PushVertex(batch, 7, 9, ref c);

            PushVertex(batch, 8, 14, ref c);
            PushVertex(batch, 9, 13, ref c);
            PushVertex(batch, 7, 13, ref c);

            PushVertex(batch, 7, 9, ref c);
            PushVertex(batch, 9, 9, ref c);
            PushVertex(batch, 7, 13, ref c);

            PushVertex(batch, 9, 9, ref c);
            PushVertex(batch, 7, 13, ref c);
            PushVertex(batch, 9, 13, ref c);

            // d
            c = (code & 0x08) != 0 ? color : offColor;

            PushVertex(batch, 2, 14, ref c);
            PushVertex(batch, 3, 13, ref c);
            PushVertex(batch, 3, 15, ref c);

            PushVertex(batch, 8, 14, ref c);
            PushVertex(batch, 7, 13, ref c);
            PushVertex(batch, 7, 15, ref c);

            PushVertex(batch, 3, 13, ref c);
            PushVertex(batch, 3, 15, ref c);
            PushVertex(batch, 7, 13, ref c);

            PushVertex(batch, 3, 15, ref c);
            PushVertex(batch, 7, 13, ref c);
            PushVertex(batch, 7, 15, ref c);

            // e
            c = (code & 0x10) != 0 ? color : offColor;

            PushVertex(batch, 2, 8, ref c);
            PushVertex(batch, 3, 9, ref c);
            PushVertex(batch, 1, 9, ref c);

            PushVertex(batch, 2, 14, ref c);
            PushVertex(batch, 3, 13, ref c);
            PushVertex(batch, 1, 13, ref c);

            PushVertex(batch, 1, 9, ref c);
            PushVertex(batch, 3, 9, ref c);
            PushVertex(batch, 1, 13, ref c);

            PushVertex(batch, 3, 9, ref c);
            PushVertex(batch, 1, 13, ref c);
            PushVertex(batch, 3, 13, ref c);

            // f
            c = (code & 0x20) != 0 ? color : offColor;

            PushVertex(batch, 2, 2, ref c);
            PushVertex(batch, 3, 3, ref c);
            PushVertex(batch, 1, 3, ref c);

            PushVertex(batch, 2, 8, ref c);
            PushVertex(batch, 3, 7, ref c);
            PushVertex(batch, 1, 7, ref c);

            PushVertex(batch, 1, 3, ref c);
            PushVertex(batch, 3, 3, ref c);
            PushVertex(batch, 1, 7, ref c);

            PushVertex(batch, 3, 3, ref c);
            PushVertex(batch, 1, 7, ref c);
            PushVertex(batch, 3, 7, ref c);

            // g
            c = (code & 0x40) != 0 ? color : offColor;

            PushVertex(batch, 2, 8, ref c);
            PushVertex(batch, 3, 7, ref c);
            PushVertex(batch, 3, 9, ref c);

            PushVertex(batch, 8, 8, ref c);
            PushVertex(batch, 7, 7, ref c);
            PushVertex(batch, 7, 9, ref c);

            PushVertex(batch, 3, 7, ref c);
            PushVertex(batch, 3, 9, ref c);
            PushVertex(batch, 7, 7, ref c);

            PushVertex(batch, 3, 9, ref c);
            PushVertex(batch, 7, 7, ref c);
            PushVertex(batch, 7, 9, ref c);

            _position.X += _size;
        }