summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-23 20:53:12 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-23 20:53:12 -0400
commit2d36105c33ffba77eb979ef6ef0d2e7d906b09bc (patch)
treefe74c3eb7dea4e6e7d59c00cab2e2308c43da3d0 /src
parenta149f82b7a00d1ebf5ab33e529be93ce70873947 (diff)
downloadSMAPI-2d36105c33ffba77eb979ef6ef0d2e7d906b09bc.tar.gz
SMAPI-2d36105c33ffba77eb979ef6ef0d2e7d906b09bc.tar.bz2
SMAPI-2d36105c33ffba77eb979ef6ef0d2e7d906b09bc.zip
drop support for SMAPI 1.x (#360)
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs6
-rw-r--r--src/StardewModdingAPI.Tests/Core/ModResolverTests.cs6
-rw-r--r--src/StardewModdingAPI.Tests/Core/TranslationTests.cs3
-rw-r--r--src/StardewModdingAPI/Command.cs159
-rw-r--r--src/StardewModdingAPI/Config.cs188
-rw-r--r--src/StardewModdingAPI/Constants.cs7
-rw-r--r--src/StardewModdingAPI/Events/EventArgsCommand.cs28
-rw-r--r--src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs33
-rw-r--r--src/StardewModdingAPI/Events/EventArgsInput.cs2
-rw-r--r--src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs27
-rw-r--r--src/StardewModdingAPI/Events/EventArgsNewDay.cs37
-rw-r--r--src/StardewModdingAPI/Events/EventArgsStringChanged.cs31
-rw-r--r--src/StardewModdingAPI/Events/GameEvents.cs112
-rw-r--r--src/StardewModdingAPI/Events/InputEvents.cs2
-rw-r--r--src/StardewModdingAPI/Events/PlayerEvents.cs74
-rw-r--r--src/StardewModdingAPI/Events/TimeEvents.cs128
-rw-r--r--src/StardewModdingAPI/Framework/CursorPosition.cs2
-rw-r--r--src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs4
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs25
-rw-r--r--src/StardewModdingAPI/Framework/ModRegistry.cs8
-rw-r--r--src/StardewModdingAPI/Framework/Models/Manifest.cs9
-rw-r--r--src/StardewModdingAPI/Framework/Models/ManifestDependency.cs12
-rw-r--r--src/StardewModdingAPI/Framework/Monitor.cs27
-rw-r--r--src/StardewModdingAPI/Framework/SGame.cs81
-rw-r--r--src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs6
-rw-r--r--src/StardewModdingAPI/Framework/Utilities/ContextHash.cs3
-rw-r--r--src/StardewModdingAPI/IContentHelper.cs6
-rw-r--r--src/StardewModdingAPI/ICursorPosition.cs2
-rw-r--r--src/StardewModdingAPI/IManifestDependency.cs4
-rw-r--r--src/StardewModdingAPI/ISemanticVersion.cs9
-rw-r--r--src/StardewModdingAPI/Log.cs320
-rw-r--r--src/StardewModdingAPI/Metadata/InstructionMetadata.cs2
-rw-r--r--src/StardewModdingAPI/Mod.cs90
-rw-r--r--src/StardewModdingAPI/Program.cs138
-rw-r--r--src/StardewModdingAPI/SemanticVersion.cs4
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj8
-rw-r--r--src/StardewModdingAPI/Utilities/SButton.cs14
-rw-r--r--src/StardewModdingAPI/Utilities/SDate.cs4
-rw-r--r--src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs30
-rw-r--r--src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs29
-rw-r--r--src/TrainerMod/TrainerMod.csproj2
41 files changed, 31 insertions, 1651 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index b52529a6..83638e10 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -135,11 +135,6 @@ namespace StardewModdingApi.Installer
/// </remarks>
public void Run(string[] args)
{
-#if SMAPI_1_x
- bool installArg = false;
- bool uninstallArg = false;
- string gamePathArg = null;
-#else
/****
** read command-line arguments
****/
@@ -160,7 +155,6 @@ namespace StardewModdingApi.Installer
if (pathIndex >= 1 && args.Length >= pathIndex)
gamePathArg = args[pathIndex];
}
-#endif
/****
** collect details
diff --git a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
index fc84ca29..7a81c68c 100644
--- a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
+++ b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
@@ -141,7 +141,7 @@ namespace StardewModdingAPI.Tests.Core
{
// arrange
Mock<IModMetadata> mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true);
- this.SetupMetadataForValidation(mock, new ModCompatibility { Compatibility = ModCompatibilityType.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" }});
+ this.SetupMetadataForValidation(mock, new ModCompatibility { Compatibility = ModCompatibilityType.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" } });
// act
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"));
@@ -179,7 +179,6 @@ namespace StardewModdingAPI.Tests.Core
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
}
-#if !SMAPI_1_x
[Test(Description = "Assert that validation fails when multiple mods have the same unique ID.")]
public void ValidateManifests_DuplicateUniqueID_Fails()
{
@@ -197,7 +196,6 @@ namespace StardewModdingAPI.Tests.Core
modA.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the first mod with a unique ID.");
modB.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<string>()), Times.Once, "The validation did not fail the second mod with a unique ID.");
}
-#endif
[Test(Description = "Assert that validation fails when the manifest references a DLL that does not exist.")]
public void ValidateManifests_Valid_Passes()
@@ -423,7 +421,6 @@ namespace StardewModdingAPI.Tests.Core
Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A.");
}
-#if !SMAPI_1_x
[Test(Description = "Assert that optional dependencies are sorted correctly if present.")]
public void ProcessDependencies_IfOptional()
{
@@ -455,7 +452,6 @@ namespace StardewModdingAPI.Tests.Core
Assert.AreEqual(1, mods.Length, 0, "Expected to get the same number of mods input.");
Assert.AreSame(modB.Object, mods[0], "The load order is incorrect: mod B should be first since it's the only mod.");
}
-#endif
/*********
diff --git a/src/StardewModdingAPI.Tests/Core/TranslationTests.cs b/src/StardewModdingAPI.Tests/Core/TranslationTests.cs
index 8511e765..63404a41 100644
--- a/src/StardewModdingAPI.Tests/Core/TranslationTests.cs
+++ b/src/StardewModdingAPI.Tests/Core/TranslationTests.cs
@@ -1,8 +1,7 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
-using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.ModHelpers;
using StardewValley;
diff --git a/src/StardewModdingAPI/Command.cs b/src/StardewModdingAPI/Command.cs
deleted file mode 100644
index 76c85287..00000000
--- a/src/StardewModdingAPI/Command.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-#if SMAPI_1_x
-using System;
-using System.Collections.Generic;
-using StardewModdingAPI.Events;
-using StardewModdingAPI.Framework;
-
-namespace StardewModdingAPI
-{
- /// <summary>A command that can be submitted through the SMAPI console to interact with SMAPI.</summary>
- [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))]
- public class Command
- {
- /*********
- ** Properties
- *********/
- /// <summary>The commands registered with SMAPI.</summary>
- private static readonly IDictionary<string, Command> LegacyCommands = new Dictionary<string, Command>(StringComparer.InvariantCultureIgnoreCase);
-
- /// <summary>Manages console commands.</summary>
- private static CommandManager CommandManager;
-
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
- /// <summary>Tracks the installed mods.</summary>
- private static ModRegistry ModRegistry;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>The event raised when this command is submitted through the console.</summary>
- public event EventHandler<EventArgsCommand> CommandFired;
-
- /****
- ** Command
- ****/
- /// <summary>The name of the command.</summary>
- public string CommandName;
-
- /// <summary>A human-readable description of what the command does.</summary>
- public string CommandDesc;
-
- /// <summary>A human-readable list of accepted arguments.</summary>
- public string[] CommandArgs;
-
- /// <summary>The actual submitted argument values.</summary>
- public string[] CalledArgs;
-
-
- /*********
- ** Public methods
- *********/
- /****
- ** Command
- ****/
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="commandManager">Manages console commands.</param>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- /// <param name="modRegistry">Tracks the installed mods.</param>
- internal static void Shim(CommandManager commandManager, DeprecationManager deprecationManager, ModRegistry modRegistry)
- {
- Command.CommandManager = commandManager;
- Command.DeprecationManager = deprecationManager;
- Command.ModRegistry = modRegistry;
- }
-
- /// <summary>Construct an instance.</summary>
- /// <param name="name">The name of the command.</param>
- /// <param name="description">A human-readable description of what the command does.</param>
- /// <param name="args">A human-readable list of accepted arguments.</param>
- public Command(string name, string description, string[] args = null)
- {
- this.CommandName = name;
- this.CommandDesc = description;
- if (args == null)
- args = new string[0];
- this.CommandArgs = args;
- }
-
- /// <summary>Trigger this command.</summary>
- public void Fire()
- {
- if (this.CommandFired == null)
- throw new InvalidOperationException($"Can't run command '{this.CommandName}' because it has no registered handler.");
- this.CommandFired.Invoke(this, new EventArgsCommand(this));
- }
-
-
- /****
- ** SMAPI
- ****/
- /// <summary>Parse a command string and invoke it if valid.</summary>
- /// <param name="input">The command to run, including the command name and any arguments.</param>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- public static void CallCommand(string input, IMonitor monitor)
- {
- Command.DeprecationManager.Warn("Command.CallCommand", "1.9", DeprecationLevel.PendingRemoval);
- Command.CommandManager.Trigger(input);
- }
-
- /// <summary>Register a command with SMAPI.</summary>
- /// <param name="name">The name of the command.</param>
- /// <param name="description">A human-readable description of what the command does.</param>
- /// <param name="args">A human-readable list of accepted arguments.</param>
- public static Command RegisterCommand(string name, string description, string[] args = null)
- {
- name = name?.Trim().ToLower();
-
- // raise deprecation warning
- Command.DeprecationManager.Warn("Command.RegisterCommand", "1.9", DeprecationLevel.PendingRemoval);
-
- // validate
- if (Command.LegacyCommands.ContainsKey(name))
- throw new InvalidOperationException($"The '{name}' command is already registered!");
-
- // add command
- string modName = Command.ModRegistry.GetModFromStack() ?? "<unknown mod>";
- string documentation = args?.Length > 0
- ? $"{description} - {string.Join(", ", args)}"
- : description;
- Command.CommandManager.Add(modName, name, documentation, Command.Fire);
-
- // add legacy command
- Command command = new Command(name, description, args);
- Command.LegacyCommands.Add(name, command);
- return command;
- }
-
- /// <summary>Find a command with the given name.</summary>
- /// <param name="name">The command name to find.</param>
- public static Command FindCommand(string name)
- {
- Command.DeprecationManager.Warn("Command.FindCommand", "1.9", DeprecationLevel.PendingRemoval);
- if (name == null)
- return null;
-
- Command command;
- Command.LegacyCommands.TryGetValue(name.Trim(), out command);
- return command;
- }
-
-
- /*********
- ** Private methods
- *********/
- /// <summary>Trigger this command.</summary>
- /// <param name="name">The command name.</param>
- /// <param name="args">The command arguments.</param>
- private static void Fire(string name, string[] args)
- {
- Command command;
- if (!Command.LegacyCommands.TryGetValue(name, out command))
- throw new InvalidOperationException($"Can't run command '{name}' because there's no such legacy command.");
- command.Fire();
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Config.cs b/src/StardewModdingAPI/Config.cs
deleted file mode 100644
index 734c04e8..00000000
--- a/src/StardewModdingAPI/Config.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-#if SMAPI_1_x
-using System;
-using System.IO;
-using System.Linq;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using StardewModdingAPI.Framework;
-
-namespace StardewModdingAPI
-{
- /// <summary>A dynamic configuration class for a mod.</summary>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public abstract class Config
- {
- /*********
- ** Properties
- *********/
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>The full path to the configuration file.</summary>
- [JsonIgnore]
- public virtual string ConfigLocation { get; protected internal set; }
-
- /// <summary>The directory path containing the configuration file.</summary>
- [JsonIgnore]
- public virtual string ConfigDir => Path.GetDirectoryName(this.ConfigLocation);
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- internal static void Shim(DeprecationManager deprecationManager)
- {
- Config.DeprecationManager = deprecationManager;
- }
-
- /// <summary>Construct an instance of the config class.</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public virtual Config Instance<T>() where T : Config => Activator.CreateInstance<T>();
-
- /// <summary>Load the config from the JSON file, saving it to disk if needed.</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public virtual T LoadConfig<T>() where T : Config
- {
- // validate
- if (string.IsNullOrEmpty(this.ConfigLocation))
- {
- Log.Error("A config tried to load without specifying a location on the disk.");
- return null;
- }
-
- // read or generate config
- T returnValue;
- if (!File.Exists(this.ConfigLocation))
- {
- T config = this.GenerateDefaultConfig<T>();
- config.ConfigLocation = this.ConfigLocation;
- returnValue = config;
- }
- else
- {
- try
- {
- T config = JsonConvert.DeserializeObject<T>(File.ReadAllText(this.ConfigLocation));
- config.ConfigLocation = this.ConfigLocation;
- returnValue = config.UpdateConfig<T>();
- }
- catch (Exception ex)
- {
- Log.Error($"Invalid JSON ({this.GetType().Name}): {this.ConfigLocation} \n{ex}");
- return this.GenerateDefaultConfig<T>();
- }
- }
-
- returnValue.WriteConfig();
- return returnValue;
- }
-
- /// <summary>Get the default config values.</summary>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public virtual T GenerateDefaultConfig<T>() where T : Config
- {
- return null;
- }
-
- /// <summary>Get the current configuration with missing values defaulted.</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public virtual T UpdateConfig<T>() where T : Config
- {
- try
- {
- // get default + user config
- JObject defaultConfig = JObject.FromObject(this.Instance<T>().GenerateDefaultConfig<T>());
- JObject currentConfig = JObject.FromObject(this);
- defaultConfig.Merge(currentConfig, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace });
-
- // cast json object to config
- T config = defaultConfig.ToObject<T>();
-
- // update location
- config.ConfigLocation = this.ConfigLocation;
-
- return config;
- }
- catch (Exception ex)
- {
- Log.Error($"An error occured when updating a config: {ex}");
- return this as T;
- }
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Construct an instance.</summary>
- protected Config()
- {
- Config.DeprecationManager.Warn("the Config class", "1.0", DeprecationLevel.PendingRemoval);
- Config.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.BaseConfigPath)}", "1.0"); // typically used to construct config, avoid redundant warnings
- }
- }
-
- /// <summary>Provides extension methods for <see cref="Config"/> classes.</summary>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public static class ConfigExtensions
- {
- /// <summary>Initialise the configuration. That includes loading, saving, and merging the config file and in memory at a default state. This method should not be used to reload or to resave a config. NOTE: You MUST set your config EQUAL to the return of this method!</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- /// <param name="baseConfig">The base configuration to initialise.</param>
- /// <param name="configLocation">The base configuration file path.</param>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public static T InitializeConfig<T>(this T baseConfig, string configLocation) where T : Config
- {
- if (baseConfig == null)
- baseConfig = Activator.CreateInstance<T>();
-
- if (string.IsNullOrEmpty(configLocation))
- {
- Log.Error("A config tried to initialize without specifying a location on the disk.");
- return null;
- }
-
- baseConfig.ConfigLocation = configLocation;
- return baseConfig.LoadConfig<T>();
- }
-
- /// <summary>Writes the configuration to the JSON file.</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- /// <param name="baseConfig">The base configuration to initialise.</param>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public static void WriteConfig<T>(this T baseConfig) where T : Config
- {
- if (string.IsNullOrEmpty(baseConfig?.ConfigLocation) || string.IsNullOrEmpty(baseConfig.ConfigDir))
- {
- Log.Error("A config attempted to save when it itself or it's location were null.");
- return;
- }
-
- string json = JsonConvert.SerializeObject(baseConfig, Formatting.Indented);
- if (!Directory.Exists(baseConfig.ConfigDir))
- Directory.CreateDirectory(baseConfig.ConfigDir);
-
- if (!File.Exists(baseConfig.ConfigLocation) || !File.ReadAllText(baseConfig.ConfigLocation).SequenceEqual(json))
- File.WriteAllText(baseConfig.ConfigLocation, json);
- }
-
- /// <summary>Rereads the JSON file and merges its values with a default config. NOTE: You MUST set your config EQUAL to the return of this method!</summary>
- /// <typeparam name="T">The config class type.</typeparam>
- /// <param name="baseConfig">The base configuration to initialise.</param>
- [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")]
- public static T ReloadConfig<T>(this T baseConfig) where T : Config
- {
- return baseConfig.LoadConfig<T>();
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 07647d2d..fc780f40 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -28,12 +28,7 @@ namespace StardewModdingAPI
** Public
****/
/// <summary>SMAPI's current semantic version.</summary>
- public static ISemanticVersion ApiVersion { get; } =
-#if SMAPI_1_x
- new SemanticVersion(1, 15, 4);
-#else
- new SemanticVersion(2, 0, 0, $"alpha-{DateTime.UtcNow:yyyyMMddHHmm}");
-#endif
+ public static ISemanticVersion ApiVersion { get; } = new SemanticVersion(2, 0, 0, $"alpha-{DateTime.UtcNow:yyyyMMddHHmm}");
/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new SemanticVersion("1.2.30");
diff --git a/src/StardewModdingAPI/Events/EventArgsCommand.cs b/src/StardewModdingAPI/Events/EventArgsCommand.cs
deleted file mode 100644
index 35370139..00000000
--- a/src/StardewModdingAPI/Events/EventArgsCommand.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-#if SMAPI_1_x
-using System;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a <see cref="StardewModdingAPI.Command.CommandFired"/> event.</summary>
- [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))]
- public class EventArgsCommand : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The triggered command.</summary>
- public Command Command { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="command">The triggered command.</param>
- public EventArgsCommand(Command command)
- {
- this.Command = command;
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs b/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs
deleted file mode 100644
index 4c359939..00000000
--- a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-#if SMAPI_1_x
-using System;
-using SFarmer = StardewValley.Farmer;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a <see cref="PlayerEvents.FarmerChanged"/> event.</summary>
- public class EventArgsFarmerChanged : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The previous player character.</summary>
- public SFarmer NewFarmer { get; }
-
- /// <summary>The new player character.</summary>
- public SFarmer PriorFarmer { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="priorFarmer">The previous player character.</param>
- /// <param name="newFarmer">The new player character.</param>
- public EventArgsFarmerChanged(SFarmer priorFarmer, SFarmer newFarmer)
- {
- this.PriorFarmer = priorFarmer;
- this.NewFarmer = newFarmer;
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/EventArgsInput.cs b/src/StardewModdingAPI/Events/EventArgsInput.cs
index 31368555..66cb19f2 100644
--- a/src/StardewModdingAPI/Events/EventArgsInput.cs
+++ b/src/StardewModdingAPI/Events/EventArgsInput.cs
@@ -1,4 +1,3 @@
-#if !SMAPI_1_x
using System;
using System.Linq;
using Microsoft.Xna.Framework;
@@ -123,4 +122,3 @@ namespace StardewModdingAPI.Events
}
}
}
-#endif
diff --git a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs
deleted file mode 100644
index 688b4b3d..00000000
--- a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-#if SMAPI_1_x
-using System;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a <see cref="PlayerEvents.LoadedGame"/> event.</summary>
- public class EventArgsLoadedGameChanged : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>Whether the save has been loaded. This is always true.</summary>
- public bool LoadedGame { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="loaded">Whether the save has been loaded. This is always true.</param>
- public EventArgsLoadedGameChanged(bool loaded)
- {
- this.LoadedGame = loaded;
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/EventArgsNewDay.cs b/src/StardewModdingAPI/Events/EventArgsNewDay.cs
deleted file mode 100644
index b8cbe9e3..00000000
--- a/src/StardewModdingAPI/Events/EventArgsNewDay.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-#if SMAPI_1_x
-using System;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a <see cref="TimeEvents.OnNewDay"/> event.</summary>
- public class EventArgsNewDay : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The previous day value.</summary>
- public int PreviousDay { get; }
-
- /// <summary>The current day value.</summary>
- public int CurrentDay { get; }
-
- /// <summary>Whether the game just started the transition (<c>true</c>) or finished it (<c>false</c>).</summary>
- public bool IsNewDay { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="priorDay">The previous day value.</param>
- /// <param name="newDay">The current day value.</param>
- /// <param name="isTransitioning">Whether the game just started the transition (<c>true</c>) or finished it (<c>false</c>).</param>
- public EventArgsNewDay(int priorDay, int newDay, bool isTransitioning)
- {
- this.PreviousDay = priorDay;
- this.CurrentDay = newDay;
- this.IsNewDay = isTransitioning;
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs
deleted file mode 100644
index f580a2ce..00000000
--- a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-#if SMAPI_1_x
-using System;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a string field that changed value.</summary>
- public class EventArgsStringChanged : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The previous value.</summary>
- public string NewString { get; }
-
- /// <summary>The current value.</summary>
- public string PriorString { get; }
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="priorString">The previous value.</param>
- /// <param name="newString">The current value.</param>
- public EventArgsStringChanged(string priorString, string newString)
- {
- this.NewString = newString;
- this.PriorString = priorString;
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs
index deb71a86..b477376e 100644
--- a/src/StardewModdingAPI/Events/GameEvents.cs
+++ b/src/StardewModdingAPI/Events/GameEvents.cs
@@ -1,94 +1,17 @@
using System;
-using System.Diagnostics.CodeAnalysis;
using StardewModdingAPI.Framework;
-#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings.
namespace StardewModdingAPI.Events
{
/// <summary>Events raised when the game changes state.</summary>
public static class GameEvents
{
/*********
- ** Properties
- *********/
-#if SMAPI_1_x
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
- /// <summary>The backing field for <see cref="Initialize"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler _Initialize;
-
- /// <summary>The backing field for <see cref="LoadContent"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler _LoadContent;
-
- /// <summary>The backing field for <see cref="GameLoaded"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler _GameLoaded;
-
- /// <summary>The backing field for <see cref="FirstUpdateTick"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler _FirstUpdateTick;
-#endif
-
-
- /*********
** Events
*********/
/// <summary>Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after <see cref="Microsoft.Xna.Framework.Game.Initialize"/>.</summary>
internal static event EventHandler InitializeInternal;
-#if SMAPI_1_x
- /// <summary>Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after <see cref="Microsoft.Xna.Framework.Game.Initialize"/>.</summary>
- [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(GameEvents.Initialize) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")]
- public static event EventHandler Initialize
- {
- add
- {
- GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}", "1.10", DeprecationLevel.PendingRemoval);
- GameEvents._Initialize += value;
- }
- remove => GameEvents._Initialize -= value;
- }
-
- /// <summary>Raised before XNA loads or reloads graphics resources. Called during <see cref="Microsoft.Xna.Framework.Game.LoadContent"/>.</summary>
- [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(GameEvents.LoadContent) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")]
- public static event EventHandler LoadContent
- {
- add
- {
- GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", "1.10", DeprecationLevel.PendingRemoval);
- GameEvents._LoadContent += value;
- }
- remove => GameEvents._LoadContent -= value;
- }
-
- /// <summary>Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point.</summary>
- [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")]
- public static event EventHandler GameLoaded
- {
- add
- {
- GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", "1.12", DeprecationLevel.PendingRemoval);
- GameEvents._GameLoaded += value;
- }
- remove => GameEvents._GameLoaded -= value;
- }
-
- /// <summary>Raised during the first game update tick.</summary>
- [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")]
- public static event EventHandler FirstUpdateTick
- {
- add
- {
- GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", "1.12", DeprecationLevel.PendingRemoval);
- GameEvents._FirstUpdateTick += value;
- }
- remove => GameEvents._FirstUpdateTick -= value;
- }
-#endif
-
/// <summary>Raised when the game updates its state (≈60 times per second).</summary>
public static event EventHandler UpdateTick;
@@ -114,47 +37,12 @@ namespace StardewModdingAPI.Events
/*********
** Internal methods
*********/
-#if SMAPI_1_x
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- internal static void Shim(DeprecationManager deprecationManager)
- {
- GameEvents.DeprecationManager = deprecationManager;
- }
-#endif
-
/// <summary>Raise an <see cref="InitializeInternal"/> event.</summary>
/// <param name="monitor">Encapsulates logging and monitoring.</param>
internal static void InvokeInitialize(IMonitor monitor)
{
monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.InitializeInternal)}", GameEvents.InitializeInternal?.GetInvocationList());
-#if SMAPI_1_x
- monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}", GameEvents._Initialize?.GetInvocationList());
-#endif
- }
-
-#if SMAPI_1_x
- /// <summary>Raise a <see cref="LoadContent"/> event.</summary>
- /// <param name="monitor">Encapsulates logging and monitoring.</param>
- internal static void InvokeLoadContent(IMonitor monitor)
- {
- monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", GameEvents._LoadContent?.GetInvocationList());
- }
-
- /// <summary>Raise a <see cref="GameLoadedInternal"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- internal static void InvokeGameLoaded(IMonitor monitor)
- {
- monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents._GameLoaded?.GetInvocationList());
- }
-
- /// <summary>Raise a <see cref="FirstUpdateTick"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- internal static void InvokeFirstUpdateTick(IMonitor monitor)
- {
- monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", GameEvents._FirstUpdateTick?.GetInvocationList());
}
-#endif
/// <summary>Raise an <see cref="UpdateTick"/> event.</summary>
/// <param name="monitor">Encapsulates logging and monitoring.</param>
diff --git a/src/StardewModdingAPI/Events/InputEvents.cs b/src/StardewModdingAPI/Events/InputEvents.cs
index b99b49e0..c31eb698 100644
--- a/src/StardewModdingAPI/Events/InputEvents.cs
+++ b/src/StardewModdingAPI/Events/InputEvents.cs
@@ -1,4 +1,3 @@
-#if !SMAPI_1_x
using System;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Utilities;
@@ -42,4 +41,3 @@ namespace StardewModdingAPI.Events
}
}
}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Events/PlayerEvents.cs b/src/StardewModdingAPI/Events/PlayerEvents.cs
index 72826330..5a9a9d5f 100644
--- a/src/StardewModdingAPI/Events/PlayerEvents.cs
+++ b/src/StardewModdingAPI/Events/PlayerEvents.cs
@@ -1,63 +1,17 @@
-using System;
+using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Linq;
using StardewModdingAPI.Framework;
using StardewValley;
-using SFarmer = StardewValley.Farmer;
-#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings.
namespace StardewModdingAPI.Events
{
/// <summary>Events raised when the player data changes.</summary>
public static class PlayerEvents
{
/*********
- ** Properties
- *********/
-#if SMAPI_1_x
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
- /// <summary>The backing field for <see cref="LoadedGame"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsLoadedGameChanged> _LoadedGame;
-
- /// <summary>The backing field for <see cref="FarmerChanged"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsFarmerChanged> _FarmerChanged;
-#endif
-
-
- /*********
** Events
*********/
-#if SMAPI_1_x
- /// <summary>Raised after the player loads a saved game.</summary>
- [Obsolete("Use " + nameof(SaveEvents) + "." + nameof(SaveEvents.AfterLoad) + " instead")]
- public static event EventHandler<EventArgsLoadedGameChanged> LoadedGame
- {
- add
- {
- PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", "1.6", DeprecationLevel.PendingRemoval);
- PlayerEvents._LoadedGame += value;
- }
- remove => PlayerEvents._LoadedGame -= value;
- }
-
- /// <summary>Raised after the game assigns a new player character. This happens just before <see cref="LoadedGame"/>; it's unclear how this would happen any other time.</summary>
- [Obsolete("should no longer be used")]
- public static event EventHandler<EventArgsFarmerChanged> FarmerChanged
- {
- add
- {
- PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", "1.6", DeprecationLevel.PendingRemoval);
- PlayerEvents._FarmerChanged += value;
- }
- remove => PlayerEvents._FarmerChanged -= value;
- }
-#endif
-
/// <summary>Raised after the player's inventory changes in any way (added or removed item, sorted, etc).</summary>
public static event EventHandler<EventArgsInventoryChanged> InventoryChanged;
@@ -68,32 +22,6 @@ namespace StardewModdingAPI.Events
/*********
** Internal methods
*********/
-#if SMAPI_1_x
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- internal static void Shim(DeprecationManager deprecationManager)
- {
- PlayerEvents.DeprecationManager = deprecationManager;
- }
-
- /// <summary>Raise a <see cref="LoadedGame"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="loaded">Whether the save has been loaded. This is always true.</param>
- internal static void InvokeLoadedGame(IMonitor monitor, EventArgsLoadedGameChanged loaded)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", PlayerEvents._LoadedGame?.GetInvocationList(), null, loaded);
- }
-
- /// <summary>Raise a <see cref="FarmerChanged"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorFarmer">The previous player character.</param>
- /// <param name="newFarmer">The new player character.</param>
- internal static void InvokeFarmerChanged(IMonitor monitor, SFarmer priorFarmer, SFarmer newFarmer)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", PlayerEvents._FarmerChanged?.GetInvocationList(), null, new EventArgsFarmerChanged(priorFarmer, newFarmer));
- }
-#endif
-
/// <summary>Raise an <see cref="InventoryChanged"/> event.</summary>
/// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="inventory">The player's inventory.</param>
diff --git a/src/StardewModdingAPI/Events/TimeEvents.cs b/src/StardewModdingAPI/Events/TimeEvents.cs
index d5ab9fb7..9aea5e04 100644
--- a/src/StardewModdingAPI/Events/TimeEvents.cs
+++ b/src/StardewModdingAPI/Events/TimeEvents.cs
@@ -1,39 +1,12 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
+using System;
using StardewModdingAPI.Framework;
-#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings.
namespace StardewModdingAPI.Events
{
/// <summary>Events raised when the in-game date or time changes.</summary>
public static class TimeEvents
{
/*********
- ** Properties
- *********/
-#if SMAPI_1_x
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
- /// <summary>The backing field for <see cref="OnNewDay"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsNewDay> _OnNewDay;
-
- /// <summary>The backing field for <see cref="DayOfMonthChanged"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsIntChanged> _DayOfMonthChanged;
-
- /// <summary>The backing field for <see cref="SeasonOfYearChanged"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsStringChanged> _SeasonOfYearChanged;
-
- /// <summary>The backing field for <see cref="YearOfGameChanged"/>.</summary>
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- private static event EventHandler<EventArgsIntChanged> _YearOfGameChanged;
-#endif
-
-
- /*********
** Events
*********/
/// <summary>Raised after the game begins a new day, including when loading a save.</summary>
@@ -42,69 +15,9 @@ namespace StardewModdingAPI.Events
/// <summary>Raised after the in-game clock changes.</summary>
public static event EventHandler<EventArgsIntChanged> TimeOfDayChanged;
-#if SMAPI_1_x
- /// <summary>Raised after the day-of-month value changes, including when loading a save. This may happen before save; in most cases you should use <see cref="AfterDayStarted"/> instead.</summary>
- [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")]
- public static event EventHandler<EventArgsIntChanged> DayOfMonthChanged
- {
- add
- {
- TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", "1.14", DeprecationLevel.PendingRemoval);
- TimeEvents._DayOfMonthChanged += value;
- }
- remove => TimeEvents._DayOfMonthChanged -= value;
- }
-
- /// <summary>Raised after the year value changes.</summary>
- [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")]
- public static event EventHandler<EventArgsIntChanged> YearOfGameChanged
- {
- add
- {
- TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", "1.14", DeprecationLevel.PendingRemoval);
- TimeEvents._YearOfGameChanged += value;
- }
- remove => TimeEvents._YearOfGameChanged -= value;
- }
-
- /// <summary>Raised after the season value changes.</summary>
- [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")]
- public static event EventHandler<EventArgsStringChanged> SeasonOfYearChanged
- {
- add
- {
- TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", "1.14", DeprecationLevel.PendingRemoval);
- TimeEvents._SeasonOfYearChanged += value;
- }
- remove => TimeEvents._SeasonOfYearChanged -= value;
- }
-
- /// <summary>Raised when the player is transitioning to a new day and the game is performing its day update logic. This event is triggered twice: once after the game starts transitioning, and again after it finishes.</summary>
- [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")]
- public static event EventHandler<EventArgsNewDay> OnNewDay
- {
- add
- {
- TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.OnNewDay)}", "1.6", DeprecationLevel.PendingRemoval);
- TimeEvents._OnNewDay += value;
- }
- remove => TimeEvents._OnNewDay -= value;
- }
-#endif
-
-
/*********
** Internal methods
*********/
-#if SMAPI_1_x
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- internal static void Shim(DeprecationManager deprecationManager)
- {
- TimeEvents.DeprecationManager = deprecationManager;
- }
-#endif
-
/// <summary>Raise an <see cref="AfterDayStarted"/> event.</summary>
/// <param name="monitor">Encapsulates monitoring and logging.</param>
internal static void InvokeAfterDayStarted(IMonitor monitor)
@@ -120,44 +33,5 @@ namespace StardewModdingAPI.Events
{
monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.TimeOfDayChanged)}", TimeEvents.TimeOfDayChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorTime, newTime));
}
-
-#if SMAPI_1_x
- /// <summary>Raise a <see cref="DayOfMonthChanged"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorDay">The previous day value.</param>
- /// <param name="newDay">The current day value.</param>
- internal static void InvokeDayOfMonthChanged(IMonitor monitor, int priorDay, int newDay)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", TimeEvents._DayOfMonthChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorDay, newDay));
- }
-
- /// <summary>Raise a <see cref="YearOfGameChanged"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorYear">The previous year value.</param>
- /// <param name="newYear">The current year value.</param>
- internal static void InvokeYearOfGameChanged(IMonitor monitor, int priorYear, int newYear)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", TimeEvents._YearOfGameChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorYear, newYear));
- }
-
- /// <summary>Raise a <see cref="SeasonOfYearChanged"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorSeason">The previous season name.</param>
- /// <param name="newSeason">The current season name.</param>
- internal static void InvokeSeasonOfYearChanged(IMonitor monitor, string priorSeason, string newSeason)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", TimeEvents._SeasonOfYearChanged?.GetInvocationList(), null, new EventArgsStringChanged(priorSeason, newSeason));
- }
-
- /// <summary>Raise a <see cref="OnNewDay"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorDay">The previous day value.</param>
- /// <param name="newDay">The current day value.</param>
- /// <param name="isTransitioning">Whether the game just started the transition (<c>true</c>) or finished it (<c>false</c>).</param>
- internal static void InvokeOnNewDay(IMonitor monitor, int priorDay, int newDay, bool isTransitioning)
- {
- monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.OnNewDay)}", TimeEvents._OnNewDay?.GetInvocationList(), null, new EventArgsNewDay(priorDay, newDay, isTransitioning));
- }
-#endif
}
}
diff --git a/src/StardewModdingAPI/Framework/CursorPosition.cs b/src/StardewModdingAPI/Framework/CursorPosition.cs
index 0fb2309b..db02b3d1 100644
--- a/src/StardewModdingAPI/Framework/CursorPosition.cs
+++ b/src/StardewModdingAPI/Framework/CursorPosition.cs
@@ -1,4 +1,3 @@
-#if !SMAPI_1_x
using Microsoft.Xna.Framework;
namespace StardewModdingAPI.Framework
@@ -34,4 +33,3 @@ namespace StardewModdingAPI.Framework
}
}
}
-#endif
diff --git a/src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs b/src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs
index 14a339da..8d435416 100644
--- a/src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs
+++ b/src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using StardewModdingAPI.Framework.Reflection;
namespace StardewModdingAPI.Framework.ModHelpers
@@ -180,7 +180,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <param name="type">The type being accessed.</param>
private void AssertAccessAllowed(Type type)
{
-#if !SMAPI_1_x
// validate type namespace
if (type.Namespace != null)
{
@@ -188,7 +187,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
if (type.Namespace == rootSmapiNamespace || type.Namespace.StartsWith(rootSmapiNamespace + "."))
throw new InvalidOperationException($"SMAPI blocked access by {this.ModName} to its internals through the reflection API. Accessing the SMAPI internals is strongly discouraged since they're subject to change, which means the mod can break without warning.");
}
-#endif
}
/// <summary>Assert that mods can use the reflection helper to access the given type.</summary>
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 6b19db5c..87b6a99c 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -109,17 +109,6 @@ namespace StardewModdingAPI.Framework.ModLoading
ModCompatibility compatibility = mod.Compatibility;
if (compatibility?.Compatibility == ModCompatibilityType.AssumeBroken)
{
-#if SMAPI_1_x
- bool hasOfficialUrl = mod.Compatibility.UpdateUrls.Length > 0;
- bool hasUnofficialUrl = mod.Compatibility.UpdateUrls.Length > 1;
-
- string reasonPhrase = compatibility.ReasonPhrase ?? "it's not compatible with the latest version of the game or SMAPI";
- string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()} here:";
- if (hasOfficialUrl)
- error += !hasUnofficialUrl ? $" {compatibility.UpdateUrls[0]}" : $"{Environment.NewLine}- official mod: {compatibility.UpdateUrls[0]}";
- if (hasUnofficialUrl)
- error += $"{Environment.NewLine}- unofficial update: {compatibility.UpdateUrls[1]}";
-#else
string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
string error = $"{reasonPhrase}. Please check for a ";
if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null)
@@ -127,7 +116,6 @@ namespace StardewModdingAPI.Framework.ModLoading
else
error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}";
error += " at " + string.Join(" or ", compatibility.UpdateUrls);
-#endif
mod.SetStatus(ModMetadataStatus.Failed, error);
continue;
@@ -150,7 +138,6 @@ namespace StardewModdingAPI.Framework.ModLoading
}
// validate required fields
-#if !SMAPI_1_x
{
List<string> missingFields = new List<string>(3);
@@ -164,11 +151,9 @@ namespace StardewModdingAPI.Framework.ModLoading
if (missingFields.Any())
mod.SetStatus(ModMetadataStatus.Failed, $"its manifest is missing required fields ({string.Join(", ", missingFields)}).");
}
-#endif
}
// validate IDs are unique
-#if !SMAPI_1_x
{
var duplicatesByID = mods
.GroupBy(mod => mod.Manifest?.UniqueID?.Trim(), mod => mod, StringComparer.InvariantCultureIgnoreCase)
@@ -183,7 +168,6 @@ namespace StardewModdingAPI.Framework.ModLoading
}
}
}
-#endif
}
/// <summary>Sort the given mods by the order they should be loaded.</summary>
@@ -264,12 +248,7 @@ namespace StardewModdingAPI.Framework.ModLoading
ID = entry.UniqueID,
MinVersion = entry.MinimumVersion,
Mod = dependencyMod,
- IsRequired =
-#if SMAPI_1_x
- true
-#else
- entry.IsRequired
-#endif
+ IsRequired = entry.IsRequired
}
)
.ToArray();
diff --git a/src/StardewModdingAPI/Framework/ModRegistry.cs b/src/StardewModdingAPI/Framework/ModRegistry.cs
index 8f30d813..9dde7a20 100644
--- a/src/StardewModdingAPI/Framework/ModRegistry.cs
+++ b/src/StardewModdingAPI/Framework/ModRegistry.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -42,11 +42,7 @@ namespace StardewModdingAPI.Framework
uniqueID = uniqueID.Trim();
// find match
- return this.GetAll().FirstOrDefault(p =>
-#if SMAPI_1_x
- p.UniqueID != null &&
-#endif
- p.UniqueID.Trim().Equals(uniqueID, StringComparison.InvariantCultureIgnoreCase));
+ return this.GetAll().FirstOrDefault(p => p.UniqueID.Trim().Equals(uniqueID, StringComparison.InvariantCultureIgnoreCase));
}
/// <summary>Get whether a mod has been loaded.</summary>
diff --git a/src/StardewModdingAPI/Framework/Models/Manifest.cs b/src/StardewModdingAPI/Framework/Models/Manifest.cs
index f97cb8ff..2e9566bf 100644
--- a/src/StardewModdingAPI/Framework/Models/Manifest.cs
+++ b/src/StardewModdingAPI/Framework/Models/Manifest.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using StardewModdingAPI.Framework.Serialisation;
@@ -35,23 +34,15 @@ namespace StardewModdingAPI.Framework.Models
[JsonConverter(typeof(SFieldConverter))]
public IManifestDependency[] Dependencies { get; set; }
-#if !SMAPI_1_x
/// <summary>The mod's unique ID in Nexus Mods (if any), used for update checks.</summary>
public string NexusID { get; set; }
/// <summary>The mod's organisation and project name on GitHub (if any), used for update checks.</summary>
public string GitHubProject { get; set; }
-#endif
/// <summary>The unique mod ID.</summary>
public string UniqueID { get; set; }
-#if SMAPI_1_x
- /// <summary>Whether the mod uses per-save config files.</summary>
- [Obsolete("Use " + nameof(Mod) + "." + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadConfig) + " instead")]
- public bool PerSaveConfigs { get; set; }
-#endif
-
/// <summary>Any manifest fields which didn't match a valid field.</summary>
[JsonExtensionData]
public IDictionary<string, object> ExtraFields { get; set; }
diff --git a/src/StardewModdingAPI/Framework/Models/ManifestDependency.cs b/src/StardewModdingAPI/Framework/Models/ManifestDependency.cs
index 67f906e3..5646b335 100644
--- a/src/StardewModdingAPI/Framework/Models/ManifestDependency.cs
+++ b/src/StardewModdingAPI/Framework/Models/ManifestDependency.cs
@@ -1,4 +1,4 @@
-namespace StardewModdingAPI.Framework.Models
+namespace StardewModdingAPI.Framework.Models
{
/// <summary>A mod dependency listed in a mod manifest.</summary>
internal class ManifestDependency : IManifestDependency
@@ -12,10 +12,8 @@
/// <summary>The minimum required version (if any).</summary>
public ISemanticVersion MinimumVersion { get; set; }
-#if !SMAPI_1_x
/// <summary>Whether the dependency must be installed to use the mod.</summary>
public bool IsRequired { get; set; }
-#endif
/*********
** Public methods
@@ -24,19 +22,13 @@
/// <param name="uniqueID">The unique mod ID to require.</param>
/// <param name="minimumVersion">The minimum required version (if any).</param>
/// <param name="required">Whether the dependency must be installed to use the mod.</param>
- public ManifestDependency(string uniqueID, string minimumVersion
-#if !SMAPI_1_x
- , bool required = true
-#endif
- )
+ public ManifestDependency(string uniqueID, string minimumVersion, bool required = true)
{
this.UniqueID = uniqueID;
this.MinimumVersion = !string.IsNullOrWhiteSpace(minimumVersion)
? new SemanticVersion(minimumVersion)
: null;
-#if !SMAPI_1_x
this.IsRequired = required;
-#endif
}
}
}
diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs
index c2c3a689..bf338386 100644
--- a/src/StardewModdingAPI/Framework/Monitor.cs
+++ b/src/StardewModdingAPI/Framework/Monitor.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -37,10 +37,8 @@ namespace StardewModdingAPI.Framework
/// <summary>Whether SMAPI is aborting. Mods don't need to worry about this unless they have background tasks.</summary>
public bool IsExiting => this.ExitTokenSource.IsCancellationRequested;
-#if !SMAPI_1_x
/// <summary>Whether to show the full log stamps (with time/level/logger) in the console. If false, shows a simplified stamp with only the logger.</summary>
internal bool ShowFullStampInConsole { get; set; }
-#endif
/// <summary>Whether to show trace messages in the console.</summary>
internal bool ShowTraceInConsole { get; set; }
@@ -89,7 +87,6 @@ namespace StardewModdingAPI.Framework
this.ExitTokenSource.Cancel();
}
-#if !SMAPI_1_x
/// <summary>Write a newline to the console and log file.</summary>
internal void Newline()
{
@@ -98,20 +95,6 @@ namespace StardewModdingAPI.Framework
if (this.WriteToFile)
this.LogFile.WriteLine("");
}
-#endif
-
-#if SMAPI_1_x
- /// <summary>Log a message for the player or developer, using the specified console color.</summary>
- /// <param name="source">The name of the mod logging the message.</param>
- /// <param name="message">The message to log.</param>
- /// <param name="color">The console color.</param>
- /// <param name="level">The log level.</param>
- [Obsolete("This method is provided for backwards compatibility and otherwise should not be used. Use " + nameof(Monitor) + "." + nameof(Monitor.Log) + " instead.")]
- internal void LegacyLog(string source, string message, ConsoleColor color, LogLevel level = LogLevel.Debug)
- {
- this.LogImpl(source, message, level, color);
- }
-#endif
/*********
@@ -136,11 +119,7 @@ namespace StardewModdingAPI.Framework
string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength);
string fullMessage = $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}] {message}";
-#if !SMAPI_1_x
string consoleMessage = this.ShowFullStampInConsole ? fullMessage : $"[{source}] {message}";
-#else
- string consoleMessage = fullMessage;
-#endif
// write to console
if (this.WriteToConsole && (this.ShowTraceInConsole || level != LogLevel.Trace))
@@ -168,11 +147,9 @@ namespace StardewModdingAPI.Framework
/// <summary>Get the color scheme to use for the current console.</summary>
private static IDictionary<LogLevel, ConsoleColor> GetConsoleColorScheme()
{
-#if !SMAPI_1_x
// scheme for dark console background
if (Monitor.IsDark(Console.BackgroundColor))
{
-#endif
return new Dictionary<LogLevel, ConsoleColor>
{
[LogLevel.Trace] = ConsoleColor.DarkGray,
@@ -182,7 +159,6 @@ namespace StardewModdingAPI.Framework
[LogLevel.Error] = ConsoleColor.Red,
[LogLevel.Alert] = ConsoleColor.Magenta
};
-#if !SMAPI_1_x
}
// scheme for light console background
@@ -195,7 +171,6 @@ namespace StardewModdingAPI.Framework
[LogLevel.Error] = ConsoleColor.Red,
[LogLevel.Alert] = ConsoleColor.DarkMagenta
};
-#endif
}
/// <summary>Get whether a console color should be considered dark, which is subjectively defined as 'white looks better than black on this text'.</summary>
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs
index 387aeacc..7287cab7 100644
--- a/src/StardewModdingAPI/Framework/SGame.cs
+++ b/src/StardewModdingAPI/Framework/SGame.cs
@@ -20,9 +20,6 @@ using StardewValley.Menus;
using StardewValley.Tools;
using xTile.Dimensions;
using xTile.Layers;
-#if SMAPI_1_x
-using SFarmer = StardewValley.Farmer;
-#endif
namespace StardewModdingAPI.Framework
{
@@ -117,23 +114,6 @@ namespace StardewModdingAPI.Framework
/// <summary>The time of day (in 24-hour military format) at last check.</summary>
private int PreviousTime;
-#if SMAPI_1_x
- /// <summary>The day of month (1–28) at last check.</summary>
- private int PreviousDay;
-
- /// <summary>The season name (winter, spring, summer, or fall) at last check.</summary>
- private string PreviousSeason;
-
- /// <summary>The year number at last check.</summary>
- private int PreviousYear;
-
- /// <summary>Whether the game was transitioning to a new day at last check.</summary>
- private bool PreviousIsNewDay;
-
- /// <summary>The player character at last check.</summary>
- private SFarmer PreviousFarmer;
-#endif
-
/// <summary>The previous content locale.</summary>
private LocalizedContentManager.LanguageCode? PreviousLocale;
@@ -164,10 +144,10 @@ namespace StardewModdingAPI.Framework
private Color bgColor => SGame.Reflection.GetPrivateField<Color>(this, nameof(bgColor)).GetValue();
public RenderTarget2D screenWrapper => SGame.Reflection.GetPrivateProperty<RenderTarget2D>(this, "screen").GetValue(); // deliberately renamed to avoid an infinite loop
public BlendState lightingBlend => SGame.Reflection.GetPrivateField<BlendState>(this, nameof(lightingBlend)).GetValue();
- private readonly Action drawFarmBuildings = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawFarmBuildings)).Invoke(new object[0]);
- private readonly Action drawHUD = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawHUD)).Invoke(new object[0]);
- private readonly Action drawDialogueBox = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawDialogueBox)).Invoke(new object[0]);
- private readonly Action renderScreenBuffer = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(renderScreenBuffer)).Invoke(new object[0]);
+ private readonly Action drawFarmBuildings = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawFarmBuildings)).Invoke();
+ private readonly Action drawHUD = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawHUD)).Invoke();
+ private readonly Action drawDialogueBox = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(drawDialogueBox)).Invoke();
+ private readonly Action renderScreenBuffer = () => SGame.Reflection.GetPrivateMethod(SGame.Instance, nameof(renderScreenBuffer)).Invoke();
// ReSharper restore ArrangeStaticMemberQualifier, ArrangeThisQualifier, InconsistentNaming
@@ -295,10 +275,6 @@ namespace StardewModdingAPI.Framework
if (this.FirstUpdate)
{
GameEvents.InvokeInitialize(this.Monitor);
-#if SMAPI_1_x
- GameEvents.InvokeLoadContent(this.Monitor);
- GameEvents.InvokeGameLoaded(this.Monitor);
-#endif
}
/*********
@@ -321,10 +297,8 @@ namespace StardewModdingAPI.Framework
*********/
if (Context.IsSaveLoaded && !SaveGame.IsProcessing /*still loading save*/ && this.AfterLoadTimer >= 0)
{
-#if !SMAPI_1_x
if (Game1.dayOfMonth != 0) // wait until new-game intro finishes (world not fully initialised yet)
-#endif
- this.AfterLoadTimer--;
+ this.AfterLoadTimer--;
if (this.AfterLoadTimer == 0)
{
@@ -332,9 +306,6 @@ namespace StardewModdingAPI.Framework
Context.IsWorldReady = true;
SaveEvents.InvokeAfterLoad(this.Monitor);
-#if SMAPI_1_x
- PlayerEvents.InvokeLoadedGame(this.Monitor, new EventArgsLoadedGameChanged(Game1.hasLoadedGame));
-#endif
TimeEvents.InvokeAfterDayStarted(this.Monitor);
}
}
@@ -403,7 +374,6 @@ namespace StardewModdingAPI.Framework
bool isClick = framePressedKeys.Contains(SButton.MouseLeft) || (framePressedKeys.Contains(SButton.ControllerA) && !currentlyPressedKeys.Contains(SButton.ControllerX));
// get cursor position
-#if !SMAPI_1_x
ICursorPosition cursor;
{
// cursor position
@@ -414,14 +384,11 @@ namespace StardewModdingAPI.Framework
: Game1.player.GetGrabTile();
cursor = new CursorPosition(screenPixels, tile, grabTile);
}
-#endif
// raise button pressed
foreach (SButton button in framePressedKeys)
{
-#if !SMAPI_1_x
InputEvents.InvokeButtonPressed(this.Monitor, button, cursor, isClick);
-#endif
// legacy events
if (button.TryGetKeyboard(out Keys key))
@@ -441,12 +408,10 @@ namespace StardewModdingAPI.Framework
// raise button released
foreach (SButton button in frameReleasedKeys)
{
-#if !SMAPI_1_x
bool wasClick =
(button == SButton.MouseLeft && previousPressedKeys.Contains(SButton.MouseLeft)) // released left click
|| (button == SButton.ControllerA && previousPressedKeys.Contains(SButton.ControllerA) && !previousPressedKeys.Contains(SButton.ControllerX));
InputEvents.InvokeButtonReleased(this.Monitor, button, cursor, wasClick);
-#endif
// legacy events
if (button.TryGetKeyboard(out Keys key))
@@ -524,12 +489,6 @@ namespace StardewModdingAPI.Framework
if (this.GetHash(Game1.locations) != this.PreviousGameLocations)
LocationEvents.InvokeLocationsChanged(this.Monitor, Game1.locations);
-#if SMAPI_1_x
- // raise player changed
- if (Game1.player != this.PreviousFarmer)
- PlayerEvents.InvokeFarmerChanged(this.Monitor, this.PreviousFarmer, Game1.player);
-#endif
-
// raise events that shouldn't be triggered on initial load
if (Game1.uniqueIDForThisGame == this.PreviousSaveID)
{
@@ -559,14 +518,6 @@ namespace StardewModdingAPI.Framework
// raise time changed
if (Game1.timeOfDay != this.PreviousTime)
TimeEvents.InvokeTimeOfDayChanged(this.Monitor, this.PreviousTime, Game1.timeOfDay);
-#if SMAPI_1_x
- if (Game1.dayOfMonth != this.PreviousDay)
- TimeEvents.InvokeDayOfMonthChanged(this.Monitor, this.PreviousDay, Game1.dayOfMonth);
- if (Game1.currentSeason != this.PreviousSeason)
- TimeEvents.InvokeSeasonOfYearChanged(this.Monitor, this.PreviousSeason, Game1.currentSeason);
- if (Game1.year != this.PreviousYear)
- TimeEvents.InvokeYearOfGameChanged(this.Monitor, this.PreviousYear, Game1.year);
-#endif
// raise mine level changed
if (Game1.mine != null && Game1.mine.mineLevel != this.PreviousMineLevel)
@@ -587,26 +538,9 @@ namespace StardewModdingAPI.Framework
this.PreviousTime = Game1.timeOfDay;
this.PreviousMineLevel = Game1.mine?.mineLevel ?? 0;
this.PreviousSaveID = Game1.uniqueIDForThisGame;
-#if SMAPI_1_x
- this.PreviousFarmer = Game1.player;
- this.PreviousDay = Game1.dayOfMonth;
- this.PreviousSeason = Game1.currentSeason;
- this.PreviousYear = Game1.year;
-#endif
}
/*********
- ** Game day transition event (obsolete)
- *********/
-#if SMAPI_1_x
- if (Game1.newDay != this.PreviousIsNewDay)
- {
- TimeEvents.InvokeOnNewDay(this.Monitor, this.PreviousDay, Game1.dayOfMonth, Game1.newDay);
- this.PreviousIsNewDay = Game1.newDay;
- }
-#endif
-
- /*********
** Game update
*********/
try
@@ -623,12 +557,7 @@ namespace StardewModdingAPI.Framework
*********/
GameEvents.InvokeUpdateTick(this.Monitor);
if (this.FirstUpdate)
- {
-#if SMAPI_1_x
- GameEvents.InvokeFirstUpdateTick(this.Monitor);
-#endif
this.FirstUpdate = false;
- }
if (this.CurrentUpdateTick % 2 == 0)
GameEvents.InvokeSecondUpdateTick(this.Monitor);
if (this.CurrentUpdateTick % 4 == 0)
diff --git a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
index 11ffdccb..5419896f 100644
--- a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
+++ b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -76,12 +76,8 @@ namespace StardewModdingAPI.Framework.Serialisation
{
string uniqueID = obj.Value<string>(nameof(IManifestDependency.UniqueID));
string minVersion = obj.Value<string>(nameof(IManifestDependency.MinimumVersion));
-#if SMAPI_1_x
- result.Add(new ManifestDependency(uniqueID, minVersion));
-#else
bool required = obj.Value<bool?>(nameof(IManifestDependency.IsRequired)) ?? true;
result.Add(new ManifestDependency(uniqueID, minVersion, required));
-#endif
}
return result.ToArray();
}
diff --git a/src/StardewModdingAPI/Framework/Utilities/ContextHash.cs b/src/StardewModdingAPI/Framework/Utilities/ContextHash.cs
index 0d8487bb..6c0fdc90 100644
--- a/src/StardewModdingAPI/Framework/Utilities/ContextHash.cs
+++ b/src/StardewModdingAPI/Framework/Utilities/ContextHash.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
namespace StardewModdingAPI.Framework.Utilities
@@ -25,7 +24,7 @@ namespace StardewModdingAPI.Framework.Utilities
/// <exception cref="InvalidOperationException">The specified key is already added.</exception>
public void Track(T key, Action action)
{
- if(this.Contains(key))
+ if (this.Contains(key))
throw new InvalidOperationException($"Can't track context for key {key} because it's already added.");
this.Add(key);
diff --git a/src/StardewModdingAPI/IContentHelper.cs b/src/StardewModdingAPI/IContentHelper.cs
index b4557134..b78b165b 100644
--- a/src/StardewModdingAPI/IContentHelper.cs
+++ b/src/StardewModdingAPI/IContentHelper.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@@ -12,13 +12,11 @@ namespace StardewModdingAPI
/*********
** Accessors
*********/
-#if !SMAPI_1_x
/// <summary>Interceptors which provide the initial versions of matching content assets.</summary>
IList<IAssetLoader> AssetLoaders { get; }
/// <summary>Interceptors which edit matching content assets after they're loaded.</summary>
IList<IAssetEditor> AssetEditors { get; }
-#endif
/// <summary>The game's current locale code (like <c>pt-BR</c>).</summary>
string CurrentLocale { get; }
@@ -44,7 +42,6 @@ namespace StardewModdingAPI
/// <exception cref="ArgumentException">The <paramref name="key"/> is empty or contains invalid characters.</exception>
string GetActualAssetKey(string key, ContentSource source = ContentSource.ModFolder);
-#if !SMAPI_1_x
/// <summary>Remove an asset from the content cache so it's reloaded on the next request. This will reload core game assets if needed, but references to the former asset will still show the previous content.</summary>
/// <param name="key">The asset key to invalidate in the content folder.</param>
/// <exception cref="ArgumentException">The <paramref name="key"/> is empty or contains invalid characters.</exception>
@@ -55,6 +52,5 @@ namespace StardewModdingAPI
/// <typeparam name="T">The asset type to remove from the cache.</typeparam>
/// <returns>Returns whether any assets were invalidated.</returns>
bool InvalidateCache<T>();
-#endif
}
}
diff --git a/src/StardewModdingAPI/ICursorPosition.cs b/src/StardewModdingAPI/ICursorPosition.cs
index 8fbc115f..ddb8eb49 100644
--- a/src/StardewModdingAPI/ICursorPosition.cs
+++ b/src/StardewModdingAPI/ICursorPosition.cs
@@ -1,4 +1,3 @@
-#if !SMAPI_1_x
using Microsoft.Xna.Framework;
namespace StardewModdingAPI
@@ -16,4 +15,3 @@ namespace StardewModdingAPI
Vector2 GrabTile { get; }
}
}
-#endif
diff --git a/src/StardewModdingAPI/IManifestDependency.cs b/src/StardewModdingAPI/IManifestDependency.cs
index 1fa6c812..e86cd1f4 100644
--- a/src/StardewModdingAPI/IManifestDependency.cs
+++ b/src/StardewModdingAPI/IManifestDependency.cs
@@ -1,4 +1,4 @@
-namespace StardewModdingAPI
+namespace StardewModdingAPI
{
/// <summary>A mod dependency listed in a mod manifest.</summary>
public interface IManifestDependency
@@ -12,9 +12,7 @@
/// <summary>The minimum required version (if any).</summary>
ISemanticVersion MinimumVersion { get; }
-#if !SMAPI_1_x
/// <summary>Whether the dependency must be installed to use the mod.</summary>
bool IsRequired { get; }
-#endif
}
}
diff --git a/src/StardewModdingAPI/ISemanticVersion.cs b/src/StardewModdingAPI/ISemanticVersion.cs
index c1a4ca3a..0483c97b 100644
--- a/src/StardewModdingAPI/ISemanticVersion.cs
+++ b/src/StardewModdingAPI/ISemanticVersion.cs
@@ -1,12 +1,9 @@
-using System;
+using System;
namespace StardewModdingAPI
{
/// <summary>A semantic version with an optional release tag.</summary>
- public interface ISemanticVersion : IComparable<ISemanticVersion>
-#if !SMAPI_1_x
- , IEquatable<ISemanticVersion>
-#endif
+ public interface ISemanticVersion : IComparable<ISemanticVersion>, IEquatable<ISemanticVersion>
{
/*********
** Accessors
@@ -59,4 +56,4 @@ namespace StardewModdingAPI
/// <summary>Get a string representation of the version.</summary>
string ToString();
}
-} \ No newline at end of file
+}
diff --git a/src/StardewModdingAPI/Log.cs b/src/StardewModdingAPI/Log.cs
deleted file mode 100644
index 60220ad8..00000000
--- a/src/StardewModdingAPI/Log.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-#if SMAPI_1_x
-using System;
-using System.Threading;
-using StardewModdingAPI.Framework;
-using Monitor = StardewModdingAPI.Framework.Monitor;
-
-namespace StardewModdingAPI
-{
- /// <summary>A singleton which logs messages to the SMAPI console and log file.</summary>
- [Obsolete("Use " + nameof(Mod) + "." + nameof(Mod.Monitor))]
- public static class Log
- {
- /*********
- ** Properties
- *********/
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
- /// <summary>The underlying logger.</summary>
- private static Monitor Monitor;
-
- /// <summary>Tracks the installed mods.</summary>
- private static ModRegistry ModRegistry;
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- /// <param name="monitor">The underlying logger.</param>
- /// <param name="modRegistry">Tracks the installed mods.</param>
- internal static void Shim(DeprecationManager deprecationManager, Monitor monitor, ModRegistry modRegistry)
- {
- Log.DeprecationManager = deprecationManager;
- Log.Monitor = monitor;
- Log.ModRegistry = modRegistry;
- }
-
- /****
- ** Exceptions
- ****/
- /// <summary>Log an exception event.</summary>
- /// <param name="sender">The event sender.</param>
- /// <param name="e">The event arguments.</param>
- public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- Log.WarnDeprecated();
- Log.Monitor.Log($"Critical app domain exception: {e.ExceptionObject}", LogLevel.Error);
- }
-
- /// <summary>Log a thread exception event.</summary>
- /// <param name="sender">The event sender.</param>
- /// <param name="e">The event arguments.</param>
- public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- Log.WarnDeprecated();
- Log.Monitor.Log($"Critical thread exception: {e.Exception}", LogLevel.Error);
- }
-
- /****
- ** Synchronous logging
- ****/
- /// <summary>Synchronously log a message to the console. NOTE: synchronous logging is discouraged; use asynchronous methods instead.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="color">The message color.</param>
- public static void SyncColour(object message, ConsoleColor color)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), color);
- }
-
- /****
- ** Asynchronous logging
- ****/
- /// <summary>Asynchronously log a message to the console with the specified color.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="color">The message color.</param>
- public static void AsyncColour(object message, ConsoleColor color)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), color);
- }
-
- /// <summary>Asynchronously log a message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Async(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Gray);
- }
-
- /// <summary>Asynchronously log a red message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncR(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Red);
- }
-
- /// <summary>Asynchronously log an orange message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncO(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.DarkYellow);
- }
-
- /// <summary>Asynchronously log a yellow message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncY(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Yellow);
- }
-
- /// <summary>Asynchronously log a green message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncG(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Green);
- }
-
- /// <summary>Asynchronously log a cyan message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncC(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Cyan);
- }
-
- /// <summary>Asynchronously log a magenta message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void AsyncM(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Magenta);
- }
-
- /// <summary>Asynchronously log a warning to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Warning(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Yellow, LogLevel.Warn);
- }
-
- /// <summary>Asynchronously log an error to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Error(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Red, LogLevel.Error);
- }
-
- /// <summary>Asynchronously log a success message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Success(object message)
- {
- Log.WarnDeprecated();
- Log.AsyncG(message);
- }
-
- /// <summary>Asynchronously log an info message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Info(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.White, LogLevel.Info);
- }
-
- /// <summary>Asynchronously log an info message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Out(object message)
- {
- Log.WarnDeprecated();
- Log.Async($"[OUT] {message}");
- }
-
- /// <summary>Asynchronously log a debug message to the console.</summary>
- /// <param name="message">The message to log.</param>
- public static void Debug(object message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.DarkGray);
- }
-
- /// <summary>Asynchronously log a message to the file that's not shown in the console.</summary>
- /// <param name="message">The message to log.</param>
- internal static void LogToFile(string message)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message, ConsoleColor.DarkGray, LogLevel.Trace);
- }
-
- /// <summary>Obsolete.</summary>
- public static void LogValueNotSpecified()
- {
- Log.WarnDeprecated();
- Log.AsyncR("<value> must be specified");
- }
-
- /// <summary>Obsolete.</summary>
- public static void LogObjectValueNotSpecified()
- {
- Log.WarnDeprecated();
- Log.AsyncR("<object> and <value> must be specified");
- }
-
- /// <summary>Obsolete.</summary>
- public static void LogValueInvalid()
- {
- Log.WarnDeprecated();
- Log.AsyncR("<value> is invalid");
- }
-
- /// <summary>Obsolete.</summary>
- public static void LogObjectInvalid()
- {
- Log.WarnDeprecated();
- Log.AsyncR("<object> is invalid");
- }
-
- /// <summary>Obsolete.</summary>
- public static void LogValueNotInt32()
- {
- Log.WarnDeprecated();
- Log.AsyncR("<value> must be a whole number (Int32)");
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="disableLogging">Obsolete.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- private static void PrintLog(object message, bool disableLogging, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Monitor.LegacyLog(Log.GetModName(), message?.ToString(), ConsoleColor.Gray);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Success(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Success(message);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Verbose(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Out(message);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Comment(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.AsyncC(message);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Info(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Info(message);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Error(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Error(message);
- }
-
- /// <summary>Obsolete.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="values">Obsolete.</param>
- [Obsolete("Parameter 'values' is no longer supported. Format before logging.")]
- public static void Debug(object message, params object[] values)
- {
- Log.WarnDeprecated();
- Log.Debug(message);
- }
-
-
- /*********
- ** Private methods
- *********/
- /// <summary>Raise a deprecation warning.</summary>
- private static void WarnDeprecated()
- {
- Log.DeprecationManager.Warn($"the {nameof(Log)} class", "1.1", DeprecationLevel.PendingRemoval);
- }
-
- /// <summary>Get the name of the mod logging a message from the stack.</summary>
- private static string GetModName()
- {
- return Log.ModRegistry.GetModFromStack() ?? "<unknown mod>";
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/StardewModdingAPI/Metadata/InstructionMetadata.cs b/src/StardewModdingAPI/Metadata/InstructionMetadata.cs
index 79fabbd2..35989801 100644
--- a/src/StardewModdingAPI/Metadata/InstructionMetadata.cs
+++ b/src/StardewModdingAPI/Metadata/InstructionMetadata.cs
@@ -44,7 +44,6 @@ namespace StardewModdingAPI.Metadata
new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "OnPreRenderGuiEventNoCheck", InstructionHandleResult.NotCompatible),
// APIs removed in SMAPI 2.0
-#if !SMAPI_1_x
new TypeFinder("StardewModdingAPI.Command", InstructionHandleResult.NotCompatible),
new TypeFinder("StardewModdingAPI.Config", InstructionHandleResult.NotCompatible),
new TypeFinder("StardewModdingAPI.Log", InstructionHandleResult.NotCompatible),
@@ -67,7 +66,6 @@ namespace StardewModdingAPI.Metadata
new PropertyFinder("StardewModdingAPI.Mod", "BaseConfigPath", InstructionHandleResult.NotCompatible),
new PropertyFinder("StardewModdingAPI.Mod", "PerSaveConfigFolder", InstructionHandleResult.NotCompatible),
new PropertyFinder("StardewModdingAPI.Mod", "PerSaveConfigPath", InstructionHandleResult.NotCompatible),
-#endif
/****
** detect code which may impact game stability
diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs
index b5607234..c511ce5a 100644
--- a/src/StardewModdingAPI/Mod.cs
+++ b/src/StardewModdingAPI/Mod.cs
@@ -1,7 +1,4 @@
-using System;
-using System.IO;
-using StardewModdingAPI.Framework;
-using StardewModdingAPI.Framework.Models;
+using System;
namespace StardewModdingAPI
{
@@ -9,19 +6,6 @@ namespace StardewModdingAPI
public class Mod : IMod, IDisposable
{
/*********
- ** Properties
- *********/
-#if SMAPI_1_x
- /// <summary>Manages deprecation warnings.</summary>
- private static DeprecationManager DeprecationManager;
-
-
- /// <summary>The backing field for <see cref="Mod.PathOnDisk"/>.</summary>
- private string _pathOnDisk;
-#endif
-
-
- /*********
** Accessors
*********/
/// <summary>Provides simplified APIs for writing mods.</summary>
@@ -33,65 +17,10 @@ namespace StardewModdingAPI
/// <summary>The mod's manifest.</summary>
public IManifest ModManifest { get; internal set; }
-#if SMAPI_1_x
- /// <summary>The full path to the mod's directory on the disk.</summary>
- [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.DirectoryPath) + " instead")]
- public string PathOnDisk
- {
- get
- {
- Mod.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0", DeprecationLevel.PendingRemoval);
- return this._pathOnDisk;
- }
- internal set { this._pathOnDisk = value; }
- }
-
- /// <summary>The full path to the mod's <c>config.json</c> file on the disk.</summary>
- [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadConfig) + " instead")]
- public string BaseConfigPath
- {
- get
- {
- Mod.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.BaseConfigPath)}", "1.0", DeprecationLevel.PendingRemoval);
- Mod.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
- return Path.Combine(this.PathOnDisk, "config.json");
- }
- }
-
- /// <summary>The full path to the per-save configs folder (if <see cref="Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
- [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadJsonFile) + " instead")]
- public string PerSaveConfigFolder => this.GetPerSaveConfigFolder();
-
- /// <summary>The full path to the per-save configuration file for the current save (if <see cref="Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
- [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadJsonFile) + " instead")]
- public string PerSaveConfigPath
- {
- get
- {
- Mod.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigPath)}", "1.0", DeprecationLevel.PendingRemoval);
- Mod.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0"); // avoid redundant warnings
- return Context.IsSaveLoaded ? Path.Combine(this.PerSaveConfigFolder, $"{Constants.SaveFolderName}.json") : "";
- }
- }
-#endif
-
/*********
** Public methods
*********/
-#if SMAPI_1_x
- /// <summary>Injects types required for backwards compatibility.</summary>
- /// <param name="deprecationManager">Manages deprecation warnings.</param>
- internal static void Shim(DeprecationManager deprecationManager)
- {
- Mod.DeprecationManager = deprecationManager;
- }
-
- /// <summary>The mod entry point, called after the mod is first loaded.</summary>
- [Obsolete("This overload is obsolete since SMAPI 1.0.")]
- public virtual void Entry(params object[] objects) { }
-#endif
-
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public virtual void Entry(IModHelper helper) { }
@@ -108,23 +37,6 @@ namespace StardewModdingAPI
/*********
** Private methods
*********/
-#if SMAPI_1_x
- /// <summary>Get the full path to the per-save configuration file for the current save (if <see cref="Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
- [Obsolete]
- private string GetPerSaveConfigFolder()
- {
- Mod.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0", DeprecationLevel.PendingRemoval);
- Mod.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
-
- if (!((Manifest)this.ModManifest).PerSaveConfigs)
- {
- this.Monitor.Log("Tried to fetch the per-save config folder, but this mod isn't configured to use per-save config files.", LogLevel.Error);
- return "";
- }
- return Path.Combine(this.PathOnDisk, "psconfigs");
- }
-#endif
-
/// <summary>Release or reset unmanaged resources when the game exits. There's no guarantee this will be called on every exit.</summary>
/// <param name="disposing">Whether the instance is being disposed explicitly rather than finalised. If this is false, the instance shouldn't dispose other objects since they may already be finalised.</param>
protected virtual void Dispose(bool disposing) { }
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index cee3aefd..8f32b9eb 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -129,9 +129,6 @@ namespace StardewModdingAPI
this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {this.GetFriendlyPlatformName()}", LogLevel.Info);
this.Monitor.Log($"Mods go here: {Constants.ModPath}");
this.Monitor.Log($"Log started at {DateTime.UtcNow:s} UTC", LogLevel.Trace);
-#if SMAPI_1_x
- this.Monitor.Log("Preparing SMAPI...");
-#endif
// validate paths
this.VerifyPath(Constants.ModPath);
@@ -213,11 +210,7 @@ namespace StardewModdingAPI
}
// start game
-#if SMAPI_1_x
- this.Monitor.Log("Starting game...");
-#else
this.Monitor.Log("Starting game...", LogLevel.Trace);
-#endif
try
{
this.IsGameRunning = true;
@@ -234,16 +227,6 @@ namespace StardewModdingAPI
}
}
-#if SMAPI_1_x
- /// <summary>Get a monitor for legacy code which doesn't have one passed in.</summary>
- [Obsolete("This method should only be used when needed for backwards compatibility.")]
- internal IMonitor GetLegacyMonitorForMod()
- {
- string modName = this.ModRegistry.GetModFromStack() ?? "unknown";
- return this.GetSecondaryMonitor(modName);
- }
-#endif
-
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{
@@ -303,7 +286,7 @@ namespace StardewModdingAPI
{
PrintErrorAndExit(
"Oops! SMAPI can't find the game. "
- + (Assembly.GetCallingAssembly().Location?.Contains(Path.Combine("internal", "Windows")) == true || Assembly.GetCallingAssembly().Location?.Contains(Path.Combine("internal", "Mono")) == true
+ + (Assembly.GetCallingAssembly().Location.Contains(Path.Combine("internal", "Windows")) || Assembly.GetCallingAssembly().Location.Contains(Path.Combine("internal", "Mono"))
? "It looks like you're running SMAPI from the download package, but you need to run the installed version instead. "
: "Make sure you're running StardewModdingAPI.exe in your game folder. "
)
@@ -333,19 +316,6 @@ namespace StardewModdingAPI
this.DeprecationManager = new DeprecationManager(this.Monitor, this.ModRegistry);
this.CommandManager = new CommandManager();
-#if SMAPI_1_x
- // inject compatibility shims
-#pragma warning disable 618
- Command.Shim(this.CommandManager, this.DeprecationManager, this.ModRegistry);
- Config.Shim(this.DeprecationManager);
- Log.Shim(this.DeprecationManager, this.GetSecondaryMonitor("legacy mod"), this.ModRegistry);
- Mod.Shim(this.DeprecationManager);
- GameEvents.Shim(this.DeprecationManager);
- PlayerEvents.Shim(this.DeprecationManager);
- TimeEvents.Shim(this.DeprecationManager);
-#pragma warning restore 618
-#endif
-
// redirect direct console output
{
Monitor monitor = this.GetSecondaryMonitor("Console.Out");
@@ -357,9 +327,7 @@ namespace StardewModdingAPI
if (this.Settings.DeveloperMode)
{
this.Monitor.ShowTraceInConsole = true;
-#if !SMAPI_1_x
this.Monitor.ShowFullStampInConsole = true;
-#endif
this.Monitor.Log($"You configured SMAPI to run in developer mode. The console may be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI, or by editing {Constants.ApiConfigPath}.", LogLevel.Info);
}
if (!this.Settings.CheckForUpdates)
@@ -375,67 +343,18 @@ namespace StardewModdingAPI
// load mods
{
-#if SMAPI_1_x
- this.Monitor.Log("Loading mod metadata...");
-#else
this.Monitor.Log("Loading mod metadata...", LogLevel.Trace);
-#endif
ModResolver resolver = new ModResolver();
// load manifests
IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModCompatibility, this.Settings.DisabledMods).ToArray();
resolver.ValidateManifests(mods, Constants.ApiVersion);
- // check for deprecated metadata
-#if SMAPI_1_x
- IList<Action> deprecationWarnings = new List<Action>();
- foreach (IModMetadata mod in mods.Where(m => m.Status != ModMetadataStatus.Failed))
- {
- // missing fields that will be required in SMAPI 2.0
- {
- List<string> missingFields = new List<string>(3);
-
- if (string.IsNullOrWhiteSpace(mod.Manifest.Name))
- missingFields.Add(nameof(IManifest.Name));
- if (mod.Manifest.Version == null || mod.Manifest.Version.ToString() == "0.0")
- missingFields.Add(nameof(IManifest.Version));
- if (string.IsNullOrWhiteSpace(mod.Manifest.UniqueID))
- missingFields.Add(nameof(IManifest.UniqueID));
-
- if (missingFields.Any())
- deprecationWarnings.Add(() => this.Monitor.Log($"{mod.DisplayName} is missing some manifest fields ({string.Join(", ", missingFields)}) which will be required in an upcoming SMAPI version.", LogLevel.Warn));
- }
-
- // per-save directories
- if ((mod.Manifest as Manifest)?.PerSaveConfigs == true)
- {
- deprecationWarnings.Add(() => this.DeprecationManager.Warn(mod.DisplayName, $"{nameof(Manifest)}.{nameof(Manifest.PerSaveConfigs)}", "1.0", DeprecationLevel.PendingRemoval));
- try
- {
- string psDir = Path.Combine(mod.DirectoryPath, "psconfigs");
- Directory.CreateDirectory(psDir);
- if (!Directory.Exists(psDir))
- mod.SetStatus(ModMetadataStatus.Failed, "it requires per-save configuration files ('psconfigs') which couldn't be created for some reason.");
- }
- catch (Exception ex)
- {
- mod.SetStatus(ModMetadataStatus.Failed, $"it requires per-save configuration files ('psconfigs') which couldn't be created: {ex.GetLogSummary()}");
- }
- }
- }
-#endif
-
// process dependencies
mods = resolver.ProcessDependencies(mods).ToArray();
// load mods
-#if SMAPI_1_x
- this.LoadMods(mods, new JsonHelper(), this.ContentManager, deprecationWarnings);
- foreach (Action warning in deprecationWarnings)
- warning();
-#else
this.LoadMods(mods, new JsonHelper(), this.ContentManager);
-#endif
// check for updates
this.CheckForUpdatesAsync(mods);
@@ -472,9 +391,6 @@ namespace StardewModdingAPI
private void RunConsoleLoop()
{
// prepare console
-#if SMAPI_1_x
- this.Monitor.Log("Starting console...");
-#endif
this.Monitor.Log("Type 'help' for help, or 'help <cmd>' for a command's usage", LogLevel.Info);
this.CommandManager.Add("SMAPI", "help", "Lists command documentation.\n\nUsage: help\nLists all available commands.\n\nUsage: help <cmd>\n- cmd: The name of a command whose documentation to display.", this.HandleCommand);
this.CommandManager.Add("SMAPI", "reload_i18n", "Reloads translation files for all mods.\n\nUsage: reload_i18n", this.HandleCommand);
@@ -600,7 +516,6 @@ namespace StardewModdingAPI
}
// fetch mod versions
-#if !SMAPI_1_x
try
{
// prepare update-check data
@@ -649,14 +564,11 @@ namespace StardewModdingAPI
{
this.Monitor.Log($"Couldn't check for new mod versions:\n{ex.GetLogSummary()}", LogLevel.Trace);
}
-#endif
// output
if (updates.Any())
{
-#if !SMAPI_1_x
this.Monitor.Newline();
-#endif
// print intro
string intro = "";
@@ -694,18 +606,10 @@ namespace StardewModdingAPI
/// <param name="mods">The mods to load.</param>
/// <param name="jsonHelper">The JSON helper with which to read mods' JSON files.</param>
/// <param name="contentManager">The content manager to use for mod content.</param>
-#if SMAPI_1_x
- /// <param name="deprecationWarnings">A list to populate with any deprecation warnings.</param>
- private void LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager, IList<Action> deprecationWarnings)
-#else
private void LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager)
-#endif
{
-#if SMAPI_1_x
- this.Monitor.Log("Loading mods...");
-#else
this.Monitor.Log("Loading mods...", LogLevel.Trace);
-#endif
+
// load mod assemblies
IDictionary<IModMetadata, string> skippedMods = new Dictionary<IModMetadata, string>();
{
@@ -740,11 +644,7 @@ namespace StardewModdingAPI
}
catch (IncompatibleInstructionException ex)
{
-#if SMAPI_1_x
- TrackSkip(metadata, $"it's not compatible with the latest version of the game or SMAPI (detected {ex.NounPhrase}). Please check for a newer version of the mod.");
-#else
TrackSkip(metadata, $"it's no longer compatible (detected {ex.NounPhrase}). Please check for a newer version of the mod.");
-#endif
continue;
}
catch (SAssemblyLoadFailedException ex)
@@ -791,16 +691,6 @@ namespace StardewModdingAPI
continue;
}
-#if SMAPI_1_x
- // prevent mods from using SMAPI 2.0 content interception before release
- // ReSharper disable SuspiciousTypeConversion.Global
- if (mod is IAssetEditor || mod is IAssetLoader)
- {
- TrackSkip(metadata, $"its entry class implements {nameof(IAssetEditor)} or {nameof(IAssetLoader)}. These are part of a prototype API that isn't available for mods to use yet.");
- }
- // ReSharper restore SuspiciousTypeConversion.Global
-#endif
-
// inject data
{
IMonitor monitor = this.GetSecondaryMonitor(metadata.DisplayName);
@@ -813,9 +703,6 @@ namespace StardewModdingAPI
mod.ModManifest = manifest;
mod.Helper = new ModHelper(manifest.UniqueID, metadata.DirectoryPath, jsonHelper, contentHelper, commandHelper, modRegistryHelper, reflectionHelper, translationHelper);
mod.Monitor = monitor;
-#if SMAPI_1_x
- mod.PathOnDisk = metadata.DirectoryPath;
-#endif
}
// track mod
@@ -831,9 +718,7 @@ namespace StardewModdingAPI
IModMetadata[] loadedMods = this.ModRegistry.GetMods().ToArray();
// log skipped mods
-#if !SMAPI_1_x
this.Monitor.Newline();
-#endif
if (skippedMods.Any())
{
this.Monitor.Log($"Skipped {skippedMods.Count} mods:", LogLevel.Error);
@@ -847,9 +732,7 @@ namespace StardewModdingAPI
else
this.Monitor.Log($" {mod.DisplayName} because {reason}", LogLevel.Error);
}
-#if !SMAPI_1_x
this.Monitor.Newline();
-#endif
}
// log loaded mods
@@ -864,9 +747,7 @@ namespace StardewModdingAPI
LogLevel.Info
);
}
-#if !SMAPI_1_x
this.Monitor.Newline();
-#endif
// initialise translations
this.ReloadTranslations();
@@ -886,16 +767,8 @@ namespace StardewModdingAPI
{
IMod mod = metadata.Mod;
mod.Entry(mod.Helper);
-#if SMAPI_1_x
- (mod as Mod)?.Entry(); // deprecated since 1.0
-
- // raise deprecation warning for old Entry() methods
- if (this.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(object[]) }))
- deprecationWarnings.Add(() => this.DeprecationManager.Warn(metadata.DisplayName, $"{nameof(Mod)}.{nameof(Mod.Entry)}(object[]) instead of {nameof(Mod)}.{nameof(Mod.Entry)}({nameof(IModHelper)})", "1.0", DeprecationLevel.PendingRemoval));
-#else
if (!this.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(IModHelper) }))
this.Monitor.Log($"{metadata.DisplayName} doesn't implement Entry() and may not work correctly.", LogLevel.Error);
-#endif
}
catch (Exception ex)
{
@@ -987,10 +860,6 @@ namespace StardewModdingAPI
}
else
{
-#if SMAPI_1_x
- this.Monitor.Log("The following commands are registered: " + string.Join(", ", this.CommandManager.GetAll().Select(p => p.Name)) + ".", LogLevel.Info);
- this.Monitor.Log("For more information about a command, type 'help command_name'.", LogLevel.Info);
-#else
string message = "The following commands are registered:\n";
IGrouping<string, string>[] groups = (from command in this.CommandManager.GetAll() orderby command.ModName, command.Name group command.Name by command.ModName).ToArray();
foreach (var group in groups)
@@ -1002,7 +871,6 @@ namespace StardewModdingAPI
message += "For more information about a command, type 'help command_name'.";
this.Monitor.Log(message, LogLevel.Info);
-#endif
}
break;
@@ -1051,9 +919,7 @@ namespace StardewModdingAPI
{
WriteToConsole = this.Monitor.WriteToConsole,
ShowTraceInConsole = this.Settings.DeveloperMode,
-#if !SMAPI_1_x
ShowFullStampInConsole = this.Settings.DeveloperMode
-#endif
};
}
diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs
index e448eae1..1b99dae6 100644
--- a/src/StardewModdingAPI/SemanticVersion.cs
+++ b/src/StardewModdingAPI/SemanticVersion.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
@@ -179,7 +179,6 @@ namespace StardewModdingAPI
return this.IsBetween(new SemanticVersion(min), new SemanticVersion(max));
}
-#if !SMAPI_1_x
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
/// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
/// <param name="other">An object to compare with this object.</param>
@@ -187,7 +186,6 @@ namespace StardewModdingAPI
{
return other != null && this.CompareTo(other) == 0;
}
-#endif
/// <summary>Get a string representation of the version.</summary>
public override string ToString()
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index 07e98674..685bef1e 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -90,7 +90,6 @@
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="Command.cs" />
<Compile Include="Framework\ModLoading\Finders\EventFinder.cs" />
<Compile Include="Framework\ModLoading\Finders\FieldFinder.cs" />
<Compile Include="Framework\ModLoading\Finders\MethodFinder.cs" />
@@ -120,10 +119,8 @@
<Compile Include="Framework\Content\AssetInfo.cs" />
<Compile Include="Framework\Exceptions\SContentLoadException.cs" />
<Compile Include="Framework\Command.cs" />
- <Compile Include="Config.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Events\ControlEvents.cs" />
- <Compile Include="Events\EventArgsCommand.cs" />
<Compile Include="Events\EventArgsClickableMenuChanged.cs" />
<Compile Include="Events\EventArgsClickableMenuClosed.cs" />
<Compile Include="Events\EventArgsControllerButtonPressed.cs" />
@@ -131,19 +128,15 @@
<Compile Include="Events\EventArgsControllerTriggerPressed.cs" />
<Compile Include="Events\EventArgsControllerTriggerReleased.cs" />
<Compile Include="Events\EventArgsCurrentLocationChanged.cs" />
- <Compile Include="Events\EventArgsFarmerChanged.cs" />
<Compile Include="Events\EventArgsGameLocationsChanged.cs" />
<Compile Include="Events\EventArgsIntChanged.cs" />
<Compile Include="Events\EventArgsInventoryChanged.cs" />
<Compile Include="Events\EventArgsKeyboardStateChanged.cs" />
<Compile Include="Events\EventArgsKeyPressed.cs" />
<Compile Include="Events\EventArgsLevelUp.cs" />
- <Compile Include="Events\EventArgsLoadedGameChanged.cs" />
<Compile Include="Events\EventArgsLocationObjectsChanged.cs" />
<Compile Include="Events\EventArgsMineLevelChanged.cs" />
<Compile Include="Events\EventArgsMouseStateChanged.cs" />
- <Compile Include="Events\EventArgsNewDay.cs" />
- <Compile Include="Events\EventArgsStringChanged.cs" />
<Compile Include="Events\GameEvents.cs" />
<Compile Include="Events\GraphicsEvents.cs" />
<Compile Include="Framework\Utilities\Countdown.cs" />
@@ -222,7 +215,6 @@
<Compile Include="IMonitor.cs" />
<Compile Include="Events\ChangeType.cs" />
<Compile Include="Events\ItemStackChange.cs" />
- <Compile Include="Log.cs" />
<Compile Include="Framework\Monitor.cs" />
<Compile Include="Framework\Models\Manifest.cs" />
<Compile Include="Metadata\InstructionMetadata.cs" />
diff --git a/src/StardewModdingAPI/Utilities/SButton.cs b/src/StardewModdingAPI/Utilities/SButton.cs
index 33058a64..fa5ae648 100644
--- a/src/StardewModdingAPI/Utilities/SButton.cs
+++ b/src/StardewModdingAPI/Utilities/SButton.cs
@@ -6,12 +6,7 @@ namespace StardewModdingAPI.Utilities
{
/// <summary>A unified button constant which includes all controller, keyboard, and mouse buttons.</summary>
/// <remarks>Derived from <see cref="Keys"/>, <see cref="Buttons"/>, and <see cref="System.Windows.Forms.MouseButtons"/>.</remarks>
-#if SMAPI_1_x
- internal
-#else
- public
-#endif
- enum SButton
+ public enum SButton
{
/// <summary>No valid key.</summary>
None = 0,
@@ -594,12 +589,7 @@ namespace StardewModdingAPI.Utilities
}
/// <summary>Provides extension methods for <see cref="SButton"/>.</summary>
-#if SMAPI_1_x
- internal
-#else
- public
-#endif
- static class SButtonExtensions
+ public static class SButtonExtensions
{
/*********
** Accessors
diff --git a/src/StardewModdingAPI/Utilities/SDate.cs b/src/StardewModdingAPI/Utilities/SDate.cs
index 5073259d..326d7fc7 100644
--- a/src/StardewModdingAPI/Utilities/SDate.cs
+++ b/src/StardewModdingAPI/Utilities/SDate.cs
@@ -32,10 +32,8 @@ namespace StardewModdingAPI.Utilities
/// <summary>The year.</summary>
public int Year { get; }
-#if !SMAPI_1_x
/// <summary>The day of week.</summary>
public DayOfWeek DayOfWeek { get; }
-#endif
/*********
@@ -69,9 +67,7 @@ namespace StardewModdingAPI.Utilities
this.Day = day;
this.Season = season;
this.Year = year;
-#if !SMAPI_1_x
this.DayOfWeek = this.GetDayOfWeek();
-#endif
}
/// <summary>Get the current in-game date.</summary>
diff --git a/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs b/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs
deleted file mode 100644
index ad79b4af..00000000
--- a/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-#if SMAPI_1_x
-using StardewModdingAPI;
-using StardewValley;
-using StardewValley.Menus;
-
-namespace TrainerMod.Framework.Commands.Saves
-{
- /// <summary>A command which shows the load screen.</summary>
- internal class LoadCommand : TrainerCommand
- {
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- public LoadCommand()
- : base("load", "Shows the load screen.") { }
-
- /// <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)
- {
- monitor.Log("Triggering load menu...", LogLevel.Info);
- Game1.hasLoadedGame = false;
- Game1.activeClickableMenu = new LoadGameMenu();
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs b/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs
deleted file mode 100644
index ea2bd6a8..00000000
--- a/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-#if SMAPI_1_x
-using StardewModdingAPI;
-using StardewValley;
-
-namespace TrainerMod.Framework.Commands.Saves
-{
- /// <summary>A command which saves the game.</summary>
- internal class SaveCommand : TrainerCommand
- {
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- public SaveCommand()
- : base("save", "Saves the game? Doesn't seem to work.") { }
-
-
- /// <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)
- {
- monitor.Log("Saving the game...", LogLevel.Info);
- SaveGame.Save();
- }
- }
-}
-#endif \ No newline at end of file
diff --git a/src/TrainerMod/TrainerMod.csproj b/src/TrainerMod/TrainerMod.csproj
index 73b40050..383e8c28 100644
--- a/src/TrainerMod/TrainerMod.csproj
+++ b/src/TrainerMod/TrainerMod.csproj
@@ -69,8 +69,6 @@
<Compile Include="Framework\Commands\Player\SetStaminaCommand.cs" />
<Compile Include="Framework\Commands\Player\SetNameCommand.cs" />
<Compile Include="Framework\Commands\Player\SetMoneyCommand.cs" />
- <Compile Include="Framework\Commands\Saves\LoadCommand.cs" />
- <Compile Include="Framework\Commands\Saves\SaveCommand.cs" />
<Compile Include="Framework\Commands\TrainerCommand.cs" />
<Compile Include="Framework\Commands\World\SetMineLevelCommand.cs" />
<Compile Include="Framework\Commands\World\DownMineLevelCommand.cs" />