From 2d36105c33ffba77eb979ef6ef0d2e7d906b09bc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 20:53:12 -0400 Subject: drop support for SMAPI 1.x (#360) --- .../InteractiveInstaller.cs | 6 - .../Core/ModResolverTests.cs | 6 +- .../Core/TranslationTests.cs | 3 +- src/StardewModdingAPI/Command.cs | 159 ---------- src/StardewModdingAPI/Config.cs | 188 ------------ src/StardewModdingAPI/Constants.cs | 7 +- src/StardewModdingAPI/Events/EventArgsCommand.cs | 28 -- .../Events/EventArgsFarmerChanged.cs | 33 --- src/StardewModdingAPI/Events/EventArgsInput.cs | 2 - .../Events/EventArgsLoadedGameChanged.cs | 27 -- src/StardewModdingAPI/Events/EventArgsNewDay.cs | 37 --- .../Events/EventArgsStringChanged.cs | 31 -- src/StardewModdingAPI/Events/GameEvents.cs | 112 -------- src/StardewModdingAPI/Events/InputEvents.cs | 2 - src/StardewModdingAPI/Events/PlayerEvents.cs | 74 +---- src/StardewModdingAPI/Events/TimeEvents.cs | 128 +-------- src/StardewModdingAPI/Framework/CursorPosition.cs | 2 - .../Framework/ModHelpers/ReflectionHelper.cs | 4 +- .../Framework/ModLoading/ModResolver.cs | 25 +- src/StardewModdingAPI/Framework/ModRegistry.cs | 8 +- src/StardewModdingAPI/Framework/Models/Manifest.cs | 9 - .../Framework/Models/ManifestDependency.cs | 12 +- src/StardewModdingAPI/Framework/Monitor.cs | 27 +- src/StardewModdingAPI/Framework/SGame.cs | 81 +----- .../Framework/Serialisation/SFieldConverter.cs | 6 +- .../Framework/Utilities/ContextHash.cs | 3 +- src/StardewModdingAPI/IContentHelper.cs | 6 +- src/StardewModdingAPI/ICursorPosition.cs | 2 - src/StardewModdingAPI/IManifestDependency.cs | 4 +- src/StardewModdingAPI/ISemanticVersion.cs | 9 +- src/StardewModdingAPI/Log.cs | 320 --------------------- .../Metadata/InstructionMetadata.cs | 2 - src/StardewModdingAPI/Mod.cs | 90 +----- src/StardewModdingAPI/Program.cs | 138 +-------- src/StardewModdingAPI/SemanticVersion.cs | 4 +- src/StardewModdingAPI/StardewModdingAPI.csproj | 8 - src/StardewModdingAPI/Utilities/SButton.cs | 14 +- src/StardewModdingAPI/Utilities/SDate.cs | 4 - .../Framework/Commands/Saves/LoadCommand.cs | 30 -- .../Framework/Commands/Saves/SaveCommand.cs | 29 -- src/TrainerMod/TrainerMod.csproj | 2 - 41 files changed, 31 insertions(+), 1651 deletions(-) delete mode 100644 src/StardewModdingAPI/Command.cs delete mode 100644 src/StardewModdingAPI/Config.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsCommand.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsNewDay.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsStringChanged.cs delete mode 100644 src/StardewModdingAPI/Log.cs delete mode 100644 src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs delete mode 100644 src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs (limited to 'src') 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 /// 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 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()), 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()), Times.Once, "The validation did not fail the first mod with a unique ID."); modB.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny()), 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 -{ - /// A command that can be submitted through the SMAPI console to interact with SMAPI. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))] - public class Command - { - /********* - ** Properties - *********/ - /// The commands registered with SMAPI. - private static readonly IDictionary LegacyCommands = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - - /// Manages console commands. - private static CommandManager CommandManager; - - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// Tracks the installed mods. - private static ModRegistry ModRegistry; - - - /********* - ** Accessors - *********/ - /// The event raised when this command is submitted through the console. - public event EventHandler CommandFired; - - /**** - ** Command - ****/ - /// The name of the command. - public string CommandName; - - /// A human-readable description of what the command does. - public string CommandDesc; - - /// A human-readable list of accepted arguments. - public string[] CommandArgs; - - /// The actual submitted argument values. - public string[] CalledArgs; - - - /********* - ** Public methods - *********/ - /**** - ** Command - ****/ - /// Injects types required for backwards compatibility. - /// Manages console commands. - /// Manages deprecation warnings. - /// Tracks the installed mods. - internal static void Shim(CommandManager commandManager, DeprecationManager deprecationManager, ModRegistry modRegistry) - { - Command.CommandManager = commandManager; - Command.DeprecationManager = deprecationManager; - Command.ModRegistry = modRegistry; - } - - /// Construct an instance. - /// The name of the command. - /// A human-readable description of what the command does. - /// A human-readable list of accepted arguments. - 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; - } - - /// Trigger this command. - 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 - ****/ - /// Parse a command string and invoke it if valid. - /// The command to run, including the command name and any arguments. - /// Encapsulates monitoring and logging. - public static void CallCommand(string input, IMonitor monitor) - { - Command.DeprecationManager.Warn("Command.CallCommand", "1.9", DeprecationLevel.PendingRemoval); - Command.CommandManager.Trigger(input); - } - - /// Register a command with SMAPI. - /// The name of the command. - /// A human-readable description of what the command does. - /// A human-readable list of accepted arguments. - 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() ?? ""; - 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; - } - - /// Find a command with the given name. - /// The command name to find. - 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 - *********/ - /// Trigger this command. - /// The command name. - /// The command arguments. - 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 -{ - /// A dynamic configuration class for a mod. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public abstract class Config - { - /********* - ** Properties - *********/ - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - - /********* - ** Accessors - *********/ - /// The full path to the configuration file. - [JsonIgnore] - public virtual string ConfigLocation { get; protected internal set; } - - /// The directory path containing the configuration file. - [JsonIgnore] - public virtual string ConfigDir => Path.GetDirectoryName(this.ConfigLocation); - - - /********* - ** Public methods - *********/ - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - Config.DeprecationManager = deprecationManager; - } - - /// Construct an instance of the config class. - /// The config class type. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public virtual Config Instance() where T : Config => Activator.CreateInstance(); - - /// Load the config from the JSON file, saving it to disk if needed. - /// The config class type. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public virtual T LoadConfig() 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(); - config.ConfigLocation = this.ConfigLocation; - returnValue = config; - } - else - { - try - { - T config = JsonConvert.DeserializeObject(File.ReadAllText(this.ConfigLocation)); - config.ConfigLocation = this.ConfigLocation; - returnValue = config.UpdateConfig(); - } - catch (Exception ex) - { - Log.Error($"Invalid JSON ({this.GetType().Name}): {this.ConfigLocation} \n{ex}"); - return this.GenerateDefaultConfig(); - } - } - - returnValue.WriteConfig(); - return returnValue; - } - - /// Get the default config values. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public virtual T GenerateDefaultConfig() where T : Config - { - return null; - } - - /// Get the current configuration with missing values defaulted. - /// The config class type. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public virtual T UpdateConfig() where T : Config - { - try - { - // get default + user config - JObject defaultConfig = JObject.FromObject(this.Instance().GenerateDefaultConfig()); - JObject currentConfig = JObject.FromObject(this); - defaultConfig.Merge(currentConfig, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }); - - // cast json object to config - T config = defaultConfig.ToObject(); - - // 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 - *********/ - /// Construct an instance. - 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 - } - } - - /// Provides extension methods for classes. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public static class ConfigExtensions - { - /// 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! - /// The config class type. - /// The base configuration to initialise. - /// The base configuration file path. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public static T InitializeConfig(this T baseConfig, string configLocation) where T : Config - { - if (baseConfig == null) - baseConfig = Activator.CreateInstance(); - - 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(); - } - - /// Writes the configuration to the JSON file. - /// The config class type. - /// The base configuration to initialise. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public static void WriteConfig(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); - } - - /// 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! - /// The config class type. - /// The base configuration to initialise. - [Obsolete("This base class is obsolete since SMAPI 1.0. See the latest project README for details.")] - public static T ReloadConfig(this T baseConfig) where T : Config - { - return baseConfig.LoadConfig(); - } - } -} -#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 ****/ /// SMAPI's current semantic version. - 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}"); /// The minimum supported version of Stardew Valley. 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 -{ - /// Event arguments for a event. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))] - public class EventArgsCommand : EventArgs - { - /********* - ** Accessors - *********/ - /// The triggered command. - public Command Command { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The triggered command. - 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 -{ - /// Event arguments for a event. - public class EventArgsFarmerChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous player character. - public SFarmer NewFarmer { get; } - - /// The new player character. - public SFarmer PriorFarmer { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous player character. - /// The new player character. - 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 -{ - /// Event arguments for a event. - public class EventArgsLoadedGameChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// Whether the save has been loaded. This is always true. - public bool LoadedGame { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// Whether the save has been loaded. This is always true. - 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 -{ - /// Event arguments for a event. - public class EventArgsNewDay : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous day value. - public int PreviousDay { get; } - - /// The current day value. - public int CurrentDay { get; } - - /// Whether the game just started the transition (true) or finished it (false). - public bool IsNewDay { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous day value. - /// The current day value. - /// Whether the game just started the transition (true) or finished it (false). - 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 -{ - /// Event arguments for a string field that changed value. - public class EventArgsStringChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous value. - public string NewString { get; } - - /// The current value. - public string PriorString { get; } - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous value. - /// The current value. - 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 { /// Events raised when the game changes state. public static class GameEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _Initialize; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _LoadContent; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _GameLoaded; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _FirstUpdateTick; -#endif - - /********* ** Events *********/ /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . internal static event EventHandler InitializeInternal; -#if SMAPI_1_x - /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . - [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; - } - - /// Raised before XNA loads or reloads graphics resources. Called during . - [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; - } - - /// Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point. - [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; - } - - /// Raised during the first game update tick. - [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 - /// Raised when the game updates its state (≈60 times per second). public static event EventHandler UpdateTick; @@ -114,47 +37,12 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ -#if SMAPI_1_x - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - GameEvents.DeprecationManager = deprecationManager; - } -#endif - /// Raise an event. /// Encapsulates logging and monitoring. 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 - /// Raise a event. - /// Encapsulates logging and monitoring. - internal static void InvokeLoadContent(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", GameEvents._LoadContent?.GetInvocationList()); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - internal static void InvokeGameLoaded(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents._GameLoaded?.GetInvocationList()); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - internal static void InvokeFirstUpdateTick(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", GameEvents._FirstUpdateTick?.GetInvocationList()); } -#endif /// Raise an event. /// Encapsulates logging and monitoring. 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 { /// Events raised when the player data changes. public static class PlayerEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _LoadedGame; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _FarmerChanged; -#endif - - /********* ** Events *********/ -#if SMAPI_1_x - /// Raised after the player loads a saved game. - [Obsolete("Use " + nameof(SaveEvents) + "." + nameof(SaveEvents.AfterLoad) + " instead")] - public static event EventHandler LoadedGame - { - add - { - PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", "1.6", DeprecationLevel.PendingRemoval); - PlayerEvents._LoadedGame += value; - } - remove => PlayerEvents._LoadedGame -= value; - } - - /// Raised after the game assigns a new player character. This happens just before ; it's unclear how this would happen any other time. - [Obsolete("should no longer be used")] - public static event EventHandler FarmerChanged - { - add - { - PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", "1.6", DeprecationLevel.PendingRemoval); - PlayerEvents._FarmerChanged += value; - } - remove => PlayerEvents._FarmerChanged -= value; - } -#endif - /// Raised after the player's inventory changes in any way (added or removed item, sorted, etc). public static event EventHandler InventoryChanged; @@ -68,32 +22,6 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ -#if SMAPI_1_x - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - PlayerEvents.DeprecationManager = deprecationManager; - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// Whether the save has been loaded. This is always true. - internal static void InvokeLoadedGame(IMonitor monitor, EventArgsLoadedGameChanged loaded) - { - monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", PlayerEvents._LoadedGame?.GetInvocationList(), null, loaded); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous player character. - /// The new player character. - 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 - /// Raise an event. /// Encapsulates monitoring and logging. /// The player's inventory. 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,38 +1,11 @@ -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 { /// Events raised when the in-game date or time changes. public static class TimeEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _OnNewDay; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _DayOfMonthChanged; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _SeasonOfYearChanged; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _YearOfGameChanged; -#endif - - /********* ** Events *********/ @@ -42,69 +15,9 @@ namespace StardewModdingAPI.Events /// Raised after the in-game clock changes. public static event EventHandler TimeOfDayChanged; -#if SMAPI_1_x - /// Raised after the day-of-month value changes, including when loading a save. This may happen before save; in most cases you should use instead. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler DayOfMonthChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._DayOfMonthChanged += value; - } - remove => TimeEvents._DayOfMonthChanged -= value; - } - - /// Raised after the year value changes. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler YearOfGameChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._YearOfGameChanged += value; - } - remove => TimeEvents._YearOfGameChanged -= value; - } - - /// Raised after the season value changes. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler SeasonOfYearChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._SeasonOfYearChanged += value; - } - remove => TimeEvents._SeasonOfYearChanged -= value; - } - - /// 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. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler 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 - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - TimeEvents.DeprecationManager = deprecationManager; - } -#endif - /// Raise an event. /// Encapsulates monitoring and logging. 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 - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous day value. - /// The current day value. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous year value. - /// The current year value. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous season name. - /// The current season name. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous day value. - /// The current day value. - /// Whether the game just started the transition (true) or finished it (false). - 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 /// The type being accessed. 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 } /// Assert that mods can use the reflection helper to access the given type. 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 missingFields = new List(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 } /// Sort the given mods by the order they should be loaded. @@ -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)); } /// Get whether a mod has been loaded. 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 /// The mod's unique ID in Nexus Mods (if any), used for update checks. public string NexusID { get; set; } /// The mod's organisation and project name on GitHub (if any), used for update checks. public string GitHubProject { get; set; } -#endif /// The unique mod ID. public string UniqueID { get; set; } -#if SMAPI_1_x - /// Whether the mod uses per-save config files. - [Obsolete("Use " + nameof(Mod) + "." + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadConfig) + " instead")] - public bool PerSaveConfigs { get; set; } -#endif - /// Any manifest fields which didn't match a valid field. [JsonExtensionData] public IDictionary 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 { /// A mod dependency listed in a mod manifest. internal class ManifestDependency : IManifestDependency @@ -12,10 +12,8 @@ /// The minimum required version (if any). public ISemanticVersion MinimumVersion { get; set; } -#if !SMAPI_1_x /// Whether the dependency must be installed to use the mod. public bool IsRequired { get; set; } -#endif /********* ** Public methods @@ -24,19 +22,13 @@ /// The unique mod ID to require. /// The minimum required version (if any). /// Whether the dependency must be installed to use the mod. - 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 /// Whether SMAPI is aborting. Mods don't need to worry about this unless they have background tasks. public bool IsExiting => this.ExitTokenSource.IsCancellationRequested; -#if !SMAPI_1_x /// Whether to show the full log stamps (with time/level/logger) in the console. If false, shows a simplified stamp with only the logger. internal bool ShowFullStampInConsole { get; set; } -#endif /// Whether to show trace messages in the console. internal bool ShowTraceInConsole { get; set; } @@ -89,7 +87,6 @@ namespace StardewModdingAPI.Framework this.ExitTokenSource.Cancel(); } -#if !SMAPI_1_x /// Write a newline to the console and log file. internal void Newline() { @@ -98,20 +95,6 @@ namespace StardewModdingAPI.Framework if (this.WriteToFile) this.LogFile.WriteLine(""); } -#endif - -#if SMAPI_1_x - /// Log a message for the player or developer, using the specified console color. - /// The name of the mod logging the message. - /// The message to log. - /// The console color. - /// The log level. - [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 /// Get the color scheme to use for the current console. private static IDictionary GetConsoleColorScheme() { -#if !SMAPI_1_x // scheme for dark console background if (Monitor.IsDark(Console.BackgroundColo