mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Add interface to obtain versioning info
This commit is contained in:
parent
20af5b40c7
commit
ffd99d5791
4 changed files with 47 additions and 16 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin the given assembly is part of.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly to check.</param>
|
||||
/// <returns>The plugin the given assembly is part of, or null if this is a shared assembly or if this information cannot be determined.</returns>
|
||||
/// <inheritdoc/>
|
||||
public IExposedPlugin? GetPlugin(Assembly assembly)
|
||||
=> AssemblyLoadContext.GetLoadContext(assembly) switch
|
||||
{
|
||||
|
|
@ -216,11 +209,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
|
|||
var context => this.GetPlugin(context),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin that loads in the given context.
|
||||
/// </summary>
|
||||
/// <param name="context">The context to check.</param>
|
||||
/// <returns>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.</returns>
|
||||
/// <inheritdoc/>
|
||||
public IExposedPlugin? GetPlugin(AssemblyLoadContext context)
|
||||
=> Service<PluginManager>.Get().InstalledPlugins.FirstOrDefault(p => p.LoadsIn(context)) switch
|
||||
{
|
||||
|
|
@ -228,6 +217,12 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
|
|||
var p => new ExposedPlugin(p),
|
||||
};
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IDalamudVersionInfo GetDalamudVersion()
|
||||
{
|
||||
return new DalamudVersionInfo(Versioning.GetAssemblyVersionParsed(), Versioning.GetActiveTrack());
|
||||
}
|
||||
|
||||
#region IPC
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// <returns>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.</returns>
|
||||
IExposedPlugin? GetPlugin(AssemblyLoadContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the version of Dalamud this plugin is loaded into.
|
||||
/// </summary>
|
||||
/// <returns>Class containing version information.</returns>
|
||||
IDalamudVersionInfo GetDalamudVersion();
|
||||
|
||||
/// <inheritdoc cref="DataShare.GetOrCreateData{T}"/>
|
||||
T GetOrCreateData<T>(string tag, Func<T> dataGenerator) where T : class;
|
||||
|
||||
|
|
|
|||
11
Dalamud/Plugin/VersionInfo/DalamudVersionInfo.cs
Normal file
11
Dalamud/Plugin/VersionInfo/DalamudVersionInfo.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Dalamud.Plugin.VersionInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
internal class DalamudVersionInfo(Version version, string? track) : IDalamudVersionInfo
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Version Version { get; } = version;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string? BetaTrack { get; } = track;
|
||||
}
|
||||
19
Dalamud/Plugin/VersionInfo/IDalamudVersionInfo.cs
Normal file
19
Dalamud/Plugin/VersionInfo/IDalamudVersionInfo.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
namespace Dalamud.Plugin.VersionInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Interface exposing various information related to Dalamud versioning.
|
||||
/// </summary>
|
||||
public interface IDalamudVersionInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Dalamud version.
|
||||
/// </summary>
|
||||
Version Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
string? BetaTrack { get; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue