diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 6fd9064b6..1051f908c 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -16,18 +16,15 @@ using Dalamud.Game.Text; using Dalamud.Game.Text.Sanitizer; using Dalamud.Interface; using Dalamud.Interface.Internal; -using Dalamud.Interface.Internal.Windows.PluginInstaller; -using Dalamud.Interface.Internal.Windows.SelfTest; -using Dalamud.Interface.Internal.Windows.Settings; using Dalamud.IoC.Internal; using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal.AutoUpdate; using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types.Manifest; using Dalamud.Plugin.Ipc; -using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Internal; -using Dalamud.Plugin.Services; +using Dalamud.Plugin.VersionInfo; +using Dalamud.Utility; using Serilog; @@ -204,11 +201,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa return true; } - /// - /// Gets the plugin the given assembly is part of. - /// - /// The assembly to check. - /// The plugin the given assembly is part of, or null if this is a shared assembly or if this information cannot be determined. + /// public IExposedPlugin? GetPlugin(Assembly assembly) => AssemblyLoadContext.GetLoadContext(assembly) switch { @@ -216,11 +209,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa var context => this.GetPlugin(context), }; - /// - /// Gets the plugin that loads in the given context. - /// - /// The context to check. - /// The plugin that loads in the given context, or null if this isn't a plugin's context or if this information cannot be determined. + /// public IExposedPlugin? GetPlugin(AssemblyLoadContext context) => Service.Get().InstalledPlugins.FirstOrDefault(p => p.LoadsIn(context)) switch { @@ -228,6 +217,12 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa var p => new ExposedPlugin(p), }; + /// + public IDalamudVersionInfo GetDalamudVersion() + { + return new DalamudVersionInfo(Versioning.GetAssemblyVersionParsed(), Versioning.GetActiveTrack()); + } + #region IPC /// diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index d1b6977d4..92ecab006 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -15,7 +15,7 @@ using Dalamud.Plugin.Internal.Types.Manifest; using Dalamud.Plugin.Ipc; using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Internal; -using Dalamud.Plugin.Services; +using Dalamud.Plugin.VersionInfo; namespace Dalamud.Plugin; @@ -194,6 +194,12 @@ public interface IDalamudPluginInterface : IServiceProvider /// The plugin that loads in the given context, or null if this isn't a plugin's context or if this information cannot be determined. IExposedPlugin? GetPlugin(AssemblyLoadContext context); + /// + /// Gets information about the version of Dalamud this plugin is loaded into. + /// + /// Class containing version information. + IDalamudVersionInfo GetDalamudVersion(); + /// T GetOrCreateData(string tag, Func dataGenerator) where T : class; diff --git a/Dalamud/Plugin/VersionInfo/DalamudVersionInfo.cs b/Dalamud/Plugin/VersionInfo/DalamudVersionInfo.cs new file mode 100644 index 000000000..c87c012af --- /dev/null +++ b/Dalamud/Plugin/VersionInfo/DalamudVersionInfo.cs @@ -0,0 +1,11 @@ +namespace Dalamud.Plugin.VersionInfo; + +/// +internal class DalamudVersionInfo(Version version, string? track) : IDalamudVersionInfo +{ + /// + public Version Version { get; } = version; + + /// + public string? BetaTrack { get; } = track; +} diff --git a/Dalamud/Plugin/VersionInfo/IDalamudVersionInfo.cs b/Dalamud/Plugin/VersionInfo/IDalamudVersionInfo.cs new file mode 100644 index 000000000..e6b6a9601 --- /dev/null +++ b/Dalamud/Plugin/VersionInfo/IDalamudVersionInfo.cs @@ -0,0 +1,19 @@ +namespace Dalamud.Plugin.VersionInfo; + +/// +/// Interface exposing various information related to Dalamud versioning. +/// +public interface IDalamudVersionInfo +{ + /// + /// Gets the Dalamud version. + /// + Version Version { get; } + + /// + /// Gets the currently used beta track. + /// Please don't tell users to switch branches. They have it bad enough, fix your things instead. + /// Null if this build wasn't launched from XIVLauncher. + /// + string? BetaTrack { get; } +}