public override void Draw(AdvancedDrawBatch drawBatch, DrawButtonInfo info) { Update(info.EllapsedTime, info.ButtonState); float opacity; Matrix transform; _transitionPushed.Get(_reverse ? 1 - PushedState : PushedState, info.Target, info.Target, out transform, out opacity); drawBatch.PushTransform(transform); info.Opacity *= opacity; for (int idx = 0; idx < _drawables.Count; ++idx) { _drawables[idx].Draw(drawBatch, info); } drawBatch.PopTransform(); }
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(); } }