Move Mod.Manager and ModCollection.Manager to outer scope and required changes.

This commit is contained in:
Ottermandias 2023-03-27 15:22:39 +02:00
parent ccdafcf85d
commit 1253079968
59 changed files with 2562 additions and 2615 deletions

View file

@ -38,7 +38,7 @@ public class IpcTester : IDisposable
private readonly ModSettings _modSettings; private readonly ModSettings _modSettings;
private readonly Temporary _temporary; private readonly Temporary _temporary;
public IpcTester(DalamudPluginInterface pi, PenumbraIpcProviders ipcProviders, Mod.Manager modManager) public IpcTester(DalamudPluginInterface pi, PenumbraIpcProviders ipcProviders, ModManager modManager)
{ {
_ipcProviders = ipcProviders; _ipcProviders = ipcProviders;
_pluginState = new PluginState(pi); _pluginState = new PluginState(pi);
@ -1139,9 +1139,9 @@ public class IpcTester : IDisposable
private class Temporary private class Temporary
{ {
private readonly DalamudPluginInterface _pi; private readonly DalamudPluginInterface _pi;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
public Temporary(DalamudPluginInterface pi, Mod.Manager modManager) public Temporary(DalamudPluginInterface pi, ModManager modManager)
{ {
_pi = pi; _pi = pi;
_modManager = modManager; _modManager = modManager;

View file

@ -93,10 +93,10 @@ public class PenumbraApi : IDisposable, IPenumbraApi
private Penumbra _penumbra; private Penumbra _penumbra;
private Lumina.GameData? _lumina; private Lumina.GameData? _lumina;
private Mod.Manager _modManager; private ModManager _modManager;
private ResourceLoader _resourceLoader; private ResourceLoader _resourceLoader;
private Configuration _config; private Configuration _config;
private ModCollection.Manager _collectionManager; private CollectionManager _collectionManager;
private DalamudServices _dalamud; private DalamudServices _dalamud;
private TempCollectionManager _tempCollections; private TempCollectionManager _tempCollections;
private TempModManager _tempMods; private TempModManager _tempMods;
@ -104,8 +104,8 @@ public class PenumbraApi : IDisposable, IPenumbraApi
private CollectionResolver _collectionResolver; private CollectionResolver _collectionResolver;
private CutsceneService _cutsceneService; private CutsceneService _cutsceneService;
public unsafe PenumbraApi(CommunicatorService communicator, Penumbra penumbra, Mod.Manager modManager, ResourceLoader resourceLoader, public unsafe PenumbraApi(CommunicatorService communicator, Penumbra penumbra, ModManager modManager, ResourceLoader resourceLoader,
Configuration config, ModCollection.Manager collectionManager, DalamudServices dalamud, TempCollectionManager tempCollections, Configuration config, CollectionManager collectionManager, DalamudServices dalamud, TempCollectionManager tempCollections,
TempModManager tempMods, ActorService actors, CollectionResolver collectionResolver, CutsceneService cutsceneService) TempModManager tempMods, ActorService actors, CollectionResolver collectionResolver, CutsceneService cutsceneService)
{ {
_communicator = communicator; _communicator = communicator;
@ -1021,7 +1021,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
// Resolve a path given by string for a specific collection. // Resolve a path given by string for a specific collection.
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
private string ResolvePath(string path, Mod.Manager _, ModCollection collection) private string ResolvePath(string path, ModManager _, ModCollection collection)
{ {
if (!_config.EnableMods) if (!_config.EnableMods)
return path; return path;

View file

@ -112,7 +112,7 @@ public class PenumbraIpcProviders : IDisposable
internal readonly FuncProvider< string, int, PenumbraApiEc > RemoveTemporaryModAll; internal readonly FuncProvider< string, int, PenumbraApiEc > RemoveTemporaryModAll;
internal readonly FuncProvider< string, string, int, PenumbraApiEc > RemoveTemporaryMod; internal readonly FuncProvider< string, string, int, PenumbraApiEc > RemoveTemporaryMod;
public PenumbraIpcProviders( DalamudPluginInterface pi, IPenumbraApi api, Mod.Manager modManager ) public PenumbraIpcProviders( DalamudPluginInterface pi, IPenumbraApi api, ModManager modManager )
{ {
Api = api; Api = api;

View file

@ -15,26 +15,24 @@ using Penumbra.Util;
namespace Penumbra.Collections; namespace Penumbra.Collections;
public partial class ModCollection public sealed partial class CollectionManager : ISavable
{
public sealed partial class Manager : ISavable
{ {
public const int Version = 1; public const int Version = 1;
// The collection currently selected for changing settings. // The collection currently selected for changing settings.
public ModCollection Current { get; private set; } = Empty; public ModCollection Current { get; private set; } = ModCollection.Empty;
// The collection currently selected is in use either as an active collection or through inheritance. // The collection currently selected is in use either as an active collection or through inheritance.
public bool CurrentCollectionInUse { get; private set; } public bool CurrentCollectionInUse { get; private set; }
// The collection used for general file redirections and all characters not specifically named. // The collection used for general file redirections and all characters not specifically named.
public ModCollection Default { get; private set; } = Empty; public ModCollection Default { get; private set; } = ModCollection.Empty;
// The collection used for all files categorized as UI files. // The collection used for all files categorized as UI files.
public ModCollection Interface { get; private set; } = Empty; public ModCollection Interface { get; private set; } = ModCollection.Empty;
// A single collection that can not be deleted as a fallback for the current collection. // A single collection that can not be deleted as a fallback for the current collection.
private ModCollection DefaultName { get; set; } = Empty; private ModCollection DefaultName { get; set; } = ModCollection.Empty;
// The list of character collections. // The list of character collections.
public readonly IndividualCollections Individuals; public readonly IndividualCollections Individuals;
@ -84,7 +82,7 @@ public partial class ModCollection
return; return;
var newCollection = this[newIdx]; var newCollection = this[newIdx];
if (newIdx > Empty.Index) if (newIdx > ModCollection.Empty.Index)
newCollection.CreateCache(collectionType is CollectionType.Default); newCollection.CreateCache(collectionType is CollectionType.Default);
switch (collectionType) switch (collectionType)
@ -179,7 +177,7 @@ public partial class ModCollection
// Obtain the index of a collection by name. // Obtain the index of a collection by name.
private int GetIndexForCollectionName(string name) private int GetIndexForCollectionName(string name)
=> name.Length == 0 ? Empty.Index : _collections.IndexOf(c => c.Name == name); => name.Length == 0 ? ModCollection.Empty.Index : _collections.IndexOf(c => c.Name == name);
// Load default, current, special, and character collections from config. // Load default, current, special, and character collections from config.
// Then create caches. If a collection does not exist anymore, reset it to an appropriate default. // Then create caches. If a collection does not exist anymore, reset it to an appropriate default.
@ -188,14 +186,14 @@ public partial class ModCollection
var configChanged = !ReadActiveCollections(files, out var jObject); var configChanged = !ReadActiveCollections(files, out var jObject);
// Load the default collection. // Load the default collection.
var defaultName = jObject[nameof(Default)]?.ToObject<string>() ?? (configChanged ? DefaultCollection : Empty.Name); var defaultName = jObject[nameof(Default)]?.ToObject<string>() ?? (configChanged ? ModCollection.DefaultCollection : ModCollection.Empty.Name);
var defaultIdx = GetIndexForCollectionName(defaultName); var defaultIdx = GetIndexForCollectionName(defaultName);
if (defaultIdx < 0) if (defaultIdx < 0)
{ {
Penumbra.ChatService.NotificationMessage( Penumbra.ChatService.NotificationMessage(
$"Last choice of {TutorialService.DefaultCollection} {defaultName} is not available, reset to {Empty.Name}.", "Load Failure", $"Last choice of {TutorialService.DefaultCollection} {defaultName} is not available, reset to {ModCollection.Empty.Name}.", "Load Failure",
NotificationType.Warning); NotificationType.Warning);
Default = Empty; Default = ModCollection.Empty;
configChanged = true; configChanged = true;
} }
else else
@ -209,9 +207,9 @@ public partial class ModCollection
if (interfaceIdx < 0) if (interfaceIdx < 0)
{ {
Penumbra.ChatService.NotificationMessage( Penumbra.ChatService.NotificationMessage(
$"Last choice of {TutorialService.InterfaceCollection} {interfaceName} is not available, reset to {Empty.Name}.", $"Last choice of {TutorialService.InterfaceCollection} {interfaceName} is not available, reset to {ModCollection.Empty.Name}.",
"Load Failure", NotificationType.Warning); "Load Failure", NotificationType.Warning);
Interface = Empty; Interface = ModCollection.Empty;
configChanged = true; configChanged = true;
} }
else else
@ -220,12 +218,12 @@ public partial class ModCollection
} }
// Load the current collection. // Load the current collection.
var currentName = jObject[nameof(Current)]?.ToObject<string>() ?? DefaultCollection; var currentName = jObject[nameof(Current)]?.ToObject<string>() ?? ModCollection.DefaultCollection;
var currentIdx = GetIndexForCollectionName(currentName); var currentIdx = GetIndexForCollectionName(currentName);
if (currentIdx < 0) if (currentIdx < 0)
{ {
Penumbra.ChatService.NotificationMessage( Penumbra.ChatService.NotificationMessage(
$"Last choice of {TutorialService.SelectedCollection} {currentName} is not available, reset to {DefaultCollection}.", $"Last choice of {TutorialService.SelectedCollection} {currentName} is not available, reset to {ModCollection.DefaultCollection}.",
"Load Failure", NotificationType.Warning); "Load Failure", NotificationType.Warning);
Current = DefaultName; Current = DefaultName;
configChanged = true; configChanged = true;
@ -305,9 +303,9 @@ public partial class ModCollection
if (idx < 0) if (idx < 0)
{ {
Penumbra.ChatService.NotificationMessage( Penumbra.ChatService.NotificationMessage(
$"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {Empty.Name}.", "Load Failure", $"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {ModCollection.Empty.Name}.", "Load Failure",
NotificationType.Warning); NotificationType.Warning);
dict.Add(player, Empty); dict.Add(player, ModCollection.Empty);
} }
else else
{ {
@ -364,7 +362,7 @@ public partial class ModCollection
private void RemoveCache(int idx) private void RemoveCache(int idx)
{ {
if (idx != Empty.Index if (idx != ModCollection.Empty.Index
&& idx != Default.Index && idx != Default.Index
&& idx != Interface.Index && idx != Interface.Index
&& idx != Current.Index && idx != Current.Index
@ -419,4 +417,3 @@ public partial class ModCollection
jObj.WriteTo(j); jObj.WriteTo(j);
} }
} }
}

View file

@ -17,11 +17,9 @@ using CharacterUtility = Penumbra.Interop.Services.CharacterUtility;
namespace Penumbra.Collections; namespace Penumbra.Collections;
public partial class ModCollection public sealed partial class CollectionManager : IDisposable, IEnumerable<ModCollection>
{ {
public sealed partial class Manager : IDisposable, IEnumerable<ModCollection> private readonly Mods.ModManager _modManager;
{
private readonly Mod.Manager _modManager;
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly CharacterUtility _characterUtility; private readonly CharacterUtility _characterUtility;
private readonly ResidentResourceManager _residentResources; private readonly ResidentResourceManager _residentResources;
@ -32,7 +30,7 @@ public partial class ModCollection
// It can not be deleted or moved. // It can not be deleted or moved.
private readonly List<ModCollection> _collections = new() private readonly List<ModCollection> _collections = new()
{ {
Empty, ModCollection.Empty,
}; };
public ModCollection this[Index idx] public ModCollection this[Index idx]
@ -58,15 +56,15 @@ public partial class ModCollection
public IEnumerable<ModCollection> GetEnumeratorWithEmpty() public IEnumerable<ModCollection> GetEnumeratorWithEmpty()
=> _collections; => _collections;
public Manager(StartTracker timer, CommunicatorService communicator, FilenameService files, CharacterUtility characterUtility, public CollectionManager(StartTracker timer, CommunicatorService communicator, FilenameService files, CharacterUtility characterUtility,
ResidentResourceManager residentResources, Configuration config, Mod.Manager manager, IndividualCollections individuals) ResidentResourceManager residentResources, Configuration config, Mods.ModManager modManager, IndividualCollections individuals)
{ {
using var time = timer.Measure(StartTimeType.Collections); using var time = timer.Measure(StartTimeType.Collections);
_communicator = communicator; _communicator = communicator;
_characterUtility = characterUtility; _characterUtility = characterUtility;
_residentResources = residentResources; _residentResources = residentResources;
_config = config; _config = config;
_modManager = manager; _modManager = modManager;
Individuals = individuals; Individuals = individuals;
// The collection manager reacts to changes in mods by itself. // The collection manager reacts to changes in mods by itself.
@ -99,7 +97,7 @@ public partial class ModCollection
// and no existing collection results in the same filename as name. // and no existing collection results in the same filename as name.
public bool CanAddCollection(string name, out string fixedName) public bool CanAddCollection(string name, out string fixedName)
{ {
if (!IsValidName(name)) if (!ModCollection.IsValidName(name))
{ {
fixedName = string.Empty; fixedName = string.Empty;
return false; return false;
@ -107,7 +105,7 @@ public partial class ModCollection
name = name.RemoveInvalidPathSymbols().ToLowerInvariant(); name = name.RemoveInvalidPathSymbols().ToLowerInvariant();
if (name.Length == 0 if (name.Length == 0
|| name == Empty.Name.ToLowerInvariant() || name == ModCollection.Empty.Name.ToLowerInvariant()
|| _collections.Any(c => c.Name.RemoveInvalidPathSymbols().ToLowerInvariant() == name)) || _collections.Any(c => c.Name.RemoveInvalidPathSymbols().ToLowerInvariant() == name))
{ {
fixedName = string.Empty; fixedName = string.Empty;
@ -131,7 +129,7 @@ public partial class ModCollection
return false; return false;
} }
var newCollection = duplicate?.Duplicate(name) ?? CreateNewEmpty(name); var newCollection = duplicate?.Duplicate(name) ?? ModCollection.CreateNewEmpty(name);
newCollection.Index = _collections.Count; newCollection.Index = _collections.Count;
_collections.Add(newCollection); _collections.Add(newCollection);
@ -147,7 +145,7 @@ public partial class ModCollection
// Also removes the collection from inheritances of all other collections. // Also removes the collection from inheritances of all other collections.
public bool RemoveCollection(int idx) public bool RemoveCollection(int idx)
{ {
if (idx <= Empty.Index || idx >= _collections.Count) if (idx <= ModCollection.Empty.Index || idx >= _collections.Count)
{ {
Penumbra.Log.Error("Can not remove the empty collection."); Penumbra.Log.Error("Can not remove the empty collection.");
return false; return false;
@ -163,18 +161,18 @@ public partial class ModCollection
SetCollection(DefaultName.Index, CollectionType.Current); SetCollection(DefaultName.Index, CollectionType.Current);
if (idx == Default.Index) if (idx == Default.Index)
SetCollection(Empty.Index, CollectionType.Default); SetCollection(ModCollection.Empty.Index, CollectionType.Default);
for (var i = 0; i < _specialCollections.Length; ++i) for (var i = 0; i < _specialCollections.Length; ++i)
{ {
if (idx == _specialCollections[i]?.Index) if (idx == _specialCollections[i]?.Index)
SetCollection(Empty, (CollectionType)i); SetCollection(ModCollection.Empty, (CollectionType)i);
} }
for (var i = 0; i < Individuals.Count; ++i) for (var i = 0; i < Individuals.Count; ++i)
{ {
if (Individuals[i].Collection.Index == idx) if (Individuals[i].Collection.Index == idx)
SetCollection(Empty, CollectionType.Individual, i); SetCollection(ModCollection.Empty, CollectionType.Individual, i);
} }
var collection = _collections[idx]; var collection = _collections[idx];
@ -304,14 +302,14 @@ public partial class ModCollection
// This can also not be deleted, so there are always at least the empty and a collection with default name. // This can also not be deleted, so there are always at least the empty and a collection with default name.
private void AddDefaultCollection() private void AddDefaultCollection()
{ {
var idx = GetIndexForCollectionName(DefaultCollection); var idx = GetIndexForCollectionName(ModCollection.DefaultCollection);
if (idx >= 0) if (idx >= 0)
{ {
DefaultName = this[idx]; DefaultName = this[idx];
return; return;
} }
var defaultCollection = CreateNewEmpty(DefaultCollection); var defaultCollection = ModCollection.CreateNewEmpty((string)ModCollection.DefaultCollection);
Penumbra.SaveService.ImmediateSave(defaultCollection); Penumbra.SaveService.ImmediateSave(defaultCollection);
defaultCollection.Index = _collections.Count; defaultCollection.Index = _collections.Count;
_collections.Add(defaultCollection); _collections.Add(defaultCollection);
@ -351,7 +349,7 @@ public partial class ModCollection
var inheritances = new List<IReadOnlyList<string>>(); var inheritances = new List<IReadOnlyList<string>>();
foreach (var file in files.CollectionFiles) foreach (var file in files.CollectionFiles)
{ {
var collection = LoadFromFile(file, out var inheritance); var collection = ModCollection.LoadFromFile(file, out var inheritance);
if (collection == null || collection.Name.Length == 0) if (collection == null || collection.Name.Length == 0)
continue; continue;
@ -475,4 +473,3 @@ public partial class ModCollection
return string.Empty; return string.Empty;
} }
} }
}

View file

@ -26,7 +26,7 @@ public partial class IndividualCollections
return ret; return ret;
} }
public bool ReadJObject( JArray? obj, ModCollection.Manager manager ) public bool ReadJObject( JArray? obj, CollectionManager manager )
{ {
if( obj == null ) if( obj == null )
{ {

View file

@ -8,7 +8,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using Penumbra.Interop;
using Penumbra.Interop.Structs; using Penumbra.Interop.Structs;
using Penumbra.Meta.Files; using Penumbra.Meta.Files;
using Penumbra.Meta.Manipulations; using Penumbra.Meta.Manipulations;
@ -20,27 +19,27 @@ namespace Penumbra.Collections;
public partial class ModCollection public partial class ModCollection
{ {
// Only active collections need to have a cache. // Only active collections need to have a cache.
private Cache? _cache; internal ModCollectionCache? _cache;
public bool HasCache public bool HasCache
=> _cache != null; => _cache != null;
// Count the number of changes of the effective file list. // Count the number of changes of the effective file list.
// This is used for material and imc changes. // This is used for material and imc changes.
public int ChangeCounter { get; private set; } public int ChangeCounter { get; internal set; }
// Only create, do not update. // Only create, do not update.
private void CreateCache(bool isDefault) internal void CreateCache(bool isDefault)
{
if (_cache == null)
{ {
if (_cache != null)
return;
CalculateEffectiveFileList(isDefault); CalculateEffectiveFileList(isDefault);
Penumbra.Log.Verbose($"Created new cache for collection {Name}."); Penumbra.Log.Verbose($"Created new cache for collection {Name}.");
} }
}
// Force an update with metadata for this cache. // Force an update with metadata for this cache.
private void ForceCacheUpdate() internal void ForceCacheUpdate()
=> CalculateEffectiveFileList(this == Penumbra.CollectionManager.Default); => CalculateEffectiveFileList(this == Penumbra.CollectionManager.Default);
// Handle temporary mods for this collection. // Handle temporary mods for this collection.
@ -83,7 +82,7 @@ public partial class ModCollection
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool CheckFullPath(Utf8GamePath path, FullPath fullPath) internal static bool CheckFullPath(Utf8GamePath path, FullPath fullPath)
{ {
if (fullPath.InternalName.Length < Utf8GamePath.MaxGamePathLength) if (fullPath.InternalName.Length < Utf8GamePath.MaxGamePathLength)
return true; return true;
@ -127,14 +126,14 @@ public partial class ModCollection
=> Penumbra.Framework.RegisterImportant(nameof(CalculateEffectiveFileList) + Name, () => => Penumbra.Framework.RegisterImportant(nameof(CalculateEffectiveFileList) + Name, () =>
CalculateEffectiveFileListInternal(isDefault)); CalculateEffectiveFileListInternal(isDefault));
private void CalculateEffectiveFileListInternal(bool isDefault) internal void CalculateEffectiveFileListInternal(bool isDefault)
{ {
// Skip the empty collection. // Skip the empty collection.
if (Index == 0) if (Index == 0)
return; return;
Penumbra.Log.Debug($"[{Thread.CurrentThread.ManagedThreadId}] Recalculating effective file list for {AnonymizedName}"); Penumbra.Log.Debug($"[{Thread.CurrentThread.ManagedThreadId}] Recalculating effective file list for {AnonymizedName}");
_cache ??= new Cache(this); _cache ??= new ModCollectionCache(this);
_cache.FullRecalculation(isDefault); _cache.FullRecalculation(isDefault);
Penumbra.Log.Debug($"[{Thread.CurrentThread.ManagedThreadId}] Recalculation of effective file list for {AnonymizedName} finished."); Penumbra.Log.Debug($"[{Thread.CurrentThread.ManagedThreadId}] Recalculation of effective file list for {AnonymizedName} finished.");

View file

@ -15,11 +15,11 @@ namespace Penumbra.Collections;
public record struct ModPath( IMod Mod, FullPath Path ); public record struct ModPath( IMod Mod, FullPath Path );
public record ModConflicts( IMod Mod2, List< object > Conflicts, bool HasPriority, bool Solved ); public record ModConflicts( IMod Mod2, List< object > Conflicts, bool HasPriority, bool Solved );
public partial class ModCollection /// <summary>
{ /// The Cache contains all required temporary data to use a collection.
// The Cache contains all required temporary data to use a collection. /// It will only be setup if a collection gets activated in any way.
// It will only be setup if a collection gets activated in any way. /// </summary>
private class Cache : IDisposable internal class ModCollectionCache : IDisposable
{ {
private readonly ModCollection _collection; private readonly ModCollection _collection;
private readonly SortedList< string, (SingleArray< IMod >, object?) > _changedItems = new(); private readonly SortedList< string, (SingleArray< IMod >, object?) > _changedItems = new();
@ -46,7 +46,7 @@ public partial class ModCollection
} }
// The cache reacts through events on its collection changing. // The cache reacts through events on its collection changing.
public Cache( ModCollection collection ) public ModCollectionCache( ModCollection collection )
{ {
_collection = collection; _collection = collection;
MetaManipulations = new MetaManager( _collection ); MetaManipulations = new MetaManager( _collection );
@ -354,7 +354,7 @@ public partial class ModCollection
// Inside the same mod, conflicts are not recorded. // Inside the same mod, conflicts are not recorded.
private void AddFile( Utf8GamePath path, FullPath file, IMod mod ) private void AddFile( Utf8GamePath path, FullPath file, IMod mod )
{ {
if( !CheckFullPath( path, file ) ) if( !ModCollection.CheckFullPath( path, file ) )
{ {
return; return;
} }
@ -543,4 +543,3 @@ public partial class ModCollection
} }
} }
} }
}

View file

@ -15,7 +15,7 @@ public partial class ModCollection : ISavable
{ {
// Since inheritances depend on other collections existing, // Since inheritances depend on other collections existing,
// we return them as a list to be applied after reading all collections. // we return them as a list to be applied after reading all collections.
private static ModCollection? LoadFromFile(FileInfo file, out IReadOnlyList<string> inheritance) internal static ModCollection? LoadFromFile(FileInfo file, out IReadOnlyList<string> inheritance)
{ {
inheritance = Array.Empty<string>(); inheritance = Array.Empty<string>();
if (!file.Exists) if (!file.Exists)

View file

@ -16,7 +16,7 @@ public partial class ModCollection
// The bool signifies whether the change was in an already inherited collection. // The bool signifies whether the change was in an already inherited collection.
public event Action< bool > InheritanceChanged; public event Action< bool > InheritanceChanged;
private readonly List< ModCollection > _inheritance = new(); internal readonly List< ModCollection > _inheritance = new();
public IReadOnlyList< ModCollection > Inheritance public IReadOnlyList< ModCollection > Inheritance
=> _inheritance; => _inheritance;
@ -98,7 +98,7 @@ public partial class ModCollection
Penumbra.Log.Debug( $"Removed {inheritance.AnonymizedName} from {AnonymizedName} inheritances." ); Penumbra.Log.Debug( $"Removed {inheritance.AnonymizedName} from {AnonymizedName} inheritances." );
} }
private void ClearSubscriptions( ModCollection other ) internal void ClearSubscriptions( ModCollection other )
{ {
other.ModSettingChanged -= OnInheritedModSettingChange; other.ModSettingChanged -= OnInheritedModSettingChange;
other.InheritanceChanged -= OnInheritedInheritanceChange; other.InheritanceChanged -= OnInheritedInheritanceChange;

View file

@ -23,18 +23,18 @@ public partial class ModCollection
// The collection name can contain invalid path characters, // The collection name can contain invalid path characters,
// but after removing those and going to lower case it has to be unique. // but after removing those and going to lower case it has to be unique.
public string Name { get; private init; } public string Name { get; internal init; }
// Get the first two letters of a collection name and its Index (or None if it is the empty collection). // Get the first two letters of a collection name and its Index (or None if it is the empty collection).
public string AnonymizedName public string AnonymizedName
=> this == Empty ? Empty.Name : Name.Length > 2 ? $"{Name[..2]}... ({Index})" : $"{Name} ({Index})"; => this == Empty ? Empty.Name : Name.Length > 2 ? $"{Name[..2]}... ({Index})" : $"{Name} ({Index})";
public int Version { get; private set; } public int Version { get; internal set; }
public int Index { get; private set; } = -1; public int Index { get; internal set; } = -1;
// If a ModSetting is null, it can be inherited from other collections. // If a ModSetting is null, it can be inherited from other collections.
// If no collection provides a setting for the mod, it is just disabled. // If no collection provides a setting for the mod, it is just disabled.
private readonly List<ModSettings?> _settings; internal readonly List<ModSettings?> _settings;
public IReadOnlyList<ModSettings?> Settings public IReadOnlyList<ModSettings?> Settings
=> _settings; => _settings;
@ -115,7 +115,7 @@ public partial class ModCollection
} }
// Add settings for a new appended mod, by checking if the mod had settings from a previous deletion. // Add settings for a new appended mod, by checking if the mod had settings from a previous deletion.
private bool AddMod(Mod mod) internal bool AddMod(Mod mod)
{ {
if (_unusedSettings.TryGetValue(mod.ModPath.Name, out var save)) if (_unusedSettings.TryGetValue(mod.ModPath.Name, out var save))
{ {
@ -130,7 +130,7 @@ public partial class ModCollection
} }
// Move settings from the current mod list to the unused mod settings. // Move settings from the current mod list to the unused mod settings.
private void RemoveMod(Mod mod, int idx) internal void RemoveMod(Mod mod, int idx)
{ {
var settings = _settings[idx]; var settings = _settings[idx];
if (settings != null) if (settings != null)
@ -150,7 +150,7 @@ public partial class ModCollection
} }
// Move all settings to unused settings for rediscovery. // Move all settings to unused settings for rediscovery.
private void PrepareModDiscovery() internal void PrepareModDiscovery()
{ {
foreach (var (mod, setting) in Penumbra.ModManager.Zip(_settings).Where(s => s.Second != null)) foreach (var (mod, setting) in Penumbra.ModManager.Zip(_settings).Where(s => s.Second != null))
_unusedSettings[mod.ModPath.Name] = new ModSettings.SavedSettings(setting!, mod); _unusedSettings[mod.ModPath.Name] = new ModSettings.SavedSettings(setting!, mod);
@ -160,7 +160,7 @@ public partial class ModCollection
// Apply all mod settings from unused settings to the current set of mods. // Apply all mod settings from unused settings to the current set of mods.
// Also fixes invalid settings. // Also fixes invalid settings.
private void ApplyModSettings() internal void ApplyModSettings()
{ {
_settings.Capacity = Math.Max(_settings.Capacity, Penumbra.ModManager.Count); _settings.Capacity = Math.Max(_settings.Capacity, Penumbra.ModManager.Count);
if (Penumbra.ModManager.Aggregate(false, (current, mod) => current | AddMod(mod))) if (Penumbra.ModManager.Aggregate(false, (current, mod) => current | AddMod(mod)))

View file

@ -27,12 +27,12 @@ public class CommandHandler : IDisposable
private readonly Configuration _config; private readonly Configuration _config;
private readonly ConfigWindow _configWindow; private readonly ConfigWindow _configWindow;
private readonly ActorManager _actors; private readonly ActorManager _actors;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly Penumbra _penumbra; private readonly Penumbra _penumbra;
public CommandHandler(Framework framework, CommandManager commandManager, ChatGui chat, RedrawService redrawService, Configuration config, public CommandHandler(Framework framework, CommandManager commandManager, ChatGui chat, RedrawService redrawService, Configuration config,
ConfigWindow configWindow, Mod.Manager modManager, ModCollection.Manager collectionManager, ActorService actors, Penumbra penumbra) ConfigWindow configWindow, ModManager modManager, CollectionManager collectionManager, ActorService actors, Penumbra penumbra)
{ {
_commandManager = commandManager; _commandManager = commandManager;
_redrawService = redrawService; _redrawService = redrawService;

View file

@ -36,10 +36,10 @@ public partial class TexToolsImporter : IDisposable
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModEditor _editor; private readonly ModEditor _editor;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
public TexToolsImporter( DirectoryInfo baseDirectory, int count, IEnumerable< FileInfo > modPackFiles, public TexToolsImporter( DirectoryInfo baseDirectory, int count, IEnumerable< FileInfo > modPackFiles,
Action< FileInfo, DirectoryInfo?, Exception? > handler, Configuration config, ModEditor editor, Mod.Manager modManager) Action< FileInfo, DirectoryInfo?, Exception? > handler, Configuration config, ModEditor editor, ModManager modManager)
{ {
_baseDirectory = baseDirectory; _baseDirectory = baseDirectory;
_tmpFile = Path.Combine( _baseDirectory.FullName, TempFileName ); _tmpFile = Path.Combine( _baseDirectory.FullName, TempFileName );

View file

@ -31,12 +31,12 @@ public unsafe class CollectionResolver
private readonly CutsceneService _cutscenes; private readonly CutsceneService _cutscenes;
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly TempCollectionManager _tempCollections; private readonly TempCollectionManager _tempCollections;
private readonly DrawObjectState _drawObjectState; private readonly DrawObjectState _drawObjectState;
public CollectionResolver(PerformanceTracker performance, IdentifiedCollectionCache cache, ClientState clientState, GameGui gameGui, public CollectionResolver(PerformanceTracker performance, IdentifiedCollectionCache cache, ClientState clientState, GameGui gameGui,
DataManager gameData, ActorService actors, CutsceneService cutscenes, Configuration config, ModCollection.Manager collectionManager, DataManager gameData, ActorService actors, CutsceneService cutscenes, Configuration config, CollectionManager collectionManager,
TempCollectionManager tempCollections, DrawObjectState drawObjectState) TempCollectionManager tempCollections, DrawObjectState drawObjectState)
{ {
_performance = performance; _performance = performance;

View file

@ -16,7 +16,7 @@ public class PathResolver : IDisposable
{ {
private readonly PerformanceTracker _performance; private readonly PerformanceTracker _performance;
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly TempCollectionManager _tempCollections; private readonly TempCollectionManager _tempCollections;
private readonly ResourceLoader _loader; private readonly ResourceLoader _loader;
@ -25,7 +25,7 @@ public class PathResolver : IDisposable
private readonly PathState _pathState; private readonly PathState _pathState;
private readonly MetaState _metaState; private readonly MetaState _metaState;
public unsafe PathResolver(PerformanceTracker performance, Configuration config, ModCollection.Manager collectionManager, public unsafe PathResolver(PerformanceTracker performance, Configuration config, CollectionManager collectionManager,
TempCollectionManager tempCollections, ResourceLoader loader, AnimationHookService animationHookService, SubfileHelper subfileHelper, TempCollectionManager tempCollections, ResourceLoader loader, AnimationHookService animationHookService, SubfileHelper subfileHelper,
PathState pathState, MetaState metaState) PathState pathState, MetaState metaState)
{ {

View file

@ -11,12 +11,12 @@ namespace Penumbra.Mods;
public class DuplicateManager public class DuplicateManager
{ {
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly SHA256 _hasher = SHA256.Create(); private readonly SHA256 _hasher = SHA256.Create();
private readonly ModFileCollection _files; private readonly ModFileCollection _files;
private readonly List<(FullPath[] Paths, long Size, byte[] Hash)> _duplicates = new(); private readonly List<(FullPath[] Paths, long Size, byte[] Hash)> _duplicates = new();
public DuplicateManager(ModFileCollection files, Mod.Manager modManager) public DuplicateManager(ModFileCollection files, ModManager modManager)
{ {
_files = files; _files = files;
_modManager = modManager; _modManager = modManager;
@ -80,7 +80,7 @@ public class DuplicateManager
} }
else else
{ {
var sub = (Mod.SubMod)subMod; var sub = (SubMod)subMod;
sub.FileData = dict; sub.FileData = dict;
if (groupIdx == -1) if (groupIdx == -1)
mod.SaveDefaultMod(); mod.SaveDefaultMod();

View file

@ -10,12 +10,12 @@ public class ModBackup
{ {
public static bool CreatingBackup { get; private set; } public static bool CreatingBackup { get; private set; }
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly Mod _mod; private readonly Mod _mod;
public readonly string Name; public readonly string Name;
public readonly bool Exists; public readonly bool Exists;
public ModBackup(Mod.Manager modManager, Mod mod) public ModBackup(ModManager modManager, Mod mod)
{ {
_modManager = modManager; _modManager = modManager;
_mod = mod; _mod = mod;
@ -24,9 +24,9 @@ public class ModBackup
} }
/// <summary> Migrate file extensions. </summary> /// <summary> Migrate file extensions. </summary>
public static void MigrateZipToPmp(Mod.Manager manager) public static void MigrateZipToPmp(ModManager modManager)
{ {
foreach (var mod in manager) foreach (var mod in modManager)
{ {
var pmpName = mod.ModPath + ".pmp"; var pmpName = mod.ModPath + ".pmp";
var zipName = mod.ModPath + ".zip"; var zipName = mod.ModPath + ".zip";

View file

@ -9,11 +9,11 @@ namespace Penumbra.Mods;
public class ModFileEditor public class ModFileEditor
{ {
private readonly ModFileCollection _files; private readonly ModFileCollection _files;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
public bool Changes { get; private set; } public bool Changes { get; private set; }
public ModFileEditor(ModFileCollection files, Mod.Manager modManager) public ModFileEditor(ModFileCollection files, ModManager modManager)
{ {
_files = files; _files = files;
_modManager = modManager; _modManager = modManager;
@ -24,7 +24,7 @@ public class ModFileEditor
Changes = false; Changes = false;
} }
public int Apply(Mod mod, Mod.SubMod option) public int Apply(Mod mod, SubMod option)
{ {
var dict = new Dictionary<Utf8GamePath, FullPath>(); var dict = new Dictionary<Utf8GamePath, FullPath>();
var num = 0; var num = 0;

View file

@ -6,7 +6,7 @@ namespace Penumbra.Mods;
public class ModMetaEditor public class ModMetaEditor
{ {
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly HashSet<ImcManipulation> _imc = new(); private readonly HashSet<ImcManipulation> _imc = new();
private readonly HashSet<EqpManipulation> _eqp = new(); private readonly HashSet<EqpManipulation> _eqp = new();
@ -15,7 +15,7 @@ public class ModMetaEditor
private readonly HashSet<EstManipulation> _est = new(); private readonly HashSet<EstManipulation> _est = new();
private readonly HashSet<RspManipulation> _rsp = new(); private readonly HashSet<RspManipulation> _rsp = new();
public ModMetaEditor(Mod.Manager modManager) public ModMetaEditor(ModManager modManager)
=> _modManager = modManager; => _modManager = modManager;
public bool Changes { get; private set; } = false; public bool Changes { get; private set; } = false;

View file

@ -11,7 +11,7 @@ namespace Penumbra.Mods;
public class ModNormalizer public class ModNormalizer
{ {
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly List<List<Dictionary<Utf8GamePath, FullPath>>> _redirections = new(); private readonly List<List<Dictionary<Utf8GamePath, FullPath>>> _redirections = new();
public Mod Mod { get; private set; } = null!; public Mod Mod { get; private set; } = null!;
@ -24,7 +24,7 @@ public class ModNormalizer
public bool Running public bool Running
=> Step < TotalSteps; => Step < TotalSteps;
public ModNormalizer(Mod.Manager modManager) public ModNormalizer(ModManager modManager)
=> _modManager = modManager; => _modManager = modManager;
public void Normalize(Mod mod) public void Normalize(Mod mod)
@ -177,7 +177,7 @@ public class ModNormalizer
_redirections[groupIdx + 1].Add(new Dictionary<Utf8GamePath, FullPath>()); _redirections[groupIdx + 1].Add(new Dictionary<Utf8GamePath, FullPath>());
var groupDir = Mod.Creator.CreateModFolder(directory, group.Name); var groupDir = Mod.Creator.CreateModFolder(directory, group.Name);
foreach (var option in group.OfType<Mod.SubMod>()) foreach (var option in group.OfType<SubMod>())
{ {
var optionDir = Mod.Creator.CreateModFolder(groupDir, option.Name); var optionDir = Mod.Creator.CreateModFolder(groupDir, option.Name);
@ -279,7 +279,7 @@ public class ModNormalizer
private void ApplyRedirections() private void ApplyRedirections()
{ {
foreach (var option in Mod.AllSubMods.OfType<Mod.SubMod>()) foreach (var option in Mod.AllSubMods.OfType<SubMod>())
{ {
_modManager.OptionSetFiles(Mod, option.GroupIdx, option.OptionIdx, _redirections[option.GroupIdx + 1][option.OptionIdx]); _modManager.OptionSetFiles(Mod, option.GroupIdx, option.OptionIdx, _redirections[option.GroupIdx + 1][option.OptionIdx]);
} }

View file

@ -5,13 +5,13 @@ using Penumbra.Util;
public class ModSwapEditor public class ModSwapEditor
{ {
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly Dictionary<Utf8GamePath, FullPath> _swaps = new(); private readonly Dictionary<Utf8GamePath, FullPath> _swaps = new();
public IReadOnlyDictionary<Utf8GamePath, FullPath> Swaps public IReadOnlyDictionary<Utf8GamePath, FullPath> Swaps
=> _swaps; => _swaps;
public ModSwapEditor(Mod.Manager modManager) public ModSwapEditor(ModManager modManager)
=> _modManager = modManager; => _modManager = modManager;
public void Revert(ISubMod option) public void Revert(ISubMod option)

View file

@ -4,9 +4,7 @@ using System.Linq;
namespace Penumbra.Mods; namespace Penumbra.Mods;
public partial class Mod public partial class ModManager
{
public partial class Manager
{ {
public delegate void ModPathChangeDelegate(ModPathChangeType type, Mod mod, DirectoryInfo? oldDirectory, public delegate void ModPathChangeDelegate(ModPathChangeType type, Mod mod, DirectoryInfo? oldDirectory,
DirectoryInfo? newDirectory); DirectoryInfo? newDirectory);
@ -132,8 +130,8 @@ public partial class Mod
if (_mods.Any(m => m.ModPath.Name == modFolder.Name)) if (_mods.Any(m => m.ModPath.Name == modFolder.Name))
return; return;
Creator.SplitMultiGroups(modFolder); Mod.Creator.SplitMultiGroups(modFolder);
var mod = LoadMod(this, modFolder, true); var mod = Mod.LoadMod(this, modFolder, true);
if (mod == null) if (mod == null)
return; return;
@ -164,7 +162,7 @@ public partial class Mod
if (oldName == newName) if (oldName == newName)
return NewDirectoryState.Identical; return NewDirectoryState.Identical;
var fixedNewName = Creator.ReplaceBadXivSymbols(newName); var fixedNewName = Mod.Creator.ReplaceBadXivSymbols(newName);
if (fixedNewName != newName) if (fixedNewName != newName)
return NewDirectoryState.ContainsInvalidSymbols; return NewDirectoryState.ContainsInvalidSymbols;
@ -202,4 +200,3 @@ public partial class Mod
} }
} }
} }
}

View file

@ -1,12 +0,0 @@
using System;
using System.Linq;
namespace Penumbra.Mods;
public sealed partial class Mod
{
public partial class Manager
{
}
}

View file

@ -11,9 +11,7 @@ using Penumbra.Util;
namespace Penumbra.Mods; namespace Penumbra.Mods;
public sealed partial class Mod public sealed partial class ModManager
{
public sealed partial class Manager
{ {
public delegate void ModOptionChangeDelegate(ModOptionChangeType type, Mod mod, int groupIdx, int optionIdx, int movedToIdx); public delegate void ModOptionChangeDelegate(ModOptionChangeType type, Mod mod, int groupIdx, int optionIdx, int movedToIdx);
public event ModOptionChangeDelegate ModOptionChanged; public event ModOptionChangeDelegate ModOptionChanged;
@ -316,7 +314,6 @@ public sealed partial class Mod
"Warning", NotificationType.Warning); "Warning", NotificationType.Warning);
return false; return false;
} }
private static SubMod GetSubMod(Mod mod, int groupIdx, int optionIdx) private static SubMod GetSubMod(Mod mod, int groupIdx, int optionIdx)
@ -378,4 +375,3 @@ public sealed partial class Mod
}; };
} }
} }
}

View file

@ -6,9 +6,7 @@ using System.Threading.Tasks;
namespace Penumbra.Mods; namespace Penumbra.Mods;
public sealed partial class Mod public sealed partial class ModManager
{
public sealed partial class Manager
{ {
public DirectoryInfo BasePath { get; private set; } = null!; public DirectoryInfo BasePath { get; private set; } = null!;
private DirectoryInfo? _exportDirectory; private DirectoryInfo? _exportDirectory;
@ -35,24 +33,19 @@ public sealed partial class Mod
private void SetBaseDirectory(string newPath, bool firstTime) private void SetBaseDirectory(string newPath, bool firstTime)
{ {
if (!firstTime && string.Equals(newPath, Penumbra.Config.ModDirectory, StringComparison.OrdinalIgnoreCase)) if (!firstTime && string.Equals(newPath, Penumbra.Config.ModDirectory, StringComparison.OrdinalIgnoreCase))
{
return; return;
}
if (newPath.Length == 0) if (newPath.Length == 0)
{ {
Valid = false; Valid = false;
BasePath = new DirectoryInfo("."); BasePath = new DirectoryInfo(".");
if (Penumbra.Config.ModDirectory != BasePath.FullName) if (Penumbra.Config.ModDirectory != BasePath.FullName)
{
ModDirectoryChanged.Invoke(string.Empty, false); ModDirectoryChanged.Invoke(string.Empty, false);
} }
}
else else
{ {
var newDir = new DirectoryInfo(newPath); var newDir = new DirectoryInfo(newPath);
if (!newDir.Exists) if (!newDir.Exists)
{
try try
{ {
Directory.CreateDirectory(newDir.FullName); Directory.CreateDirectory(newDir.FullName);
@ -62,16 +55,13 @@ public sealed partial class Mod
{ {
Penumbra.Log.Error($"Could not create specified mod directory {newDir.FullName}:\n{e}"); Penumbra.Log.Error($"Could not create specified mod directory {newDir.FullName}:\n{e}");
} }
}
BasePath = newDir; BasePath = newDir;
Valid = Directory.Exists(newDir.FullName); Valid = Directory.Exists(newDir.FullName);
if (Penumbra.Config.ModDirectory != BasePath.FullName) if (Penumbra.Config.ModDirectory != BasePath.FullName)
{
ModDirectoryChanged.Invoke(BasePath.FullName, Valid); ModDirectoryChanged.Invoke(BasePath.FullName, Valid);
} }
} }
}
private static void OnModDirectoryChange(string newPath, bool _) private static void OnModDirectoryChange(string newPath, bool _)
{ {
@ -97,11 +87,9 @@ public sealed partial class Mod
var queue = new ConcurrentQueue<Mod>(); var queue = new ConcurrentQueue<Mod>();
Parallel.ForEach(BasePath.EnumerateDirectories(), options, dir => Parallel.ForEach(BasePath.EnumerateDirectories(), options, dir =>
{ {
var mod = LoadMod( this, dir, false ); var mod = Mod.LoadMod(this, dir, false);
if (mod != null) if (mod != null)
{
queue.Enqueue(mod); queue.Enqueue(mod);
}
}); });
foreach (var mod in queue) foreach (var mod in queue)
@ -115,19 +103,15 @@ public sealed partial class Mod
Penumbra.Log.Information("Rediscovered mods."); Penumbra.Log.Information("Rediscovered mods.");
if (MigrateModBackups) if (MigrateModBackups)
{
ModBackup.MigrateZipToPmp(this); ModBackup.MigrateZipToPmp(this);
} }
}
public void UpdateExportDirectory(string newDirectory, bool change) public void UpdateExportDirectory(string newDirectory, bool change)
{ {
if (newDirectory.Length == 0) if (newDirectory.Length == 0)
{ {
if (_exportDirectory == null) if (_exportDirectory == null)
{
return; return;
}
_exportDirectory = null; _exportDirectory = null;
_config.ExportDirectory = string.Empty; _config.ExportDirectory = string.Empty;
@ -137,12 +121,9 @@ public sealed partial class Mod
var dir = new DirectoryInfo(newDirectory); var dir = new DirectoryInfo(newDirectory);
if (dir.FullName.Equals(_exportDirectory?.FullName, StringComparison.OrdinalIgnoreCase)) if (dir.FullName.Equals(_exportDirectory?.FullName, StringComparison.OrdinalIgnoreCase))
{
return; return;
}
if (!dir.Exists) if (!dir.Exists)
{
try try
{ {
Directory.CreateDirectory(dir.FullName); Directory.CreateDirectory(dir.FullName);
@ -152,15 +133,10 @@ public sealed partial class Mod
Penumbra.Log.Error($"Could not create Export Directory:\n{e}"); Penumbra.Log.Error($"Could not create Export Directory:\n{e}");
return; return;
} }
}
if (change) if (change)
{
foreach (var mod in _mods) foreach (var mod in _mods)
{
new ModBackup(this, mod).Move(dir.FullName); new ModBackup(this, mod).Move(dir.FullName);
}
}
_exportDirectory = dir; _exportDirectory = dir;
@ -171,4 +147,3 @@ public sealed partial class Mod
} }
} }
} }
}

View file

@ -7,9 +7,7 @@ using Penumbra.Util;
namespace Penumbra.Mods; namespace Penumbra.Mods;
public sealed partial class Mod public sealed partial class ModManager : IReadOnlyList<Mod>
{
public sealed partial class Manager : IReadOnlyList<Mod>
{ {
// Set when reading Config and migrating from v4 to v5. // Set when reading Config and migrating from v4 to v5.
public static bool MigrateModBackups = false; public static bool MigrateModBackups = false;
@ -41,7 +39,7 @@ public sealed partial class Mod
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
public readonly ModDataEditor DataEditor; public readonly ModDataEditor DataEditor;
public Manager(StartTracker time, Configuration config, CommunicatorService communicator, ModDataEditor dataEditor) public ModManager(StartTracker time, Configuration config, CommunicatorService communicator, ModDataEditor dataEditor)
{ {
using var timer = time.Measure(StartTimeType.Mods); using var timer = time.Measure(StartTimeType.Mods);
_config = config; _config = config;
@ -76,4 +74,3 @@ public sealed partial class Mod
return mod != null; return mod != null;
} }
} }
}

View file

@ -2,7 +2,6 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Dalamud.Utility; using Dalamud.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OtterGui.Classes; using OtterGui.Classes;
using Penumbra.Services; using Penumbra.Services;

View file

@ -15,10 +15,10 @@ public enum ModPathChangeType
public partial class Mod public partial class Mod
{ {
public DirectoryInfo ModPath { get; private set; } public DirectoryInfo ModPath { get; internal set; }
public string Identifier public string Identifier
=> Index >= 0 ? ModPath.Name : Name; => Index >= 0 ? ModPath.Name : Name;
public int Index { get; private set; } = -1; public int Index { get; internal set; } = -1;
public bool IsTemporary public bool IsTemporary
=> Index < 0; => Index < 0;
@ -33,7 +33,7 @@ public partial class Mod
_default = new SubMod( this ); _default = new SubMod( this );
} }
private static Mod? LoadMod( Manager modManager, DirectoryInfo modPath, bool incorporateMetaChanges ) public static Mod? LoadMod( ModManager modManager, DirectoryInfo modPath, bool incorporateMetaChanges )
{ {
modPath.Refresh(); modPath.Refresh();
if( !modPath.Exists ) if( !modPath.Exists )
@ -52,7 +52,7 @@ public partial class Mod
} }
internal bool Reload(Manager modManager, bool incorporateMetaChanges, out ModDataChangeType modDataChange ) internal bool Reload(ModManager modManager, bool incorporateMetaChanges, out ModDataChangeType modDataChange )
{ {
modDataChange = ModDataChangeType.Deletion; modDataChange = ModDataChangeType.Deletion;
ModPath.Refresh(); ModPath.Refresh();

View file

@ -12,7 +12,7 @@ public sealed partial class Mod
public SortedList< string, object? > ChangedItems { get; } = new(); public SortedList< string, object? > ChangedItems { get; } = new();
public string LowerChangedItemsString { get; private set; } = string.Empty; public string LowerChangedItemsString { get; private set; } = string.Empty;
private void ComputeChangedItems() internal void ComputeChangedItems()
{ {
ChangedItems.Clear(); ChangedItems.Clear();
foreach( var gamePath in AllRedirects ) foreach( var gamePath in AllRedirects )

View file

@ -18,15 +18,15 @@ public partial class Mod
public IReadOnlyList< IModGroup > Groups public IReadOnlyList< IModGroup > Groups
=> _groups; => _groups;
private readonly SubMod _default; internal readonly SubMod _default;
private readonly List< IModGroup > _groups = new(); internal readonly List< IModGroup > _groups = new();
public int TotalFileCount { get; private set; } public int TotalFileCount { get; internal set; }
public int TotalSwapCount { get; private set; } public int TotalSwapCount { get; internal set; }
public int TotalManipulations { get; private set; } public int TotalManipulations { get; internal set; }
public bool HasOptions { get; private set; } public bool HasOptions { get; internal set; }
private bool SetCounts() internal bool SetCounts()
{ {
TotalFileCount = 0; TotalFileCount = 0;
TotalSwapCount = 0; TotalSwapCount = 0;
@ -120,7 +120,7 @@ public partial class Mod
// Delete all existing group files and save them anew. // Delete all existing group files and save them anew.
// Used when indices change in complex ways. // Used when indices change in complex ways.
private void SaveAllGroups() internal void SaveAllGroups()
{ {
foreach( var file in GroupFiles ) foreach( var file in GroupFiles )
{ {

View file

@ -12,12 +12,12 @@ namespace Penumbra.Mods;
public sealed class ModFileSystem : FileSystem<Mod>, IDisposable, ISavable public sealed class ModFileSystem : FileSystem<Mod>, IDisposable, ISavable
{ {
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly FilenameService _files; private readonly FilenameService _files;
// Create a new ModFileSystem from the currently loaded mods and the current sort order file. // Create a new ModFileSystem from the currently loaded mods and the current sort order file.
public ModFileSystem(Mod.Manager modManager, CommunicatorService communicator, FilenameService files) public ModFileSystem(ModManager modManager, CommunicatorService communicator, FilenameService files)
{ {
_modManager = modManager; _modManager = modManager;
_communicator = communicator; _communicator = communicator;

View file

@ -15,8 +15,11 @@ namespace Penumbra.Mods;
public partial class Mod public partial class Mod
{ {
// Groups that allow all available options to be selected at once.
private sealed class MultiModGroup : IModGroup }
/// <summary> Groups that allow all available options to be selected at once. </summary>
public sealed class MultiModGroup : IModGroup
{ {
public GroupType Type public GroupType Type
=> GroupType.Multi; => GroupType.Multi;
@ -114,4 +117,3 @@ public partial class Mod
o.SetPosition(o.GroupIdx, i); o.SetPosition(o.GroupIdx, i);
} }
} }
}

View file

@ -10,10 +10,8 @@ using Penumbra.Api.Enums;
namespace Penumbra.Mods; namespace Penumbra.Mods;
public partial class Mod /// <summary> Groups that allow only one of their available options to be selected. </summary>
{ public sealed class SingleModGroup : IModGroup
// Groups that allow only one of their available options to be selected.
private sealed class SingleModGroup : IModGroup
{ {
public GroupType Type public GroupType Type
=> GroupType.Single; => GroupType.Single;
@ -128,4 +126,3 @@ public partial class Mod
} }
} }
} }
}

View file

@ -36,7 +36,7 @@ public partial class Mod
ISubMod.WriteSubMod( j, serializer, _default, ModPath, 0 ); ISubMod.WriteSubMod( j, serializer, _default, ModPath, 0 );
} }
private void SaveDefaultModDelayed() internal void SaveDefaultModDelayed()
=> Penumbra.Framework.RegisterDelayed( nameof( SaveDefaultMod ) + ModPath.Name, SaveDefaultMod ); => Penumbra.Framework.RegisterDelayed( nameof( SaveDefaultMod ) + ModPath.Name, SaveDefaultMod );
private void LoadDefaultOption() private void LoadDefaultOption()
@ -92,14 +92,19 @@ public partial class Mod
} }
// A sub mod is a collection of
// - file replacements }
// - file swaps
// - meta manipulations /// <summary>
// that can be used either as an option or as the default data for a mod. /// A sub mod is a collection of
// It can be loaded and reloaded from Json. /// - file replacements
// Nothing is checked for existence or validity when loading. /// - file swaps
// Objects are also not checked for uniqueness, the first appearance of a game path or meta path decides. /// - meta manipulations
/// that can be used either as an option or as the default data for a mod.
/// It can be loaded and reloaded from Json.
/// Nothing is checked for existence or validity when loading.
/// Objects are also not checked for uniqueness, the first appearance of a game path or meta path decides.
/// </summary>
public sealed class SubMod : ISubMod public sealed class SubMod : ISubMod
{ {
public string Name { get; set; } = "Default"; public string Name { get; set; } = "Default";
@ -321,4 +326,3 @@ public partial class Mod
} }
} }
} }
}

View file

@ -10,7 +10,7 @@ using Penumbra.String.Classes;
namespace Penumbra.Mods; namespace Penumbra.Mods;
// Contains the settings for a given mod. /// <summary> Contains the settings for a given mod. </summary>
public class ModSettings public class ModSettings
{ {
public static readonly ModSettings Empty = new(); public static readonly ModSettings Empty = new();

View file

@ -27,10 +27,10 @@ public class TemporaryMod : IMod
public IEnumerable< ISubMod > AllSubMods public IEnumerable< ISubMod > AllSubMods
=> new[] { Default }; => new[] { Default };
private readonly Mod.SubMod _default; private readonly SubMod _default;
public TemporaryMod() public TemporaryMod()
=> _default = new Mod.SubMod( this ); => _default = new SubMod( this );
public void SetFile( Utf8GamePath gamePath, FullPath fullPath ) public void SetFile( Utf8GamePath gamePath, FullPath fullPath )
=> _default.FileData[ gamePath ] = fullPath; => _default.FileData[ gamePath ] = fullPath;
@ -44,7 +44,7 @@ public class TemporaryMod : IMod
_default.ManipulationData = manips; _default.ManipulationData = manips;
} }
public static void SaveTempCollection( Mod.Manager modManager, ModCollection collection, string? character = null ) public static void SaveTempCollection( ModManager modManager, ModCollection collection, string? character = null )
{ {
DirectoryInfo? dir = null; DirectoryInfo? dir = null;
try try
@ -54,7 +54,7 @@ public class TemporaryMod : IMod
modManager.DataEditor.CreateMeta( dir, collection.Name, character ?? Penumbra.Config.DefaultModAuthor, modManager.DataEditor.CreateMeta( dir, collection.Name, character ?? Penumbra.Config.DefaultModAuthor,
$"Mod generated from temporary collection {collection.Name} for {character ?? "Unknown Character"}.", null, null ); $"Mod generated from temporary collection {collection.Name} for {character ?? "Unknown Character"}.", null, null );
var mod = new Mod( dir ); var mod = new Mod( dir );
var defaultMod = (Mod.SubMod) mod.Default; var defaultMod = (SubMod) mod.Default;
foreach( var (gamePath, fullPath) in collection.ResolvedFiles ) foreach( var (gamePath, fullPath) in collection.ResolvedFiles )
{ {
if( gamePath.Path.EndsWith( ".imc"u8 ) ) if( gamePath.Path.EndsWith( ".imc"u8 ) )

View file

@ -47,8 +47,8 @@ public class Penumbra : IDalamudPlugin
public static CharacterUtility CharacterUtility { get; private set; } = null!; public static CharacterUtility CharacterUtility { get; private set; } = null!;
public static GameEventManager GameEvents { get; private set; } = null!; public static GameEventManager GameEvents { get; private set; } = null!;
public static MetaFileManager MetaFileManager { get; private set; } = null!; public static MetaFileManager MetaFileManager { get; private set; } = null!;
public static Mod.Manager ModManager { get; private set; } = null!; public static ModManager ModManager { get; private set; } = null!;
public static ModCollection.Manager CollectionManager { get; private set; } = null!; public static CollectionManager CollectionManager { get; private set; } = null!;
public static TempCollectionManager TempCollections { get; private set; } = null!; public static TempCollectionManager TempCollections { get; private set; } = null!;
public static TempModManager TempMods { get; private set; } = null!; public static TempModManager TempMods { get; private set; } = null!;
public static ResourceLoader ResourceLoader { get; private set; } = null!; public static ResourceLoader ResourceLoader { get; private set; } = null!;
@ -96,8 +96,8 @@ public class Penumbra : IDalamudPlugin
TempMods = _tmp.Services.GetRequiredService<TempModManager>(); TempMods = _tmp.Services.GetRequiredService<TempModManager>();
ResidentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>(); ResidentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>();
_tmp.Services.GetRequiredService<ResourceManagerService>(); _tmp.Services.GetRequiredService<ResourceManagerService>();
ModManager = _tmp.Services.GetRequiredService<Mod.Manager>(); ModManager = _tmp.Services.GetRequiredService<ModManager>();
CollectionManager = _tmp.Services.GetRequiredService<ModCollection.Manager>(); CollectionManager = _tmp.Services.GetRequiredService<CollectionManager>();
TempCollections = _tmp.Services.GetRequiredService<TempCollectionManager>(); TempCollections = _tmp.Services.GetRequiredService<TempCollectionManager>();
ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>(); ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>();
RedrawService = _tmp.Services.GetRequiredService<RedrawService>(); RedrawService = _tmp.Services.GetRequiredService<RedrawService>();

View file

@ -88,12 +88,12 @@ public class PenumbraNew
// Add Collection Services // Add Collection Services
services.AddTransient<IndividualCollections>() services.AddTransient<IndividualCollections>()
.AddSingleton<TempCollectionManager>() .AddSingleton<TempCollectionManager>()
.AddSingleton<ModCollection.Manager>(); .AddSingleton<CollectionManager>();
// Add Mod Services // Add Mod Services
services.AddSingleton<TempModManager>() services.AddSingleton<TempModManager>()
.AddSingleton<ModDataEditor>() .AddSingleton<ModDataEditor>()
.AddSingleton<Mod.Manager>() .AddSingleton<ModManager>()
.AddSingleton<ModFileSystem>(); .AddSingleton<ModFileSystem>();
// Add Resource services // Add Resource services

View file

@ -87,7 +87,7 @@ public class ConfigMigrationService
if (_config.Version != 6) if (_config.Version != 6)
return; return;
ModCollection.Manager.MigrateUngenderedCollections(_fileNames); CollectionManager.MigrateUngenderedCollections(_fileNames);
_config.Version = 7; _config.Version = 7;
} }
@ -113,7 +113,7 @@ public class ConfigMigrationService
if (_config.Version != 4) if (_config.Version != 4)
return; return;
Mod.Manager.MigrateModBackups = true; ModManager.MigrateModBackups = true;
_config.Version = 5; _config.Version = 5;
} }
@ -257,11 +257,11 @@ public class ConfigMigrationService
using var j = new JsonTextWriter(writer); using var j = new JsonTextWriter(writer);
j.Formatting = Formatting.Indented; j.Formatting = Formatting.Indented;
j.WriteStartObject(); j.WriteStartObject();
j.WritePropertyName(nameof(ModCollection.Manager.Default)); j.WritePropertyName(nameof(CollectionManager.Default));
j.WriteValue(def); j.WriteValue(def);
j.WritePropertyName(nameof(ModCollection.Manager.Interface)); j.WritePropertyName(nameof(CollectionManager.Interface));
j.WriteValue(ui); j.WriteValue(ui);
j.WritePropertyName(nameof(ModCollection.Manager.Current)); j.WritePropertyName(nameof(CollectionManager.Current));
j.WriteValue(current); j.WriteValue(current);
foreach (var (type, collection) in special) foreach (var (type, collection) in special)
{ {

View file

@ -25,12 +25,12 @@ public class ItemSwapTab : IDisposable, ITab
{ {
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly ItemService _itemService; private readonly ItemService _itemService;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly Configuration _config; private readonly Configuration _config;
public ItemSwapTab(CommunicatorService communicator, ItemService itemService, ModCollection.Manager collectionManager, public ItemSwapTab(CommunicatorService communicator, ItemService itemService, CollectionManager collectionManager,
Mod.Manager modManager, Configuration config) ModManager modManager, Configuration config)
{ {
_communicator = communicator; _communicator = communicator;
_itemService = itemService; _itemService = itemService;

View file

@ -297,7 +297,7 @@ public partial class ModEditWindow
var tt = changes ? "Apply the current file setup to the currently selected option." : "No changes made."; var tt = changes ? "Apply the current file setup to the currently selected option." : "No changes made.";
if (ImGuiUtil.DrawDisabledButton("Apply Changes", Vector2.Zero, tt, !changes)) if (ImGuiUtil.DrawDisabledButton("Apply Changes", Vector2.Zero, tt, !changes))
{ {
var failedFiles = _editor.FileEditor.Apply(_editor.Mod!, (Mod.SubMod)_editor.Option!); var failedFiles = _editor.FileEditor.Apply(_editor.Mod!, (SubMod)_editor.Option!);
if (failedFiles > 0) if (failedFiles > 0)
Penumbra.Log.Information($"Failed to apply {failedFiles} file redirections to {_editor.Option!.FullName}."); Penumbra.Log.Information($"Failed to apply {failedFiles} file redirections to {_editor.Option!.FullName}.");
} }

View file

@ -194,7 +194,7 @@ public partial class ModEditWindow
_editor.FileEditor.Revert(_editor.Mod!, _editor.Option!); _editor.FileEditor.Revert(_editor.Mod!, _editor.Option!);
var fileRegistry = _editor.Files.Available.First(file => file.File.FullName == _targetPath); var fileRegistry = _editor.Files.Available.First(file => file.File.FullName == _targetPath);
_editor.FileEditor.AddPathsToSelected(_editor.Option!, new []{ fileRegistry }, _subDirs); _editor.FileEditor.AddPathsToSelected(_editor.Option!, new []{ fileRegistry }, _subDirs);
_editor.FileEditor.Apply(_editor.Mod!, (Mod.SubMod) _editor.Option!); _editor.FileEditor.Apply(_editor.Mod!, (SubMod) _editor.Option!);
return fileRegistry; return fileRegistry;
} }

View file

@ -9,9 +9,9 @@ namespace Penumbra.UI.CollectionTab;
public sealed class CollectionSelector : FilterComboCache<ModCollection> public sealed class CollectionSelector : FilterComboCache<ModCollection>
{ {
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
public CollectionSelector(ModCollection.Manager manager, Func<IReadOnlyList<ModCollection>> items) public CollectionSelector(CollectionManager manager, Func<IReadOnlyList<ModCollection>> items)
: base(items) : base(items)
=> _collectionManager = manager; => _collectionManager = manager;

View file

@ -16,10 +16,10 @@ namespace Penumbra.UI.CollectionTab;
public class IndividualCollectionUi public class IndividualCollectionUi
{ {
private readonly ActorService _actorService; private readonly ActorService _actorService;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly CollectionSelector _withEmpty; private readonly CollectionSelector _withEmpty;
public IndividualCollectionUi(ActorService actors, ModCollection.Manager collectionManager, CollectionSelector withEmpty) public IndividualCollectionUi(ActorService actors, CollectionManager collectionManager, CollectionSelector withEmpty)
{ {
_actorService = actors; _actorService = actors;
_collectionManager = collectionManager; _collectionManager = collectionManager;

View file

@ -16,9 +16,9 @@ public class InheritanceUi
private const int InheritedCollectionHeight = 9; private const int InheritedCollectionHeight = 9;
private const string InheritanceDragDropLabel = "##InheritanceMove"; private const string InheritanceDragDropLabel = "##InheritanceMove";
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
public InheritanceUi(ModCollection.Manager collectionManager) public InheritanceUi(CollectionManager collectionManager)
=> _collectionManager = collectionManager; => _collectionManager = collectionManager;
/// <summary> Draw the whole inheritance block. </summary> /// <summary> Draw the whole inheritance block. </summary>

View file

@ -7,7 +7,7 @@ namespace Penumbra.UI.CollectionTab;
public sealed class SpecialCombo : FilterComboBase<(CollectionType, string, string)> public sealed class SpecialCombo : FilterComboBase<(CollectionType, string, string)>
{ {
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
public (CollectionType, string, string)? CurrentType public (CollectionType, string, string)? CurrentType
=> CollectionTypeExtensions.Special[CurrentIdx]; => CollectionTypeExtensions.Special[CurrentIdx];
@ -16,7 +16,7 @@ public sealed class SpecialCombo : FilterComboBase<(CollectionType, string, stri
private readonly float _unscaledWidth; private readonly float _unscaledWidth;
private readonly string _label; private readonly string _label;
public SpecialCombo(ModCollection.Manager collectionManager, string label, float unscaledWidth) public SpecialCombo(CollectionManager collectionManager, string label, float unscaledWidth)
: base(CollectionTypeExtensions.Special, false) : base(CollectionTypeExtensions.Special, false)
{ {
_collectionManager = collectionManager; _collectionManager = collectionManager;

View file

@ -14,12 +14,12 @@ namespace Penumbra.UI;
public class FileDialogService : IDisposable public class FileDialogService : IDisposable
{ {
private readonly Mod.Manager _mods; private readonly ModManager _mods;
private readonly FileDialogManager _manager; private readonly FileDialogManager _manager;
private readonly ConcurrentDictionary<string, string> _startPaths = new(); private readonly ConcurrentDictionary<string, string> _startPaths = new();
private bool _isOpen; private bool _isOpen;
public FileDialogService(Mod.Manager mods, Configuration config) public FileDialogService(ModManager mods, Configuration config)
{ {
_mods = mods; _mods = mods;
_manager = SetupFileManager(config.ModDirectory); _manager = SetupFileManager(config.ModDirectory);

View file

@ -29,8 +29,8 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector<Mod, ModF
private readonly ChatService _chat; private readonly ChatService _chat;
private readonly Configuration _config; private readonly Configuration _config;
private readonly FileDialogService _fileDialog; private readonly FileDialogService _fileDialog;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly ModEditor _modEditor; private readonly ModEditor _modEditor;
@ -38,8 +38,8 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector<Mod, ModF
public ModSettings SelectedSettings { get; private set; } = ModSettings.Empty; public ModSettings SelectedSettings { get; private set; } = ModSettings.Empty;
public ModCollection SelectedSettingCollection { get; private set; } = ModCollection.Empty; public ModCollection SelectedSettingCollection { get; private set; } = ModCollection.Empty;
public ModFileSystemSelector(CommunicatorService communicator, ModFileSystem fileSystem, Mod.Manager modManager, public ModFileSystemSelector(CommunicatorService communicator, ModFileSystem fileSystem, ModManager modManager,
ModCollection.Manager collectionManager, Configuration config, TutorialService tutorial, FileDialogService fileDialog, ChatService chat, CollectionManager collectionManager, Configuration config, TutorialService tutorial, FileDialogService fileDialog, ChatService chat,
ModEditor modEditor) ModEditor modEditor)
: base(fileSystem, DalamudServices.KeyState, HandleException) : base(fileSystem, DalamudServices.KeyState, HandleException)
{ {

View file

@ -14,9 +14,9 @@ namespace Penumbra.UI.ModsTab;
public class ModPanelConflictsTab : ITab public class ModPanelConflictsTab : ITab
{ {
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
public ModPanelConflictsTab(ModCollection.Manager collectionManager, ModFileSystemSelector selector) public ModPanelConflictsTab(CollectionManager collectionManager, ModFileSystemSelector selector)
{ {
_collectionManager = collectionManager; _collectionManager = collectionManager;
_selector = selector; _selector = selector;

View file

@ -13,11 +13,11 @@ public class ModPanelDescriptionTab : ITab
{ {
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly TagButtons _localTags = new(); private readonly TagButtons _localTags = new();
private readonly TagButtons _modTags = new(); private readonly TagButtons _modTags = new();
public ModPanelDescriptionTab(ModFileSystemSelector selector, TutorialService tutorial, Mod.Manager modManager) public ModPanelDescriptionTab(ModFileSystemSelector selector, TutorialService tutorial, ModManager modManager)
{ {
_selector = selector; _selector = selector;
_tutorial = tutorial; _tutorial = tutorial;

View file

@ -20,7 +20,7 @@ namespace Penumbra.UI.ModsTab;
public class ModPanelEditTab : ITab public class ModPanelEditTab : ITab
{ {
private readonly ChatService _chat; private readonly ChatService _chat;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ModFileSystem _fileSystem; private readonly ModFileSystem _fileSystem;
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly ModEditWindow _editWindow; private readonly ModEditWindow _editWindow;
@ -33,7 +33,7 @@ public class ModPanelEditTab : ITab
private ModFileSystem.Leaf _leaf = null!; private ModFileSystem.Leaf _leaf = null!;
private Mod _mod = null!; private Mod _mod = null!;
public ModPanelEditTab(Mod.Manager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, ChatService chat, public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, ChatService chat,
ModEditWindow editWindow, ModEditor editor) ModEditWindow editWindow, ModEditor editor)
{ {
_modManager = modManager; _modManager = modManager;
@ -219,7 +219,7 @@ public class ModPanelEditTab : ITab
public static void Reset() public static void Reset()
=> _newGroupName = string.Empty; => _newGroupName = string.Empty;
public static void Draw(Mod.Manager modManager, Mod mod) public static void Draw(ModManager modManager, Mod mod)
{ {
using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3)); using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3));
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3); ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3);
@ -250,15 +250,15 @@ public class ModPanelEditTab : ITab
private static class MoveDirectory private static class MoveDirectory
{ {
private static string? _currentModDirectory; private static string? _currentModDirectory;
private static Mod.Manager.NewDirectoryState _state = Mod.Manager.NewDirectoryState.Identical; private static ModManager.NewDirectoryState _state = ModManager.NewDirectoryState.Identical;
public static void Reset() public static void Reset()
{ {
_currentModDirectory = null; _currentModDirectory = null;
_state = Mod.Manager.NewDirectoryState.Identical; _state = ModManager.NewDirectoryState.Identical;
} }
public static void Draw(Mod.Manager modManager, Mod mod, Vector2 buttonSize) public static void Draw(ModManager modManager, Mod mod, Vector2 buttonSize)
{ {
ImGui.SetNextItemWidth(buttonSize.X * 2 + ImGui.GetStyle().ItemSpacing.X); ImGui.SetNextItemWidth(buttonSize.X * 2 + ImGui.GetStyle().ItemSpacing.X);
var tmp = _currentModDirectory ?? mod.ModPath.Name; var tmp = _currentModDirectory ?? mod.ModPath.Name;
@ -270,13 +270,13 @@ public class ModPanelEditTab : ITab
var (disabled, tt) = _state switch var (disabled, tt) = _state switch
{ {
Mod.Manager.NewDirectoryState.Identical => (true, "Current directory name is identical to new one."), ModManager.NewDirectoryState.Identical => (true, "Current directory name is identical to new one."),
Mod.Manager.NewDirectoryState.Empty => (true, "Please enter a new directory name first."), ModManager.NewDirectoryState.Empty => (true, "Please enter a new directory name first."),
Mod.Manager.NewDirectoryState.NonExisting => (false, $"Move mod from {mod.ModPath.Name} to {_currentModDirectory}."), ModManager.NewDirectoryState.NonExisting => (false, $"Move mod from {mod.ModPath.Name} to {_currentModDirectory}."),
Mod.Manager.NewDirectoryState.ExistsEmpty => (false, $"Move mod from {mod.ModPath.Name} to {_currentModDirectory}."), ModManager.NewDirectoryState.ExistsEmpty => (false, $"Move mod from {mod.ModPath.Name} to {_currentModDirectory}."),
Mod.Manager.NewDirectoryState.ExistsNonEmpty => (true, $"{_currentModDirectory} already exists and is not empty."), ModManager.NewDirectoryState.ExistsNonEmpty => (true, $"{_currentModDirectory} already exists and is not empty."),
Mod.Manager.NewDirectoryState.ExistsAsFile => (true, $"{_currentModDirectory} exists as a file."), ModManager.NewDirectoryState.ExistsAsFile => (true, $"{_currentModDirectory} exists as a file."),
Mod.Manager.NewDirectoryState.ContainsInvalidSymbols => (true, ModManager.NewDirectoryState.ContainsInvalidSymbols => (true,
$"{_currentModDirectory} contains invalid symbols for FFXIV."), $"{_currentModDirectory} contains invalid symbols for FFXIV."),
_ => (true, "Unknown error."), _ => (true, "Unknown error."),
}; };
@ -317,7 +317,7 @@ public class ModPanelEditTab : ITab
ImGui.OpenPopup(PopupName); ImGui.OpenPopup(PopupName);
} }
public static void DrawPopup(Mod.Manager modManager) public static void DrawPopup(ModManager modManager)
{ {
if (_mod == null) if (_mod == null)
return; return;

View file

@ -18,11 +18,11 @@ namespace Penumbra.UI.ModsTab;
public class ModPanelSettingsTab : ITab public class ModPanelSettingsTab : ITab
{ {
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly PenumbraApi _api; private readonly PenumbraApi _api;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private bool _inherited; private bool _inherited;
private ModSettings _settings = null!; private ModSettings _settings = null!;
@ -30,7 +30,7 @@ public class ModPanelSettingsTab : ITab
private bool _empty; private bool _empty;
private int? _currentPriority = null; private int? _currentPriority = null;
public ModPanelSettingsTab(ModCollection.Manager collectionManager, Mod.Manager modManager, ModFileSystemSelector selector, public ModPanelSettingsTab(CollectionManager collectionManager, ModManager modManager, ModFileSystemSelector selector,
TutorialService tutorial, PenumbraApi api, Configuration config) TutorialService tutorial, PenumbraApi api, Configuration config)
{ {
_collectionManager = collectionManager; _collectionManager = collectionManager;

View file

@ -27,7 +27,7 @@ public class ModPanelTabBar
public readonly ModPanelChangedItemsTab ChangedItems; public readonly ModPanelChangedItemsTab ChangedItems;
public readonly ModPanelEditTab Edit; public readonly ModPanelEditTab Edit;
private readonly ModEditWindow _modEditWindow; private readonly ModEditWindow _modEditWindow;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
public readonly ITab[] Tabs; public readonly ITab[] Tabs;
@ -35,7 +35,7 @@ public class ModPanelTabBar
private Mod? _lastMod = null; private Mod? _lastMod = null;
public ModPanelTabBar(ModEditWindow modEditWindow, ModPanelSettingsTab settings, ModPanelDescriptionTab description, public ModPanelTabBar(ModEditWindow modEditWindow, ModPanelSettingsTab settings, ModPanelDescriptionTab description,
ModPanelConflictsTab conflicts, ModPanelChangedItemsTab changedItems, ModPanelEditTab edit, Mod.Manager modManager, ModPanelConflictsTab conflicts, ModPanelChangedItemsTab changedItems, ModPanelEditTab edit, ModManager modManager,
TutorialService tutorial) TutorialService tutorial)
{ {
_modEditWindow = modEditWindow; _modEditWindow = modEditWindow;
@ -107,7 +107,7 @@ public class ModPanelTabBar
if (ImGui.TabItemButton("Advanced Editing", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip)) if (ImGui.TabItemButton("Advanced Editing", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip))
{ {
_modEditWindow.ChangeMod(mod); _modEditWindow.ChangeMod(mod);
_modEditWindow.ChangeOption((Mod.SubMod) mod.Default); _modEditWindow.ChangeOption((SubMod) mod.Default);
_modEditWindow.IsOpen = true; _modEditWindow.IsOpen = true;
} }

View file

@ -16,10 +16,10 @@ namespace Penumbra.UI.Tabs;
public class ChangedItemsTab : ITab public class ChangedItemsTab : ITab
{ {
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly PenumbraApi _api; private readonly PenumbraApi _api;
public ChangedItemsTab(ModCollection.Manager collectionManager, PenumbraApi api) public ChangedItemsTab(CollectionManager collectionManager, PenumbraApi api)
{ {
_collectionManager = collectionManager; _collectionManager = collectionManager;
_api = api; _api = api;

View file

@ -17,7 +17,7 @@ public class CollectionsTab : IDisposable, ITab
{ {
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly SpecialCombo _specialCollectionCombo; private readonly SpecialCombo _specialCollectionCombo;
@ -26,7 +26,7 @@ public class CollectionsTab : IDisposable, ITab
private readonly InheritanceUi _inheritance; private readonly InheritanceUi _inheritance;
private readonly IndividualCollectionUi _individualCollections; private readonly IndividualCollectionUi _individualCollections;
public CollectionsTab(ActorService actorService, CommunicatorService communicator, ModCollection.Manager collectionManager, public CollectionsTab(ActorService actorService, CommunicatorService communicator, CollectionManager collectionManager,
TutorialService tutorial, Configuration config) TutorialService tutorial, Configuration config)
{ {
_communicator = communicator; _communicator = communicator;

View file

@ -34,8 +34,8 @@ public class DebugTab : ITab
private readonly StartTracker _timer; private readonly StartTracker _timer;
private readonly PerformanceTracker _performance; private readonly PerformanceTracker _performance;
private readonly Configuration _config; private readonly Configuration _config;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ValidityChecker _validityChecker; private readonly ValidityChecker _validityChecker;
private readonly HttpApi _httpApi; private readonly HttpApi _httpApi;
private readonly ActorService _actorService; private readonly ActorService _actorService;
@ -52,8 +52,8 @@ public class DebugTab : ITab
private readonly IdentifiedCollectionCache _identifiedCollectionCache; private readonly IdentifiedCollectionCache _identifiedCollectionCache;
private readonly CutsceneService _cutsceneService; private readonly CutsceneService _cutsceneService;
public DebugTab(StartTracker timer, PerformanceTracker performance, Configuration config, ModCollection.Manager collectionManager, public DebugTab(StartTracker timer, PerformanceTracker performance, Configuration config, CollectionManager collectionManager,
ValidityChecker validityChecker, Mod.Manager modManager, HttpApi httpApi, ActorService actorService, ValidityChecker validityChecker, ModManager modManager, HttpApi httpApi, ActorService actorService,
DalamudServices dalamud, StainService stains, CharacterUtility characterUtility, ResidentResourceManager residentResources, DalamudServices dalamud, StainService stains, CharacterUtility characterUtility, ResidentResourceManager residentResources,
ResourceManagerService resourceManager, PenumbraIpcProviders ipc, CollectionResolver collectionResolver, ResourceManagerService resourceManager, PenumbraIpcProviders ipc, CollectionResolver collectionResolver,
DrawObjectState drawObjectState, PathState pathState, SubfileHelper subfileHelper, IdentifiedCollectionCache identifiedCollectionCache, DrawObjectState drawObjectState, PathState pathState, SubfileHelper subfileHelper, IdentifiedCollectionCache identifiedCollectionCache,

View file

@ -17,9 +17,9 @@ namespace Penumbra.UI.Tabs;
public class EffectiveTab : ITab public class EffectiveTab : ITab
{ {
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
public EffectiveTab(ModCollection.Manager collectionManager) public EffectiveTab(CollectionManager collectionManager)
=> _collectionManager = collectionManager; => _collectionManager = collectionManager;
public ReadOnlySpan<byte> Label public ReadOnlySpan<byte> Label

View file

@ -23,13 +23,13 @@ public class ModsTab : ITab
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly ModPanel _panel; private readonly ModPanel _panel;
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ModCollection.Manager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly RedrawService _redrawService; private readonly RedrawService _redrawService;
private readonly Configuration _config; private readonly Configuration _config;
private readonly CollectionsTab _collectionsTab; private readonly CollectionsTab _collectionsTab;
public ModsTab(Mod.Manager modManager, ModCollection.Manager collectionManager, ModFileSystemSelector selector, ModPanel panel, public ModsTab(ModManager modManager, CollectionManager collectionManager, ModFileSystemSelector selector, ModPanel panel,
TutorialService tutorial, RedrawService redrawService, Configuration config, CollectionsTab collectionsTab) TutorialService tutorial, RedrawService redrawService, Configuration config, CollectionsTab collectionsTab)
{ {
_modManager = modManager; _modManager = modManager;

View file

@ -31,14 +31,14 @@ public class SettingsTab : ITab
private readonly TutorialService _tutorial; private readonly TutorialService _tutorial;
private readonly Penumbra _penumbra; private readonly Penumbra _penumbra;
private readonly FileDialogService _fileDialog; private readonly FileDialogService _fileDialog;
private readonly Mod.Manager _modManager; private readonly ModManager _modManager;
private readonly ModFileSystemSelector _selector; private readonly ModFileSystemSelector _selector;
private readonly CharacterUtility _characterUtility; private readonly CharacterUtility _characterUtility;
private readonly ResidentResourceManager _residentResources; private readonly ResidentResourceManager _residentResources;
private readonly DalamudServices _dalamud; private readonly DalamudServices _dalamud;
public SettingsTab(Configuration config, FontReloader fontReloader, TutorialService tutorial, Penumbra penumbra, public SettingsTab(Configuration config, FontReloader fontReloader, TutorialService tutorial, Penumbra penumbra,
FileDialogService fileDialog, Mod.Manager modManager, ModFileSystemSelector selector, CharacterUtility characterUtility, FileDialogService fileDialog, ModManager modManager, ModFileSystemSelector selector, CharacterUtility characterUtility,
ResidentResourceManager residentResources, DalamudServices dalamud) ResidentResourceManager residentResources, DalamudServices dalamud)
{ {
_config = config; _config = config;