diff --git a/Penumbra/Api/PenumbraApi.cs b/Penumbra/Api/PenumbraApi.cs index a620ff54..b9b18c70 100644 --- a/Penumbra/Api/PenumbraApi.cs +++ b/Penumbra/Api/PenumbraApi.cs @@ -474,7 +474,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi int priority ) { CheckInitialized(); - if( !Penumbra.TempMods.Collections.Values.FindFirst( c => c.Name == collectionName, out var collection ) + if( !Penumbra.TempMods.CollectionByName( collectionName, out var collection ) && !Penumbra.CollectionManager.ByName( collectionName, out collection ) ) { return PenumbraApiEc.CollectionMissing; @@ -511,7 +511,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi public PenumbraApiEc RemoveTemporaryMod( string tag, string collectionName, int priority ) { CheckInitialized(); - if( !Penumbra.TempMods.Collections.Values.FindFirst( c => c.Name == collectionName, out var collection ) + if( !Penumbra.TempMods.CollectionByName( collectionName, out var collection ) && !Penumbra.CollectionManager.ByName( collectionName, out collection ) ) { return PenumbraApiEc.CollectionMissing; diff --git a/Penumbra/Api/TempModManager.cs b/Penumbra/Api/TempModManager.cs index 996306e8..9fb40ec6 100644 --- a/Penumbra/Api/TempModManager.cs +++ b/Penumbra/Api/TempModManager.cs @@ -1,4 +1,7 @@ +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using OtterGui; using Penumbra.Collections; using Penumbra.GameData.ByteString; using Penumbra.Meta.Manipulations; @@ -29,6 +32,9 @@ public class TempModManager public IReadOnlyDictionary< string, ModCollection > Collections => _collections; + public bool CollectionByName( string name, [NotNullWhen( true )] out ModCollection? collection ) + => Collections.Values.FindFirst( c => string.Equals( c.Name, name, StringComparison.OrdinalIgnoreCase ), out collection ); + // These functions to check specific redirections or meta manipulations for existence are currently unused. //public bool IsRegistered( string tag, ModCollection? collection, Utf8GamePath gamePath, out FullPath? fullPath, out int priority ) //{ diff --git a/Penumbra/Interop/Resolver/PathResolver.Material.cs b/Penumbra/Interop/Resolver/PathResolver.Material.cs index a93024b2..450eceab 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Material.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Material.cs @@ -82,8 +82,7 @@ public unsafe partial class PathResolver var lastUnderscore = split.LastIndexOf( ( byte )'_' ); var name = lastUnderscore == -1 ? split.ToString() : split.Substring( 0, lastUnderscore ).ToString(); - if( Penumbra.TempMods.Collections.Values.FindFirst( c => string.Equals( c.Name, name, StringComparison.OrdinalIgnoreCase ), - out var collection ) + if( Penumbra.TempMods.CollectionByName( name, out var collection ) || Penumbra.CollectionManager.ByName( name, out collection ) ) { #if DEBUG diff --git a/Penumbra/Meta/Manager/MetaManager.Imc.cs b/Penumbra/Meta/Manager/MetaManager.Imc.cs index 77c90023..517681ff 100644 --- a/Penumbra/Meta/Manager/MetaManager.Imc.cs +++ b/Penumbra/Meta/Manager/MetaManager.Imc.cs @@ -161,7 +161,7 @@ public partial class MetaManager var lastUnderscore = split.LastIndexOf( ( byte )'_' ); var name = lastUnderscore == -1 ? split.ToString() : split.Substring( 0, lastUnderscore ).ToString(); - if( ( Penumbra.TempMods.Collections.TryGetValue( name, out var collection ) + if( ( Penumbra.TempMods.CollectionByName( name, out var collection ) || Penumbra.CollectionManager.ByName( name, out collection ) ) && collection.HasCache && collection.MetaCache!._imcFiles.TryGetValue( Utf8GamePath.FromSpan( path.Span, out var p ) ? p : Utf8GamePath.Empty, out var file ) )