Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed May 12, 2022
2 parents 09f69d9 + e943ae8 commit a9cadc7
Show file tree
Hide file tree
Showing 26 changed files with 483 additions and 336 deletions.
2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
<Version>3.14.2</Version>
<Version>3.14.3</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Expand Down
15 changes: 15 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
[README](README.md)

# Release notes
## 3.14.3
Released 12 May 2022 for Stardew Valley 1.5.6 or later.

* For players:
* Reduced in-game performance impact.

* For mod authors:
* Refactored how event handling works under the hood, particularly the new content API. This should have no effect on mod usage.
* Verbose mode now logs the in-game time.
* Fixed error when loading a `.xnb` file through the old content API without the file extension.
* Fixed asset propagation for player sprites not fully updating recolor masks in some cases.

* For the web UI:
* Updated the JSON validator/schema for Content Patcher 1.26.0.

## 3.14.2
Released 08 May 2022 for Stardew Valley 1.5.6 or later.

Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ConsoleCommands/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
"Version": "3.14.2",
"Version": "3.14.3",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.14.2"
"MinimumApiVersion": "3.14.3"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ErrorHandler/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Error Handler",
"Author": "SMAPI",
"Version": "3.14.2",
"Version": "3.14.3",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll",
"MinimumApiVersion": "3.14.2"
"MinimumApiVersion": "3.14.3"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.SaveBackup/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
"Version": "3.14.2",
"Version": "3.14.3",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.14.2"
"MinimumApiVersion": "3.14.3"
}
9 changes: 7 additions & 2 deletions src/SMAPI.Web/wwwroot/schemas/content-patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"title": "Format version",
"description": "The format version. You should always use the latest version to enable the latest features, avoid obsolete behavior, and reduce load times.",
"type": "string",
"const": "1.25.0",
"const": "1.26.0",
"@errorMessages": {
"const": "Incorrect value '@value'. You should always use the latest format version (currently 1.25.0) to enable the latest features, avoid obsolete behavior, and reduce load times."
"const": "Incorrect value '@value'. You should always use the latest format version (currently 1.26.0) to enable the latest features, avoid obsolete behavior, and reduce load times."
}
},
"ConfigSchema": {
Expand Down Expand Up @@ -51,6 +51,11 @@
"description": "An optional explanation of the config field for players, shown in UIs like Generic Mod Config Menu.",
"type": "string"
},
"Section": {
"title": "Section",
"description": "An optional section key to group related fields on config UIs. This can be the literal text to show, or you can add a translation with the key 'config.section.<section value>.name' and '.description' to add a translated name & tooltip.",
"type": "string"
},

"additionalProperties": false
},
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static class EarlyConstants
internal static int? LogScreenId { get; set; }

/// <summary>SMAPI's current raw semantic version.</summary>
internal static string RawApiVersion = "3.14.2";
internal static string RawApiVersion = "3.14.3";
}

/// <summary>Contains SMAPI's constants and assumptions.</summary>
Expand Down
43 changes: 31 additions & 12 deletions src/SMAPI/Events/AssetRequestedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class AssetRequestedEventArgs : EventArgs
** Fields
*********/
/// <summary>The mod handling the event.</summary>
private readonly IModMetadata Mod;
private IModMetadata? Mod;

/// <summary>Get the mod metadata for a content pack, if it's a valid content pack for the mod.</summary>
private readonly Func<IModMetadata, string?, string, IModMetadata?> GetOnBehalfOf;
Expand All @@ -37,26 +37,31 @@ public class AssetRequestedEventArgs : EventArgs
public Type DataType => this.AssetInfo.DataType;

/// <summary>The load operations requested by the event handler.</summary>
internal IList<AssetLoadOperation> LoadOperations { get; } = new List<AssetLoadOperation>();
internal List<AssetLoadOperation> LoadOperations { get; } = new();

/// <summary>The edit operations requested by the event handler.</summary>
internal IList<AssetEditOperation> EditOperations { get; } = new List<AssetEditOperation>();
internal List<AssetEditOperation> EditOperations { get; } = new();


/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="mod">The mod handling the event.</param>
/// <param name="assetInfo">The asset info being requested.</param>
/// <param name="getOnBehalfOf">Get the mod metadata for a content pack, if it's a valid content pack for the mod.</param>
internal AssetRequestedEventArgs(IModMetadata mod, IAssetInfo assetInfo, Func<IModMetadata, string?, string, IModMetadata?> getOnBehalfOf)
internal AssetRequestedEventArgs(IAssetInfo assetInfo, Func<IModMetadata, string?, string, IModMetadata?> getOnBehalfOf)
{
this.Mod = mod;
this.AssetInfo = assetInfo;
this.GetOnBehalfOf = getOnBehalfOf;
}

/// <summary>Set the mod handling the event.</summary>
/// <param name="mod">The mod handling the event.</param>
internal void SetMod(IModMetadata mod)
{
this.Mod = mod;
}

/// <summary>Provide the initial instance for the asset, instead of trying to load it from the game's <c>Content</c> folder.</summary>
/// <param name="load">Get the initial instance of an asset.</param>
/// <param name="priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
Expand All @@ -70,10 +75,11 @@ internal AssetRequestedEventArgs(IModMetadata mod, IAssetInfo assetInfo, Func<IM
/// </remarks>
public void LoadFrom(Func<object> load, AssetLoadPriority priority, string? onBehalfOf = null)
{
IModMetadata mod = this.GetMod();
this.LoadOperations.Add(
new AssetLoadOperation(
Mod: this.Mod,
OnBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"),
Mod: mod,
OnBehalfOf: this.GetOnBehalfOf(mod, onBehalfOf, "load assets"),
Priority: priority,
GetData: _ => load()
)
Expand All @@ -94,12 +100,13 @@ public void LoadFrom(Func<object> load, AssetLoadPriority priority, string? onBe
public void LoadFromModFile<TAsset>(string relativePath, AssetLoadPriority priority)
where TAsset : notnull
{
IModMetadata mod = this.GetMod();
this.LoadOperations.Add(
new AssetLoadOperation(
Mod: this.Mod,
Mod: mod,
OnBehalfOf: null,
Priority: priority,
GetData: _ => this.Mod.Mod!.Helper.ModContent.Load<TAsset>(relativePath)
GetData: _ => mod.Mod!.Helper.ModContent.Load<TAsset>(relativePath)
)
);
}
Expand All @@ -117,14 +124,26 @@ public void LoadFromModFile<TAsset>(string relativePath, AssetLoadPriority prior
/// </remarks>
public void Edit(Action<IAssetData> apply, AssetEditPriority priority = AssetEditPriority.Default, string? onBehalfOf = null)
{
IModMetadata mod = this.GetMod();
this.EditOperations.Add(
new AssetEditOperation(
Mod: this.Mod,
Mod: mod,
Priority: priority,
OnBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "edit assets"),
OnBehalfOf: this.GetOnBehalfOf(mod, onBehalfOf, "edit assets"),
ApplyEdit: apply
)
);
}


/*********
** Private methods
*********/
/// <summary>Get the mod handling the event.</summary>
/// <exception cref="InvalidOperationException">This instance hasn't been initialized with the mod metadata yet.</exception>
private IModMetadata GetMod()
{
return this.Mod ?? throw new InvalidOperationException($"This {nameof(AssetRequestedEventArgs)} instance hasn't been initialized yet.");
}
}
}
7 changes: 4 additions & 3 deletions src/SMAPI/Framework/Content/AssetOperationGroup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Collections.Generic;

namespace StardewModdingAPI.Framework.Content
{
/// <summary>A set of operations to apply to an asset for a given <see cref="IAssetEditor"/> or <see cref="IAssetLoader"/> implementation.</summary>
/// <param name="Mod">The mod applying the changes.</param>
/// <summary>A set of operations to apply to an asset.</summary>
/// <param name="LoadOperations">The load operations to apply.</param>
/// <param name="EditOperations">The edit operations to apply.</param>
internal record AssetOperationGroup(IModMetadata Mod, AssetLoadOperation[] LoadOperations, AssetEditOperation[] EditOperations);
internal record AssetOperationGroup(List<AssetLoadOperation> LoadOperations, List<AssetEditOperation> EditOperations);
}
Loading

0 comments on commit a9cadc7

Please sign in to comment.