diff --git a/docs/release-notes.md b/docs/release-notes.md index 554b9518..6e531dbd 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,6 +12,7 @@ * Added heuristic compatibility rewrites, which fix some mods previously incompatible with Android or newer game versions. * Tweaked the rules for showing update alerts (see _for SMAPI developers_ below for details). * Fixed crossplatform compatibility for mods which use the `[HarmonyPatch(type)]` attribute (thanks to spacechase0!). + * Fixed map tile rotation broken when you return to the title screen and reload a save. * Fixed broken URL in update alerts for unofficial versions. * Fixed rare error when a mod adds/removes event handlers asynchronously. * Fixed rare issue where the console showed incorrect colors when mods wrote to it asynchronously. diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index 1a76bec3..0f341665 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -25,22 +25,22 @@ namespace StardewModdingAPI.Toolkit /********* ** Accessors *********/ - /// The major version incremented for major API changes. + /// public int MajorVersion { get; } - /// The minor version incremented for backwards-compatible changes. + /// public int MinorVersion { get; } - /// The patch version for backwards-compatible bug fixes. + /// public int PatchVersion { get; } /// The platform release. This is a non-standard semver extension used by Stardew Valley on ported platforms to represent platform-specific patches to a ported version, represented as a fourth number in the version string. public int PlatformRelease { get; } - /// An optional prerelease tag. + /// public string PrereleaseTag { get; } - /// Optional build metadata. This is ignored when determining version precedence. + /// public string BuildMetadata { get; } @@ -103,9 +103,7 @@ namespace StardewModdingAPI.Toolkit this.AssertValid(); } - /// Get an integer indicating whether this version precedes (less than 0), supersedes (more than 0), or is equivalent to (0) the specified version. - /// The version to compare with this instance. - /// The value is null. + /// public int CompareTo(ISemanticVersion other) { if (other == null) @@ -113,68 +111,55 @@ namespace StardewModdingAPI.Toolkit return this.CompareTo(other.MajorVersion, other.MinorVersion, other.PatchVersion, (other as SemanticVersion)?.PlatformRelease ?? 0, other.PrereleaseTag); } - /// Indicates whether the current object is equal to another object of the same type. - /// true if the current object is equal to the parameter; otherwise, false. - /// An object to compare with this object. + /// public bool Equals(ISemanticVersion other) { return other != null && this.CompareTo(other) == 0; } - /// Whether this is a prerelease version. + /// public bool IsPrerelease() { return !string.IsNullOrWhiteSpace(this.PrereleaseTag); } - /// Get whether this version is older than the specified version. - /// The version to compare with this instance. + /// public bool IsOlderThan(ISemanticVersion other) { return this.CompareTo(other) < 0; } - /// Get whether this version is older than the specified version. - /// The version to compare with this instance. - /// The specified version is not a valid semantic version. + /// public bool IsOlderThan(string other) { return this.IsOlderThan(new SemanticVersion(other, allowNonStandard: true)); } - /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. + /// public bool IsNewerThan(ISemanticVersion other) { return this.CompareTo(other) > 0; } - /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. - /// The specified version is not a valid semantic version. + /// public bool IsNewerThan(string other) { return this.IsNewerThan(new SemanticVersion(other, allowNonStandard: true)); } - /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. + /// public bool IsBetween(ISemanticVersion min, ISemanticVersion max) { return this.CompareTo(min) >= 0 && this.CompareTo(max) <= 0; } - /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. - /// One of the specified versions is not a valid semantic version. + /// public bool IsBetween(string min, string max) { return this.IsBetween(new SemanticVersion(min, allowNonStandard: true), new SemanticVersion(max, allowNonStandard: true)); } - /// Get a string representation of the version. + /// public override string ToString() { string version = $"{this.MajorVersion}.{this.MinorVersion}.{this.PatchVersion}"; @@ -187,7 +172,7 @@ namespace StardewModdingAPI.Toolkit return version; } - /// Whether the version uses non-standard extensions, like four-part game versions on some platforms. + /// public bool IsNonStandard() { return this.PlatformRelease != 0; diff --git a/src/SMAPI/Framework/Content/AssetData.cs b/src/SMAPI/Framework/Content/AssetData.cs index cacc6078..5c90d83b 100644 --- a/src/SMAPI/Framework/Content/AssetData.cs +++ b/src/SMAPI/Framework/Content/AssetData.cs @@ -16,7 +16,7 @@ namespace StardewModdingAPI.Framework.Content /********* ** Accessors *********/ - /// The content data being read. + /// public TValue Data { get; protected set; } @@ -36,10 +36,7 @@ namespace StardewModdingAPI.Framework.Content this.OnDataReplaced = onDataReplaced; } - /// Replace the entire content value with the given value. This is generally not recommended, since it may break compatibility with other mods or different versions of the game. - /// The new content value. - /// The is null. - /// The 's type is not compatible with the loaded asset's type. + /// public void ReplaceWith(TValue value) { if (value == null) diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs index 44a97136..5f91610e 100644 --- a/src/SMAPI/Framework/Content/AssetDataForImage.cs +++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs @@ -28,13 +28,7 @@ namespace StardewModdingAPI.Framework.Content public AssetDataForImage(string locale, string assetName, Texture2D data, Func getNormalizedPath, Action onDataReplaced) : base(locale, assetName, data, getNormalizedPath, onDataReplaced) { } - /// Overwrite part of the image. - /// The image to patch into the content. - /// The part of the to copy (or null to take the whole texture). This must be within the bounds of the texture. - /// The part of the content to patch (or null to patch the whole texture). The original content within this area will be erased. This must be within the bounds of the existing spritesheet. - /// Indicates how an image should be patched. - /// One of the arguments is null. - /// The is outside the bounds of the spritesheet. + /// public void PatchImage(Texture2D source, Rectangle? sourceArea = null, Rectangle? targetArea = null, PatchMode patchMode = PatchMode.Replace) { // get texture @@ -104,10 +98,7 @@ namespace StardewModdingAPI.Framework.Content target.SetData(0, targetArea, sourceData, 0, pixelCount); } - /// Extend the image if needed to fit the given size. Note that this is an expensive operation, creates a new texture instance, and that extending a spritesheet horizontally may cause game errors or bugs. - /// The minimum texture width. - /// The minimum texture height. - /// Whether the texture was resized. + /// public bool ExtendImage(int minWidth, int minHeight) { if (this.Data.Width >= minWidth && this.Data.Height >= minHeight) diff --git a/src/SMAPI/Framework/Content/AssetDataForMap.cs b/src/SMAPI/Framework/Content/AssetDataForMap.cs index dee5b034..e80c6e53 100644 --- a/src/SMAPI/Framework/Content/AssetDataForMap.cs +++ b/src/SMAPI/Framework/Content/AssetDataForMap.cs @@ -24,10 +24,7 @@ namespace StardewModdingAPI.Framework.Content public AssetDataForMap(string locale, string assetName, Map data, Func getNormalizedPath, Action onDataReplaced) : base(locale, assetName, data, getNormalizedPath, onDataReplaced) { } - /// Copy layers, tiles, and tilesheets from another map onto the asset. - /// The map from which to copy. - /// The tile area within the source map to copy, or null for the entire source map size. This must be within the bounds of the map. - /// The tile area within the target map to overwrite, or null to patch the whole map. The original content within this area will be erased. This must be within the bounds of the existing map. + /// /// Derived from with a few changes: /// - can be applied directly to the maps when loading, before the location is created; /// - added support for source/target areas; diff --git a/src/SMAPI/Framework/Content/AssetDataForObject.cs b/src/SMAPI/Framework/Content/AssetDataForObject.cs index f00ba124..b7e8dfeb 100644 --- a/src/SMAPI/Framework/Content/AssetDataForObject.cs +++ b/src/SMAPI/Framework/Content/AssetDataForObject.cs @@ -26,32 +26,25 @@ namespace StardewModdingAPI.Framework.Content public AssetDataForObject(IAssetInfo info, object data, Func getNormalizedPath) : this(info.Locale, info.AssetName, data, getNormalizedPath) { } - /// Get a helper to manipulate the data as a dictionary. - /// The expected dictionary key. - /// The expected dictionary balue. - /// The content being read isn't a dictionary. + /// public IAssetDataForDictionary AsDictionary() { return new AssetDataForDictionary(this.Locale, this.AssetName, this.GetData>(), this.GetNormalizedPath, this.ReplaceWith); } - /// Get a helper to manipulate the data as an image. - /// The content being read isn't an image. + /// public IAssetDataForImage AsImage() { return new AssetDataForImage(this.Locale, this.AssetName, this.GetData(), this.GetNormalizedPath, this.ReplaceWith); } - /// Get a helper to manipulate the data as a map. - /// The content being read isn't a map. + /// public IAssetDataForMap AsMap() { return new AssetDataForMap(this.Locale, this.AssetName, this.GetData(), this.GetNormalizedPath, this.ReplaceWith); } - /// Get the data as a given type. - /// The expected data type. - /// The data can't be converted to . + /// public TData GetData() { if (!(this.Data is TData)) diff --git a/src/SMAPI/Framework/Content/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs index ed009499..d8106439 100644 --- a/src/SMAPI/Framework/Content/AssetInfo.cs +++ b/src/SMAPI/Framework/Content/AssetInfo.cs @@ -16,13 +16,13 @@ namespace StardewModdingAPI.Framework.Content /********* ** Accessors *********/ - /// The content's locale code, if the content is localized. + /// public string Locale { get; } - /// The normalized asset name being read. The format may change between platforms; see to compare with a known path. + /// public string AssetName { get; } - /// The content data type. + /// public Type DataType { get; } @@ -42,8 +42,7 @@ namespace StardewModdingAPI.Framework.Content this.GetNormalizedPath = getNormalizedPath; } - /// Get whether the asset name being loaded matches a given name after normalization. - /// The expected asset path, relative to the game's content folder and without the .xnb extension or locale suffix (like 'Data\ObjectInformation'). + /// public bool AssetNameEquals(string path) { path = this.GetNormalizedPath(path); diff --git a/src/SMAPI/Framework/ContentPack.cs b/src/SMAPI/Framework/ContentPack.cs index 9c0bb9d1..43621141 100644 --- a/src/SMAPI/Framework/ContentPack.cs +++ b/src/SMAPI/Framework/ContentPack.cs @@ -24,13 +24,13 @@ namespace StardewModdingAPI.Framework /********* ** Accessors *********/ - /// The full path to the content pack's folder. + /// public string DirectoryPath { get; } - /// The content pack's manifest. + /// public IManifest Manifest { get; } - /// Provides translations stored in the content pack's i18n folder. See for more info. + /// public ITranslationHelper Translation { get; } @@ -52,8 +52,7 @@ namespace StardewModdingAPI.Framework this.JsonHelper = jsonHelper; } - /// Get whether a given file exists in the content pack. - /// The file path to check. + /// public bool HasFile(string path) { this.AssertRelativePath(path, nameof(this.HasFile)); @@ -61,11 +60,7 @@ namespace StardewModdingAPI.Framework return File.Exists(Path.Combine(this.DirectoryPath, path)); } - /// Read a JSON file from the content pack folder. - /// The model type. - /// The file path relative to the content directory. - /// Returns the deserialized model, or null if the file doesn't exist or is empty. - /// The is not relative or contains directory climbing (../). + /// public TModel ReadJsonFile(string path) where TModel : class { this.AssertRelativePath(path, nameof(this.ReadJsonFile)); @@ -76,11 +71,7 @@ namespace StardewModdingAPI.Framework : null; } - /// Save data to a JSON file in the content pack's folder. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The file path relative to the mod folder. - /// The arbitrary data to save. - /// The is not relative or contains directory climbing (../). + /// public void WriteJsonFile(string path, TModel data) where TModel : class { this.AssertRelativePath(path, nameof(this.WriteJsonFile)); @@ -89,19 +80,13 @@ namespace StardewModdingAPI.Framework this.JsonHelper.WriteJsonFile(path, data); } - /// Load content from the content pack folder (if not already cached), and return it. When loading a .png file, this must be called outside the game's draw loop. - /// The expected data type. The main supported types are , , and dictionaries; other types may be supported by the game's content pipeline. - /// The local path to a content file relative to the content pack folder. - /// The is empty or contains invalid characters. - /// The content asset couldn't be loaded (e.g. because it doesn't exist). + /// public T LoadAsset(string key) { return this.Content.Load(key, ContentSource.ModFolder); } - /// Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists. - /// The the local path to a content file relative to the content pack folder. - /// The is empty or contains invalid characters. + /// public string GetActualAssetKey(string key) { return this.Content.GetActualAssetKey(key, ContentSource.ModFolder); diff --git a/src/SMAPI/Framework/CursorPosition.cs b/src/SMAPI/Framework/CursorPosition.cs index 2008ccce..80d89994 100644 --- a/src/SMAPI/Framework/CursorPosition.cs +++ b/src/SMAPI/Framework/CursorPosition.cs @@ -8,16 +8,16 @@ namespace StardewModdingAPI.Framework /********* ** Accessors *********/ - /// The pixel position relative to the top-left corner of the in-game map, adjusted for pixel zoom. + /// public Vector2 AbsolutePixels { get; } - /// The pixel position relative to the top-left corner of the visible screen, adjusted for pixel zoom. + /// public Vector2 ScreenPixels { get; } - /// The tile position under the cursor relative to the top-left corner of the map. + /// public Vector2 Tile { get; } - /// The tile position that the game considers under the cursor for purposes of clicking actions. This may be different than if that's too far from the player. + /// public Vector2 GrabTile { get; } @@ -37,8 +37,7 @@ namespace StardewModdingAPI.Framework this.GrabTile = grabTile; } - /// Get whether the current object is equal to another object of the same type. - /// An object to compare with this object. + /// public bool Equals(ICursorPosition other) { return other != null && this.AbsolutePixels == other.AbsolutePixels; diff --git a/src/SMAPI/Framework/GameVersion.cs b/src/SMAPI/Framework/GameVersion.cs index 3ed60920..b69c6757 100644 --- a/src/SMAPI/Framework/GameVersion.cs +++ b/src/SMAPI/Framework/GameVersion.cs @@ -38,7 +38,7 @@ namespace StardewModdingAPI.Framework public GameVersion(string version) : base(GameVersion.GetSemanticVersionString(version), allowNonStandard: true) { } - /// Get a string representation of the version. + /// public override string ToString() { return GameVersion.GetGameVersionString(base.ToString()); diff --git a/src/SMAPI/Framework/ModHelpers/BaseHelper.cs b/src/SMAPI/Framework/ModHelpers/BaseHelper.cs index 16032da1..5a3d4bed 100644 --- a/src/SMAPI/Framework/ModHelpers/BaseHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/BaseHelper.cs @@ -1,4 +1,4 @@ -namespace StardewModdingAPI.Framework.ModHelpers +namespace StardewModdingAPI.Framework.ModHelpers { /// The common base class for mod helpers. internal abstract class BaseHelper : IModLinked @@ -6,7 +6,7 @@ /********* ** Accessors *********/ - /// The unique ID of the mod for which the helper was created. + /// public string ModID { get; } diff --git a/src/SMAPI/Framework/ModHelpers/CommandHelper.cs b/src/SMAPI/Framework/ModHelpers/CommandHelper.cs index e9d53d84..600f867f 100644 --- a/src/SMAPI/Framework/ModHelpers/CommandHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/CommandHelper.cs @@ -28,23 +28,14 @@ namespace StardewModdingAPI.Framework.ModHelpers this.CommandManager = commandManager; } - /// Add a console command. - /// The command name, which the user must type to trigger it. - /// The human-readable documentation shown when the player runs the built-in 'help' command. - /// The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user. - /// The or is null or empty. - /// The is not a valid format. - /// There's already a command with that name. + /// public ICommandHelper Add(string name, string documentation, Action callback) { this.CommandManager.Add(this.Mod, name, documentation, callback); return this; } - /// Trigger a command. - /// The command name. - /// The command arguments. - /// Returns whether a matching command was triggered. + /// public bool Trigger(string name, string[] arguments) { return this.CommandManager.Trigger(name, arguments); diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs index 23e45fd1..80f61c13 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs @@ -40,10 +40,10 @@ namespace StardewModdingAPI.Framework.ModHelpers /********* ** Accessors *********/ - /// The game's current locale code (like pt-BR). + /// public string CurrentLocale => this.GameContentManager.GetLocale(); - /// The game's current locale as an enum value. + /// public LocalizedContentManager.LanguageCode CurrentLocaleConstant => this.GameContentManager.Language; /// The observable implementation of . @@ -52,10 +52,10 @@ namespace StardewModdingAPI.Framework.ModHelpers /// The observable implementation of . internal ObservableCollection ObservableAssetLoaders { get; } = new ObservableCollection(); - /// Interceptors which provide the initial versions of matching content assets. + /// public IList AssetLoaders => this.ObservableAssetLoaders; - /// Interceptors which edit matching content assets after they're loaded. + /// public IList AssetEditors => this.ObservableAssetEditors; @@ -80,12 +80,7 @@ namespace StardewModdingAPI.Framework.ModHelpers this.Monitor = monitor; } - /// Load content from the game folder or mod folder (if not already cached), and return it. When loading a .png file, this must be called outside the game's draw loop. - /// The expected data type. The main supported types are , , and dictionaries; other types may be supported by the game's content pipeline. - /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. - /// Where to search for a matching content asset. - /// The is empty or contains invalid characters. - /// The content asset couldn't be loaded (e.g. because it doesn't exist). + /// public T Load(string key, ContentSource source = ContentSource.ModFolder) { try @@ -109,18 +104,14 @@ namespace StardewModdingAPI.Framework.ModHelpers } } - /// Normalize an asset name so it's consistent with those generated by the game. This is mainly useful for string comparisons like on generated asset names, and isn't necessary when passing asset names into other content helper methods. - /// The asset key. + /// [Pure] public string NormalizeAssetName(string assetName) { return this.ModContentManager.AssertAndNormalizeAssetName(assetName); } - /// Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists. - /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. - /// Where to search for a matching content asset. - /// The is empty or contains invalid characters. + /// public string GetActualAssetKey(string key, ContentSource source = ContentSource.ModFolder) { switch (source) @@ -136,10 +127,7 @@ namespace StardewModdingAPI.Framework.ModHelpers } } - /// 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. - /// The asset key to invalidate in the content folder. - /// The is empty or contains invalid characters. - /// Returns whether the given asset key was cached. + /// public bool InvalidateCache(string key) { string actualKey = this.GetActualAssetKey(key, ContentSource.GameContent); @@ -147,28 +135,21 @@ namespace StardewModdingAPI.Framework.ModHelpers return this.ContentCore.InvalidateCache(asset => asset.AssetNameEquals(actualKey)).Any(); } - /// Remove all assets of the given type from the cache so they're reloaded on the next request. This can be a very expensive operation and should only be used in very specific cases. This will reload core game assets if needed, but references to the former assets will still show the previous content. - /// The asset type to remove from the cache. - /// Returns whether any assets were invalidated. + /// public bool InvalidateCache() { this.Monitor.Log($"Requested cache invalidation for all assets of type {typeof(T)}. This is an expensive operation and should be avoided if possible.", LogLevel.Trace); return this.ContentCore.InvalidateCache((key, type) => typeof(T).IsAssignableFrom(type)).Any(); } - /// Remove matching assets from the content cache so they're 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. - /// A predicate matching the assets to invalidate. - /// Returns whether any cache entries were invalidated. + /// public bool InvalidateCache(Func predicate) { this.Monitor.Log("Requested cache invalidation for all assets matching a predicate.", LogLevel.Trace); return this.ContentCore.InvalidateCache(predicate).Any(); } - /// Get a patch helper for arbitrary data. - /// The data type. - /// The asset data. - /// The asset name. This is only used for tracking purposes and has no effect on the patch helper. + /// public IAssetData GetPatchHelper(T data, string assetName = null) { if (data == null) diff --git a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs index acdd82a0..d39abc7d 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs @@ -32,27 +32,20 @@ namespace StardewModdingAPI.Framework.ModHelpers this.CreateContentPack = createContentPack; } - /// Get all content packs loaded for this mod. + /// public IEnumerable GetOwned() { return this.ContentPacks.Value; } - /// Create a temporary content pack to read files from a directory, using randomized manifest fields. This will generate fake manifest data; any manifest.json in the directory will be ignored. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. - /// The absolute directory path containing the content pack files. + /// public IContentPack CreateFake(string directoryPath) { string id = Guid.NewGuid().ToString("N"); return this.CreateTemporary(directoryPath, id, id, id, id, new SemanticVersion(1, 0, 0)); } - /// Create a temporary content pack to read files from a directory. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. - /// The absolute directory path containing the content pack files. - /// The content pack's unique ID. - /// The content pack name. - /// The content pack description. - /// The content pack author's name. - /// The content pack version. + /// public IContentPack CreateTemporary(string directoryPath, string id, string name, string description, string author, ISemanticVersion version) { // validate diff --git a/src/SMAPI/Framework/ModHelpers/DataHelper.cs b/src/SMAPI/Framework/ModHelpers/DataHelper.cs index 6cde849c..c232a6dd 100644 --- a/src/SMAPI/Framework/ModHelpers/DataHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/DataHelper.cs @@ -39,11 +39,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /**** ** JSON file ****/ - /// Read data from a JSON file in the mod's folder. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The file path relative to the mod folder. - /// Returns the deserialized model, or null if the file doesn't exist or is empty. - /// The is not relative or contains directory climbing (../). + /// public TModel ReadJsonFile(string path) where TModel : class { if (!PathUtilities.IsSafeRelativePath(path)) @@ -55,11 +51,7 @@ namespace StardewModdingAPI.Framework.ModHelpers : null; } - /// Save data to a JSON file in the mod's folder. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The file path relative to the mod folder. - /// The arbitrary data to save. - /// The is not relative or contains directory climbing (../). + /// public void WriteJsonFile(string path, TModel data) where TModel : class { if (!PathUtilities.IsSafeRelativePath(path)) @@ -72,11 +64,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /**** ** Save file ****/ - /// Read arbitrary data stored in the current save slot. This is only possible if a save has been loaded. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The unique key identifying the data. - /// Returns the parsed data, or null if the entry doesn't exist or is empty. - /// The player hasn't loaded a save file yet or isn't the main player. + /// public TModel ReadSaveData(string key) where TModel : class { if (Context.LoadStage == LoadStage.None) @@ -94,11 +82,7 @@ namespace StardewModdingAPI.Framework.ModHelpers return null; } - /// Save arbitrary data to the current save slot. This is only possible if a save has been loaded, and the data will be lost if the player exits without saving the current day. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The unique key identifying the data. - /// The arbitrary data to save. - /// The player hasn't loaded a save file yet or isn't the main player. + /// public void WriteSaveData(string key, TModel model) where TModel : class { if (Context.LoadStage == LoadStage.None) @@ -123,10 +107,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /**** ** Global app data ****/ - /// Read arbitrary data stored on the local computer, synchronised by GOG/Steam if applicable. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The unique key identifying the data. - /// Returns the parsed data, or null if the entry doesn't exist or is empty. + /// public TModel ReadGlobalData(string key) where TModel : class { string path = this.GetGlobalDataPath(key); @@ -135,10 +116,7 @@ namespace StardewModdingAPI.Framework.ModHelpers : null; } - /// Save arbitrary data to the local computer, synchronised by GOG/Steam if applicable. - /// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types. - /// The unique key identifying the data. - /// The arbitrary data to save. + /// public void WriteGlobalData(string key, TModel data) where TModel : class { string path = this.GetGlobalDataPath(key); diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs index 134ba8d1..09ce3c65 100644 --- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs @@ -24,35 +24,31 @@ namespace StardewModdingAPI.Framework.ModHelpers this.InputState = inputState; } - /// Get the current cursor position. + /// public ICursorPosition GetCursorPosition() { return this.InputState.CursorPosition; } - /// Get whether a button is currently pressed. - /// The button. + /// public bool IsDown(SButton button) { return this.InputState.IsDown(button); } - /// Get whether a button is currently suppressed, so the game won't see it. - /// The button. + /// public bool IsSuppressed(SButton button) { return this.InputState.IsSuppressed(button); } - /// Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event. - /// The button to suppress. + /// public void Suppress(SButton button) { this.InputState.OverrideButton(button, setDown: false); } - /// Get the state of a button. - /// The button to check. + /// public SButtonState GetState(SButton button) { return this.InputState.GetState(button); diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs index 9fbb6072..d9fc8621 100644 --- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs @@ -11,37 +11,37 @@ namespace StardewModdingAPI.Framework.ModHelpers /********* ** Accessors *********/ - /// The full path to the mod's folder. + /// public string DirectoryPath { get; } - /// Manages access to events raised by SMAPI, which let your mod react when something happens in the game. + /// public IModEvents Events { get; } - /// An API for loading content assets. + /// public IContentHelper Content { get; } - /// An API for managing content packs. + /// public IContentPackHelper ContentPacks { get; } - /// An API for reading and writing persistent mod data. + /// public IDataHelper Data { get; } - /// An API for checking and changing input state. + /// public IInputHelper Input { get; } - /// An API for accessing private game code. + /// public IReflectionHelper Reflection { get; } - /// an API for fetching metadata about loaded mods. + /// public IModRegistry ModRegistry { get; } - /// An API for managing console commands. + /// public ICommandHelper ConsoleCommands { get; } - /// Provides multiplayer utilities. + /// public IMultiplayerHelper Multiplayer { get; } - /// An API for reading translations stored in the mod's i18n folder, with one file per locale (like en.json) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like pt-BR.json < pt.json < default.json). + /// public ITranslationHelper Translation { get; } @@ -89,8 +89,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /**** ** Mod config file ****/ - /// Read the mod's configuration file (and create it if needed). - /// The config class type. This should be a plain class that has public properties for the settings you want. These can be complex types. + /// public TConfig ReadConfig() where TConfig : class, new() { @@ -99,9 +98,7 @@ namespace StardewModdingAPI.Framework.ModHelpers return config; } - /// Save to the mod's configuration file. - /// The config class type. - /// The config settings to save. + /// public void WriteConfig(TConfig config) where TConfig : class, new() { @@ -111,7 +108,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /**** ** Disposal ****/ - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// public void Dispose() { // nothing to dispose yet diff --git a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs index f42cb085..ef1ad30c 100644 --- a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs @@ -38,28 +38,25 @@ namespace StardewModdingAPI.Framework.ModHelpers this.Monitor = monitor; } - /// Get metadata for all loaded mods. + /// public IEnumerable GetAll() { return this.Registry.GetAll(); } - /// Get metadata for a loaded mod. - /// The mod's unique ID. - /// Returns the matching mod's metadata, or null if not found. + /// public IModInfo Get(string uniqueID) { return this.Registry.Get(uniqueID); } - /// Get whether a mod has been loaded. - /// The mod's unique ID. + /// public bool IsLoaded(string uniqueID) { return this.Registry.Get(uniqueID) != null; } - /// Get the API provided by a mod, or null if it has none. This signature requires using the API to access the API's properties and methods. + /// public object GetApi(string uniqueID) { // validate ready @@ -76,9 +73,7 @@ namespace StardewModdingAPI.Framework.ModHelpers return mod?.Api; } - /// Get the API provided by a mod, mapped to a given interface which specifies the expected properties and methods. If the mod has no API or it's not compatible with the given interface, get null. - /// The interface which matches the properties and methods you intend to access. - /// The mod's unique ID. + /// public TInterface GetApi(string uniqueID) where TInterface : class { // get raw API diff --git a/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs b/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs index c62dd121..a7ce8692 100644 --- a/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using StardewModdingAPI.Framework.Networking; using StardewValley; @@ -27,21 +26,19 @@ namespace StardewModdingAPI.Framework.ModHelpers this.Multiplayer = multiplayer; } - /// Get a new multiplayer ID. + /// public long GetNewID() { return this.Multiplayer.getNewID(); } - /// Get the locations which are being actively synced from the host. + /// public IEnumerable GetActiveLocations() { return this.Multiplayer.activeLocations(); } - /// Get a connected player. - /// The player's unique ID. - /// Returns the connected player, or null if no such player is connected. + /// public IMultiplayerPeer GetConnectedPlayer(long id) { return this.Multiplayer.Peers.TryGetValue(id, out MultiplayerPeer peer) @@ -49,19 +46,13 @@ namespace StardewModdingAPI.Framework.ModHelpers : null; } - /// Get all connected players. + /// public IEnumerable GetConnectedPlayers() { return this.Multiplayer.Peers.Values; } - /// Send a message to mods installed by connected players. - /// The data type. This can be a class with a default constructor, or a value type. - /// The data to send over the network. - /// A message type which receiving mods can use to decide whether it's the one they want to handle, like SetPlayerLocation. This doesn't need to be globally unique, since mods should check the originating mod ID. - /// The mod IDs which should receive the message on the destination computers, or null for all mods. Specifying mod IDs is recommended to improve performance, unless it's a general-purpose broadcast. - /// The values for the players who should receive the message, or null for all players. If you don't need to broadcast to all players, specifying player IDs is recommended to reduce latency. - /// The or is null. + /// public void SendMessage(TMessage message, string messageType, string[] modIDs = null, long[] playerIDs = null) { this.Multiplayer.BroadcastModMessage( diff --git a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs index 916c215d..5a4ea742 100644 --- a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs @@ -32,11 +32,7 @@ namespace StardewModdingAPI.Framework.ModHelpers this.Reflector = reflector; } - /// Get an instance field. - /// The field type. - /// The object which has the field. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// public IReflectedField GetField(object obj, string name, bool required = true) { return this.AssertAccessAllowed( @@ -44,11 +40,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - /// Get a static field. - /// The field type. - /// The type which has the field. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// public IReflectedField GetField(Type type, string name, bool required = true) { return this.AssertAccessAllowed( @@ -56,11 +48,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - /// Get an instance property. - /// The property type. - /// The object which has the property. - /// The property name. - /// Whether to throw an exception if the property is not found. + /// public IReflectedProperty GetProperty(object obj, string name, bool required = true) { return this.AssertAccessAllowed( @@ -68,11 +56,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - /// Get a static property. - /// The property type. - /// The type which has the property. - /// The property name. - /// Whether to throw an exception if the property is not found. + /// public IReflectedProperty GetProperty(Type type, string name, bool required = true) { return this.AssertAccessAllowed( @@ -80,10 +64,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - /// Get an instance method. - /// The object which has the method. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// public IReflectedMethod GetMethod(object obj, string name, bool required = true) { return this.AssertAccessAllowed( @@ -91,10 +72,7 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } - /// Get a static method. - /// The type which has the method. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// public IReflectedMethod GetMethod(Type type, string name, bool required = true) { return this.AssertAccessAllowed( diff --git a/src/SMAPI/Framework/ModHelpers/TranslationHelper.cs b/src/SMAPI/Framework/ModHelpers/TranslationHelper.cs index be7768e8..a88ca9c9 100644 --- a/src/SMAPI/Framework/ModHelpers/TranslationHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/TranslationHelper.cs @@ -16,10 +16,10 @@ namespace StardewModdingAPI.Framework.ModHelpers /********* ** Accessors *********/ - /// The current locale. + /// public string Locale => this.Translator.Locale; - /// The game's current language code. + /// public LocalizedContentManager.LanguageCode LocaleEnum => this.Translator.LocaleEnum; @@ -37,22 +37,19 @@ namespace StardewModdingAPI.Framework.ModHelpers this.Translator.SetLocale(locale, languageCode); } - /// Get all translations for the current locale. + /// public IEnumerable GetTranslations() { return this.Translator.GetTranslations(); } - /// Get a translation for the current locale. - /// The translation key. + /// public Translation Get(string key) { return this.Translator.Get(key); } - /// Get a translation for the current locale. - /// The translation key. - /// An object containing token key/value pairs. This can be an anonymous object (like new { value = 42, name = "Cranberries" }), a dictionary, or a class instance. + /// public Translation Get(string key, object tokens) { return this.Translator.Get(key, tokens); diff --git a/src/SMAPI/Framework/Monitor.cs b/src/SMAPI/Framework/Monitor.cs index 49b510da..f59a1aa0 100644 --- a/src/SMAPI/Framework/Monitor.cs +++ b/src/SMAPI/Framework/Monitor.cs @@ -34,7 +34,7 @@ namespace StardewModdingAPI.Framework /********* ** Accessors *********/ - /// Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed. + /// public bool IsVerbose { get; } /// Whether to show the full log stamps (with time/level/logger) in the console. If false, shows a simplified stamp with only the logger. @@ -70,25 +70,20 @@ namespace StardewModdingAPI.Framework this.IsVerbose = isVerbose; } - /// Log a message for the player or developer. - /// The message to log. - /// The log severity level. + /// public void Log(string message, LogLevel level = LogLevel.Trace) { this.LogImpl(this.Source, message, (ConsoleLogLevel)level); } - /// Log a message for the player or developer, but only if it hasn't already been logged since the last game launch. - /// The message to log. - /// The log severity level. + /// public void LogOnce(string message, LogLevel level = LogLevel.Trace) { if (this.LogOnceCache.Add($"{message}|{level}")) this.LogImpl(this.Source, message, (ConsoleLogLevel)level); } - /// Log a message that only appears when is enabled. - /// The message to log. + /// public void VerboseLog(string message) { if (this.IsVerbose) diff --git a/src/SMAPI/Framework/Networking/MultiplayerPeer.cs b/src/SMAPI/Framework/Networking/MultiplayerPeer.cs index 6b45b04a..5eda71f6 100644 --- a/src/SMAPI/Framework/Networking/MultiplayerPeer.cs +++ b/src/SMAPI/Framework/Networking/MultiplayerPeer.cs @@ -18,25 +18,25 @@ namespace StardewModdingAPI.Framework.Networking /********* ** Accessors *********/ - /// The player's unique ID. + /// public long PlayerID { get; } - /// Whether this is a connection to the host player. + /// public bool IsHost { get; } - /// Whether the player has SMAPI installed. + /// public bool HasSmapi => this.ApiVersion != null; - /// The player's OS platform, if is true. + /// public GamePlatform? Platform { get; } - /// The installed version of Stardew Valley, if is true. + /// public ISemanticVersion GameVersion { get; } - /// The installed version of SMAPI, if is true. + /// public ISemanticVersion ApiVersion { get; } - /// The installed mods, if is true. + /// public IEnumerable Mods { get; } @@ -62,9 +62,7 @@ namespace StardewModdingAPI.Framework.Networking this.SendMessageImpl = sendMessage; } - /// Get metadata for a mod installed by the player. - /// The unique mod ID. - /// Returns the mod info, or null if the player doesn't have that mod. + /// public IMultiplayerPeerMod GetMod(string id) { if (string.IsNullOrWhiteSpace(id) || this.Mods == null || !this.Mods.Any()) diff --git a/src/SMAPI/Framework/Networking/MultiplayerPeerMod.cs b/src/SMAPI/Framework/Networking/MultiplayerPeerMod.cs index 1b324bcd..8087dc7e 100644 --- a/src/SMAPI/Framework/Networking/MultiplayerPeerMod.cs +++ b/src/SMAPI/Framework/Networking/MultiplayerPeerMod.cs @@ -5,13 +5,13 @@ namespace StardewModdingAPI.Framework.Networking /********* ** Accessors *********/ - /// The mod's display name. + /// public string Name { get; } - /// The unique mod ID. + /// public string ID { get; } - /// The mod version. + /// public ISemanticVersion Version { get; } diff --git a/src/SMAPI/Framework/Reflection/ReflectedField.cs b/src/SMAPI/Framework/Reflection/ReflectedField.cs index d771422c..3c4da4fc 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedField.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedField.cs @@ -23,7 +23,7 @@ namespace StardewModdingAPI.Framework.Reflection /********* ** Accessors *********/ - /// The reflection metadata. + /// public FieldInfo FieldInfo { get; } @@ -55,7 +55,7 @@ namespace StardewModdingAPI.Framework.Reflection this.FieldInfo = field; } - /// Get the field value. + /// public TValue GetValue() { try @@ -72,8 +72,7 @@ namespace StardewModdingAPI.Framework.Reflection } } - /// Set the field value. - //// The value to set. + /// public void SetValue(TValue value) { try diff --git a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs index 82737a7f..26112806 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs @@ -22,7 +22,7 @@ namespace StardewModdingAPI.Framework.Reflection /********* ** Accessors *********/ - /// The reflection metadata. + /// public MethodInfo MethodInfo { get; } @@ -54,9 +54,7 @@ namespace StardewModdingAPI.Framework.Reflection this.MethodInfo = method; } - /// Invoke the method. - /// The return type. - /// The method arguments to pass in. + /// public TValue Invoke(params object[] arguments) { // invoke method @@ -85,8 +83,7 @@ namespace StardewModdingAPI.Framework.Reflection } } - /// Invoke the method. - /// The method arguments to pass in. + /// public void Invoke(params object[] arguments) { // invoke method diff --git a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs index 8a10ff9a..42d7bb59 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs @@ -23,7 +23,7 @@ namespace StardewModdingAPI.Framework.Reflection /********* ** Accessors *********/ - /// The reflection metadata. + /// public PropertyInfo PropertyInfo { get; } @@ -61,7 +61,7 @@ namespace StardewModdingAPI.Framework.Reflection this.SetMethod = (Action)Delegate.CreateDelegate(typeof(Action), obj, this.PropertyInfo.SetMethod); } - /// Get the property value. + /// public TValue GetValue() { if (this.GetMethod == null) @@ -81,8 +81,7 @@ namespace StardewModdingAPI.Framework.Reflection } } - /// Set the property value. - //// The value to set. + /// public void SetValue(TValue value) { if (this.SetMethod == null) diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index f152a3e3..7634685a 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -153,6 +153,9 @@ namespace StardewModdingAPI.Framework /// Whether the game is creating the save file and SMAPI has already raised . private bool IsBetweenCreateEvents; + /// Whether the player just returned to the title screen. + private bool JustReturnedToTitle; + /// Asset interceptors added or removed since the last tick. private readonly List ReloadAssetInterceptorsQueue = new List(); @@ -306,10 +309,10 @@ namespace StardewModdingAPI.Framework }).Start(); // set window titles -#if !SMAPI_FOR_MOBILE - this.Game.Window.Title = $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}"; - this.LogManager.SetConsoleTitle($"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}"); -#endif + this.SetWindowTitles( + game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}", + smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}" + ); } catch (Exception ex) { @@ -324,9 +327,11 @@ namespace StardewModdingAPI.Framework #if !SMAPI_FOR_MOBILE // set window titles - this.Game.Window.Title = $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}"; - this.LogManager.SetConsoleTitle($"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}"); -#endif + this.SetWindowTitles( + game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}", + smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}" + ); + // start game this.Monitor.Log("Starting game...", LogLevel.Debug); try @@ -437,12 +442,13 @@ namespace StardewModdingAPI.Framework this.CheckForUpdatesAsync(mods); } -#if !SMAPI_FOR_MOBILE // update window titles int modsLoaded = this.ModRegistry.GetAll().Count(); - this.Game.Window.Title = $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion} with {modsLoaded} mods"; - this.LogManager.SetConsoleTitle($"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion} with {modsLoaded} mods"); -#else + this.SetWindowTitles( + game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion} with {modsLoaded} mods", + smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion} with {modsLoaded} mods" + ); +#if SMAPI_FOR_MOBILE SGameConsole.Instance.isVisible = false; this.Game.IsGameSuspended = false; }).Start(); @@ -512,6 +518,10 @@ namespace StardewModdingAPI.Framework SCore.DeprecationManager.PrintQueued(); SCore.PerformanceMonitor.PrintQueuedAlerts(); + // reapply overrides + if (this.JustReturnedToTitle && !(Game1.mapDisplayDevice is SDisplayDevice)) + Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice); + /********* ** First-tick initialization *********/ @@ -1170,8 +1180,7 @@ namespace StardewModdingAPI.Framework { // perform cleanup this.Multiplayer.CleanupOnMultiplayerExit(); - if (!(Game1.mapDisplayDevice is SDisplayDevice)) - Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice); + this.JustReturnedToTitle = true; } /// Raised before the game exits. @@ -1279,6 +1288,17 @@ namespace StardewModdingAPI.Framework return !issuesFound; } + /// Set the window titles for the game and console windows. + /// The game window text. + /// The SMAPI window text. + private void SetWindowTitles(string game, string smapi) + { +#if !SMAPI_FOR_MOBILE + this.Game.Window.Title = game; + this.LogManager.SetConsoleTitle(smapi); +#endif + } + /// Asynchronously check for a new version of SMAPI and any installed mods, and print alerts to the console if an update is available. /// The mods to include in the update check (if eligible). private void CheckForUpdatesAsync(IModMetadata[] mods) diff --git a/src/SMAPI/Patches/DialogueErrorPatch.cs b/src/SMAPI/Patches/DialogueErrorPatch.cs index 8043eda3..42494390 100644 --- a/src/SMAPI/Patches/DialogueErrorPatch.cs +++ b/src/SMAPI/Patches/DialogueErrorPatch.cs @@ -33,7 +33,7 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(DialogueErrorPatch); @@ -50,8 +50,7 @@ namespace StardewModdingAPI.Patches } - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) { @@ -78,6 +77,7 @@ namespace StardewModdingAPI.Patches } #endif + /********* ** Private methods *********/ diff --git a/src/SMAPI/Patches/EventErrorPatch.cs b/src/SMAPI/Patches/EventErrorPatch.cs index 4dbb25f3..8fa882d4 100644 --- a/src/SMAPI/Patches/EventErrorPatch.cs +++ b/src/SMAPI/Patches/EventErrorPatch.cs @@ -27,7 +27,7 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(EventErrorPatch); @@ -41,8 +41,7 @@ namespace StardewModdingAPI.Patches EventErrorPatch.MonitorForGame = monitorForGame; } - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) { diff --git a/src/SMAPI/Patches/LoadContextPatch.cs b/src/SMAPI/Patches/LoadContextPatch.cs index 768ddd6b..ceda061b 100644 --- a/src/SMAPI/Patches/LoadContextPatch.cs +++ b/src/SMAPI/Patches/LoadContextPatch.cs @@ -33,7 +33,7 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(LoadContextPatch); @@ -49,8 +49,7 @@ namespace StardewModdingAPI.Patches LoadContextPatch.OnStageChanged = onStageChanged; } - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) #else diff --git a/src/SMAPI/Patches/LoadErrorPatch.cs b/src/SMAPI/Patches/LoadErrorPatch.cs index 5e67b169..f5ee5d71 100644 --- a/src/SMAPI/Patches/LoadErrorPatch.cs +++ b/src/SMAPI/Patches/LoadErrorPatch.cs @@ -34,7 +34,7 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(LoadErrorPatch); @@ -51,8 +51,7 @@ namespace StardewModdingAPI.Patches } - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) #else diff --git a/src/SMAPI/Patches/ObjectErrorPatch.cs b/src/SMAPI/Patches/ObjectErrorPatch.cs index 4edcc64e..64b8e6b6 100644 --- a/src/SMAPI/Patches/ObjectErrorPatch.cs +++ b/src/SMAPI/Patches/ObjectErrorPatch.cs @@ -23,15 +23,14 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(ObjectErrorPatch); /********* ** Public methods *********/ - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) #else diff --git a/src/SMAPI/Patches/ScheduleErrorPatch.cs b/src/SMAPI/Patches/ScheduleErrorPatch.cs index cc2238b0..17db07a6 100644 --- a/src/SMAPI/Patches/ScheduleErrorPatch.cs +++ b/src/SMAPI/Patches/ScheduleErrorPatch.cs @@ -29,7 +29,7 @@ namespace StardewModdingAPI.Patches /********* ** Accessors *********/ - /// A unique name for this patch. + /// public string Name => nameof(ScheduleErrorPatch); @@ -43,8 +43,7 @@ namespace StardewModdingAPI.Patches ScheduleErrorPatch.MonitorForGame = monitorForGame; } - /// Apply the Harmony patch. - /// The Harmony instance. + /// #if HARMONY_2 public void Apply(Harmony harmony) #else diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs index 4a175efe..ae616419 100644 --- a/src/SMAPI/SemanticVersion.cs +++ b/src/SMAPI/SemanticVersion.cs @@ -16,19 +16,19 @@ namespace StardewModdingAPI /********* ** Accessors *********/ - /// The major version incremented for major API changes. + /// public int MajorVersion => this.Version.MajorVersion; - /// The minor version incremented for backwards-compatible changes. + /// public int MinorVersion => this.Version.MinorVersion; - /// The patch version for backwards-compatible bug fixes. + /// public int PatchVersion => this.Version.PatchVersion; - /// An optional prerelease tag. + /// public string PrereleaseTag => this.Version.PrereleaseTag; - /// Optional build metadata. This is ignored when determining version precedence. + /// public string BuildMetadata => this.Version.BuildMetadata; @@ -83,83 +83,68 @@ namespace StardewModdingAPI this.Version = version; } - /// Whether this is a prerelease version. + /// public bool IsPrerelease() { return this.Version.IsPrerelease(); } - /// Get an integer indicating whether this version precedes (less than 0), supersedes (more than 0), or is equivalent to (0) the specified version. - /// The version to compare with this instance. - /// The value is null. + /// /// The implementation is defined by Semantic Version 2.0 (https://semver.org/). public int CompareTo(ISemanticVersion other) { return this.Version.CompareTo(other); } - /// Get whether this version is older than the specified version. - /// The version to compare with this instance. + /// public bool IsOlderThan(ISemanticVersion other) { return this.Version.IsOlderThan(other); } - /// Get whether this version is older than the specified version. - /// The version to compare with this instance. - /// The specified version is not a valid semantic version. + /// public bool IsOlderThan(string other) { return this.Version.IsOlderThan(other); } - /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. + /// public bool IsNewerThan(ISemanticVersion other) { return this.Version.IsNewerThan(other); } - /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. - /// The specified version is not a valid semantic version. + /// public bool IsNewerThan(string other) { return this.Version.IsNewerThan(other); } - /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. + /// public bool IsBetween(ISemanticVersion min, ISemanticVersion max) { return this.Version.IsBetween(min, max); } - /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. - /// One of the specified versions is not a valid semantic version. + /// public bool IsBetween(string min, string max) { return this.Version.IsBetween(min, max); } - /// Indicates whether the current object is equal to another object of the same type. - /// true if the current object is equal to the parameter; otherwise, false. - /// An object to compare with this object. + /// public bool Equals(ISemanticVersion other) { return other != null && this.CompareTo(other) == 0; } - /// Get a string representation of the version. + /// public override string ToString() { return this.Version.ToString(); } - /// Whether the version uses non-standard extensions, like four-part game versions on some platforms. + /// public bool IsNonStandard() { return this.Version.IsNonStandard();