From 41715cefcde3c838bb079cb37aac5a3b2dcb1004 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 11 Mar 2018 19:09:08 -0400 Subject: add initial compatibility with Stardew Valley 1.3 (#453) --- src/SMAPI/Events/EventArgsInventoryChanged.cs | 12 +++++++++++- src/SMAPI/Events/EventArgsLocationObjectsChanged.cs | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/EventArgsInventoryChanged.cs b/src/SMAPI/Events/EventArgsInventoryChanged.cs index 1ee02842..b85ae9db 100644 --- a/src/SMAPI/Events/EventArgsInventoryChanged.cs +++ b/src/SMAPI/Events/EventArgsInventoryChanged.cs @@ -12,7 +12,11 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The player's inventory. +#if STARDEW_VALLEY_1_3 + public IList Inventory { get; } +#else public List Inventory { get; } +#endif /// The added items. public List Added { get; } @@ -30,7 +34,13 @@ namespace StardewModdingAPI.Events /// Construct an instance. /// The player's inventory. /// The inventory changes. - public EventArgsInventoryChanged(List inventory, List changedItems) + public EventArgsInventoryChanged( +#if STARDEW_VALLEY_1_3 + IList inventory, +#else + List inventory, +#endif + List changedItems) { this.Inventory = inventory; this.Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList(); diff --git a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs index 058999e9..de3c31ea 100644 --- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs @@ -1,6 +1,10 @@ -using System; +using System; using Microsoft.Xna.Framework; +#if STARDEW_VALLEY_1_3 +using Netcode; +#else using StardewValley; +#endif using Object = StardewValley.Object; namespace StardewModdingAPI.Events @@ -12,7 +16,11 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The current list of objects in the current location. +#if STARDEW_VALLEY_1_3 + public IDictionary> NewObjects { get; } +#else public SerializableDictionary NewObjects { get; } +#endif /********* @@ -20,7 +28,13 @@ namespace StardewModdingAPI.Events *********/ /// Construct an instance. /// The current list of objects in the current location. - public EventArgsLocationObjectsChanged(SerializableDictionary newObjects) + public EventArgsLocationObjectsChanged( +#if STARDEW_VALLEY_1_3 + IDictionary> newObjects +#else + SerializableDictionary newObjects +#endif + ) { this.NewObjects = newObjects; } -- cgit From 6db91f832998ab07e7a937c25b32f1151a0274bc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 11 Mar 2018 19:10:27 -0400 Subject: drop support for some deprecated APIs in the Stardew Valley 1.3 branch (#453) --- docs/release-notes.md | 3 +++ src/SMAPI/Events/EventArgsInput.cs | 2 ++ src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs | 3 ++- src/SMAPI/Framework/Reflection/ReflectedField.cs | 5 ++++- src/SMAPI/Framework/Reflection/ReflectedMethod.cs | 5 ++++- src/SMAPI/Framework/Reflection/ReflectedProperty.cs | 5 ++++- src/SMAPI/IPrivateField.cs | 2 ++ src/SMAPI/IPrivateMethod.cs | 2 ++ src/SMAPI/IPrivateProperty.cs | 2 ++ src/SMAPI/IReflectionHelper.cs | 2 ++ 10 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/docs/release-notes.md b/docs/release-notes.md index 05a95fc1..2d71da7f 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,6 +3,9 @@ * For players: * Updated for Stardew Valley 1.3 (multiplayer update); no longer compatible with earlier versions. +* For modders: + * Dropped support for some deprecated APIs. + ## 2.5.3 * For players: * Simplified and improved skipped-incompatible-mod messages. diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs index a5325b76..75b9b8cd 100644 --- a/src/SMAPI/Events/EventArgsInput.cs +++ b/src/SMAPI/Events/EventArgsInput.cs @@ -18,9 +18,11 @@ namespace StardewModdingAPI.Events /// The current cursor position. public ICursorPosition Cursor { get; } +#if !STARDEW_VALLEY_1_3 /// Whether the input is considered a 'click' by the game for enabling action. [Obsolete("Use " + nameof(EventArgsInput.IsActionButton) + " or " + nameof(EventArgsInput.IsUseToolButton) + " instead")] // deprecated in SMAPI 2.1 public bool IsClick => this.IsActionButton; +#endif /// Whether the input should trigger actions on the affected tile. public bool IsActionButton { get; } diff --git a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs index 81453003..e5bf47f6 100644 --- a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs @@ -107,7 +107,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - +#if !STARDEW_VALLEY_1_3 /**** ** Obsolete ****/ @@ -221,6 +221,7 @@ namespace StardewModdingAPI.Framework.ModHelpers this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); return (IPrivateMethod)this.GetMethod(type, name, required); } +#endif /********* diff --git a/src/SMAPI/Framework/Reflection/ReflectedField.cs b/src/SMAPI/Framework/Reflection/ReflectedField.cs index ad1557bb..fb420dc5 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedField.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedField.cs @@ -5,7 +5,10 @@ namespace StardewModdingAPI.Framework.Reflection { /// A field obtained through reflection. /// The field value type. - internal class ReflectedField : IPrivateField, IReflectedField + internal class ReflectedField : IReflectedField +#if !STARDEW_VALLEY_1_3 + , IPrivateField +#endif { /********* ** Properties diff --git a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs index 376de869..803bc316 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs @@ -4,7 +4,10 @@ using System.Reflection; namespace StardewModdingAPI.Framework.Reflection { /// A method obtained through reflection. - internal class ReflectedMethod : IPrivateMethod, IReflectedMethod + internal class ReflectedMethod : IReflectedMethod +#if !STARDEW_VALLEY_1_3 + , IPrivateMethod +#endif { /********* ** Properties diff --git a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs index d6c964c1..4f9d4e19 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs @@ -5,7 +5,10 @@ namespace StardewModdingAPI.Framework.Reflection { /// A property obtained through reflection. /// The property value type. - internal class ReflectedProperty : IPrivateProperty, IReflectedProperty + internal class ReflectedProperty : IReflectedProperty +#if !STARDEW_VALLEY_1_3 + , IPrivateProperty +#endif { /********* ** Properties diff --git a/src/SMAPI/IPrivateField.cs b/src/SMAPI/IPrivateField.cs index 512bfdab..42bf7d2e 100644 --- a/src/SMAPI/IPrivateField.cs +++ b/src/SMAPI/IPrivateField.cs @@ -1,3 +1,4 @@ +#if !STARDEW_VALLEY_1_3 using System; using System.Reflection; @@ -26,3 +27,4 @@ namespace StardewModdingAPI void SetValue(TValue value); } } +#endif diff --git a/src/SMAPI/IPrivateMethod.cs b/src/SMAPI/IPrivateMethod.cs index b2fdaaeb..c24db602 100644 --- a/src/SMAPI/IPrivateMethod.cs +++ b/src/SMAPI/IPrivateMethod.cs @@ -1,3 +1,4 @@ +#if !STARDEW_VALLEY_1_3 using System; using System.Reflection; @@ -27,3 +28,4 @@ namespace StardewModdingAPI void Invoke(params object[] arguments); } } +#endif diff --git a/src/SMAPI/IPrivateProperty.cs b/src/SMAPI/IPrivateProperty.cs index a24495dd..a1b21a69 100644 --- a/src/SMAPI/IPrivateProperty.cs +++ b/src/SMAPI/IPrivateProperty.cs @@ -1,3 +1,4 @@ +#if !STARDEW_VALLEY_1_3 using System; using System.Reflection; @@ -26,3 +27,4 @@ namespace StardewModdingAPI void SetValue(TValue value); } } +#endif diff --git a/src/SMAPI/IReflectionHelper.cs b/src/SMAPI/IReflectionHelper.cs index fcebae42..60441471 100644 --- a/src/SMAPI/IReflectionHelper.cs +++ b/src/SMAPI/IReflectionHelper.cs @@ -48,6 +48,7 @@ namespace StardewModdingAPI /// Whether to throw an exception if the field is not found. IReflectedMethod GetMethod(Type type, string name, bool required = true); +#if !STARDEW_VALLEY_1_3 /***** ** Obsolete *****/ @@ -114,5 +115,6 @@ namespace StardewModdingAPI /// Whether to throw an exception if the private field is not found. [Obsolete("Use " + nameof(IReflectionHelper) + "." + nameof(IReflectionHelper.GetMethod) + " instead")] IPrivateMethod GetPrivateMethod(Type type, string name, bool required = true); +#endif } } -- cgit From 98fa9f03891e3dc487bee6dcb3756e6251c67aef Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 11 Mar 2018 20:45:58 -0400 Subject: update for Stardew Valley 1.3.0.5 (#453) --- src/SMAPI/Constants.cs | 2 +- src/SMAPI/Events/EventArgsGameLocationsChanged.cs | 6 +++--- .../Events/EventArgsLocationObjectsChanged.cs | 1 + src/SMAPI/Framework/GameVersion.cs | 24 ++++++++++++++-------- 4 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 011762fb..d91fa5fb 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -47,7 +47,7 @@ namespace StardewModdingAPI /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = #if STARDEW_VALLEY_1_3 - new GameVersion("1.3.0.2"); + new GameVersion("1.3.0.4"); #else new SemanticVersion("1.2.33"); #endif diff --git a/src/SMAPI/Events/EventArgsGameLocationsChanged.cs b/src/SMAPI/Events/EventArgsGameLocationsChanged.cs index fb8c821e..78ba38fa 100644 --- a/src/SMAPI/Events/EventArgsGameLocationsChanged.cs +++ b/src/SMAPI/Events/EventArgsGameLocationsChanged.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using StardewValley; @@ -11,7 +11,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The current list of game locations. - public List NewLocations { get; } + public IList NewLocations { get; } /********* @@ -19,7 +19,7 @@ namespace StardewModdingAPI.Events *********/ /// Construct an instance. /// The current list of game locations. - public EventArgsGameLocationsChanged(List newLocations) + public EventArgsGameLocationsChanged(IList newLocations) { this.NewLocations = newLocations; } diff --git a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs index de3c31ea..180e9d78 100644 --- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; #if STARDEW_VALLEY_1_3 +using System.Collections.Generic; using Netcode; #else using StardewValley; diff --git a/src/SMAPI/Framework/GameVersion.cs b/src/SMAPI/Framework/GameVersion.cs index c347ffba..e5022212 100644 --- a/src/SMAPI/Framework/GameVersion.cs +++ b/src/SMAPI/Framework/GameVersion.cs @@ -23,9 +23,7 @@ namespace StardewModdingAPI.Framework ["1.07"] = "1.0.7", ["1.07a"] = "1.0.8-prerelease1", ["1.08"] = "1.0.8", - ["1.11"] = "1.1.1", - ["1.3.0.1"] = "1.13-alpha.1", - ["1.3.0.2"] = "1.13-alpha.2" + ["1.11"] = "1.1.1" }; @@ -51,21 +49,31 @@ namespace StardewModdingAPI.Framework /// The game version string. private static string GetSemanticVersionString(string gameVersion) { +#if STARDEW_VALLEY_1_3 + if(gameVersion.StartsWith("1.3.0.")) + return new SemanticVersion(1, 3, 0, "alpha." + gameVersion.Substring("1.3.0.".Length)).ToString(); +#endif + return GameVersion.VersionMap.TryGetValue(gameVersion, out string semanticVersion) ? semanticVersion : gameVersion; } - /// Convert a game version string to a semantic version string. - /// The game version string. - private static string GetGameVersionString(string gameVersion) + /// Convert a semantic version string to the equivalent game version string. + /// The semantic version string. + private static string GetGameVersionString(string semanticVersion) { + #if STARDEW_VALLEY_1_3 + if(semanticVersion.StartsWith("1.3-alpha.")) + return "1.3.0." + semanticVersion.Substring("1.3-alpha.".Length); + #endif + foreach (var mapping in GameVersion.VersionMap) { - if (mapping.Value.Equals(gameVersion, StringComparison.InvariantCultureIgnoreCase)) + if (mapping.Value.Equals(semanticVersion, StringComparison.InvariantCultureIgnoreCase)) return mapping.Key; } - return gameVersion; + return semanticVersion; } } } -- cgit