feat(core): add static Plugin.Instance handle for UI helper access

This commit is contained in:
2026-06-10 10:09:32 +02:00
parent e5a17ee798
commit c7047407f5
+11
View File
@@ -91,6 +91,13 @@ public sealed class Plugin : IAsyncDalamudPlugin
public static Configuration Config = null!;
public static FileDialogManager FileDialogManager { get; private set; } = null!;
// Single static handle to the live Plugin instance. Lets statically-accessed
// UI helpers (TabContextMenu) reach instance-only members — SaveConfig(),
// AutoTellTabsService, CustomAudioPlayer — without ctor-injection. A per-member
// static accessor is impossible: it would collide by name with the instance
// property (CS0102). Filled in the post-resolve bridge block below.
internal static Plugin Instance = null!;
public readonly WindowSystem WindowSystem = new(PluginName);
// Phase-2 services are constructed in LoadAsync; null! shape is kept
@@ -289,6 +296,10 @@ public sealed class Plugin : IAsyncDalamudPlugin
);
_host = PluginHostFactory.Build(this, dependencies);
// Bridge the static handle before the instance members below are read.
Instance = this;
_lifecycle = _host.Services.GetRequiredService<PluginLifecycle>();
_lifecycle.Host = _host;