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();
            }
        }
Beispiel #2
0
 void PushVertex(AdvancedDrawBatch batch, int x, int y, ref Color c)
 {
     batch.PushVertex(new Vector2(x * _thick, y * _thick) + _position, c);
 }