public override void Update(GameTime gameTime)
{
// Update draw string.
stringBuilder.Length = 0;
if (_history == null) {
InitializeHistory();
return;
}
SpriteFont font = debugManager.DebugFont;
// Compute command window size and draw.
float w = GraphicsDevice.Viewport.Width;
float h = GraphicsDevice.Viewport.Height;
float topMargin = h * 0.1f;
float leftMargin = w * 0.1f;
Rectangle rect = new Rectangle();
rect.X = (int)leftMargin;
rect.Y = (int)topMargin;
rect.Width = (int)(w * 0.8f);
rect.Height = (int)(20 * font.LineSpacing);
float sampleStride = rect.Width / (float)_historyCount;
const float frameSpan = 1.0f / 60.0f * 1000f;
float scaleY = rect.Height * 1f / frameSpan;
if (_total == null)
_total = InitializeHistory(new Vector2(rect.Left, rect.Bottom), sampleStride, Color.White * 0.33f);
if (_total2 == null)
_total2 = InitializeHistory2(new Vector2(rect.Left, rect.Bottom), sampleStride);
int bars = _ruler.Frame.Bars.Length;
float accum = 0;
for (int i = 0; i < bars; i++) {
for (int j = 0; j < _ruler.Frame.Bars[i].MarkCount; j++) {
float time = _ruler.Frame.Bars[i].Markers[j].EndTime - _ruler.Frame.Bars[i].Markers[j].BeginTime;
accum += time;
Color c = _ruler.Frame.Bars[i].Markers[j].Color;
if (_history[i][j] == null)
_history[i][j] = InitializeHistory(new Vector2(rect.Left, rect.Bottom), sampleStride, c);
if (_history2[i][j] == null)
_history2[i][j] = InitializeHistory2(new Vector2(rect.Left, rect.Bottom), sampleStride);
_history[i][j][_graphIndex] = new VertexPositionColor(new Vector3(rect.X + _graphIndex * sampleStride, rect.Bottom - time * scaleY, 0), c);
_history2[i][j][_graphIndex] = new Vector2(rect.X + _graphIndex * sampleStride, rect.Bottom - time * scaleY);
}
}
_total[_graphIndex] = new VertexPositionColor(new Vector3(rect.X + _graphIndex * sampleStride, rect.Bottom - accum * scaleY, 0), Color.White * .33f);
_total2[_graphIndex] = new Vector2(rect.X + _graphIndex * sampleStride, rect.Bottom - accum * scaleY);
_graphIndex++;
if (_graphIndex >= _historyCount)
_graphIndex = 0;
base.Update(gameTime);
}