diff --git a/Questionable/External/QuestionableIpc.cs b/Questionable/External/QuestionableIpc.cs new file mode 100644 index 000000000..e73053ef5 --- /dev/null +++ b/Questionable/External/QuestionableIpc.cs @@ -0,0 +1,31 @@ +using System; +using Dalamud.Plugin; +using Dalamud.Plugin.Ipc; +using Questionable.Controller; + +namespace Questionable.External; + +internal sealed class QuestionableIpc : IDisposable +{ + private const string IpcIsRunning = "Questionable.IsRunning"; + private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId"; + + private readonly ICallGateProvider _isRunning; + private readonly ICallGateProvider _getCurrentQuestId; + + public QuestionableIpc(QuestController questController, IDalamudPluginInterface pluginInterface) + { + _isRunning = pluginInterface.GetIpcProvider(IpcIsRunning); + _isRunning.RegisterFunc(() => questController.IsRunning); + + _getCurrentQuestId = pluginInterface.GetIpcProvider(IpcGetCurrentQuestId); + _getCurrentQuestId.RegisterFunc(() => questController.CurrentQuest?.Quest.Id.ToString()); + } + + + public void Dispose() + { + _getCurrentQuestId.UnregisterFunc(); + _isRunning.UnregisterFunc(); + } +} diff --git a/Questionable/QuestionablePlugin.cs b/Questionable/QuestionablePlugin.cs index 207cf2b11..d1a5b543f 100644 --- a/Questionable/QuestionablePlugin.cs +++ b/Questionable/QuestionablePlugin.cs @@ -120,6 +120,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); } private static void AddTaskFactories(ServiceCollection serviceCollection) @@ -235,6 +236,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceProvider.GetRequiredService(); serviceProvider.GetRequiredService(); serviceProvider.GetRequiredService(); + serviceProvider.GetRequiredService(); serviceProvider.GetRequiredService(); }