2
0

DebugManager.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // DebugManager.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Graphics;
  12. using Microsoft.Xna.Framework.Content;
  13. #endregion
  14. namespace PerformanceMeasuring.GameDebugTools
  15. {
  16. /// <summary>
  17. /// DebugManager class that holds graphics resources for debug
  18. /// </summary>
  19. public class DebugManager : DrawableGameComponent
  20. {
  21. // the name of the font to load
  22. private string debugFont;
  23. #region Properties
  24. /// <summary>
  25. /// Gets a sprite batch for debug.
  26. /// </summary>
  27. public SpriteBatch SpriteBatch { get; private set; }
  28. /// <summary>
  29. /// Gets white texture.
  30. /// </summary>
  31. public Texture2D WhiteTexture { get; private set; }
  32. /// <summary>
  33. /// Gets SpriteFont for debug.
  34. /// </summary>
  35. public SpriteFont DebugFont { get; private set; }
  36. #endregion
  37. #region Initialize
  38. public DebugManager(Game game, string debugFont)
  39. : base(game)
  40. {
  41. // Added as a Service.
  42. Game.Services.AddService(typeof(DebugManager), this);
  43. this.debugFont = debugFont;
  44. // This component doesn't need be call neither update nor draw.
  45. this.Enabled = false;
  46. this.Visible = false;
  47. }
  48. protected override void LoadContent()
  49. {
  50. // Load debug content.
  51. SpriteBatch = new SpriteBatch(GraphicsDevice);
  52. DebugFont = Game.Content.Load<SpriteFont>(debugFont);
  53. // Create white texture.
  54. WhiteTexture = new Texture2D(GraphicsDevice, 1, 1);
  55. Color[] whitePixels = new Color[] { Color.White };
  56. WhiteTexture.SetData<Color>(whitePixels);
  57. base.LoadContent();
  58. }
  59. #endregion
  60. }
  61. }