remove test_input time limit

This commit is contained in:
Jesse Plamondon-Willard 2023-06-24 14:20:37 -04:00
parent db33481dff
commit 7d96f29aff
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 9 additions and 21 deletions

View File

@ -10,6 +10,7 @@
## Upcoming release ## Upcoming release
* For players: * For players:
* In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand. * In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand.
* The `test_input` console command now logs player input until the command is run again, instead of only 30 seconds.
* Fixed wezterm terminal support on Linux/macoS (thanks to romangraef!). * Fixed wezterm terminal support on Linux/macoS (thanks to romangraef!).
* Fixed logged SMAPI errors not having line numbers on Linux/macOS. * Fixed logged SMAPI errors not having line numbers on Linux/macOS.
* Fixed install error if a game folder has an invalid symlink. * Fixed install error if a game folder has an invalid symlink.

View File

@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
@ -10,11 +9,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/********* /*********
** Fields ** Fields
*********/ *********/
/// <summary>The number of seconds for which to log input.</summary> /// <summary>Whether the command should print input.</summary>
private readonly int LogSeconds = 30; private bool Enabled;
/// <summary>When the command should stop printing input, or <c>null</c> if currently disabled.</summary>
private long? ExpiryTicks;
/********* /*********
@ -30,21 +26,12 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/// <param name="args">The command arguments.</param> /// <param name="args">The command arguments.</param>
public override void Handle(IMonitor monitor, string command, ArgumentParser args) public override void Handle(IMonitor monitor, string command, ArgumentParser args)
{ {
this.ExpiryTicks = DateTime.UtcNow.Add(TimeSpan.FromSeconds(this.LogSeconds)).Ticks; this.Enabled = !this.Enabled;
monitor.Log($"OK, logging all player input for {this.LogSeconds} seconds.", LogLevel.Info);
}
/// <summary>Perform any logic needed on update tick.</summary> monitor.Log(
/// <param name="monitor">Writes messages to the console and log file.</param> this.Enabled ? "OK, logging all player input until you run this command again." : "OK, no longer logging player input.",
public override void OnUpdated(IMonitor monitor) LogLevel.Info
{ );
// handle expiry
if (this.ExpiryTicks != null && this.ExpiryTicks <= DateTime.UtcNow.Ticks)
{
monitor.Log("No longer logging input.", LogLevel.Info);
this.ExpiryTicks = null;
return;
}
} }
/// <summary>Perform any logic when input is received.</summary> /// <summary>Perform any logic when input is received.</summary>
@ -52,7 +39,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/// <param name="button">The button that was pressed.</param> /// <param name="button">The button that was pressed.</param>
public override void OnButtonPressed(IMonitor monitor, SButton button) public override void OnButtonPressed(IMonitor monitor, SButton button)
{ {
if (this.ExpiryTicks != null) if (this.Enabled)
monitor.Log($"Pressed {button}", LogLevel.Info); monitor.Log($"Pressed {button}", LogLevel.Info);
} }
} }