Use PluginWatchService for Glamournumbra too
This commit is contained in:
@@ -27,6 +27,9 @@ public sealed class IpcCallerGlamourer : DisposableMediatorSubscriberBase, IIpcC
|
||||
private readonly UnlockStateName _glamourerUnlockByName;
|
||||
private readonly EventSubscriber<nint>? _glamourerStateChanged;
|
||||
|
||||
private bool _pluginLoaded;
|
||||
private Version _pluginVersion;
|
||||
|
||||
private bool _shownGlamourerUnavailable = false;
|
||||
private readonly uint LockCode = 0x626E7579;
|
||||
|
||||
@@ -52,6 +55,18 @@ public sealed class IpcCallerGlamourer : DisposableMediatorSubscriberBase, IIpcC
|
||||
_glamourerStateChanged.Enable();
|
||||
|
||||
Mediator.Subscribe<DalamudLoginMessage>(this, s => _shownGlamourerUnavailable = false);
|
||||
|
||||
var plugin = _pi.InstalledPlugins.FirstOrDefault(p => p.InternalName.Equals("Glamourer", StringComparison.Ordinal));
|
||||
|
||||
_pluginLoaded = plugin?.IsLoaded ?? false;
|
||||
_pluginVersion = plugin?.Version ?? new(0, 0, 0, 0);
|
||||
|
||||
Mediator.SubscribeKeyed<PluginChangeMessage>(this, "Glamourer", (msg) =>
|
||||
{
|
||||
_pluginLoaded = msg.IsLoaded;
|
||||
_pluginVersion = msg.Version;
|
||||
CheckAPI();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -69,9 +84,7 @@ public sealed class IpcCallerGlamourer : DisposableMediatorSubscriberBase, IIpcC
|
||||
bool apiAvailable = false;
|
||||
try
|
||||
{
|
||||
bool versionValid = (_pi.InstalledPlugins
|
||||
.FirstOrDefault(p => string.Equals(p.InternalName, "Glamourer", StringComparison.OrdinalIgnoreCase))
|
||||
?.Version ?? new Version(0, 0, 0, 0)) >= new Version(1, 0, 6, 1);
|
||||
bool versionValid = _pluginLoaded && _pluginVersion >= new Version(1, 0, 6, 1);
|
||||
try
|
||||
{
|
||||
var version = _glamourerApiVersions.Invoke();
|
||||
|
||||
@@ -53,6 +53,9 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
||||
private readonly ResolvePlayerPathsAsync _penumbraResolvePaths;
|
||||
private readonly GetGameObjectResourcePaths _penumbraResourcePaths;
|
||||
|
||||
private bool _pluginLoaded;
|
||||
private Version _pluginVersion;
|
||||
|
||||
public IpcCallerPenumbra(ILogger<IpcCallerPenumbra> logger, IDalamudPluginInterface pi, DalamudUtilService dalamudUtil,
|
||||
MareMediator mareMediator, RedrawManager redrawManager) : base(logger, mareMediator)
|
||||
{
|
||||
@@ -92,6 +95,18 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
||||
});
|
||||
|
||||
Mediator.Subscribe<DalamudLoginMessage>(this, (msg) => _shownPenumbraUnavailable = false);
|
||||
|
||||
var plugin = _pi.InstalledPlugins.FirstOrDefault(p => p.InternalName.Equals("Penumbra", StringComparison.Ordinal));
|
||||
|
||||
_pluginLoaded = plugin?.IsLoaded ?? false;
|
||||
_pluginVersion = plugin?.Version ?? new(0, 0, 0, 0);
|
||||
|
||||
Mediator.SubscribeKeyed<PluginChangeMessage>(this, "Penumbra", (msg) =>
|
||||
{
|
||||
_pluginLoaded = msg.IsLoaded;
|
||||
_pluginVersion = msg.Version;
|
||||
CheckAPI();
|
||||
});
|
||||
}
|
||||
|
||||
public bool APIAvailable { get; private set; } = false;
|
||||
@@ -101,10 +116,7 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
|
||||
bool penumbraAvailable = false;
|
||||
try
|
||||
{
|
||||
var penumbraVersion = (_pi.InstalledPlugins
|
||||
.FirstOrDefault(p => string.Equals(p.InternalName, "Penumbra", StringComparison.OrdinalIgnoreCase))
|
||||
?.Version ?? new Version(0, 0, 0, 0));
|
||||
penumbraAvailable = penumbraVersion >= new Version(1, 0, 1, 0);
|
||||
penumbraAvailable = _pluginLoaded && _pluginVersion >= new Version(1, 0, 1, 0);
|
||||
try
|
||||
{
|
||||
penumbraAvailable &= _penumbraEnabled.Invoke();
|
||||
|
||||
@@ -58,9 +58,8 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
});
|
||||
|
||||
_marePluginEnabled = pi.InstalledPlugins.Any(p => p.InternalName == "MareSynchronos" && p.IsLoaded);
|
||||
Mediator.Subscribe<PluginChangeMessage>(this, p => {
|
||||
if (p.InternalName == "MareSynchronos")
|
||||
_marePluginEnabled = p.IsLoaded;
|
||||
Mediator.SubscribeKeyed<PluginChangeMessage>(this, "MareSynchronos", p => {
|
||||
_marePluginEnabled = p.IsLoaded;
|
||||
HandleMareImpersonation();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user