Move CollectionManager out of ModManager

This commit is contained in:
Ottermandias 2022-03-23 11:45:38 +01:00
parent 0eff4e2e67
commit 9c0fc8a8c7
19 changed files with 94 additions and 102 deletions

View file

@ -16,7 +16,7 @@ public class ModsController : WebApiController
[Route( HttpVerbs.Get, "/mods" )] [Route( HttpVerbs.Get, "/mods" )]
public object? GetMods() public object? GetMods()
{ {
return Penumbra.ModManager.Collections.CurrentCollection.Cache?.AvailableMods.Values.Select( x => new return Penumbra.CollectionManager.CurrentCollection.Cache?.AvailableMods.Values.Select( x => new
{ {
x.Settings.Enabled, x.Settings.Enabled,
x.Settings.Priority, x.Settings.Priority,
@ -34,7 +34,7 @@ public class ModsController : WebApiController
[Route( HttpVerbs.Get, "/files" )] [Route( HttpVerbs.Get, "/files" )]
public object GetFiles() public object GetFiles()
{ {
return Penumbra.ModManager.Collections.CurrentCollection.Cache?.ResolvedFiles.ToDictionary( return Penumbra.CollectionManager.CurrentCollection.Cache?.ResolvedFiles.ToDictionary(
o => o.Key.ToString(), o => o.Key.ToString(),
o => o.Value.FullName o => o.Value.FullName
) )

View file

@ -76,7 +76,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
_penumbra!.ObjectReloader.RedrawAll( setting ); _penumbra!.ObjectReloader.RedrawAll( setting );
} }
private static string ResolvePath( string path, ModManager manager, ModCollection collection ) private static string ResolvePath( string path, ModManager _, ModCollection collection )
{ {
if( !Penumbra.Config.EnableMods ) if( !Penumbra.Config.EnableMods )
{ {
@ -85,21 +85,21 @@ public class PenumbraApi : IDisposable, IPenumbraApi
var gamePath = Utf8GamePath.FromString( path, out var p, true ) ? p : Utf8GamePath.Empty; var gamePath = Utf8GamePath.FromString( path, out var p, true ) ? p : Utf8GamePath.Empty;
var ret = collection.Cache?.ResolveSwappedOrReplacementPath( gamePath ); var ret = collection.Cache?.ResolveSwappedOrReplacementPath( gamePath );
ret ??= manager.Collections.ForcedCollection.Cache?.ResolveSwappedOrReplacementPath( gamePath ); ret ??= Penumbra.CollectionManager.ForcedCollection.Cache?.ResolveSwappedOrReplacementPath( gamePath );
return ret?.ToString() ?? path; return ret?.ToString() ?? path;
} }
public string ResolvePath( string path ) public string ResolvePath( string path )
{ {
CheckInitialized(); CheckInitialized();
return ResolvePath( path, Penumbra.ModManager, Penumbra.ModManager.Collections.DefaultCollection ); return ResolvePath( path, Penumbra.ModManager, Penumbra.CollectionManager.DefaultCollection );
} }
public string ResolvePath( string path, string characterName ) public string ResolvePath( string path, string characterName )
{ {
CheckInitialized(); CheckInitialized();
return ResolvePath( path, Penumbra.ModManager, return ResolvePath( path, Penumbra.ModManager,
Penumbra.ModManager.Collections.CharacterCollection.TryGetValue( characterName, out var collection ) Penumbra.CollectionManager.CharacterCollection.TryGetValue( characterName, out var collection )
? collection ? collection
: ModCollection.Empty ); : ModCollection.Empty );
} }
@ -134,7 +134,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
CheckInitialized(); CheckInitialized();
try try
{ {
if( !Penumbra.ModManager.Collections.Collections.TryGetValue( collectionName, out var collection ) ) if( !Penumbra.CollectionManager.Collections.TryGetValue( collectionName, out var collection ) )
{ {
collection = ModCollection.Empty; collection = ModCollection.Empty;
} }

View file

@ -68,12 +68,12 @@ public unsafe partial class PathResolver
CharacterBaseCreateHook?.Enable(); CharacterBaseCreateHook?.Enable();
EnableDrawHook?.Enable(); EnableDrawHook?.Enable();
CharacterBaseDestructorHook?.Enable(); CharacterBaseDestructorHook?.Enable();
Penumbra.ModManager.Collections.CollectionChanged += CheckCollections; Penumbra.CollectionManager.CollectionChanged += CheckCollections;
} }
private void DisableDataHooks() private void DisableDataHooks()
{ {
Penumbra.ModManager.Collections.CollectionChanged -= CheckCollections; Penumbra.CollectionManager.CollectionChanged -= CheckCollections;
CharacterBaseCreateHook?.Disable(); CharacterBaseCreateHook?.Disable();
EnableDrawHook?.Disable(); EnableDrawHook?.Disable();
CharacterBaseDestructorHook?.Disable(); CharacterBaseDestructorHook?.Disable();
@ -161,7 +161,7 @@ public unsafe partial class PathResolver
{ {
if( gameObject == null ) if( gameObject == null )
{ {
return Penumbra.ModManager.Collections.DefaultCollection; return Penumbra.CollectionManager.DefaultCollection;
} }
var name = gameObject->ObjectIndex switch var name = gameObject->ObjectIndex switch
@ -174,9 +174,9 @@ public unsafe partial class PathResolver
} }
?? new Utf8String( gameObject->Name ).ToString(); ?? new Utf8String( gameObject->Name ).ToString();
return Penumbra.ModManager.Collections.CharacterCollection.TryGetValue( name, out var col ) return Penumbra.CollectionManager.CharacterCollection.TryGetValue( name, out var col )
? col ? col
: Penumbra.ModManager.Collections.DefaultCollection; : Penumbra.CollectionManager.DefaultCollection;
} }
// Update collections linked to Game/DrawObjects due to a change in collection configuration. // Update collections linked to Game/DrawObjects due to a change in collection configuration.

View file

@ -163,12 +163,12 @@ public unsafe partial class PathResolver
private ModCollection? GetCollection( IntPtr drawObject ) private ModCollection? GetCollection( IntPtr drawObject )
{ {
var parent = FindParent( drawObject, out var collection ); var parent = FindParent( drawObject, out var collection );
if( parent == null || collection == Penumbra.ModManager.Collections.DefaultCollection ) if( parent == null || collection == Penumbra.CollectionManager.DefaultCollection )
{ {
return null; return null;
} }
return collection.Cache == null ? Penumbra.ModManager.Collections.ForcedCollection : collection; return collection.Cache == null ? Penumbra.CollectionManager.ForcedCollection : collection;
} }
@ -274,7 +274,7 @@ public unsafe partial class PathResolver
{ {
collection = IdentifyCollection( resolver.LastGameObject ); collection = IdentifyCollection( resolver.LastGameObject );
#if USE_CMP #if USE_CMP
if( collection != Penumbra.ModManager.Collections.DefaultCollection && collection.Cache != null ) if( collection != Penumbra.CollectionManager.DefaultCollection && collection.Cache != null )
{ {
collection.SetCmpFiles(); collection.SetCmpFiles();
return new MetaChanger( MetaManipulation.Type.Rsp ); return new MetaChanger( MetaManipulation.Type.Rsp );
@ -309,25 +309,25 @@ public unsafe partial class PathResolver
case MetaManipulation.Type.Eqdp: case MetaManipulation.Type.Eqdp:
if( --_eqdpCounter == 0 ) if( --_eqdpCounter == 0 )
{ {
Penumbra.ModManager.Collections.DefaultCollection.SetEqdpFiles(); Penumbra.CollectionManager.DefaultCollection.SetEqdpFiles();
} }
break; break;
case MetaManipulation.Type.Eqp: case MetaManipulation.Type.Eqp:
if( --_eqpCounter == 0 ) if( --_eqpCounter == 0 )
{ {
Penumbra.ModManager.Collections.DefaultCollection.SetEqpFiles(); Penumbra.CollectionManager.DefaultCollection.SetEqpFiles();
} }
break; break;
case MetaManipulation.Type.Est: case MetaManipulation.Type.Est:
Penumbra.ModManager.Collections.DefaultCollection.SetEstFiles(); Penumbra.CollectionManager.DefaultCollection.SetEstFiles();
break; break;
case MetaManipulation.Type.Gmp: case MetaManipulation.Type.Gmp:
Penumbra.ModManager.Collections.DefaultCollection.SetGmpFiles(); Penumbra.CollectionManager.DefaultCollection.SetGmpFiles();
break; break;
case MetaManipulation.Type.Rsp: case MetaManipulation.Type.Rsp:
Penumbra.ModManager.Collections.DefaultCollection.SetCmpFiles(); Penumbra.CollectionManager.DefaultCollection.SetCmpFiles();
break; break;
} }
} }

View file

@ -104,7 +104,7 @@ public unsafe partial class PathResolver
[MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )]
private IntPtr ResolvePathDetour( IntPtr drawObject, IntPtr path ) private IntPtr ResolvePathDetour( IntPtr drawObject, IntPtr path )
=> ResolvePathDetour( FindParent( drawObject, out var collection ) == null => ResolvePathDetour( FindParent( drawObject, out var collection ) == null
? Penumbra.ModManager.Collections.DefaultCollection ? Penumbra.CollectionManager.DefaultCollection
: collection, path ); : collection, path );
// Weapons have the characters DrawObject as a parent, // Weapons have the characters DrawObject as a parent,
@ -123,7 +123,7 @@ public unsafe partial class PathResolver
{ {
var parent = FindParent( ( IntPtr )parentObject, out var collection ); var parent = FindParent( ( IntPtr )parentObject, out var collection );
return ResolvePathDetour( parent == null return ResolvePathDetour( parent == null
? Penumbra.ModManager.Collections.DefaultCollection ? Penumbra.CollectionManager.DefaultCollection
: collection, path ); : collection, path );
} }
} }
@ -138,7 +138,7 @@ public unsafe partial class PathResolver
} }
var gamePath = new Utf8String( ( byte* )path ); var gamePath = new Utf8String( ( byte* )path );
if( collection == Penumbra.ModManager.Collections.DefaultCollection ) if( collection == Penumbra.CollectionManager.DefaultCollection )
{ {
SetCollection( gamePath, null ); SetCollection( gamePath, null );
return path; return path;

View file

@ -36,7 +36,7 @@ public partial class PathResolver : IDisposable
var nonDefault = HandleMaterialSubFiles( gamePath, out var collection ) || PathCollections.TryGetValue( gamePath.Path, out collection ); var nonDefault = HandleMaterialSubFiles( gamePath, out var collection ) || PathCollections.TryGetValue( gamePath.Path, out collection );
if( !nonDefault ) if( !nonDefault )
{ {
collection = Penumbra.ModManager.Collections.DefaultCollection; collection = Penumbra.CollectionManager.DefaultCollection;
} }
else else
{ {
@ -49,7 +49,7 @@ public partial class PathResolver : IDisposable
var resolved = collection!.ResolveSwappedOrReplacementPath( gamePath ); var resolved = collection!.ResolveSwappedOrReplacementPath( gamePath );
if( resolved == null ) if( resolved == null )
{ {
resolved = Penumbra.ModManager.Collections.ForcedCollection.ResolveSwappedOrReplacementPath( gamePath ); resolved = Penumbra.CollectionManager.ForcedCollection.ResolveSwappedOrReplacementPath( gamePath );
if( resolved == null ) if( resolved == null )
{ {
// We also need to handle defaulted materials against a non-default collection. // We also need to handle defaulted materials against a non-default collection.
@ -61,7 +61,7 @@ public partial class PathResolver : IDisposable
return ( null, collection ); return ( null, collection );
} }
collection = Penumbra.ModManager.Collections.ForcedCollection; collection = Penumbra.CollectionManager.ForcedCollection;
} }
// Since mtrl files load their files separately, we need to add the new, resolved path // Since mtrl files load their files separately, we need to add the new, resolved path

View file

@ -135,7 +135,7 @@ public partial class MetaManager
fileDescriptor->ResourceHandle->FileNameLength = split[ 1 ].Length; fileDescriptor->ResourceHandle->FileNameLength = split[ 1 ].Length;
var ret = Penumbra.ResourceLoader.ReadSqPackHook.Original( resourceManager, fileDescriptor, priority, isSync ); var ret = Penumbra.ResourceLoader.ReadSqPackHook.Original( resourceManager, fileDescriptor, priority, isSync );
if( Penumbra.ModManager.Collections.Collections.TryGetValue( split[ 0 ].ToString(), out var collection ) if( Penumbra.CollectionManager.Collections.TryGetValue( split[ 0 ].ToString(), out var collection )
&& collection.Cache != null && collection.Cache != null
&& collection.Cache.MetaManipulations.Imc.Files.TryGetValue( && collection.Cache.MetaManipulations.Imc.Files.TryGetValue(
Utf8GamePath.FromSpan( split[ 1 ].Span, out var p, false ) ? p : Utf8GamePath.Empty, out var file ) ) Utf8GamePath.FromSpan( split[ 1 ].Span, out var p, false ) ? p : Utf8GamePath.Empty, out var file ) )

View file

@ -521,7 +521,7 @@ public class ModCleanup
} }
} }
foreach( var collection in Penumbra.ModManager.Collections.Collections.Values ) foreach( var collection in Penumbra.CollectionManager.Collections.Values )
{ {
collection.UpdateSetting( baseDir, meta, true ); collection.UpdateSetting( baseDir, meta, true );
} }

View file

@ -260,8 +260,8 @@ public class ModManager
public FullPath? ResolveSwappedOrReplacementPath( Utf8GamePath gameResourcePath ) public FullPath? ResolveSwappedOrReplacementPath( Utf8GamePath gameResourcePath )
{ {
var ret = Collections.DefaultCollection.ResolveSwappedOrReplacementPath( gameResourcePath ); var ret = Penumbra.CollectionManager.DefaultCollection.ResolveSwappedOrReplacementPath( gameResourcePath );
ret ??= Collections.ForcedCollection.ResolveSwappedOrReplacementPath( gameResourcePath ); ret ??= Penumbra.CollectionManager.ForcedCollection.ResolveSwappedOrReplacementPath( gameResourcePath );
return ret; return ret;
} }
} }

View file

@ -82,7 +82,7 @@ public static class ModManagerEditExtensions
manager.Config.Save(); manager.Config.Save();
} }
foreach( var collection in manager.Collections.Collections.Values ) foreach( var collection in Penumbra.CollectionManager.Collections.Values )
{ {
if( collection.Settings.TryGetValue( oldBasePath.Name, out var settings ) ) if( collection.Settings.TryGetValue( oldBasePath.Name, out var settings ) )
{ {
@ -140,7 +140,7 @@ public static class ModManagerEditExtensions
mod.SaveMeta(); mod.SaveMeta();
foreach( var collection in manager.Collections.Collections.Values ) foreach( var collection in Penumbra.CollectionManager.Collections.Values )
{ {
if( !collection.Settings.TryGetValue( mod.BasePath.Name, out var settings ) ) if( !collection.Settings.TryGetValue( mod.BasePath.Name, out var settings ) )
{ {
@ -176,7 +176,7 @@ public static class ModManagerEditExtensions
return ( oldSetting & bitmaskFront ) | ( ( oldSetting & bitmaskBack ) >> 1 ); return ( oldSetting & bitmaskFront ) | ( ( oldSetting & bitmaskBack ) >> 1 );
} }
foreach( var collection in manager.Collections.Collections.Values ) foreach( var collection in Penumbra.CollectionManager.Collections.Values )
{ {
if( !collection.Settings.TryGetValue( mod.BasePath.Name, out var settings ) ) if( !collection.Settings.TryGetValue( mod.BasePath.Name, out var settings ) )
{ {
@ -202,7 +202,7 @@ public static class ModManagerEditExtensions
if( collection.Cache != null && settings.Enabled ) if( collection.Cache != null && settings.Enabled )
{ {
collection.CalculateEffectiveFileList( mod.Resources.MetaManipulations.Count > 0, collection.CalculateEffectiveFileList( mod.Resources.MetaManipulations.Count > 0,
manager.Collections.IsActive( collection ) ); Penumbra.CollectionManager.IsActive( collection ) );
} }
} }
} }

View file

@ -214,7 +214,7 @@ public class Penumbra : IDalamudPlugin
var collection = string.Equals( collectionName, ModCollection.Empty.Name, StringComparison.InvariantCultureIgnoreCase ) var collection = string.Equals( collectionName, ModCollection.Empty.Name, StringComparison.InvariantCultureIgnoreCase )
? ModCollection.Empty ? ModCollection.Empty
: ModManager.Collections.Collections.Values.FirstOrDefault( c : CollectionManager.Collections.Values.FirstOrDefault( c
=> string.Equals( c.Name, collectionName, StringComparison.InvariantCultureIgnoreCase ) ); => string.Equals( c.Name, collectionName, StringComparison.InvariantCultureIgnoreCase ) );
if( collection == null ) if( collection == null )
{ {
@ -225,24 +225,24 @@ public class Penumbra : IDalamudPlugin
switch( type ) switch( type )
{ {
case "default": case "default":
if( collection == ModManager.Collections.DefaultCollection ) if( collection == CollectionManager.DefaultCollection )
{ {
Dalamud.Chat.Print( $"{collection.Name} already is the default collection." ); Dalamud.Chat.Print( $"{collection.Name} already is the default collection." );
return false; return false;
} }
ModManager.Collections.SetCollection( collection, CollectionType.Default ); CollectionManager.SetCollection( collection, CollectionType.Default );
Dalamud.Chat.Print( $"Set {collection.Name} as default collection." ); Dalamud.Chat.Print( $"Set {collection.Name} as default collection." );
SettingsInterface.ResetDefaultCollection(); SettingsInterface.ResetDefaultCollection();
return true; return true;
case "forced": case "forced":
if( collection == ModManager.Collections.ForcedCollection ) if( collection == CollectionManager.ForcedCollection )
{ {
Dalamud.Chat.Print( $"{collection.Name} already is the forced collection." ); Dalamud.Chat.Print( $"{collection.Name} already is the forced collection." );
return false; return false;
} }
ModManager.Collections.SetCollection( collection, CollectionType.Forced ); CollectionManager.SetCollection( collection, CollectionType.Forced );
Dalamud.Chat.Print( $"Set {collection.Name} as forced collection." ); Dalamud.Chat.Print( $"Set {collection.Name} as forced collection." );
SettingsInterface.ResetForcedCollection(); SettingsInterface.ResetForcedCollection();
return true; return true;

View file

@ -26,8 +26,8 @@ public partial class SettingsInterface
} }
var modManager = Penumbra.ModManager; var modManager = Penumbra.ModManager;
var items = modManager.Collections.DefaultCollection.Cache?.ChangedItems ?? new Dictionary< string, object? >(); var items = Penumbra.CollectionManager.DefaultCollection.Cache?.ChangedItems ?? new Dictionary< string, object? >();
var forced = modManager.Collections.ForcedCollection.Cache?.ChangedItems ?? new Dictionary< string, object? >(); var forced = Penumbra.CollectionManager.ForcedCollection.Cache?.ChangedItems ?? new Dictionary< string, object? >();
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTabItem ); using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTabItem );

View file

@ -31,7 +31,7 @@ public partial class SettingsInterface
private void UpdateNames() private void UpdateNames()
{ {
_collections = Penumbra.ModManager.Collections.Collections.Values.Prepend( ModCollection.Empty ).ToArray(); _collections = Penumbra.CollectionManager.Collections.Values.Prepend( ModCollection.Empty ).ToArray();
_collectionNames = string.Join( "\0", _collections.Skip( 1 ).Select( c => c.Name ) ) + '\0'; _collectionNames = string.Join( "\0", _collections.Skip( 1 ).Select( c => c.Name ) ) + '\0';
_collectionNamesWithNone = "None\0" + _collectionNames; _collectionNamesWithNone = "None\0" + _collectionNames;
UpdateIndices(); UpdateIndices();
@ -51,18 +51,18 @@ public partial class SettingsInterface
} }
private void UpdateIndex() private void UpdateIndex()
=> _currentCollectionIndex = GetIndex( Penumbra.ModManager.Collections.CurrentCollection ) - 1; => _currentCollectionIndex = GetIndex( Penumbra.CollectionManager.CurrentCollection ) - 1;
public void UpdateForcedIndex() public void UpdateForcedIndex()
=> _currentForcedIndex = GetIndex( Penumbra.ModManager.Collections.ForcedCollection ); => _currentForcedIndex = GetIndex( Penumbra.CollectionManager.ForcedCollection );
public void UpdateDefaultIndex() public void UpdateDefaultIndex()
=> _currentDefaultIndex = GetIndex( Penumbra.ModManager.Collections.DefaultCollection ); => _currentDefaultIndex = GetIndex( Penumbra.CollectionManager.DefaultCollection );
private void UpdateCharacterIndices() private void UpdateCharacterIndices()
{ {
_currentCharacterIndices.Clear(); _currentCharacterIndices.Clear();
foreach( var kvp in Penumbra.ModManager.Collections.CharacterCollection ) foreach( var kvp in Penumbra.CollectionManager.CharacterCollection )
{ {
_currentCharacterIndices[ kvp.Key ] = GetIndex( kvp.Value ); _currentCharacterIndices[ kvp.Key ] = GetIndex( kvp.Value );
} }
@ -84,11 +84,10 @@ public partial class SettingsInterface
private void CreateNewCollection( Dictionary< string, ModSettings > settings ) private void CreateNewCollection( Dictionary< string, ModSettings > settings )
{ {
var manager = Penumbra.ModManager; if( Penumbra.CollectionManager.AddCollection( _newCollectionName, settings ) )
if( manager.Collections.AddCollection( _newCollectionName, settings ) )
{ {
UpdateNames(); UpdateNames();
SetCurrentCollection( manager.Collections.Collections[ _newCollectionName ], true ); SetCurrentCollection( Penumbra.CollectionManager.Collections[ _newCollectionName ], true );
} }
_newCollectionName = string.Empty; _newCollectionName = string.Empty;
@ -98,10 +97,9 @@ public partial class SettingsInterface
{ {
if( ImGui.Button( "Clean Settings" ) ) if( ImGui.Button( "Clean Settings" ) )
{ {
var manager = Penumbra.ModManager; var changes = ModFunctions.CleanUpCollection( Penumbra.CollectionManager.CurrentCollection.Settings,
var changes = ModFunctions.CleanUpCollection( manager.Collections.CurrentCollection.Settings, Penumbra.ModManager.BasePath.EnumerateDirectories() );
manager.BasePath.EnumerateDirectories() ); Penumbra.CollectionManager.CurrentCollection.UpdateSettings( changes );
manager.Collections.CurrentCollection.UpdateSettings( changes );
} }
ImGuiCustom.HoverTooltip( ImGuiCustom.HoverTooltip(
@ -126,10 +124,9 @@ public partial class SettingsInterface
var hover = ImGui.IsItemHovered(); var hover = ImGui.IsItemHovered();
ImGui.SameLine(); ImGui.SameLine();
var manager = Penumbra.ModManager;
if( ImGui.Button( "Duplicate Current Collection" ) && _newCollectionName.Length > 0 ) if( ImGui.Button( "Duplicate Current Collection" ) && _newCollectionName.Length > 0 )
{ {
CreateNewCollection( manager.Collections.CurrentCollection.Settings ); CreateNewCollection( Penumbra.CollectionManager.CurrentCollection.Settings );
} }
hover |= ImGui.IsItemHovered(); hover |= ImGui.IsItemHovered();
@ -140,13 +137,13 @@ public partial class SettingsInterface
ImGui.SetTooltip( "Please enter a name before creating a collection." ); ImGui.SetTooltip( "Please enter a name before creating a collection." );
} }
var deleteCondition = manager.Collections.Collections.Count > 1 var deleteCondition = Penumbra.CollectionManager.Collections.Count > 1
&& manager.Collections.CurrentCollection.Name != ModCollection.DefaultCollection; && Penumbra.CollectionManager.CurrentCollection.Name != ModCollection.DefaultCollection;
ImGui.SameLine(); ImGui.SameLine();
if( ImGuiCustom.DisableButton( "Delete Current Collection", deleteCondition ) ) if( ImGuiCustom.DisableButton( "Delete Current Collection", deleteCondition ) )
{ {
manager.Collections.RemoveCollection( manager.Collections.CurrentCollection.Name ); Penumbra.CollectionManager.RemoveCollection( Penumbra.CollectionManager.CurrentCollection.Name );
SetCurrentCollection( manager.Collections.CurrentCollection, true ); SetCurrentCollection( Penumbra.CollectionManager.CurrentCollection, true );
UpdateNames(); UpdateNames();
} }
@ -169,7 +166,7 @@ public partial class SettingsInterface
return; return;
} }
Penumbra.ModManager.Collections.SetCollection( _collections[ idx + 1 ], CollectionType.Current ); Penumbra.CollectionManager.SetCollection( _collections[ idx + 1 ], CollectionType.Current );
_currentCollectionIndex = idx; _currentCollectionIndex = idx;
_selector.Cache.TriggerListReset(); _selector.Cache.TriggerListReset();
if( _selector.Mod != null ) if( _selector.Mod != null )
@ -208,7 +205,7 @@ public partial class SettingsInterface
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth ); ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
if( ImGui.Combo( "##Default Collection", ref index, _collectionNamesWithNone ) && index != _currentDefaultIndex ) if( ImGui.Combo( "##Default Collection", ref index, _collectionNamesWithNone ) && index != _currentDefaultIndex )
{ {
Penumbra.ModManager.Collections.SetCollection( _collections[ index ], CollectionType.Default ); Penumbra.CollectionManager.SetCollection( _collections[ index ], CollectionType.Default );
_currentDefaultIndex = index; _currentDefaultIndex = index;
} }
@ -225,18 +222,17 @@ public partial class SettingsInterface
{ {
var index = _currentForcedIndex; var index = _currentForcedIndex;
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth ); ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
var manager = Penumbra.ModManager; using var style = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f, Penumbra.CollectionManager.CharacterCollection.Count == 0 );
using var style = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f, manager.Collections.CharacterCollection.Count == 0 );
if( ImGui.Combo( "##Forced Collection", ref index, _collectionNamesWithNone ) if( ImGui.Combo( "##Forced Collection", ref index, _collectionNamesWithNone )
&& index != _currentForcedIndex && index != _currentForcedIndex
&& manager.Collections.CharacterCollection.Count > 0 ) && Penumbra.CollectionManager.CharacterCollection.Count > 0 )
{ {
manager.Collections.SetCollection( _collections[ index ], CollectionType.Forced ); Penumbra.CollectionManager.SetCollection( _collections[ index ], CollectionType.Forced );
_currentForcedIndex = index; _currentForcedIndex = index;
} }
style.Pop(); style.Pop();
if( manager.Collections.CharacterCollection.Count == 0 && ImGui.IsItemHovered() ) if( Penumbra.CollectionManager.CharacterCollection.Count == 0 && ImGui.IsItemHovered() )
{ {
ImGui.SetTooltip( ImGui.SetTooltip(
"Forced Collections only provide value if you have at least one Character Collection. There is no need to set one until then." ); "Forced Collections only provide value if you have at least one Character Collection. There is no need to set one until then." );
@ -262,7 +258,7 @@ public partial class SettingsInterface
if( ImGuiCustom.DisableButton( "Create New Character Collection", if( ImGuiCustom.DisableButton( "Create New Character Collection",
_newCharacterName.Length > 0 && Penumbra.Config.HasReadCharacterCollectionDesc ) ) _newCharacterName.Length > 0 && Penumbra.Config.HasReadCharacterCollectionDesc ) )
{ {
Penumbra.ModManager.Collections.CreateCharacterCollection( _newCharacterName ); Penumbra.CollectionManager.CreateCharacterCollection( _newCharacterName );
_currentCharacterIndices[ _newCharacterName ] = 0; _currentCharacterIndices[ _newCharacterName ] = 0;
_newCharacterName = string.Empty; _newCharacterName = string.Empty;
} }
@ -344,15 +340,14 @@ public partial class SettingsInterface
DrawDefaultCollectionSelector(); DrawDefaultCollectionSelector();
DrawForcedCollectionSelector(); DrawForcedCollectionSelector();
var manager = Penumbra.ModManager; foreach( var name in Penumbra.CollectionManager.CharacterCollection.Keys.ToArray() )
foreach( var name in manager.Collections.CharacterCollection.Keys.ToArray() )
{ {
var idx = _currentCharacterIndices[ name ]; var idx = _currentCharacterIndices[ name ];
var tmp = idx; var tmp = idx;
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth ); ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
if( ImGui.Combo( $"##{name}collection", ref tmp, _collectionNamesWithNone ) && idx != tmp ) if( ImGui.Combo( $"##{name}collection", ref tmp, _collectionNamesWithNone ) && idx != tmp )
{ {
manager.Collections.SetCollection( _collections[ tmp ], CollectionType.Character, name ); Penumbra.CollectionManager.SetCollection( _collections[ tmp ], CollectionType.Character, name );
_currentCharacterIndices[ name ] = tmp; _currentCharacterIndices[ name ] = tmp;
} }
@ -362,7 +357,7 @@ public partial class SettingsInterface
if( ImGui.Button( $"{FontAwesomeIcon.Trash.ToIconString()}##{name}", Vector2.One * ImGui.GetFrameHeight() ) ) if( ImGui.Button( $"{FontAwesomeIcon.Trash.ToIconString()}##{name}", Vector2.One * ImGui.GetFrameHeight() ) )
{ {
manager.Collections.RemoveCharacterCollection( name ); Penumbra.CollectionManager.RemoveCharacterCollection( name );
} }
font.Pop(); font.Pop();

View file

@ -49,17 +49,16 @@ public partial class SettingsInterface
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTable ); using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTable );
var manager = Penumbra.ModManager; var manager = Penumbra.ModManager;
PrintValue( "Current Collection", manager.Collections.CurrentCollection.Name ); PrintValue( "Current Collection", Penumbra.CollectionManager.CurrentCollection.Name );
PrintValue( " has Cache", ( manager.Collections.CurrentCollection.Cache != null ).ToString() ); PrintValue( " has Cache", ( Penumbra.CollectionManager.CurrentCollection.Cache != null ).ToString() );
PrintValue( "Default Collection", manager.Collections.DefaultCollection.Name ); PrintValue( "Default Collection", Penumbra.CollectionManager.DefaultCollection.Name );
PrintValue( " has Cache", ( manager.Collections.DefaultCollection.Cache != null ).ToString() ); PrintValue( " has Cache", ( Penumbra.CollectionManager.DefaultCollection.Cache != null ).ToString() );
PrintValue( "Forced Collection", manager.Collections.ForcedCollection.Name ); PrintValue( "Forced Collection", Penumbra.CollectionManager.ForcedCollection.Name );
PrintValue( " has Cache", ( manager.Collections.ForcedCollection.Cache != null ).ToString() ); PrintValue( " has Cache", ( Penumbra.CollectionManager.ForcedCollection.Cache != null ).ToString() );
PrintValue( "Mod Manager BasePath", manager.BasePath?.Name ?? "NULL" ); PrintValue( "Mod Manager BasePath", manager.BasePath.Name );
PrintValue( "Mod Manager BasePath-Full", manager.BasePath?.FullName ?? "NULL" ); PrintValue( "Mod Manager BasePath-Full", manager.BasePath.FullName );
PrintValue( "Mod Manager BasePath IsRooted", Path.IsPathRooted( Penumbra.Config.ModDirectory ).ToString() ); PrintValue( "Mod Manager BasePath IsRooted", Path.IsPathRooted( Penumbra.Config.ModDirectory ).ToString() );
PrintValue( "Mod Manager BasePath Exists", PrintValue( "Mod Manager BasePath Exists", Directory.Exists( manager.BasePath.FullName ).ToString() );
manager.BasePath != null ? Directory.Exists( manager.BasePath.FullName ).ToString() : false.ToString() );
PrintValue( "Mod Manager Valid", manager.Valid.ToString() ); PrintValue( "Mod Manager Valid", manager.Valid.ToString() );
//PrintValue( "Resource Loader Enabled", _penumbra.ResourceLoader.IsEnabled.ToString() ); //PrintValue( "Resource Loader Enabled", _penumbra.ResourceLoader.IsEnabled.ToString() );
} }
@ -122,7 +121,7 @@ public partial class SettingsInterface
return; return;
} }
var cache = Penumbra.ModManager.Collections.CurrentCollection.Cache; var cache = Penumbra.CollectionManager.CurrentCollection.Cache;
if( cache == null || !ImGui.BeginTable( "##MissingFilesDebugList", 1, ImGuiTableFlags.RowBg, -Vector2.UnitX ) ) if( cache == null || !ImGui.BeginTable( "##MissingFilesDebugList", 1, ImGuiTableFlags.RowBg, -Vector2.UnitX ) )
{ {
return; return;

View file

@ -141,8 +141,8 @@ public partial class SettingsInterface
const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX; const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;
var modManager = Penumbra.ModManager; var modManager = Penumbra.ModManager;
var defaultCollection = modManager.Collections.DefaultCollection.Cache; var defaultCollection = Penumbra.CollectionManager.DefaultCollection.Cache;
var forcedCollection = modManager.Collections.ForcedCollection.Cache; var forcedCollection = Penumbra.CollectionManager.ForcedCollection.Cache;
var (defaultResolved, defaultMeta) = defaultCollection != null var (defaultResolved, defaultMeta) = defaultCollection != null
? ( defaultCollection.ResolvedFiles.Count, defaultCollection.MetaManipulations.Count ) ? ( defaultCollection.ResolvedFiles.Count, defaultCollection.MetaManipulations.Count )

View file

@ -120,13 +120,13 @@ namespace Penumbra.UI
var lower = filter.ToLowerInvariant(); var lower = filter.ToLowerInvariant();
if( lower.StartsWith( "c:" ) ) if( lower.StartsWith( "c:" ) )
{ {
_modFilterChanges = lower.Substring( 2 ); _modFilterChanges = lower[ 2.. ];
_modFilter = string.Empty; _modFilter = string.Empty;
_modFilterAuthor = string.Empty; _modFilterAuthor = string.Empty;
} }
else if( lower.StartsWith( "a:" ) ) else if( lower.StartsWith( "a:" ) )
{ {
_modFilterAuthor = lower.Substring( 2 ); _modFilterAuthor = lower[ 2.. ];
_modFilter = string.Empty; _modFilter = string.Empty;
_modFilterChanges = string.Empty; _modFilterChanges = string.Empty;
} }
@ -147,11 +147,11 @@ namespace Penumbra.UI
_visibleFolders.Clear(); _visibleFolders.Clear();
PluginLog.Debug( "Resetting mod selector list..." ); PluginLog.Debug( "Resetting mod selector list..." );
if( !_modsInOrder.Any() ) if( _modsInOrder.Count == 0 )
{ {
foreach( var modData in _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst ) ) foreach( var modData in _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst ) )
{ {
var mod = _manager.Collections.CurrentCollection.GetMod( modData ); var mod = Penumbra.CollectionManager.CurrentCollection.GetMod( modData );
_modsInOrder.Add( mod ); _modsInOrder.Add( mod );
_visibleMods.Add( CheckFilters( mod ) ); _visibleMods.Add( CheckFilters( mod ) );
} }

View file

@ -127,7 +127,7 @@ public partial class SettingsInterface
private void Save() private void Save()
{ {
Penumbra.ModManager.Collections.CurrentCollection.Save(); Penumbra.CollectionManager.CurrentCollection.Save();
} }
private void DrawAboutTab() private void DrawAboutTab()
@ -422,11 +422,10 @@ public partial class SettingsInterface
_fullFilenameList = null; _fullFilenameList = null;
_selector.SaveCurrentMod(); _selector.SaveCurrentMod();
// Since files may have changed, we need to recompute effective files. // Since files may have changed, we need to recompute effective files.
var modManager = Penumbra.ModManager; foreach( var collection in Penumbra.CollectionManager.Collections.Values
foreach( var collection in modManager.Collections.Collections.Values
.Where( c => c.Cache != null && c.Settings[ Mod!.Data.BasePath.Name ].Enabled ) ) .Where( c => c.Cache != null && c.Settings[ Mod!.Data.BasePath.Name ].Enabled ) )
{ {
collection.CalculateEffectiveFileList( false, modManager.Collections.IsActive( collection ) ); collection.CalculateEffectiveFileList( false, Penumbra.CollectionManager.IsActive( collection ) );
} }
// If the mod is enabled in the current collection, its conflicts may have changed. // If the mod is enabled in the current collection, its conflicts may have changed.

View file

@ -526,10 +526,10 @@ public partial class SettingsInterface
} }
Cache.TriggerFilterReset(); Cache.TriggerFilterReset();
var collection = Penumbra.ModManager.Collections.CurrentCollection; var collection = Penumbra.CollectionManager.CurrentCollection;
if( collection.Cache != null ) if( collection.Cache != null )
{ {
collection.CalculateEffectiveFileList( metaManips, Penumbra.ModManager.Collections.IsActive( collection ) ); collection.CalculateEffectiveFileList( metaManips, Penumbra.CollectionManager.IsActive( collection ) );
} }
collection.Save(); collection.Save();
@ -609,7 +609,7 @@ public partial class SettingsInterface
private void DrawCollectionButton( string label, string tooltipLabel, float size, ModCollection collection ) private void DrawCollectionButton( string label, string tooltipLabel, float size, ModCollection collection )
{ {
if( collection == ModCollection.Empty if( collection == ModCollection.Empty
|| collection == Penumbra.ModManager.Collections.CurrentCollection ) || collection == Penumbra.CollectionManager.CurrentCollection )
{ {
using var _ = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f ); using var _ = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f );
ImGui.Button( label, Vector2.UnitX * size ); ImGui.Button( label, Vector2.UnitX * size );
@ -638,10 +638,10 @@ public partial class SettingsInterface
- 4 * ImGui.GetStyle().ItemSpacing.X ) - 4 * ImGui.GetStyle().ItemSpacing.X )
/ 2, 5f ); / 2, 5f );
ImGui.SameLine(); ImGui.SameLine();
DrawCollectionButton( "Default", "default", buttonSize, Penumbra.ModManager.Collections.DefaultCollection ); DrawCollectionButton( "Default", "default", buttonSize, Penumbra.CollectionManager.DefaultCollection );
ImGui.SameLine(); ImGui.SameLine();
DrawCollectionButton( "Forced", "forced", buttonSize, Penumbra.ModManager.Collections.ForcedCollection ); DrawCollectionButton( "Forced", "forced", buttonSize, Penumbra.CollectionManager.ForcedCollection );
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth( comboSize ); ImGui.SetNextItemWidth( comboSize );

View file

@ -57,18 +57,17 @@ public partial class SettingsInterface : IDisposable
private void SaveCurrentCollection( bool recalculateMeta ) private void SaveCurrentCollection( bool recalculateMeta )
{ {
var current = Penumbra.ModManager.Collections.CurrentCollection; var current = Penumbra.CollectionManager.CurrentCollection;
current.Save(); current.Save();
RecalculateCurrent( recalculateMeta ); RecalculateCurrent( recalculateMeta );
} }
private void RecalculateCurrent( bool recalculateMeta ) private void RecalculateCurrent( bool recalculateMeta )
{ {
var modManager = Penumbra.ModManager; var current = Penumbra.CollectionManager.CurrentCollection;
var current = modManager.Collections.CurrentCollection;
if( current.Cache != null ) if( current.Cache != null )
{ {
current.CalculateEffectiveFileList( recalculateMeta, modManager.Collections.IsActive( current ) ); current.CalculateEffectiveFileList( recalculateMeta, Penumbra.CollectionManager.IsActive( current ) );
_menu.InstalledTab.Selector.Cache.TriggerFilterReset(); _menu.InstalledTab.Selector.Cache.TriggerFilterReset();
} }
} }