mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-16 12:57:44 +01:00
[Api13] Update ChatLinkHandler functions (#2322)
* Update ChatLinkHandler functions - Move functions to IChatGui - Switch CommandId to type Guid and generate them automatically * Remove unused field
This commit is contained in:
parent
ecbb4053ce
commit
63e7cb25b5
8 changed files with 74 additions and 77 deletions
|
|
@ -13,8 +13,6 @@ using Dalamud.Data;
|
|||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.Sanitizer;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||
|
|
@ -427,39 +425,6 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
|
|||
|
||||
#endregion
|
||||
|
||||
#region Chat Links
|
||||
|
||||
// TODO API9: Move to chatgui, don't allow passing own commandId
|
||||
|
||||
/// <summary>
|
||||
/// Register a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandId">The ID of the command.</param>
|
||||
/// <param name="commandAction">The action to be executed.</param>
|
||||
/// <returns>Returns an SeString payload for the link.</returns>
|
||||
public DalamudLinkPayload AddChatLinkHandler(uint commandId, Action<uint, SeString> commandAction)
|
||||
{
|
||||
return Service<ChatGui>.Get().AddChatLinkHandler(this.plugin.InternalName, commandId, commandAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandId">The ID of the command.</param>
|
||||
public void RemoveChatLinkHandler(uint commandId)
|
||||
{
|
||||
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName, commandId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all chat link handlers registered by the plugin.
|
||||
/// </summary>
|
||||
public void RemoveChatLinkHandler()
|
||||
{
|
||||
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dependency Injection
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -281,25 +281,6 @@ public interface IDalamudPluginInterface
|
|||
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName/loc.</returns>
|
||||
string GetPluginLocDirectory();
|
||||
|
||||
/// <summary>
|
||||
/// Register a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandId">The ID of the command.</param>
|
||||
/// <param name="commandAction">The action to be executed.</param>
|
||||
/// <returns>Returns an SeString payload for the link.</returns>
|
||||
DalamudLinkPayload AddChatLinkHandler(uint commandId, Action<uint, SeString> commandAction);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandId">The ID of the command.</param>
|
||||
void RemoveChatLinkHandler(uint commandId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all chat link handlers registered by the plugin.
|
||||
/// </summary>
|
||||
void RemoveChatLinkHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new object of the provided type using its default constructor, then inject objects and properties.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@ internal class AutoUpdateManager : IServiceType
|
|||
this.openInstallerWindowLinkTask =
|
||||
Service<ChatGui>.GetAsync().ContinueWith(
|
||||
chatGuiTask => chatGuiTask.Result.AddChatLinkHandler(
|
||||
"Dalamud",
|
||||
1001,
|
||||
(_, _) =>
|
||||
{
|
||||
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerOpenKind.InstalledPlugins);
|
||||
|
|
|
|||
|
|
@ -125,8 +125,6 @@ internal class PluginManager : IInternalDisposableService
|
|||
this.openInstallerWindowPluginChangelogsLink =
|
||||
Service<ChatGui>.GetAsync().ContinueWith(
|
||||
chatGuiTask => chatGuiTask.Result.AddChatLinkHandler(
|
||||
"Dalamud",
|
||||
1003,
|
||||
(_, _) =>
|
||||
{
|
||||
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
|
|
@ -82,7 +83,25 @@ public interface IChatGui
|
|||
/// <summary>
|
||||
/// Gets the dictionary of Dalamud Link Handlers.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<(string PluginName, uint CommandId), Action<uint, SeString>> RegisteredLinkHandlers { get; }
|
||||
public IReadOnlyDictionary<(string PluginName, Guid CommandId), Action<Guid, SeString>> RegisteredLinkHandlers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Register a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandAction">The action to be executed.</param>
|
||||
/// <returns>Returns an SeString payload for the link.</returns>
|
||||
public DalamudLinkPayload AddChatLinkHandler(Action<Guid, SeString> commandAction);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a chat link handler.
|
||||
/// </summary>
|
||||
/// <param name="commandId">The ID of the command.</param>
|
||||
public void RemoveChatLinkHandler(Guid commandId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all chat link handlers registered by the plugin.
|
||||
/// </summary>
|
||||
public void RemoveChatLinkHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Queue a chat message. Dalamud will send queued messages on the next framework event.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue