diff options
author | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-27 01:32:15 -0400 |
---|---|---|
committer | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-27 01:32:15 -0400 |
commit | d127436533fba5168a89501f5b442b6575ed3723 (patch) | |
tree | 72284949854789a0d2b6a7461d8e76434c930004 /StardewModdingAPI | |
parent | 12bf4fd843be26f89b5fe3415aeec3055c54d786 (diff) | |
download | SMAPI-d127436533fba5168a89501f5b442b6575ed3723.tar.gz SMAPI-d127436533fba5168a89501f5b442b6575ed3723.tar.bz2 SMAPI-d127436533fba5168a89501f5b442b6575ed3723.zip |
fixes bugs
Diffstat (limited to 'StardewModdingAPI')
-rw-r--r-- | StardewModdingAPI/Command.cs | 2 | ||||
-rw-r--r-- | StardewModdingAPI/Events/Graphics.cs | 13 | ||||
-rw-r--r-- | StardewModdingAPI/Inheritance/SGame.cs | 24 |
3 files changed, 37 insertions, 2 deletions
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 { };
+ /// <summary>
+ /// 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.
+ /// </summary>
+ 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 @@ -202,6 +202,14 @@ namespace StardewModdingAPI.Inheritance public static bool Debug { get; private set; }
/// <summary>
+ /// 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.
+ /// </summary>
+ public static Queue<String> DebugMessageQueue { get; private set; }
+
+ /// <summary>
/// The current player (equal to Farmer.Player)
/// </summary>
[Obsolete("Use Farmer.Player instead")]
@@ -363,6 +371,7 @@ namespace StardewModdingAPI.Inheritance {
Log.AsyncY("XNA Initialize");
//ModItems = new Dictionary<int, SObject>();
+ DebugMessageQueue = new Queue<string>();
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.")]
|