Inherit documentation in DalamudPluginInterface

This commit is contained in:
Haselnussbomber 2025-10-19 22:54:34 +02:00
parent a8c8c79902
commit 65016f88c1
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -83,126 +83,73 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved; configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved;
} }
/// <summary> /// <inheritdoc/>
/// Event that gets fired when loc is changed
/// </summary>
public event IDalamudPluginInterface.LanguageChangedDelegate? LanguageChanged; public event IDalamudPluginInterface.LanguageChangedDelegate? LanguageChanged;
/// <summary> /// <inheritdoc/>
/// Event that is fired when the active list of plugins is changed.
/// </summary>
public event IDalamudPluginInterface.ActivePluginsChangedDelegate? ActivePluginsChanged; public event IDalamudPluginInterface.ActivePluginsChangedDelegate? ActivePluginsChanged;
/// <summary> /// <inheritdoc/>
/// Gets the reason this plugin was loaded.
/// </summary>
public PluginLoadReason Reason { get; } public PluginLoadReason Reason { get; }
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether auto-updates have already completed this session.
/// </summary>
public bool IsAutoUpdateComplete => Service<AutoUpdateManager>.Get().IsAutoUpdateComplete; public bool IsAutoUpdateComplete => Service<AutoUpdateManager>.Get().IsAutoUpdateComplete;
/// <summary> /// <inheritdoc/>
/// Gets the repository from which this plugin was installed.
///
/// If a plugin was installed from the official/main repository, this will return the value of
/// <see cref="SpecialPluginSource.MainRepo"/>. Developer plugins will return the value of
/// <see cref="SpecialPluginSource.DevPlugin"/>.
/// </summary>
public string SourceRepository { get; } public string SourceRepository { get; }
/// <summary> /// <inheritdoc/>
/// Gets the current internal plugin name.
/// </summary>
public string InternalName => this.plugin.InternalName; public string InternalName => this.plugin.InternalName;
/// <summary> /// <inheritdoc/>
/// Gets the plugin's manifest.
/// </summary>
public IPluginManifest Manifest => this.plugin.Manifest; public IPluginManifest Manifest => this.plugin.Manifest;
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether this is a dev plugin.
/// </summary>
public bool IsDev => this.plugin.IsDev; public bool IsDev => this.plugin.IsDev;
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether this is a testing release of a plugin.
/// </summary>
/// <remarks>
/// Dev plugins have undefined behavior for this value, but can be expected to return <c>false</c>.
/// </remarks>
public bool IsTesting { get; } public bool IsTesting { get; }
/// <summary> /// <inheritdoc/>
/// Gets the time that this plugin was loaded.
/// </summary>
public DateTime LoadTime { get; } public DateTime LoadTime { get; }
/// <summary> /// <inheritdoc/>
/// Gets the UTC time that this plugin was loaded.
/// </summary>
public DateTime LoadTimeUTC { get; } public DateTime LoadTimeUTC { get; }
/// <summary> /// <inheritdoc/>
/// Gets the timespan delta from when this plugin was loaded.
/// </summary>
public TimeSpan LoadTimeDelta => DateTime.Now - this.LoadTime; public TimeSpan LoadTimeDelta => DateTime.Now - this.LoadTime;
/// <summary> /// <inheritdoc/>
/// Gets the directory Dalamud assets are stored in.
/// </summary>
public DirectoryInfo DalamudAssetDirectory => Service<Dalamud>.Get().AssetDirectory; public DirectoryInfo DalamudAssetDirectory => Service<Dalamud>.Get().AssetDirectory;
/// <summary> /// <inheritdoc/>
/// Gets the location of your plugin assembly.
/// </summary>
public FileInfo AssemblyLocation => this.plugin.DllFile; public FileInfo AssemblyLocation => this.plugin.DllFile;
/// <summary> /// <inheritdoc/>
/// Gets the directory your plugin configurations are stored in.
/// </summary>
public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory()); public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory());
/// <summary> /// <inheritdoc/>
/// Gets the config file of your plugin.
/// </summary>
public FileInfo ConfigFile => this.configs.GetConfigFile(this.plugin.InternalName); public FileInfo ConfigFile => this.configs.GetConfigFile(this.plugin.InternalName);
/// <summary> /// <inheritdoc/>
/// Gets the <see cref="UiBuilder"/> instance which allows you to draw UI into the game via ImGui draw calls.
/// </summary>
public IUiBuilder UiBuilder { get; private set; } public IUiBuilder UiBuilder { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether Dalamud is running in Debug mode or the /xldev menu is open. This can occur on release builds.
/// </summary>
public bool IsDevMenuOpen => Service<DalamudInterface>.GetNullable() is { IsDevMenuOpen: true }; // Can be null during boot public bool IsDevMenuOpen => Service<DalamudInterface>.GetNullable() is { IsDevMenuOpen: true }; // Can be null during boot
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether a debugger is attached.
/// </summary>
public bool IsDebugging => Debugger.IsAttached; public bool IsDebugging => Debugger.IsAttached;
/// <summary> /// <inheritdoc/>
/// Gets the current UI language in two-letter iso format.
/// </summary>
public string UiLanguage { get; private set; } public string UiLanguage { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets serializer class with functions to remove special characters from strings.
/// </summary>
public ISanitizer Sanitizer { get; } public ISanitizer Sanitizer { get; }
/// <summary> /// <inheritdoc/>
/// Gets the chat type used by default for plugin messages.
/// </summary>
public XivChatType GeneralChatType { get; private set; } public XivChatType GeneralChatType { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets a list of installed plugins along with their current state.
/// </summary>
public IEnumerable<IExposedPlugin> InstalledPlugins => public IEnumerable<IExposedPlugin> InstalledPlugins =>
Service<PluginManager>.Get().InstalledPlugins.Select(p => new ExposedPlugin(p)); Service<PluginManager>.Get().InstalledPlugins.Select(p => new ExposedPlugin(p));
@ -211,12 +158,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
/// </summary> /// </summary>
internal UiBuilder LocalUiBuilder => this.uiBuilder; internal UiBuilder LocalUiBuilder => this.uiBuilder;
/// <summary> /// <inheritdoc/>
/// Opens the <see cref="PluginInstallerWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The page to open the installer to. Defaults to the "All Plugins" page.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenPluginInstallerTo(PluginInstallerOpenKind openTo = PluginInstallerOpenKind.AllPlugins, string? searchText = null) public bool OpenPluginInstallerTo(PluginInstallerOpenKind openTo = PluginInstallerOpenKind.AllPlugins, string? searchText = null)
{ {
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -231,12 +173,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return true; return true;
} }
/// <summary> /// <inheritdoc/>
/// Opens the <see cref="SettingsWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The tab to open the settings to. Defaults to the "General" tab.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenDalamudSettingsTo(SettingsOpenKind openTo = SettingsOpenKind.General, string? searchText = null) public bool OpenDalamudSettingsTo(SettingsOpenKind openTo = SettingsOpenKind.General, string? searchText = null)
{ {
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -251,10 +188,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return true; return true;
} }
/// <summary> /// <inheritdoc/>
/// Opens the dev menu bar.
/// </summary>
/// <returns>Returns false if the DalamudInterface was null.</returns>
public bool OpenDeveloperMenu() public bool OpenDeveloperMenu()
{ {
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -269,102 +203,91 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#region IPC #region IPC
/// <inheritdoc cref="DataShare.GetOrCreateData{T}"/> /// <inheritdoc/>
public T GetOrCreateData<T>(string tag, Func<T> dataGenerator) where T : class public T GetOrCreateData<T>(string tag, Func<T> dataGenerator) where T : class
=> Service<DataShare>.Get().GetOrCreateData(tag, dataGenerator); => Service<DataShare>.Get().GetOrCreateData(tag, dataGenerator);
/// <inheritdoc cref="DataShare.RelinquishData"/> /// <inheritdoc/>
public void RelinquishData(string tag) public void RelinquishData(string tag)
=> Service<DataShare>.Get().RelinquishData(tag); => Service<DataShare>.Get().RelinquishData(tag);
/// <inheritdoc cref="DataShare.TryGetData{T}"/> /// <inheritdoc/>
public bool TryGetData<T>(string tag, [NotNullWhen(true)] out T? data) where T : class public bool TryGetData<T>(string tag, [NotNullWhen(true)] out T? data) where T : class
=> Service<DataShare>.Get().TryGetData(tag, out data); => Service<DataShare>.Get().TryGetData(tag, out data);
/// <inheritdoc cref="DataShare.GetData{T}"/> /// <inheritdoc/>
public T? GetData<T>(string tag) where T : class public T? GetData<T>(string tag) where T : class
=> Service<DataShare>.Get().GetData<T>(tag); => Service<DataShare>.Get().GetData<T>(tag);
/// <summary> /// <inheritdoc/>
/// Gets an IPC provider.
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC provider.</returns>
/// <exception cref="IpcTypeMismatchError">This is thrown when the requested types do not match the previously registered types are different.</exception>
public ICallGateProvider<TRet> GetIpcProvider<TRet>(string name) public ICallGateProvider<TRet> GetIpcProvider<TRet>(string name)
=> new CallGatePubSub<TRet>(name); => new CallGatePubSub<TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, TRet> GetIpcProvider<T1, TRet>(string name) public ICallGateProvider<T1, TRet> GetIpcProvider<T1, TRet>(string name)
=> new CallGatePubSub<T1, TRet>(name); => new CallGatePubSub<T1, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, TRet> GetIpcProvider<T1, T2, TRet>(string name) public ICallGateProvider<T1, T2, TRet> GetIpcProvider<T1, T2, TRet>(string name)
=> new CallGatePubSub<T1, T2, TRet>(name); => new CallGatePubSub<T1, T2, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, TRet> GetIpcProvider<T1, T2, T3, TRet>(string name) public ICallGateProvider<T1, T2, T3, TRet> GetIpcProvider<T1, T2, T3, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, TRet>(name); => new CallGatePubSub<T1, T2, T3, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, TRet> GetIpcProvider<T1, T2, T3, T4, TRet>(string name) public ICallGateProvider<T1, T2, T3, T4, TRet> GetIpcProvider<T1, T2, T3, T4, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, TRet> GetIpcProvider<T1, T2, T3, T4, T5, TRet>(string name) public ICallGateProvider<T1, T2, T3, T4, T5, TRet> GetIpcProvider<T1, T2, T3, T4, T5, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, TRet>(string name) public ICallGateProvider<T1, T2, T3, T4, T5, T6, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, TRet>(string name) public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/> /// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name) public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name);
/// <summary> /// <inheritdoc/>
/// Gets an IPC subscriber.
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC subscriber.</returns>
public ICallGateSubscriber<TRet> GetIpcSubscriber<TRet>(string name) public ICallGateSubscriber<TRet> GetIpcSubscriber<TRet>(string name)
=> new CallGatePubSub<TRet>(name); => new CallGatePubSub<TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, TRet> GetIpcSubscriber<T1, TRet>(string name) public ICallGateSubscriber<T1, TRet> GetIpcSubscriber<T1, TRet>(string name)
=> new CallGatePubSub<T1, TRet>(name); => new CallGatePubSub<T1, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, TRet> GetIpcSubscriber<T1, T2, TRet>(string name) public ICallGateSubscriber<T1, T2, TRet> GetIpcSubscriber<T1, T2, TRet>(string name)
=> new CallGatePubSub<T1, T2, TRet>(name); => new CallGatePubSub<T1, T2, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, TRet> GetIpcSubscriber<T1, T2, T3, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, TRet> GetIpcSubscriber<T1, T2, T3, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, TRet>(name); => new CallGatePubSub<T1, T2, T3, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, TRet> GetIpcSubscriber<T1, T2, T3, T4, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, T4, TRet> GetIpcSubscriber<T1, T2, T3, T4, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, T4, T5, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/> /// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name) public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name); => new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name);
@ -372,10 +295,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#region Configuration #region Configuration
/// <summary> /// <inheritdoc/>
/// Save a plugin configuration(inheriting IPluginConfiguration).
/// </summary>
/// <param name="currentConfig">The current configuration.</param>
public void SavePluginConfig(IPluginConfiguration? currentConfig) public void SavePluginConfig(IPluginConfiguration? currentConfig)
{ {
if (currentConfig == null) if (currentConfig == null)
@ -384,10 +304,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId); this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
} }
/// <summary> /// <inheritdoc/>
/// Get a previously saved plugin configuration or null if none was saved before.
/// </summary>
/// <returns>A previously saved config or null if none was saved before.</returns>
public IPluginConfiguration? GetPluginConfig() public IPluginConfiguration? GetPluginConfig()
{ {
// This is done to support json deserialization of plugin configurations // This is done to support json deserialization of plugin configurations
@ -411,16 +328,10 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return this.configs.Load(this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId); return this.configs.Load(this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
} }
/// <summary> /// <inheritdoc/>
/// Get the config directory.
/// </summary>
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName.</returns>
public string GetPluginConfigDirectory() => this.configs.GetDirectory(this.plugin.InternalName); public string GetPluginConfigDirectory() => this.configs.GetDirectory(this.plugin.InternalName);
/// <summary> /// <inheritdoc/>
/// Get the loc directory.
/// </summary>
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName/loc.</returns>
public string GetPluginLocDirectory() => this.configs.GetDirectory(Path.Combine(this.plugin.InternalName, "loc")); public string GetPluginLocDirectory() => this.configs.GetDirectory(Path.Combine(this.plugin.InternalName, "loc"));
#endregion #endregion
@ -481,8 +392,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#endregion #endregion
/// <summary>Unregister the plugin and dispose all references.</summary> /// <inheritdoc/>
/// <remarks>Dalamud internal use only.</remarks>
public void Dispose() public void Dispose()
{ {
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName); Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName);