From 9c954471fbfdcd32890a674b6a4710ac0b6c1411 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Sat, 27 Jul 2024 02:29:59 +0200 Subject: [PATCH] stub --- .../Interop/Ipc/IpcCallerPetNames.cs | 35 +++++++++++++++++++ MareSynchronos/Interop/Ipc/IpcManager.cs | 5 ++- .../PlayerData/Factories/PlayerDataFactory.cs | 1 + .../PlayerData/Handlers/PairHandler.cs | 1 + .../Services/CacheCreationService.cs | 3 ++ MareSynchronos/Plugin.cs | 4 ++- .../PluginWarningNotificationService.cs | 1 + 7 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 MareSynchronos/Interop/Ipc/IpcCallerPetNames.cs diff --git a/MareSynchronos/Interop/Ipc/IpcCallerPetNames.cs b/MareSynchronos/Interop/Ipc/IpcCallerPetNames.cs new file mode 100644 index 0000000..ff5ae70 --- /dev/null +++ b/MareSynchronos/Interop/Ipc/IpcCallerPetNames.cs @@ -0,0 +1,35 @@ +using Dalamud.Plugin; +using MareSynchronos.Services; +using MareSynchronos.Services.Mediator; +using Microsoft.Extensions.Logging; + +namespace MareSynchronos.Interop.Ipc; + +public sealed class IpcCallerPetNames : IIpcCaller +{ + private readonly ILogger _logger; + private readonly DalamudUtilService _dalamudUtil; + private readonly MareMediator _mareMediator; + + public IpcCallerPetNames(ILogger logger, IDalamudPluginInterface pi, DalamudUtilService dalamudUtil, + MareMediator mareMediator) + { + _logger = logger; + _dalamudUtil = dalamudUtil; + _mareMediator = mareMediator; + + // todo: implement this, bitch, look at moodles as example implementation + } + + public bool APIAvailable => throw new NotImplementedException(); + + public void CheckAPI() + { + throw new NotImplementedException(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } +} diff --git a/MareSynchronos/Interop/Ipc/IpcManager.cs b/MareSynchronos/Interop/Ipc/IpcManager.cs index 8be4968..ae6934c 100644 --- a/MareSynchronos/Interop/Ipc/IpcManager.cs +++ b/MareSynchronos/Interop/Ipc/IpcManager.cs @@ -7,7 +7,7 @@ public sealed partial class IpcManager : DisposableMediatorSubscriberBase { public IpcManager(ILogger logger, MareMediator mediator, IpcCallerPenumbra penumbraIpc, IpcCallerGlamourer glamourerIpc, IpcCallerCustomize customizeIpc, IpcCallerHeels heelsIpc, - IpcCallerHonorific honorificIpc, IpcCallerMoodles moodlesIpc) : base(logger, mediator) + IpcCallerHonorific honorificIpc, IpcCallerMoodles moodlesIpc, IpcCallerPetNames ipcCallerPetNames) : base(logger, mediator) { CustomizePlus = customizeIpc; Heels = heelsIpc; @@ -15,6 +15,7 @@ public sealed partial class IpcManager : DisposableMediatorSubscriberBase Penumbra = penumbraIpc; Honorific = honorificIpc; Moodles = moodlesIpc; + PetNames = ipcCallerPetNames; if (Initialized) { @@ -41,6 +42,7 @@ public sealed partial class IpcManager : DisposableMediatorSubscriberBase public IpcCallerGlamourer Glamourer { get; } public IpcCallerPenumbra Penumbra { get; } public IpcCallerMoodles Moodles { get; } + public IpcCallerPetNames PetNames { get; } private void PeriodicApiStateCheck() { @@ -51,5 +53,6 @@ public sealed partial class IpcManager : DisposableMediatorSubscriberBase CustomizePlus.CheckAPI(); Honorific.CheckAPI(); Moodles.CheckAPI(); + PetNames.CheckAPI(); } } \ No newline at end of file diff --git a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs index eadf9b4..ee2fc7b 100644 --- a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs +++ b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs @@ -216,6 +216,7 @@ public class PlayerDataFactory _logger.LogDebug("Heels is now: {heels}", previousData.HeelsData); if (objectKind == ObjectKind.Player) { + // TODO: use petnames here and save it to moodles data for temporary transfer previousData.MoodlesData = await _ipcManager.Moodles.GetStatusAsync(playerRelatedObject.Address).ConfigureAwait(false) ?? string.Empty; _logger.LogDebug("Moodles is now: {moodles}", previousData.MoodlesData); } diff --git a/MareSynchronos/PlayerData/Handlers/PairHandler.cs b/MareSynchronos/PlayerData/Handlers/PairHandler.cs index f7aab7c..a746bd8 100644 --- a/MareSynchronos/PlayerData/Handlers/PairHandler.cs +++ b/MareSynchronos/PlayerData/Handlers/PairHandler.cs @@ -342,6 +342,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase break; case PlayerChanges.Moodles: + // TODO: send it to petnames ipc here instead await _ipcManager.Moodles.SetStatusAsync(handler.Address, charaData.MoodlesData).ConfigureAwait(false); break; diff --git a/MareSynchronos/PlayerData/Services/CacheCreationService.cs b/MareSynchronos/PlayerData/Services/CacheCreationService.cs index 5078376..02fd9dd 100644 --- a/MareSynchronos/PlayerData/Services/CacheCreationService.cs +++ b/MareSynchronos/PlayerData/Services/CacheCreationService.cs @@ -122,6 +122,9 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase MoodlesChanged(); } }); + + // TODO: if event is needed for petnames add it here similar to moodles + Mediator.Subscribe(this, (msg) => { Logger.LogDebug("Received Penumbra Mod settings change, updating player"); diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 5a5fd1d..d6ea8f4 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -102,10 +102,12 @@ public sealed class Plugin : IDalamudPlugin s.GetRequiredService(), s.GetRequiredService())); collection.AddSingleton((s) => new IpcCallerMoodles(s.GetRequiredService>(), pluginInterface, s.GetRequiredService(), s.GetRequiredService())); + collection.AddSingleton((s) => new IpcCallerPetNames(s.GetRequiredService>(), pluginInterface, + s.GetRequiredService(), s.GetRequiredService())); collection.AddSingleton((s) => new IpcManager(s.GetRequiredService>(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), - s.GetRequiredService())); + s.GetRequiredService(), s.GetRequiredService())); collection.AddSingleton((s) => new NotificationService(s.GetRequiredService>(), s.GetRequiredService(), s.GetRequiredService(), notificationManager, chatGui, s.GetRequiredService())); diff --git a/MareSynchronos/Services/PluginWarningNotificationService.cs b/MareSynchronos/Services/PluginWarningNotificationService.cs index 4885832..98bcc11 100644 --- a/MareSynchronos/Services/PluginWarningNotificationService.cs +++ b/MareSynchronos/Services/PluginWarningNotificationService.cs @@ -53,6 +53,7 @@ public class PluginWarningNotificationService warning.ShownHonorificWarning = true; } + // todo: change the moodles apiavailable to petnames for testing if (changes.Contains(PlayerChanges.Moodles) && !warning.ShownMoodlesWarning && !_ipcManager.Moodles.APIAvailable) { missingPluginsForData.Add("Moodles");