From 49c8afb72ab3a58cee02c113533461cda4d39064 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 21 Apr 2023 23:12:26 +0200 Subject: [PATCH] Remove remaining static ModManager. --- Penumbra/Api/IpcTester.cs | 8 +++++--- Penumbra/Mods/TemporaryMod.cs | 6 +++--- Penumbra/Penumbra.cs | 8 +++----- Penumbra/UI/ModsTab/ModFileSystemSelector.cs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Penumbra/Api/IpcTester.cs b/Penumbra/Api/IpcTester.cs index 32366bed..8c859bc8 100644 --- a/Penumbra/Api/IpcTester.cs +++ b/Penumbra/Api/IpcTester.cs @@ -54,7 +54,7 @@ public class IpcTester : IDisposable _meta = new Meta(pi); _mods = new Mods(pi); _modSettings = new ModSettings(pi); - _temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService); + _temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService, _configuration); UnsubscribeEvents(); } @@ -1157,9 +1157,10 @@ public class IpcTester : IDisposable private readonly TempModManager _tempMods; private readonly TempCollectionManager _tempCollections; private readonly SaveService _saveService; + private readonly Configuration _config; public Temporary(DalamudPluginInterface pi, ModManager modManager, CollectionManager collections, TempModManager tempMods, - TempCollectionManager tempCollections, SaveService saveService) + TempCollectionManager tempCollections, SaveService saveService, Configuration config) { _pi = pi; _modManager = modManager; @@ -1167,6 +1168,7 @@ public class IpcTester : IDisposable _tempMods = tempMods; _tempCollections = tempCollections; _saveService = saveService; + _config = config; } public string LastCreatedCollectionName = string.Empty; @@ -1275,7 +1277,7 @@ public class IpcTester : IDisposable .FirstOrDefault() ?? "Unknown"; if (ImGui.Button($"Save##{collection.Name}")) - TemporaryMod.SaveTempCollection(_saveService, _modManager, collection, character); + TemporaryMod.SaveTempCollection(_config, _saveService, _modManager, collection, character); ImGuiUtil.DrawTableColumn(collection.Name); ImGuiUtil.DrawTableColumn(collection.ResolvedFiles.Count.ToString()); diff --git a/Penumbra/Mods/TemporaryMod.cs b/Penumbra/Mods/TemporaryMod.cs index 9019b468..1f408b15 100644 --- a/Penumbra/Mods/TemporaryMod.cs +++ b/Penumbra/Mods/TemporaryMod.cs @@ -46,14 +46,14 @@ public class TemporaryMod : IMod Default.ManipulationData = manips; } - public static void SaveTempCollection( SaveService saveService, ModManager modManager, ModCollection collection, string? character = null ) + public static void SaveTempCollection( Configuration config, SaveService saveService, ModManager modManager, ModCollection collection, string? character = null ) { DirectoryInfo? dir = null; try { - dir = ModCreator.CreateModFolder( Penumbra.ModManager.BasePath, collection.Name ); + dir = ModCreator.CreateModFolder( modManager.BasePath, collection.Name ); var fileDir = Directory.CreateDirectory( Path.Combine( dir.FullName, "files" ) ); - modManager.DataEditor.CreateMeta( dir, collection.Name, character ?? Penumbra.Config.DefaultModAuthor, + modManager.DataEditor.CreateMeta( dir, collection.Name, character ?? config.DefaultModAuthor, $"Mod generated from temporary collection {collection.Name} for {character ?? "Unknown Character"}.", null, null ); var mod = new Mod( dir ); var defaultMod = mod.Default; diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index 259048f0..c46f23b4 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -15,7 +15,6 @@ using Penumbra.UI; using Penumbra.Util; using Penumbra.Collections; using Penumbra.Collections.Cache; -using Penumbra.GameData; using Penumbra.GameData.Actors; using Penumbra.Interop.ResourceLoading; using Penumbra.Interop.PathResolving; @@ -27,7 +26,6 @@ using Penumbra.Interop.Services; using Penumbra.Mods.Manager; using Penumbra.Collections.Manager; using Penumbra.Mods; -using Penumbra.Meta; namespace Penumbra; @@ -41,7 +39,6 @@ public class Penumbra : IDalamudPlugin public static Configuration Config { get; private set; } = null!; public static CharacterUtility CharacterUtility { get; private set; } = null!; - public static ModManager ModManager { get; private set; } = null!; public static ModCacheManager ModCaches { get; private set; } = null!; public static CollectionManager CollectionManager { get; private set; } = null!; public static ActorManager Actors { get; private set; } = null!; @@ -55,6 +52,7 @@ public class Penumbra : IDalamudPlugin private readonly ResidentResourceManager _residentResources; private readonly TempModManager _tempMods; private readonly TempCollectionManager _tempCollections; + private readonly ModManager _modManager; private PenumbraWindowSystem? _windowSystem; private bool _disposed; @@ -75,7 +73,7 @@ public class Penumbra : IDalamudPlugin _tempMods = _tmp.Services.GetRequiredService(); _residentResources = _tmp.Services.GetRequiredService(); _tmp.Services.GetRequiredService(); - ModManager = _tmp.Services.GetRequiredService(); + _modManager = _tmp.Services.GetRequiredService(); CollectionManager = _tmp.Services.GetRequiredService(); _tempCollections = _tmp.Services.GetRequiredService(); ModFileSystem = _tmp.Services.GetRequiredService(); @@ -211,7 +209,7 @@ public class Penumbra : IDalamudPlugin $"> **`Logging: `** Log: {Config.EnableResourceLogging}, Watcher: {Config.EnableResourceWatcher} ({Config.MaxResourceWatcherRecords})\n"); sb.Append($"> **`Use Ownership: `** {Config.UseOwnerNameForCharacterCollection}\n"); sb.AppendLine("**Mods**"); - sb.Append($"> **`Installed Mods: `** {ModManager.Count}\n"); + sb.Append($"> **`Installed Mods: `** {_modManager.Count}\n"); sb.Append($"> **`Mods with Config: `** {ModCaches.Count(m => m.HasOptions)}\n"); sb.Append( $"> **`Mods with File Redirections: `** {ModCaches.Count(m => m.TotalFileCount > 0)}, Total: {ModCaches.Sum(m => m.TotalFileCount)}\n"); diff --git a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs index 32844294..8a78b6fb 100644 --- a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs +++ b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs @@ -211,7 +211,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector