Remove remaining static ModManager.

This commit is contained in:
Ottermandias 2023-04-21 23:12:26 +02:00
parent 10c0117402
commit 49c8afb72a
4 changed files with 12 additions and 12 deletions

View file

@ -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());

View file

@ -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;

View file

@ -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<TempModManager>();
_residentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>();
_tmp.Services.GetRequiredService<ResourceManagerService>();
ModManager = _tmp.Services.GetRequiredService<ModManager>();
_modManager = _tmp.Services.GetRequiredService<ModManager>();
CollectionManager = _tmp.Services.GetRequiredService<CollectionManager>();
_tempCollections = _tmp.Services.GetRequiredService<TempCollectionManager>();
ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>();
@ -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");

View file

@ -211,7 +211,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
private void AddImportModButton(Vector2 size)
{
var button = ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileImport.ToIconString(), size,
"Import one or multiple mods from Tex Tools Mod Pack Files or Penumbra Mod Pack Files.", !Penumbra.ModManager.Valid, true);
"Import one or multiple mods from Tex Tools Mod Pack Files or Penumbra Mod Pack Files.", !_modManager.Valid, true);
_tutorial.OpenTutorial(BasicTutorialSteps.ModImport);
if (!button)
return;