|
|
@ -27,13 +27,16 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
|
|
|
|
public static bool Enabled; |
|
|
|
// This is a LinkedList instead of a List because SetFpsText() adds to its front.
|
|
|
|
static LinkedList<string> toasts = new LinkedList<string>(); |
|
|
|
static List<DebugRect> rects = new List<DebugRect>(); |
|
|
|
static List<DebugLine> lines = new List<DebugLine>(); |
|
|
|
|
|
|
|
static Texture2D whiteTexture; |
|
|
|
static string toast = null; |
|
|
|
|
|
|
|
public static void Toast(string s) { |
|
|
|
toast = s; |
|
|
|
public static void Initialize(GraphicsDevice graphics) { |
|
|
|
whiteTexture = new Texture2D(graphics, 1, 1); |
|
|
|
whiteTexture.SetData(new Color[] { Color.White }); |
|
|
|
} |
|
|
|
|
|
|
|
public static void WriteLine(string s) { |
|
|
@ -43,17 +46,22 @@ namespace SemiColinGames { |
|
|
|
public static void WriteLine(string s, params object[] args) { |
|
|
|
System.Diagnostics.Debug.WriteLine(s, args); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Initialize(GraphicsDevice graphics) { |
|
|
|
whiteTexture = new Texture2D(graphics, 1, 1); |
|
|
|
whiteTexture.SetData(new Color[] { Color.White }); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void Clear() { |
|
|
|
toasts.Clear(); |
|
|
|
rects.Clear(); |
|
|
|
lines.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
public static void AddToast(string s) { |
|
|
|
toasts.AddLast(s); |
|
|
|
} |
|
|
|
|
|
|
|
// FPS text is always displayed as the first toast (if set).
|
|
|
|
public static void SetFpsText(string s) { |
|
|
|
toasts.AddFirst(s); |
|
|
|
} |
|
|
|
|
|
|
|
public static void AddRect(Rectangle rect, Color color) { |
|
|
|
rects.Add(new DebugRect(rect, color)); |
|
|
|
} |
|
|
@ -62,12 +70,12 @@ namespace SemiColinGames { |
|
|
|
lines.Add(new DebugLine(start, end, color)); |
|
|
|
} |
|
|
|
|
|
|
|
public static void DrawToast(SpriteBatch spriteBatch, SpriteFont font) { |
|
|
|
if (toast == null) { |
|
|
|
return; |
|
|
|
public static void DrawToasts(SpriteBatch spriteBatch, SpriteFont font) { |
|
|
|
int y = 10; |
|
|
|
foreach (var toast in toasts) { |
|
|
|
spriteBatch.DrawString(font, toast, new Vector2(10, y), Color.Teal); |
|
|
|
y += 30; |
|
|
|
} |
|
|
|
spriteBatch.DrawString(font, toast, new Vector2(10, 40), Color.Teal); |
|
|
|
toast = null; |
|
|
|
} |
|
|
|
|
|
|
|
public static void Draw(SpriteBatch spriteBatch, Camera camera) { |
|
|
|