Remove Mod.BasePath

This commit is contained in:
Ottermandias 2023-04-21 23:17:05 +02:00
parent 49c8afb72a
commit aa4bc45641
7 changed files with 78 additions and 80 deletions

View file

@ -28,33 +28,34 @@ public class IpcTester : IDisposable
private readonly PenumbraIpcProviders _ipcProviders; private readonly PenumbraIpcProviders _ipcProviders;
private bool _subscribed = true; private bool _subscribed = true;
private readonly PluginState _pluginState; private readonly PluginState _pluginState;
private readonly Configuration _configuration; private readonly IpcConfiguration _ipcConfiguration;
private readonly Ui _ui; private readonly Ui _ui;
private readonly Redrawing _redrawing; private readonly Redrawing _redrawing;
private readonly GameState _gameState; private readonly GameState _gameState;
private readonly Resolve _resolve; private readonly Resolve _resolve;
private readonly Collections _collections; private readonly Collections _collections;
private readonly Meta _meta; private readonly Meta _meta;
private readonly Mods _mods; private readonly Mods _mods;
private readonly ModSettings _modSettings; private readonly ModSettings _modSettings;
private readonly Temporary _temporary; 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) TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService)
{ {
_ipcProviders = ipcProviders; _ipcProviders = ipcProviders;
_pluginState = new PluginState(pi); _pluginState = new PluginState(pi);
_configuration = new Configuration(pi); _ipcConfiguration = new IpcConfiguration(pi);
_ui = new Ui(pi); _ui = new Ui(pi);
_redrawing = new Redrawing(pi); _redrawing = new Redrawing(pi);
_gameState = new GameState(pi); _gameState = new GameState(pi);
_resolve = new Resolve(pi); _resolve = new Resolve(pi);
_collections = new Collections(pi); _collections = new Collections(pi);
_meta = new Meta(pi); _meta = new Meta(pi);
_mods = new Mods(pi); _mods = new Mods(pi);
_modSettings = new ModSettings(pi); _modSettings = new ModSettings(pi);
_temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService, _configuration); _temporary = new Temporary(pi, modManager, collections, tempMods, tempCollections, saveService, config);
UnsubscribeEvents(); UnsubscribeEvents();
} }
@ -65,7 +66,7 @@ public class IpcTester : IDisposable
SubscribeEvents(); SubscribeEvents();
ImGui.TextUnformatted($"API Version: {_ipcProviders.Api.ApiVersion.Breaking}.{_ipcProviders.Api.ApiVersion.Feature:D4}"); ImGui.TextUnformatted($"API Version: {_ipcProviders.Api.ApiVersion.Breaking}.{_ipcProviders.Api.ApiVersion.Feature:D4}");
_pluginState.Draw(); _pluginState.Draw();
_configuration.Draw(); _ipcConfiguration.Draw();
_ui.Draw(); _ui.Draw();
_redrawing.Draw(); _redrawing.Draw();
_gameState.Draw(); _gameState.Draw();
@ -97,7 +98,7 @@ public class IpcTester : IDisposable
_modSettings.SettingChanged.Enable(); _modSettings.SettingChanged.Enable();
_gameState.CharacterBaseCreating.Enable(); _gameState.CharacterBaseCreating.Enable();
_gameState.CharacterBaseCreated.Enable(); _gameState.CharacterBaseCreated.Enable();
_configuration.ModDirectoryChanged.Enable(); _ipcConfiguration.ModDirectoryChanged.Enable();
_gameState.GameObjectResourcePathResolved.Enable(); _gameState.GameObjectResourcePathResolved.Enable();
_mods.DeleteSubscriber.Enable(); _mods.DeleteSubscriber.Enable();
_mods.AddSubscriber.Enable(); _mods.AddSubscriber.Enable();
@ -121,7 +122,7 @@ public class IpcTester : IDisposable
_modSettings.SettingChanged.Disable(); _modSettings.SettingChanged.Disable();
_gameState.CharacterBaseCreating.Disable(); _gameState.CharacterBaseCreating.Disable();
_gameState.CharacterBaseCreated.Disable(); _gameState.CharacterBaseCreated.Disable();
_configuration.ModDirectoryChanged.Disable(); _ipcConfiguration.ModDirectoryChanged.Disable();
_gameState.GameObjectResourcePathResolved.Disable(); _gameState.GameObjectResourcePathResolved.Disable();
_mods.DeleteSubscriber.Disable(); _mods.DeleteSubscriber.Disable();
_mods.AddSubscriber.Disable(); _mods.AddSubscriber.Disable();
@ -143,7 +144,7 @@ public class IpcTester : IDisposable
_modSettings.SettingChanged.Dispose(); _modSettings.SettingChanged.Dispose();
_gameState.CharacterBaseCreating.Dispose(); _gameState.CharacterBaseCreating.Dispose();
_gameState.CharacterBaseCreated.Dispose(); _gameState.CharacterBaseCreated.Dispose();
_configuration.ModDirectoryChanged.Dispose(); _ipcConfiguration.ModDirectoryChanged.Dispose();
_gameState.GameObjectResourcePathResolved.Dispose(); _gameState.GameObjectResourcePathResolved.Dispose();
_mods.DeleteSubscriber.Dispose(); _mods.DeleteSubscriber.Dispose();
_mods.AddSubscriber.Dispose(); _mods.AddSubscriber.Dispose();
@ -229,7 +230,7 @@ public class IpcTester : IDisposable
=> (_lastEnabledChange, _lastEnabledValue) = (DateTimeOffset.Now, val); => (_lastEnabledChange, _lastEnabledValue) = (DateTimeOffset.Now, val);
} }
private class Configuration private class IpcConfiguration
{ {
private readonly DalamudPluginInterface _pi; private readonly DalamudPluginInterface _pi;
public readonly EventSubscriber<string, bool> ModDirectoryChanged; public readonly EventSubscriber<string, bool> ModDirectoryChanged;
@ -239,7 +240,7 @@ public class IpcTester : IDisposable
private bool _lastModDirectoryValid; private bool _lastModDirectoryValid;
private DateTimeOffset _lastModDirectoryTime = DateTimeOffset.MinValue; private DateTimeOffset _lastModDirectoryTime = DateTimeOffset.MinValue;
public Configuration(DalamudPluginInterface pi) public IpcConfiguration(DalamudPluginInterface pi)
{ {
_pi = pi; _pi = pi;
ModDirectoryChanged = Ipc.ModDirectoryChanged.Subscriber(pi, UpdateModDirectoryChanged); ModDirectoryChanged = Ipc.ModDirectoryChanged.Subscriber(pi, UpdateModDirectoryChanged);

View file

@ -116,7 +116,7 @@ public class PenumbraIpcProviders : IDisposable
internal readonly FuncProvider<string, string, int, PenumbraApiEc> RemoveTemporaryMod; internal readonly FuncProvider<string, string, int, PenumbraApiEc> RemoveTemporaryMod;
public PenumbraIpcProviders(DalamudPluginInterface pi, IPenumbraApi api, ModManager modManager, CollectionManager collections, 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; Api = api;
@ -228,7 +228,7 @@ public class PenumbraIpcProviders : IDisposable
RemoveTemporaryModAll = Ipc.RemoveTemporaryModAll.Provider(pi, Api.RemoveTemporaryModAll); RemoveTemporaryModAll = Ipc.RemoveTemporaryModAll.Provider(pi, Api.RemoveTemporaryModAll);
RemoveTemporaryMod = Ipc.RemoveTemporaryMod.Provider(pi, Api.RemoveTemporaryMod); 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(); Initialized.Invoke();
} }

View file

@ -18,6 +18,16 @@ public enum NewDirectoryState
Identical, Identical,
Empty, Empty,
} }
/// <summary> Describes the state of a changed mod event. </summary>
public enum ModPathChangeType
{
Added,
Deleted,
Moved,
Reloaded,
StartingReload,
}
public sealed class ModManager : ModStorage public sealed class ModManager : ModStorage
{ {

View file

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

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using OtterGui; using OtterGui;
using OtterGui.Classes; using OtterGui.Classes;
@ -18,6 +19,25 @@ public sealed partial class Mod : IMod
Priority = int.MaxValue, 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;
/// <summary>Unused if Index < 0 but used for special temporary mods.</summary>
public int Priority
=> 0;
public Mod(DirectoryInfo modPath)
{
ModPath = modPath;
Default = new SubMod(this);
}
// Meta Data // Meta Data
public LowerString Name { get; internal set; } = "New Mod"; public LowerString Name { get; internal set; } = "New Mod";
public LowerString Author { get; internal set; } = LowerString.Empty; public LowerString Author { get; internal set; } = LowerString.Empty;

View file

@ -13,6 +13,9 @@ public class ModCache
public string LowerChangedItemsString = string.Empty; public string LowerChangedItemsString = string.Empty;
public string AllTagsLower = string.Empty; public string AllTagsLower = string.Empty;
public ModCache()
{}
public void Reset() public void Reset()
{ {
TotalFileCount = 0; TotalFileCount = 0;

View file

@ -34,14 +34,14 @@ public class Penumbra : IDalamudPlugin
public string Name public string Name
=> "Penumbra"; => "Penumbra";
public static Logger Log { get; private set; } = null!; public static Logger Log { get; private set; } = null!;
public static ChatService ChatService { get; private set; } = null!; public static ChatService ChatService { get; private set; } = null!;
public static Configuration Config { get; private set; } = null!; public static Configuration Config { get; private set; } = null!;
public static CharacterUtility CharacterUtility { get; private set; } = null!; public static CharacterUtility CharacterUtility { get; private set; } = null!;
public static ModCacheManager ModCaches { get; private set; } = null!; public static ModCacheManager ModCaches { get; private set; } = null!;
public static CollectionManager CollectionManager { get; private set; } = null!; public static CollectionManager CollectionManager { get; private set; } = null!;
public static ActorManager Actors { get; private set; } = null!; public static ActorManager Actors { get; private set; } = null!;
public readonly RedrawService RedrawService; public readonly RedrawService RedrawService;
public readonly ModFileSystem ModFileSystem; public readonly ModFileSystem ModFileSystem;
@ -67,15 +67,15 @@ public class Penumbra : IDalamudPlugin
ChatService = _tmp.Services.GetRequiredService<ChatService>(); ChatService = _tmp.Services.GetRequiredService<ChatService>();
_validityChecker = _tmp.Services.GetRequiredService<ValidityChecker>(); _validityChecker = _tmp.Services.GetRequiredService<ValidityChecker>();
_tmp.Services.GetRequiredService<BackupService>(); _tmp.Services.GetRequiredService<BackupService>();
Config = _tmp.Services.GetRequiredService<Configuration>(); Config = _tmp.Services.GetRequiredService<Configuration>();
CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>(); CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService; Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService;
_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<ModManager>(); _modManager = _tmp.Services.GetRequiredService<ModManager>();
CollectionManager = _tmp.Services.GetRequiredService<CollectionManager>(); 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>();
_tmp.Services.GetRequiredService<ResourceService>(); _tmp.Services.GetRequiredService<ResourceService>();