From 3707f481a567df5149aea00ffb14cddb7b14fccb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 23:53:30 -0400 Subject: extend load conflict resolution into load priority (#766) --- src/SMAPI/Framework/ContentManagers/GameContentManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/Framework/ContentManagers') 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(info).ToArray(); + AssetLoadOperation[] loaders = this.GetLoaders(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 true if only one loader will apply, else false. 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 -- cgit