/// <summary> /// Constructor /// </summary> /// <param name="game"></param> public Profiler(TechCraftGame game) : base(game) { spriteBatch = new SpriteBatch(game.GraphicsDevice); blank = game.Content.Load <Texture2D>("Textures\\blank"); font = game.Content.Load <SpriteFont>("Fonts\\console"); timers = new Dictionary <String, Stopwatch>(); }
/// <summary> /// Draws the timers in bar form. /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { TechCraftGame techCraftGame = (TechCraftGame)Game; if (techCraftGame.ShowDebugInfo) { int currentY = Y_START; spriteBatch.Begin(); foreach (String timerId in timers.Keys) { spriteBatch.DrawString(font, timerId, new Vector2(X_START - 5 - font.MeasureString(timerId).X, currentY - 5), Color.Yellow); spriteBatch.Draw(blank, new Rectangle(X_START, currentY, (int)(timers[timerId].ElapsedTicks * ADJUSTMENT), 18), Color.Yellow); timers[timerId].Reset(); currentY += 20; } spriteBatch.End(); } }