diff --git a/StardewModdingAPI/Command.cs b/StardewModdingAPI/Command.cs index 8bc2c0c3..4214b1a7 100644 --- a/StardewModdingAPI/Command.cs +++ b/StardewModdingAPI/Command.cs @@ -78,7 +78,7 @@ namespace StardewModdingAPI } RegisteredCommands.Add(c); - Log.AsyncY("Registered command: " + command); + Log.Async("Registered command: " + command); return c; } diff --git a/StardewModdingAPI/Events/Graphics.cs b/StardewModdingAPI/Events/Graphics.cs index a2e7fc40..2b91144a 100644 --- a/StardewModdingAPI/Events/Graphics.cs +++ b/StardewModdingAPI/Events/Graphics.cs @@ -8,6 +8,14 @@ namespace StardewModdingAPI.Events public static event EventHandler DrawTick = delegate { }; public static event EventHandler DrawInRenderTargetTick = delegate { }; + /// + /// Draws when SGame.Debug is true. F3 toggles this. + /// Game1.spriteBatch.Begin() is pre-called. + /// Do not make end or begin calls to the spritebatch. + /// If you are only trying to add debug information, use SGame.DebugMessageQueue in your Update loop. + /// + public static event EventHandler DrawDebug = delegate { }; + public static void InvokeDrawTick() { try @@ -29,5 +37,10 @@ namespace StardewModdingAPI.Events { Resize.Invoke(sender, e); } + + public static void InvokeDrawDebug(object sender, EventArgs e) + { + DrawDebug.Invoke(sender, e); + } } } \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index f1887253..b6fe727b 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -201,6 +201,14 @@ namespace StardewModdingAPI.Inheritance /// public static bool Debug { get; private set; } + /// + /// A queue of messages to log when Debug is true. + /// If debug is false this queue will be emptied every frame. + /// Do not add to the queue if debug is false. + /// The queue will be drawn once every Draw update. + /// + public static Queue DebugMessageQueue { get; private set; } + /// /// The current player (equal to Farmer.Player) /// @@ -363,6 +371,7 @@ namespace StardewModdingAPI.Inheritance { Log.AsyncY("XNA Initialize"); //ModItems = new Dictionary(); + DebugMessageQueue = new Queue(); PreviouslyPressedButtons = new Buttons[4][]; for (var i = 0; i < 4; ++i) PreviouslyPressedButtons[i] = new Buttons[0]; @@ -499,9 +508,22 @@ namespace StardewModdingAPI.Inheritance if (Debug) { spriteBatch.Begin(); - spriteBatch.DrawString(dialogueFont, "FPS: " + FramesPerSecond, Vector2.Zero, Color.CornflowerBlue); + spriteBatch.DrawString(smoothFont, "FPS: " + FramesPerSecond, Vector2.Zero, Color.CornflowerBlue); + + int i = 1; + while (DebugMessageQueue.Any()) + { + string s = DebugMessageQueue.Dequeue(); + spriteBatch.DrawString(smoothFont, s, new Vector2(0, i * 12), Color.CornflowerBlue); + i++; + } + GraphicsEvents.InvokeDrawDebug(null, null); spriteBatch.End(); } + else + { + DebugMessageQueue.Clear(); + } } [Obsolete("Do not use at this time.")]