listen to glamourer changes
This commit is contained in:
@@ -114,6 +114,8 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
_glamourerRevertByName = pi.GetIpcSubscriber<string, uint, object?>("Glamourer.RevertLock");
|
_glamourerRevertByName = pi.GetIpcSubscriber<string, uint, object?>("Glamourer.RevertLock");
|
||||||
_glamourerUnlock = pi.GetIpcSubscriber<string, uint, bool>("Glamourer.UnlockName");
|
_glamourerUnlock = pi.GetIpcSubscriber<string, uint, bool>("Glamourer.UnlockName");
|
||||||
|
|
||||||
|
pi.GetIpcSubscriber<int, nint, Lazy<string>, object?>("Glamourer.StateChanged").Subscribe((type, address, customize) => GlamourerChanged(address));
|
||||||
|
|
||||||
_heelsGetApiVersion = pi.GetIpcSubscriber<(int, int)>("SimpleHeels.ApiVersion");
|
_heelsGetApiVersion = pi.GetIpcSubscriber<(int, int)>("SimpleHeels.ApiVersion");
|
||||||
_heelsGetOffset = pi.GetIpcSubscriber<string>("SimpleHeels.GetLocalPlayer");
|
_heelsGetOffset = pi.GetIpcSubscriber<string>("SimpleHeels.GetLocalPlayer");
|
||||||
_heelsRegisterPlayer = pi.GetIpcSubscriber<GameObject, string, object?>("SimpleHeels.RegisterPlayer");
|
_heelsRegisterPlayer = pi.GetIpcSubscriber<GameObject, string, object?>("SimpleHeels.RegisterPlayer");
|
||||||
@@ -755,6 +757,11 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||||||
return _penumbraResolveModDir!.Invoke().ToLowerInvariant();
|
return _penumbraResolveModDir!.Invoke().ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GlamourerChanged(nint address)
|
||||||
|
{
|
||||||
|
Mediator.Publish(new GlamourerChangedMessage(address));
|
||||||
|
}
|
||||||
|
|
||||||
private void HeelsOffsetChange(string offset)
|
private void HeelsOffsetChange(string offset)
|
||||||
{
|
{
|
||||||
Mediator.Publish(new HeelsOffsetMessage());
|
Mediator.Publish(new HeelsOffsetMessage());
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
|||||||
private CancellationTokenSource _honorificCts = new();
|
private CancellationTokenSource _honorificCts = new();
|
||||||
private bool _isZoning = false;
|
private bool _isZoning = false;
|
||||||
private CancellationTokenSource _palettePlusCts = new();
|
private CancellationTokenSource _palettePlusCts = new();
|
||||||
|
private readonly Dictionary<ObjectKind, CancellationTokenSource> _glamourerCts = new();
|
||||||
|
|
||||||
public CacheCreationService(ILogger<CacheCreationService> logger, MareMediator mediator, GameObjectHandlerFactory gameObjectHandlerFactory,
|
public CacheCreationService(ILogger<CacheCreationService> logger, MareMediator mediator, GameObjectHandlerFactory gameObjectHandlerFactory,
|
||||||
PlayerDataFactory characterDataFactory, DalamudUtilService dalamudUtil) : base(logger, mediator)
|
PlayerDataFactory characterDataFactory, DalamudUtilService dalamudUtil) : base(logger, mediator)
|
||||||
@@ -90,6 +91,15 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
|||||||
Logger.LogDebug("Received Heels Offset change, updating player");
|
Logger.LogDebug("Received Heels Offset change, updating player");
|
||||||
await AddPlayerCacheToCreate().ConfigureAwait(false);
|
await AddPlayerCacheToCreate().ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
Mediator.Subscribe<GlamourerChangedMessage>(this, async (msg) =>
|
||||||
|
{
|
||||||
|
if (_isZoning) return;
|
||||||
|
var changedType = _playerRelatedObjects.FirstOrDefault(f => f.Value.Address == msg.Address);
|
||||||
|
if (!default(KeyValuePair<ObjectKind, GameObjectHandler>).Equals(changedType))
|
||||||
|
{
|
||||||
|
GlamourerChanged(changedType.Key);
|
||||||
|
}
|
||||||
|
});
|
||||||
Mediator.Subscribe<PalettePlusMessage>(this, (msg) =>
|
Mediator.Subscribe<PalettePlusMessage>(this, (msg) =>
|
||||||
{
|
{
|
||||||
if (_isZoning) return;
|
if (_isZoning) return;
|
||||||
@@ -132,6 +142,23 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
|||||||
_cacheCreateLock.Release();
|
_cacheCreateLock.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GlamourerChanged(ObjectKind kind)
|
||||||
|
{
|
||||||
|
if (_glamourerCts.TryGetValue(kind, out var cts))
|
||||||
|
{
|
||||||
|
_glamourerCts[kind]?.Cancel();
|
||||||
|
_glamourerCts[kind]?.Dispose();
|
||||||
|
}
|
||||||
|
_glamourerCts[kind] = new();
|
||||||
|
var token = _glamourerCts[kind].Token;
|
||||||
|
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(1), token).ConfigureAwait(false);
|
||||||
|
await AddPlayerCacheToCreate(kind).ConfigureAwait(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void HonorificChanged()
|
private void HonorificChanged()
|
||||||
{
|
{
|
||||||
_honorificCts?.Cancel();
|
_honorificCts?.Cancel();
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
collection.AddSingleton<FileDownloadManagerFactory>();
|
collection.AddSingleton<FileDownloadManagerFactory>();
|
||||||
collection.AddSingleton((s) => new PairHandlerFactory(s.GetRequiredService<ILoggerFactory>(), s.GetRequiredService<GameObjectHandlerFactory>(),
|
collection.AddSingleton((s) => new PairHandlerFactory(s.GetRequiredService<ILoggerFactory>(), s.GetRequiredService<GameObjectHandlerFactory>(),
|
||||||
s.GetRequiredService<IpcManager>(), s.GetRequiredService<FileDownloadManagerFactory>(), s.GetRequiredService<DalamudUtilService>(),
|
s.GetRequiredService<IpcManager>(), s.GetRequiredService<FileDownloadManagerFactory>(), s.GetRequiredService<DalamudUtilService>(),
|
||||||
s.GetRequiredService<PluginWarningNotificationService>(), CancellationTokenSource.CreateLinkedTokenSource(addonLifecycle.GameShuttingDownToken, addonLifecycle.DalamudUnloadingToken).Token,
|
s.GetRequiredService<PluginWarningNotificationService>(),
|
||||||
|
CancellationTokenSource.CreateLinkedTokenSource(addonLifecycle.GameShuttingDownToken, addonLifecycle.DalamudUnloadingToken).Token,
|
||||||
s.GetRequiredService<FileCacheManager>(), s.GetRequiredService<MareMediator>()));
|
s.GetRequiredService<FileCacheManager>(), s.GetRequiredService<MareMediator>()));
|
||||||
collection.AddSingleton<PairFactory>();
|
collection.AddSingleton<PairFactory>();
|
||||||
collection.AddSingleton<CharacterAnalyzer>();
|
collection.AddSingleton<CharacterAnalyzer>();
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public record PenumbraModSettingChangedMessage : MessageBase;
|
|||||||
public record PenumbraInitializedMessage : MessageBase;
|
public record PenumbraInitializedMessage : MessageBase;
|
||||||
public record PenumbraDisposedMessage : MessageBase;
|
public record PenumbraDisposedMessage : MessageBase;
|
||||||
public record PenumbraRedrawMessage(IntPtr Address, int ObjTblIdx, bool WasRequested) : SameThreadMessage;
|
public record PenumbraRedrawMessage(IntPtr Address, int ObjTblIdx, bool WasRequested) : SameThreadMessage;
|
||||||
|
public record GlamourerChangedMessage(IntPtr Address) : MessageBase;
|
||||||
public record HeelsOffsetMessage : MessageBase;
|
public record HeelsOffsetMessage : MessageBase;
|
||||||
public record PenumbraResourceLoadMessage(IntPtr GameObject, string GamePath, string FilePath) : SameThreadMessage;
|
public record PenumbraResourceLoadMessage(IntPtr GameObject, string GamePath, string FilePath) : SameThreadMessage;
|
||||||
public record CustomizePlusMessage(string ProfileName) : MessageBase;
|
public record CustomizePlusMessage(string ProfileName) : MessageBase;
|
||||||
|
|||||||
Reference in New Issue
Block a user