mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix some enabling stuff. Always use PathResolver. Add counter to materials and imcs.
This commit is contained in:
parent
e8ee729ec5
commit
15602f5be5
6 changed files with 22 additions and 35 deletions
|
|
@ -16,6 +16,9 @@ public partial class ModCollection
|
|||
public bool HasCache
|
||||
=> _cache != null;
|
||||
|
||||
public int RecomputeCounter
|
||||
=> _cache?.RecomputeCounter ?? 0;
|
||||
|
||||
// Only create, do not update.
|
||||
private void CreateCache( bool isDefault )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public partial class ModCollection
|
|||
// Shared caches to avoid allocations.
|
||||
private static readonly Dictionary< Utf8GamePath, FileRegister > RegisteredFiles = new(1024);
|
||||
private static readonly Dictionary< MetaManipulation, FileRegister > RegisteredManipulations = new(1024);
|
||||
private static readonly List< ModSettings? > ResolvedSettings = new(128);
|
||||
private static readonly List< ModSettings? > ResolvedSettings = new(128);
|
||||
|
||||
private readonly ModCollection _collection;
|
||||
private readonly SortedList< string, object? > _changedItems = new();
|
||||
|
|
@ -27,6 +27,10 @@ public partial class ModCollection
|
|||
public readonly MetaManager MetaManipulations;
|
||||
public ConflictCache Conflicts = new();
|
||||
|
||||
// Count the number of recalculations of the effective file list.
|
||||
// This is used for material and imc changes.
|
||||
public int RecomputeCounter { get; private set; } = 0;
|
||||
|
||||
// Obtain currently changed items. Computes them if they haven't been computed before.
|
||||
public IReadOnlyDictionary< string, object? > ChangedItems
|
||||
{
|
||||
|
|
@ -120,6 +124,7 @@ public partial class ModCollection
|
|||
}
|
||||
|
||||
AddMetaFiles();
|
||||
++RecomputeCounter;
|
||||
}
|
||||
|
||||
// Identify and record all manipulated objects for this entire collection.
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ public unsafe partial class PathResolver
|
|||
return false;
|
||||
}
|
||||
|
||||
if( Penumbra.CollectionManager.ByName( split.ToString(), out var collection ) )
|
||||
var lastUnderscore = split.LastIndexOf( ( byte )'_' );
|
||||
var name = lastUnderscore == -1 ? split.ToString() : split.Substring( 0, lastUnderscore ).ToString();
|
||||
if( Penumbra.CollectionManager.ByName( name, out var collection ) )
|
||||
{
|
||||
PluginLog.Verbose( "Using MtrlLoadHandler with collection {$Split:l} for path {$Path:l}.", split, path );
|
||||
SetCollection( path, collection );
|
||||
|
|
@ -100,7 +102,7 @@ public unsafe partial class PathResolver
|
|||
{
|
||||
if( nonDefault && type == ResourceType.Mtrl )
|
||||
{
|
||||
var fullPath = new FullPath( $"|{collection.Name}|{path}" );
|
||||
var fullPath = new FullPath( $"|{collection.RecomputeCounter}_{collection.Name}|{path}" );
|
||||
data = ( fullPath, collection );
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ public partial class PathResolver : IDisposable
|
|||
SetupHumanHooks();
|
||||
SetupWeaponHooks();
|
||||
SetupMetaHooks();
|
||||
Penumbra.CollectionManager.CollectionChanged += OnCollectionChange;
|
||||
}
|
||||
|
||||
// The modified resolver that handles game path resolving.
|
||||
|
|
@ -74,7 +73,7 @@ public partial class PathResolver : IDisposable
|
|||
PluginLog.Debug( "Character Path Resolver enabled." );
|
||||
}
|
||||
|
||||
private void Disable()
|
||||
public void Disable()
|
||||
{
|
||||
if( !Enabled )
|
||||
{
|
||||
|
|
@ -103,23 +102,5 @@ public partial class PathResolver : IDisposable
|
|||
DisposeMtrlHooks();
|
||||
DisposeDataHooks();
|
||||
DisposeMetaHooks();
|
||||
Penumbra.CollectionManager.CollectionChanged -= OnCollectionChange;
|
||||
}
|
||||
|
||||
private void OnCollectionChange( ModCollection.Type type, ModCollection? _1, ModCollection? _2, string? characterName )
|
||||
{
|
||||
if( type != ModCollection.Type.Character )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( Penumbra.CollectionManager.HasCharacterCollections )
|
||||
{
|
||||
Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ public partial class MetaManager
|
|||
}
|
||||
|
||||
private FullPath CreateImcPath( Utf8GamePath path )
|
||||
=> new($"|{_collection.Name}|{path}");
|
||||
=> new($"|{_collection.RecomputeCounter}_{_collection.Name}|{path}");
|
||||
|
||||
private static unsafe bool ImcLoadHandler( Utf8String split, Utf8String path, ResourceManager* resourceManager,
|
||||
SeFileDescriptor* fileDescriptor, int priority, bool isSync, out byte ret )
|
||||
|
|
@ -138,7 +138,10 @@ public partial class MetaManager
|
|||
|
||||
PluginLog.Verbose( "Using ImcLoadHandler for path {$Path:l}.", path );
|
||||
ret = Penumbra.ResourceLoader.ReadSqPackHook.Original( resourceManager, fileDescriptor, priority, isSync );
|
||||
if( Penumbra.CollectionManager.ByName( split.ToString(), out var collection )
|
||||
|
||||
var lastUnderscore = split.LastIndexOf( ( byte )'_' );
|
||||
var name = lastUnderscore == -1 ? split.ToString() : split.Substring( 0, lastUnderscore ).ToString();
|
||||
if( Penumbra.CollectionManager.ByName( name, out var collection )
|
||||
&& collection.HasCache
|
||||
&& collection.MetaCache!.Imc.Files.TryGetValue(
|
||||
Utf8GamePath.FromSpan( path.Span, out var p ) ? p : Utf8GamePath.Empty, out var file ) )
|
||||
|
|
|
|||
|
|
@ -90,11 +90,6 @@ public class Penumbra : IDalamudPlugin
|
|||
HelpMessage = "/penumbra - toggle ui\n/penumbra reload - reload mod file lists & discover any new mods",
|
||||
} );
|
||||
|
||||
if( Config.DebugMode )
|
||||
{
|
||||
ResourceLoader.EnableDebug();
|
||||
}
|
||||
|
||||
ResidentResources.Reload();
|
||||
|
||||
Api = new PenumbraApi( this );
|
||||
|
|
@ -111,6 +106,7 @@ public class Penumbra : IDalamudPlugin
|
|||
if( Config.EnableMods )
|
||||
{
|
||||
ResourceLoader.EnableReplacements();
|
||||
PathResolver.Enable();
|
||||
}
|
||||
|
||||
if( Config.DebugMode )
|
||||
|
|
@ -124,11 +120,6 @@ public class Penumbra : IDalamudPlugin
|
|||
ResourceLoader.EnableFullLogging();
|
||||
}
|
||||
|
||||
if( CollectionManager.HasCharacterCollections )
|
||||
{
|
||||
PathResolver.Enable();
|
||||
}
|
||||
|
||||
ResidentResources.Reload();
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +153,7 @@ public class Penumbra : IDalamudPlugin
|
|||
ResourceLoader.EnableReplacements();
|
||||
CollectionManager.Default.SetFiles();
|
||||
ResidentResources.Reload();
|
||||
PathResolver.Enable();
|
||||
|
||||
Config.Save();
|
||||
ObjectReloader.RedrawAll( RedrawType.Redraw );
|
||||
|
|
@ -179,6 +171,7 @@ public class Penumbra : IDalamudPlugin
|
|||
ResourceLoader.DisableReplacements();
|
||||
CharacterUtility.ResetAll();
|
||||
ResidentResources.Reload();
|
||||
PathResolver.Disable();
|
||||
|
||||
Config.Save();
|
||||
ObjectReloader.RedrawAll( RedrawType.Redraw );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue