summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CONTRIBUTING.md12
-rw-r--r--.github/SUPPORT.md3
-rw-r--r--docs/release-notes.md32
-rw-r--r--docs/technical/smapi.md13
-rw-r--r--src/SMAPI.Installer/Framework/InstallerPaths.cs18
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs21
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs14
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs59
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs15
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs13
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs15
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs20
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs15
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/ModEntry.cs31
-rw-r--r--src/SMAPI.Tests/Utilities/SemanticVersionTests.cs208
-rw-r--r--src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs3
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs22
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs16
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs12
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs4
-rw-r--r--src/SMAPI.Toolkit/Framework/SemanticVersionReader.cs126
-rw-r--r--src/SMAPI.Toolkit/SemanticVersion.cs72
-rw-r--r--src/SMAPI.Toolkit/Serialization/Converters/SemanticVersionConverter.cs2
-rw-r--r--src/SMAPI.Web/Controllers/ModsApiController.cs17
-rw-r--r--src/SMAPI.Web/Framework/Caching/Wiki/CachedWikiMod.cs8
-rw-r--r--src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs2
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogParser.cs9
-rw-r--r--src/SMAPI.Web/Framework/VersionConstraint.cs28
-rw-r--r--src/SMAPI.Web/ViewModels/ModModel.cs7
-rw-r--r--src/SMAPI.Web/Views/Index/Index.cshtml4
-rw-r--r--src/SMAPI.Web/Views/Mods/Index.cshtml7
-rw-r--r--src/SMAPI/Constants.cs3
-rw-r--r--src/SMAPI/Framework/Content/ContentCache.cs1
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs95
-rw-r--r--src/SMAPI/Framework/GameVersion.cs30
-rw-r--r--src/SMAPI/Framework/InternalExtensions.cs70
-rw-r--r--src/SMAPI/Framework/ModHelpers/DataHelper.cs2
-rw-r--r--src/SMAPI/Framework/SCore.cs7
-rw-r--r--src/SMAPI/Framework/SnapshotListDiff.cs6
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs53
-rw-r--r--src/SMAPI/Patches/LoadErrorPatch.cs87
-rw-r--r--src/SMAPI/SMAPI.config.json6
-rw-r--r--src/SMAPI/SemanticVersion.cs34
43 files changed, 895 insertions, 327 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 8746a487..74a7c500 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -1,16 +1,12 @@
Do you want to...
-* **Ask for help using SMAPI?**
- Please ask in [the Stardew Valley Discord or mod forums](https://smapi.io/community), don't
- create a GitHub issue.
-
-* **Report a bug?**
- Please report it in [the Stardew Valley Discord or mod forums](https://smapi.io/community), don't
- create a GitHub issue unless you're sure it's a bug in the SMAPI code.
+* **Ask for help or report a bug?**
+ Please see 'get help' on [the SMAPI website](https://smapi.io) instead, don't create a GitHub
+ issue.
* **Submit a pull request?**
Pull requests are welcome! If you're submitting a new feature, it's best to discuss first to make
- sure it'll be accepted. Feel free to come chat [on Discord or in the SMAPI discussion thread](https://smapi.io/community).
+ sure it'll be accepted. Feel free to come chat [on Discord](https://smapi.io/community).
Documenting your code and using the same formatting conventions is appreciated, but don't worry too
much about it. We'll fix up the code after we accept the pull request if needed.
diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md
index 9263666f..cb968c30 100644
--- a/.github/SUPPORT.md
+++ b/.github/SUPPORT.md
@@ -1,4 +1,3 @@
GitHub issues are only used for SMAPI development tasks.
-To get help with SMAPI problems, [ask on Discord or in the forums](https://smapi.io/community)
-instead.
+To get help with SMAPI problems, see 'get help' on [the SMAPI website](https://smapi.io/) instead.
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 5aa279b5..dc26db2d 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -5,7 +5,28 @@
* For players:
* SMAPI now prevents mods from crashing the game with invalid schedule data.
+ * SMAPI now prevents load crashes due to invalid building types.
+ * Added support for persistent `smapi-internal/config.json` overrides (see info in the file).
* Updated minimum game version (1.4 → 1.4.1).
+ * Fixed 'collection was modified' error when returning to title in rare cases.
+ * Fixed update-check error if a mod's Chucklefish page has no version.
+ * Fixed SMAPI beta versions not showing update alert on next launch (thanks to danvolchek!).
+ * Fixed rare error when building/demolishing buildings.
+
+* For the Console Commands mod:
+ * Added `test_input` command to view button codes in the console.
+
+* For modders:
+ * Asset propagation for player sprites now affects other players' sprites, and updates recolor maps (e.g. sleeves).
+ * Removed invalid-schedule validation which had false positives.
+ * Fixed `helper.Data.Read/WriteGlobalData` using the `Saves` folder. The installer will move existing folders to the appdata folder.
+ * Fixed dialogue asset changes not correctly propagated until the next day.
+
+* For SMAPI/tool developers:
+ * Added internal support for four-part versions to support SMAPI on Android.
+ * Updated links for the new r/SMAPI subreddit.
+ * The `/mods` web API endpoint now includes version mappings from the wiki.
+ * Dropped API support for the pre-3.0 update-check format.
## 3.1
Released 05 January 2019 for Stardew Valley 1.4 or later.
@@ -18,13 +39,14 @@ Released 05 January 2019 for Stardew Valley 1.4 or later.
* Fixed compatibility with Linux Mint 18 (thanks to techge!), Arch Linux, and Linux systems with libhybris-utils installed.
* Fixed memory leak when repeatedly loading a save and returning to title.
* Fixed memory leak when mods reload assets.
- * Fixes for Console Commands mod:
- * added new clothing items;
- * fixed spawning new flooring and rings (thanks to Mizzion!);
- * fixed spawning custom rings added by mods;
- * Fixed errors when some item data is invalid.
* Updated translations. Thanks to L30Bola (added Portuguese), PlussRolf (added Spanish), and shirutan (added Japanese)!
+* For the Console Commands mod:
+ * Added new clothing items.
+ * Fixed spawning new flooring and rings (thanks to Mizzion!).
+ * Fixed spawning custom rings added by mods.
+ * Fixed errors when some item data is invalid.
+
* For the web UI:
* Added option to edit & reupload in the JSON validator.
* File uploads are now stored in Azure storage instead of Pastebin, due to ongoing Pastebin perfomance issues.
diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md
index d565aeb4..c9d5c07e 100644
--- a/docs/technical/smapi.md
+++ b/docs/technical/smapi.md
@@ -19,17 +19,8 @@ This document is about SMAPI itself; see also [mod build package](mod-package.md
## Customisation
### Configuration file
-You can customise the SMAPI behaviour by editing the `smapi-internal/config.json` file in your game
-folder.
-
-Basic fields:
-
-field | purpose
------------------ | -------
-`DeveloperMode` | Default `false` (except in _SMAPI for developers_ releases). Whether to enable features intended for mod developers (mainly more detailed console logging).
-`CheckForUpdates` | Default `true`. Whether SMAPI should check for a newer version when you load the game. If a new version is available, a small message will appear in the console. This doesn't affect the load time even if your connection is offline or slow, because it happens in the background.
-`VerboseLogging` | Default `false`. Whether SMAPI should log more information about the game context.
-`ModData` | Internal metadata about SMAPI mods. Changing this isn't recommended and may destabilise your game. See documentation in the file.
+You can customise some SMAPI behaviour by editing the `smapi-internal/config.json` file in your
+game folder. See documentation in the file for more info.
### Command-line arguments
The SMAPI installer recognises three command-line arguments:
diff --git a/src/SMAPI.Installer/Framework/InstallerPaths.cs b/src/SMAPI.Installer/Framework/InstallerPaths.cs
index 9393e14f..ac6c3a8e 100644
--- a/src/SMAPI.Installer/Framework/InstallerPaths.cs
+++ b/src/SMAPI.Installer/Framework/InstallerPaths.cs
@@ -8,6 +8,9 @@ namespace StardewModdingAPI.Installer.Framework
/*********
** Accessors
*********/
+ /****
+ ** Main folders
+ ****/
/// <summary>The directory path containing the files to copy into the game folder.</summary>
public DirectoryInfo BundleDir { get; }
@@ -17,9 +20,18 @@ namespace StardewModdingAPI.Installer.Framework
/// <summary>The directory into which to install mods.</summary>
public DirectoryInfo ModsDir { get; }
+ /****
+ ** Installer paths
+ ****/
/// <summary>The full path to directory path containing the files to copy into the game folder.</summary>
public string BundlePath => this.BundleDir.FullName;
+ /// <summary>The full path to the backup API user settings folder, if applicable.</summary>
+ public string BundleApiUserConfigPath { get; }
+
+ /****
+ ** Game paths
+ ****/
/// <summary>The full path to the directory containing the installed game.</summary>
public string GamePath => this.GameDir.FullName;
@@ -29,6 +41,9 @@ namespace StardewModdingAPI.Installer.Framework
/// <summary>The full path to SMAPI's internal configuration file.</summary>
public string ApiConfigPath { get; }
+ /// <summary>The full path to the user's config overrides file.</summary>
+ public string ApiUserConfigPath { get; }
+
/// <summary>The full path to the installed SMAPI executable file.</summary>
public string ExecutablePath { get; }
@@ -55,11 +70,14 @@ namespace StardewModdingAPI.Installer.Framework
this.GameDir = gameDir;
this.ModsDir = new DirectoryInfo(Path.Combine(gameDir.FullName, "Mods"));
+ this.BundleApiUserConfigPath = Path.Combine(bundleDir.FullName, "smapi-internal", "config.user.json");
+
this.ExecutablePath = Path.Combine(gameDir.FullName, gameExecutableName);
this.UnixLauncherPath = Path.Combine(gameDir.FullName, "StardewValley");
this.UnixSmapiLauncherPath = Path.Combine(gameDir.FullName, "StardewModdingAPI");
this.UnixBackupLauncherPath = Path.Combine(gameDir.FullName, "StardewValley-original");
this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json");
+ this.ApiUserConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.user.json");
}
}
}
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index 964300ac..2d58baf0 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -352,6 +352,12 @@ namespace StardewModdingApi.Installer
Console.WriteLine();
/****
+ ** Back up user settings
+ ****/
+ if (File.Exists(paths.ApiUserConfigPath))
+ File.Copy(paths.ApiUserConfigPath, paths.BundleApiUserConfigPath);
+
+ /****
** Always uninstall old files
****/
// restore game launcher
@@ -373,6 +379,21 @@ namespace StardewModdingApi.Installer
this.InteractivelyDelete(path);
}
+ // move global save data folder (changed in 3.2)
+ {
+ string dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
+ DirectoryInfo oldDir = new DirectoryInfo(Path.Combine(dataPath, "Saves", ".smapi"));
+ DirectoryInfo newDir = new DirectoryInfo(Path.Combine(dataPath, ".smapi"));
+
+ if (oldDir.Exists)
+ {
+ if (newDir.Exists)
+ this.InteractivelyDelete(oldDir.FullName);
+ else
+ oldDir.MoveTo(newDir.FullName);
+ }
+ }
+
/****
** Install new files
****/
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs
index a0b739f8..d4d36e5d 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs
@@ -12,8 +12,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <summary>The command description.</summary>
string Description { get; }
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- bool NeedsUpdate { get; }
+ /// <summary>Whether the command may need to perform logic when the game updates. This value shouldn't change.</summary>
+ bool MayNeedUpdate { get; }
+
+ /// <summary>Whether the command may need to perform logic when the player presses a button. This value shouldn't change.</summary>
+ bool MayNeedInput { get; }
/*********
@@ -27,6 +30,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
- void Update(IMonitor monitor);
+ void OnUpdated(IMonitor monitor);
+
+ /// <summary>Perform any logic when input is received.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="button">The button that was pressed.</param>
+ void OnButtonPressed(IMonitor monitor, SButton button);
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
new file mode 100644
index 00000000..11aa10c3
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
@@ -0,0 +1,59 @@
+using System;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
+{
+ /// <summary>A command which logs the keys being pressed for 30 seconds once enabled.</summary>
+ internal class TestInputCommand : TrainerCommand
+ {
+ /*********
+ ** Fields
+ *********/
+ /// <summary>The number of seconds for which to log input.</summary>
+ private readonly int LogSeconds = 30;
+
+ /// <summary>When the command should stop printing input, or <c>null</c> if currently disabled.</summary>
+ private long? ExpiryTicks;
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public TestInputCommand()
+ : base("test_input", "Prints all input to the console for 30 seconds.", mayNeedUpdate: true, mayNeedInput: true) { }
+
+ /// <summary>Handle the command.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="command">The command name.</param>
+ /// <param name="args">The command arguments.</param>
+ public override void Handle(IMonitor monitor, string command, ArgumentParser args)
+ {
+ this.ExpiryTicks = DateTime.UtcNow.Add(TimeSpan.FromSeconds(this.LogSeconds)).Ticks;
+ monitor.Log($"OK, logging all player input for {this.LogSeconds} seconds.", LogLevel.Info);
+ }
+
+ /// <summary>Perform any logic needed on update tick.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ public override void OnUpdated(IMonitor monitor)
+ {
+ // handle expiry
+ if (this.ExpiryTicks == null)
+ return;
+ if (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>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="button">The button that was pressed.</param>
+ public override void OnButtonPressed(IMonitor monitor, SButton button)
+ {
+ if (this.ExpiryTicks != null)
+ monitor.Log($"Pressed {button}", LogLevel.Info);
+ }
+ }
+}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
index 1abb82b5..59bda5dd 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
@@ -14,18 +14,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/*********
- ** Accessors
- *********/
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- public override bool NeedsUpdate => this.InfiniteHealth;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetHealthCommand()
- : base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount, or 'inf' for infinite health.") { }
+ : base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount, or 'inf' for infinite health.", mayNeedUpdate: true) { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -62,9 +55,9 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
- public override void Update(IMonitor monitor)
+ public override void OnUpdated(IMonitor monitor)
{
- if (this.InfiniteHealth)
+ if (this.InfiniteHealth && Context.IsWorldReady)
Game1.player.health = Game1.player.maxHealth;
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
index 1706bbc1..6e3d68b6 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
@@ -14,18 +14,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/*********
- ** Accessors
- *********/
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- public override bool NeedsUpdate => this.InfiniteMoney;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetMoneyCommand()
- : base("player_setmoney", "Sets the player's money.\n\nUsage: player_setmoney <value>\n- value: an integer amount, or 'inf' for infinite money.") { }
+ : base("player_setmoney", "Sets the player's money.\n\nUsage: player_setmoney <value>\n- value: an integer amount, or 'inf' for infinite money.", mayNeedUpdate: true) { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -62,9 +55,9 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
- public override void Update(IMonitor monitor)
+ public override void OnUpdated(IMonitor monitor)
{
- if (this.InfiniteMoney)
+ if (this.InfiniteMoney && Context.IsWorldReady)
Game1.player.Money = 999999;
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
index 009cb1de..60a1dcb1 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
@@ -14,18 +14,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/*********
- ** Accessors
- *********/
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- public override bool NeedsUpdate => this.InfiniteStamina;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetStaminaCommand()
- : base("player_setstamina", "Sets the player's stamina.\n\nUsage: player_setstamina [value]\n- value: an integer amount, or 'inf' for infinite stamina.") { }
+ : base("player_setstamina", "Sets the player's stamina.\n\nUsage: player_setstamina [value]\n- value: an integer amount, or 'inf' for infinite stamina.", mayNeedUpdate: true) { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -62,9 +55,9 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
- public override void Update(IMonitor monitor)
+ public override void OnUpdated(IMonitor monitor)
{
- if (this.InfiniteStamina)
+ if (this.InfiniteStamina && Context.IsWorldReady)
Game1.player.stamina = Game1.player.MaxStamina;
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
index 2b562a08..77a26c6a 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
@@ -16,8 +16,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <summary>The command description.</summary>
public string Description { get; }
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- public virtual bool NeedsUpdate { get; } = false;
+ /// <summary>Whether the command may need to perform logic when the player presses a button. This value shouldn't change.</summary>
+ public bool MayNeedInput { get; }
+
+ /// <summary>Whether the command may need to perform logic when the game updates. This value shouldn't change.</summary>
+ public bool MayNeedUpdate { get; }
/*********
@@ -31,7 +34,12 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <summary>Perform any logic needed on update tick.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
- public virtual void Update(IMonitor monitor) { }
+ public virtual void OnUpdated(IMonitor monitor) { }
+
+ /// <summary>Perform any logic when input is received.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="button">The button that was pressed.</param>
+ public virtual void OnButtonPressed(IMonitor monitor, SButton button) { }
/*********
@@ -40,10 +48,14 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <summary>Construct an instance.</summary>
/// <param name="name">The command name the user must type.</param>
/// <param name="description">The command description.</param>
- protected TrainerCommand(string name, string description)
+ /// <param name="mayNeedInput">Whether the command may need to perform logic when the player presses a button.</param>
+ /// <param name="mayNeedUpdate">Whether the command may need to perform logic when the game updates.</param>
+ protected TrainerCommand(string name, string description, bool mayNeedInput = false, bool mayNeedUpdate = false)
{
this.Name = name;
this.Description = description;
+ this.MayNeedInput = mayNeedInput;
+ this.MayNeedUpdate = mayNeedUpdate;
}
/// <summary>Log an error indicating incorrect usage.</summary>
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
index 6a7ab162..736a93a0 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
@@ -17,18 +17,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
/*********
- ** Accessors
- *********/
- /// <summary>Whether the command needs to perform logic when the game updates.</summary>
- public override bool NeedsUpdate => this.FreezeTime;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>