Debug: turn functions into noops if not compiled with DEBUG.
Fixes #11.
This commit is contained in:
parent
3d1de388b8
commit
a93076419d
@ -32,23 +32,30 @@ namespace SemiColinGames {
|
|||||||
// Lines in excess of MAX_LINES get dropped on the floor.
|
// Lines in excess of MAX_LINES get dropped on the floor.
|
||||||
const int MAX_LINES = 2000;
|
const int MAX_LINES = 2000;
|
||||||
const int MAX_LINE_VERTICES = MAX_LINES * 2;
|
const int MAX_LINE_VERTICES = MAX_LINES * 2;
|
||||||
|
|
||||||
static int lineIdx = 0;
|
static int lineIdx = 0;
|
||||||
static readonly VertexPositionColor[] lineVertices = new VertexPositionColor[MAX_LINE_VERTICES];
|
static VertexPositionColor[] lineVertices;
|
||||||
static VertexBuffer vertexBuffer;
|
static VertexBuffer vertexBuffer;
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void Initialize(GraphicsDevice graphics) {
|
public static void Initialize(GraphicsDevice graphics) {
|
||||||
|
lineVertices = new VertexPositionColor[MAX_LINE_VERTICES];
|
||||||
|
vertexBuffer?.Dispose();
|
||||||
vertexBuffer = new VertexBuffer(
|
vertexBuffer = new VertexBuffer(
|
||||||
graphics, typeof(VertexPositionColor), MAX_LINE_VERTICES, BufferUsage.WriteOnly);
|
graphics, typeof(VertexPositionColor), MAX_LINE_VERTICES, BufferUsage.WriteOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void WriteLine(string s) {
|
public static void WriteLine(string s) {
|
||||||
System.Diagnostics.Debug.WriteLine(s);
|
System.Diagnostics.Debug.WriteLine(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void WriteLine(string s, params object[] args) {
|
public static void WriteLine(string s, params object[] args) {
|
||||||
System.Diagnostics.Debug.WriteLine(s, args);
|
System.Diagnostics.Debug.WriteLine(s, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void Clear(bool paused) {
|
public static void Clear(bool paused) {
|
||||||
toasts.Clear();
|
toasts.Clear();
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
@ -56,15 +63,18 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddToast(string s) {
|
public static void AddToast(string s) {
|
||||||
toasts.AddLast(s);
|
toasts.AddLast(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FPS text is always displayed as the first toast (if set).
|
// FPS text is always displayed as the first toast (if set).
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void SetFpsText(string s) {
|
public static void SetFpsText(string s) {
|
||||||
toasts.AddFirst(s);
|
toasts.AddFirst(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddRect(Rectangle rect, Color color) {
|
public static void AddRect(Rectangle rect, Color color) {
|
||||||
AddLine(rect.Left, rect.Top + 1, rect.Right, rect.Top + 1, color);
|
AddLine(rect.Left, rect.Top + 1, rect.Right, rect.Top + 1, color);
|
||||||
AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom, color);
|
AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom, color);
|
||||||
@ -72,6 +82,7 @@ namespace SemiColinGames {
|
|||||||
AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom, color);
|
AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddRect(AABB box, Color color) {
|
public static void AddRect(AABB box, Color color) {
|
||||||
Rectangle rect = new Rectangle(
|
Rectangle rect = new Rectangle(
|
||||||
(int) (box.Position.X - box.HalfSize.X), (int) (box.Position.Y - box.HalfSize.Y),
|
(int) (box.Position.X - box.HalfSize.X), (int) (box.Position.Y - box.HalfSize.Y),
|
||||||
@ -79,6 +90,7 @@ namespace SemiColinGames {
|
|||||||
AddRect(rect, color);
|
AddRect(rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddLine(Point start, Point end, Color color) {
|
public static void AddLine(Point start, Point end, Color color) {
|
||||||
if (lineIdx >= MAX_LINE_VERTICES) {
|
if (lineIdx >= MAX_LINE_VERTICES) {
|
||||||
return;
|
return;
|
||||||
@ -88,14 +100,17 @@ namespace SemiColinGames {
|
|||||||
lineIdx += 2;
|
lineIdx += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddLine(int p1x, int p1y, int p2x, int p2y, Color color) {
|
public static void AddLine(int p1x, int p1y, int p2x, int p2y, Color color) {
|
||||||
AddLine(new Point(p1x, p1y), new Point(p2x, p2y), color);
|
AddLine(new Point(p1x, p1y), new Point(p2x, p2y), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void AddLine(Vector2 start, Vector2 end, Color color) {
|
public static void AddLine(Vector2 start, Vector2 end, Color color) {
|
||||||
AddLine(start.ToPoint(), end.ToPoint(), color);
|
AddLine(start.ToPoint(), end.ToPoint(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void DrawToasts(SpriteBatch spriteBatch) {
|
public static void DrawToasts(SpriteBatch spriteBatch) {
|
||||||
if (!Enabled) {
|
if (!Enabled) {
|
||||||
return;
|
return;
|
||||||
@ -111,6 +126,7 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
public static void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
|
public static void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
|
||||||
if (!Enabled) {
|
if (!Enabled) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user