diff --git a/Penumbra/Api/IpcTester.cs b/Penumbra/Api/IpcTester.cs index 8c859bc8..1044581f 100644 --- a/Penumbra/Api/IpcTester.cs +++ b/Penumbra/Api/IpcTester.cs @@ -28,33 +28,34 @@ public class IpcTester : IDisposable private readonly PenumbraIpcProviders _ipcProviders; private bool _subscribed = true; - private readonly PluginState _pluginState; - private readonly Configuration _configuration; - private readonly Ui _ui; - private readonly Redrawing _redrawing; - private readonly GameState _gameState; - private readonly Resolve _resolve; - private readonly Collections _collections; - private readonly Meta _meta; - private readonly Mods _mods; - private readonly ModSettings _modSettings; - private readonly Temporary _temporary; + private readonly PluginState _pluginState; + private readonly IpcConfiguration _ipcConfiguration; + private readonly Ui _ui; + private readonly Redrawing _redrawing; + private readonly GameState _gameState; + private readonly Resolve _resolve; + private readonly Collections _collections; + private readonly Meta _meta; + private readonly Mods _mods; + private readonly ModSettings _modSettings; + private readonly Temporary _temporary; - public IpcTester(DalamudPluginInterface pi, PenumbraIpcProviders ipcProviders, ModManager modManager, CollectionManager collections, + public IpcTester(Configuration config, DalamudPluginInterface pi, PenumbraIpcProviders ipcProviders, ModManager modManager, + CollectionManager collections, TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService) { - _ipcProviders = ipcProviders; - _pluginState = new PluginState(pi); - _configuration = new Configuration(pi); - _ui = new Ui(pi); - _redrawing = new Redrawing(pi); - _gameState = new GameState(pi); - _resolve = new Resolve(pi); - _collections = new Collections(pi); - _meta = new Meta(pi); - _mods = new Mods(pi); - _modSettings = new ModSettings(pi); - _temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService, _configuration); + _ipcProviders = ipcProviders; + _pluginState = new PluginState(pi); + _ipcConfiguration = new IpcConfiguration(pi); + _ui = new Ui(pi); + _redrawing = new Redrawing(pi); + _gameState = new GameState(pi); + _resolve = new Resolve(pi); + _collections = new Collections(pi); + _meta = new Meta(pi); + _mods = new Mods(pi); + _modSettings = new ModSettings(pi); + _temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService, config); UnsubscribeEvents(); } @@ -65,7 +66,7 @@ public class IpcTester : IDisposable SubscribeEvents(); ImGui.TextUnformatted($"API Version: {_ipcProviders.Api.ApiVersion.Breaking}.{_ipcProviders.Api.ApiVersion.Feature:D4}"); _pluginState.Draw(); - _configuration.Draw(); + _ipcConfiguration.Draw(); _ui.Draw(); _redrawing.Draw(); _gameState.Draw(); @@ -97,7 +98,7 @@ public class IpcTester : IDisposable _modSettings.SettingChanged.Enable(); _gameState.CharacterBaseCreating.Enable(); _gameState.CharacterBaseCreated.Enable(); - _configuration.ModDirectoryChanged.Enable(); + _ipcConfiguration.ModDirectoryChanged.Enable(); _gameState.GameObjectResourcePathResolved.Enable(); _mods.DeleteSubscriber.Enable(); _mods.AddSubscriber.Enable(); @@ -121,7 +122,7 @@ public class IpcTester : IDisposable _modSettings.SettingChanged.Disable(); _gameState.CharacterBaseCreating.Disable(); _gameState.CharacterBaseCreated.Disable(); - _configuration.ModDirectoryChanged.Disable(); + _ipcConfiguration.ModDirectoryChanged.Disable(); _gameState.GameObjectResourcePathResolved.Disable(); _mods.DeleteSubscriber.Disable(); _mods.AddSubscriber.Disable(); @@ -143,7 +144,7 @@ public class IpcTester : IDisposable _modSettings.SettingChanged.Dispose(); _gameState.CharacterBaseCreating.Dispose(); _gameState.CharacterBaseCreated.Dispose(); - _configuration.ModDirectoryChanged.Dispose(); + _ipcConfiguration.ModDirectoryChanged.Dispose(); _gameState.GameObjectResourcePathResolved.Dispose(); _mods.DeleteSubscriber.Dispose(); _mods.AddSubscriber.Dispose(); @@ -229,7 +230,7 @@ public class IpcTester : IDisposable => (_lastEnabledChange, _lastEnabledValue) = (DateTimeOffset.Now, val); } - private class Configuration + private class IpcConfiguration { private readonly DalamudPluginInterface _pi; public readonly EventSubscriber ModDirectoryChanged; @@ -239,7 +240,7 @@ public class IpcTester : IDisposable private bool _lastModDirectoryValid; private DateTimeOffset _lastModDirectoryTime = DateTimeOffset.MinValue; - public Configuration(DalamudPluginInterface pi) + public IpcConfiguration(DalamudPluginInterface pi) { _pi = pi; ModDirectoryChanged = Ipc.ModDirectoryChanged.Subscriber(pi, UpdateModDirectoryChanged); diff --git a/Penumbra/Api/PenumbraIpcProviders.cs b/Penumbra/Api/PenumbraIpcProviders.cs index 36245110..e8139453 100644 --- a/Penumbra/Api/PenumbraIpcProviders.cs +++ b/Penumbra/Api/PenumbraIpcProviders.cs @@ -116,7 +116,7 @@ public class PenumbraIpcProviders : IDisposable internal readonly FuncProvider RemoveTemporaryMod; public PenumbraIpcProviders(DalamudPluginInterface pi, IPenumbraApi api, ModManager modManager, CollectionManager collections, - TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService) + TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config) { Api = api; @@ -228,7 +228,7 @@ public class PenumbraIpcProviders : IDisposable RemoveTemporaryModAll = Ipc.RemoveTemporaryModAll.Provider(pi, Api.RemoveTemporaryModAll); RemoveTemporaryMod = Ipc.RemoveTemporaryMod.Provider(pi, Api.RemoveTemporaryMod); - Tester = new IpcTester(pi, this, modManager, collections, tempMods, tempCollections, saveService); + Tester = new IpcTester(config, pi, this, modManager, collections, tempMods, tempCollections, saveService); Initialized.Invoke(); } diff --git a/Penumbra/Mods/Manager/ModManager.cs b/Penumbra/Mods/Manager/ModManager.cs index ae22c5e9..746cb645 100644 --- a/Penumbra/Mods/Manager/ModManager.cs +++ b/Penumbra/Mods/Manager/ModManager.cs @@ -18,6 +18,16 @@ public enum NewDirectoryState Identical, Empty, } + +/// Describes the state of a changed mod event. +public enum ModPathChangeType +{ + Added, + Deleted, + Moved, + Reloaded, + StartingReload, +} public sealed class ModManager : ModStorage { diff --git a/Penumbra/Mods/Mod.BasePath.cs b/Penumbra/Mods/Mod.BasePath.cs deleted file mode 100644 index 28258ded..00000000 --- a/Penumbra/Mods/Mod.BasePath.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Penumbra.Mods.Manager; - -namespace Penumbra.Mods; - -public enum ModPathChangeType -{ - Added, - Deleted, - Moved, - Reloaded, - StartingReload, -} - -public partial class Mod -{ - public DirectoryInfo ModPath { get; internal set; } - public string Identifier - => Index >= 0 ? ModPath.Name : Name; - public int Index { get; internal set; } = -1; - - public bool IsTemporary - => Index < 0; - - // Unused if Index < 0 but used for special temporary mods. - public int Priority - => 0; - - internal Mod( DirectoryInfo modPath ) - { - ModPath = modPath; - Default = new SubMod( this ); - } -} \ No newline at end of file diff --git a/Penumbra/Mods/Mod.cs b/Penumbra/Mods/Mod.cs index 24a78370..fb011b2b 100644 --- a/Penumbra/Mods/Mod.cs +++ b/Penumbra/Mods/Mod.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using OtterGui; using OtterGui.Classes; @@ -18,6 +19,25 @@ public sealed partial class Mod : IMod Priority = int.MaxValue, }; + // Main Data + public DirectoryInfo ModPath { get; internal set; } + public string Identifier + => Index >= 0 ? ModPath.Name : Name; + public int Index { get; internal set; } = -1; + + public bool IsTemporary + => Index < 0; + + /// Unused if Index < 0 but used for special temporary mods. + public int Priority + => 0; + + public Mod(DirectoryInfo modPath) + { + ModPath = modPath; + Default = new SubMod(this); + } + // Meta Data public LowerString Name { get; internal set; } = "New Mod"; public LowerString Author { get; internal set; } = LowerString.Empty; diff --git a/Penumbra/Mods/ModCache.cs b/Penumbra/Mods/ModCache.cs index 76e01bf6..5872587d 100644 --- a/Penumbra/Mods/ModCache.cs +++ b/Penumbra/Mods/ModCache.cs @@ -13,6 +13,9 @@ public class ModCache public string LowerChangedItemsString = string.Empty; public string AllTagsLower = string.Empty; + public ModCache() + {} + public void Reset() { TotalFileCount = 0; diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index c46f23b4..ca0a06ae 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -34,14 +34,14 @@ public class Penumbra : IDalamudPlugin public string Name => "Penumbra"; - public static Logger Log { get; private set; } = null!; - public static ChatService ChatService { get; private set; } = null!; - public static Configuration Config { get; private set; } = null!; + public static Logger Log { get; private set; } = null!; + public static ChatService ChatService { get; private set; } = null!; + public static Configuration Config { get; private set; } = null!; - public static CharacterUtility CharacterUtility { 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!; + public static CharacterUtility CharacterUtility { 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!; public readonly RedrawService RedrawService; public readonly ModFileSystem ModFileSystem; @@ -67,15 +67,15 @@ public class Penumbra : IDalamudPlugin ChatService = _tmp.Services.GetRequiredService(); _validityChecker = _tmp.Services.GetRequiredService(); _tmp.Services.GetRequiredService(); - Config = _tmp.Services.GetRequiredService(); - CharacterUtility = _tmp.Services.GetRequiredService(); - Actors = _tmp.Services.GetRequiredService().AwaitedService; + Config = _tmp.Services.GetRequiredService(); + CharacterUtility = _tmp.Services.GetRequiredService(); + Actors = _tmp.Services.GetRequiredService().AwaitedService; _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(); + _tempCollections = _tmp.Services.GetRequiredService(); ModFileSystem = _tmp.Services.GetRequiredService(); RedrawService = _tmp.Services.GetRequiredService(); _tmp.Services.GetRequiredService();