summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-26 01:43:40 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-26 01:43:40 -0400
commitad8912047beaf84ce34f4918703d55841be13ff0 (patch)
treee7f8c44c4a58bf2baf568b98793c051be6c41cd1 /src/SMAPI/Framework
parente40907ab8b97bd8a557adf683a406413646b1fc5 (diff)
downloadSMAPI-ad8912047beaf84ce34f4918703d55841be13ff0.tar.gz
SMAPI-ad8912047beaf84ce34f4918703d55841be13ff0.tar.bz2
SMAPI-ad8912047beaf84ce34f4918703d55841be13ff0.zip
add asset edit priority (#766)
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Content/AssetEditOperation.cs8
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs1
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs7
3 files changed, 13 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/Content/AssetEditOperation.cs b/src/SMAPI/Framework/Content/AssetEditOperation.cs
index 14db231c..818209fa 100644
--- a/src/SMAPI/Framework/Content/AssetEditOperation.cs
+++ b/src/SMAPI/Framework/Content/AssetEditOperation.cs
@@ -1,4 +1,5 @@
using System;
+using StardewModdingAPI.Events;
namespace StardewModdingAPI.Framework.Content
{
@@ -11,6 +12,9 @@ namespace StardewModdingAPI.Framework.Content
/// <summary>The mod applying the edit.</summary>
public IModMetadata Mod { get; }
+ /// <summary>If there are multiple edits that apply to the same asset, the priority with which this one should be applied.</summary>
+ public AssetEditPriority Priority { get; }
+
/// <summary>The content pack on whose behalf the edit is being applied, if any.</summary>
public IModMetadata OnBehalfOf { get; }
@@ -23,11 +27,13 @@ namespace StardewModdingAPI.Framework.Content
*********/
/// <summary>Construct an instance.</summary>
/// <param name="mod">The mod applying the edit.</param>
+ /// <param name="priority">If there are multiple edits that apply to the same asset, the priority with which this one should be applied.</param>
/// <param name="onBehalfOf">The content pack on whose behalf the edit is being applied, if any.</param>
/// <param name="applyEdit">Apply the edit to an asset.</param>
- public AssetEditOperation(IModMetadata mod, IModMetadata onBehalfOf, Action<IAssetData> applyEdit)
+ public AssetEditOperation(IModMetadata mod, AssetEditPriority priority, IModMetadata onBehalfOf, Action<IAssetData> applyEdit)
{
this.Mod = mod;
+ this.Priority = priority;
this.OnBehalfOf = onBehalfOf;
this.ApplyEdit = applyEdit;
}
diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs
index fc137e50..8e7465de 100644
--- a/src/SMAPI/Framework/ContentCoordinator.cs
+++ b/src/SMAPI/Framework/ContentCoordinator.cs
@@ -640,6 +640,7 @@ namespace StardewModdingAPI.Framework
{
new AssetEditOperation(
mod: editor.Mod,
+ priority: AssetEditPriority.Default,
onBehalfOf: null,
applyEdit: assetData => editor.Data.Edit<T>(assetData)
)
diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
index 16eddb00..a121f4c0 100644
--- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
@@ -82,9 +82,12 @@ namespace StardewModdingAPI.Framework.ContentManagers
AssetLoadOperation[] loaders = this.GetLoaders<object>(info).ToArray();
if (!this.AssertMaxOneRequiredLoader(info, loaders, out string error))
+ {
this.Monitor.Log(error, LogLevel.Warn);
+ return false;
+ }
- return loaders.Length == 1;
+ return loaders.Any();
}
/// <inheritdoc />
@@ -334,7 +337,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
}
// edit asset
- AssetEditOperation[] editors = this.GetEditors<T>(info).ToArray();
+ AssetEditOperation[] editors = this.GetEditors<T>(info).OrderBy(p => p.Priority).ToArray();
foreach (AssetEditOperation editor in editors)
{
IModMetadata mod = editor.Mod;