summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ContentManagers
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-25 23:53:30 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-25 23:53:30 -0400
commit3707f481a567df5149aea00ffb14cddb7b14fccb (patch)
treea078b00dd396853ed23f4f542d1877d6a40c3482 /src/SMAPI/Framework/ContentManagers
parent021891ff0ceb6b327bc196c336aa56ddfaf99b0e (diff)
downloadSMAPI-3707f481a567df5149aea00ffb14cddb7b14fccb.tar.gz
SMAPI-3707f481a567df5149aea00ffb14cddb7b14fccb.tar.bz2
SMAPI-3707f481a567df5149aea00ffb14cddb7b14fccb.zip
extend load conflict resolution into load priority (#766)
Diffstat (limited to 'src/SMAPI/Framework/ContentManagers')
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
index b3e98648..16eddb00 100644
--- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
+using StardewModdingAPI.Events;
using StardewModdingAPI.Framework.Content;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Framework.Reflection;
@@ -275,7 +276,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
// find matching loader
AssetLoadOperation loader;
{
- AssetLoadOperation[] loaders = this.GetLoaders<T>(info).ToArray();
+ AssetLoadOperation[] loaders = this.GetLoaders<T>(info).OrderByDescending(p => p.Priority).ToArray();
if (!this.AssertMaxOneRequiredLoader(info, loaders, out string error))
{
@@ -283,9 +284,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
return null;
}
- loader =
- loaders.FirstOrDefault(p => !p.AllowSkipOnConflict)
- ?? loaders.FirstOrDefault();
+ loader = loaders.FirstOrDefault();
}
// no loader found
@@ -396,7 +395,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
/// <returns>Returns true if only one loader will apply, else false.</returns>
private bool AssertMaxOneRequiredLoader(IAssetInfo info, AssetLoadOperation[] loaders, out string error)
{
- AssetLoadOperation[] required = loaders.Where(p => !p.AllowSkipOnConflict).ToArray();
+ AssetLoadOperation[] required = loaders.Where(p => p.Priority == AssetLoadPriority.Exclusive).ToArray();
if (required.Length <= 1)
{
error = null;
@@ -405,6 +404,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
string[] loaderNames = required
.Select(p => p.Mod.DisplayName + this.GetOnBehalfOfLabel(p.OnBehalfOf))
+ .OrderBy(p => p)
.Distinct()
.ToArray();
string errorPhrase = loaderNames.Length > 1