From 01e6f5846335d3741395c741c3f244e71ef36446 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 28 Mar 2025 16:53:43 +0100 Subject: [PATCH] Add Launching IPC Event. API 5.8 --- Penumbra.Api | 2 +- Penumbra/Api/Api/PenumbraApi.cs | 5 ++++- Penumbra/Api/IpcLaunchingProvider.cs | 28 ++++++++++++++++++++++++++++ Penumbra/Penumbra.cs | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Penumbra/Api/IpcLaunchingProvider.cs diff --git a/Penumbra.Api b/Penumbra.Api index 2cbf4bac..bd56d828 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 2cbf4bace53a5749d3eab1ff03025a6e6bd9fc37 +Subproject commit bd56d82816b8366e19dddfb2dc7fd7f167e264ee diff --git a/Penumbra/Api/Api/PenumbraApi.cs b/Penumbra/Api/Api/PenumbraApi.cs index 36f799a0..47d44cfc 100644 --- a/Penumbra/Api/Api/PenumbraApi.cs +++ b/Penumbra/Api/Api/PenumbraApi.cs @@ -16,13 +16,16 @@ public class PenumbraApi( TemporaryApi temporary, UiApi ui) : IDisposable, IApiService, IPenumbraApi { + public const int BreakingVersion = 5; + public const int FeatureVersion = 8; + public void Dispose() { Valid = false; } public (int Breaking, int Feature) ApiVersion - => (5, 7); + => (BreakingVersion, FeatureVersion); public bool Valid { get; private set; } = true; public IPenumbraApiCollection Collection { get; } = collection; diff --git a/Penumbra/Api/IpcLaunchingProvider.cs b/Penumbra/Api/IpcLaunchingProvider.cs new file mode 100644 index 00000000..ff851003 --- /dev/null +++ b/Penumbra/Api/IpcLaunchingProvider.cs @@ -0,0 +1,28 @@ +using Dalamud.Plugin; +using OtterGui.Log; +using OtterGui.Services; +using Penumbra.Api.Api; +using Serilog.Events; + +namespace Penumbra.Api; + +public sealed class IpcLaunchingProvider : IApiService +{ + public IpcLaunchingProvider(IDalamudPluginInterface pi, Logger log) + { + try + { + using var subscriber = log.MainLogger.IsEnabled(LogEventLevel.Debug) + ? IpcSubscribers.Launching.Subscriber(pi, + (major, minor) => log.Debug($"[IPC] Invoked Penumbra.Launching IPC with API Version {major}.{minor}.")) + : null; + + using var provider = IpcSubscribers.Launching.Provider(pi); + provider.Invoke(PenumbraApi.BreakingVersion, PenumbraApi.FeatureVersion); + } + catch (Exception ex) + { + log.Error($"[IPC] Could not invoke Penumbra.Launching IPC:\n{ex}"); + } + } +} diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index b6009627..79c7f2db 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -58,6 +58,8 @@ public class Penumbra : IDalamudPlugin { HookOverrides.Instance = HookOverrides.LoadFile(pluginInterface); _services = StaticServiceManager.CreateProvider(this, pluginInterface, Log); + // Invoke the IPC Penumbra.Launching method before any hooks or other services are created. + _services.GetService(); Messager = _services.GetService(); _validityChecker = _services.GetService(); _services.EnsureRequiredServices();