-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkPayloads.cs
47 lines (37 loc) · 1.29 KB
/
LinkPayloads.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Heliosphere.Ui;
namespace Heliosphere;
internal class LinkPayloads : IDisposable {
private Plugin Plugin { get; }
private Dictionary<Command, DalamudLinkPayload> Payloads { get; } = new();
internal enum Command : uint {
OpenChangelog = 1,
}
internal LinkPayloads(Plugin plugin) {
this.Plugin = plugin;
foreach (var command in Enum.GetValues<Command>()) {
// no need for unchecked: Command is represented as a uint
this.Payloads[command] = this.Plugin.Interface.AddChatLinkHandler((uint) command, this.HandleCommand);
}
}
public void Dispose() {
this.Plugin.Interface.RemoveChatLinkHandler();
}
internal DalamudLinkPayload this[Command command] => this.Payloads[command];
private void HandleCommand(uint id, SeString message) {
switch ((Command) id) {
case Command.OpenChangelog: {
this.OpenChangelog();
break;
}
default: {
break;
}
}
}
private void OpenChangelog() {
this.Plugin.PluginUi.ForceOpen = PluginUi.Tab.LatestUpdate;
this.Plugin.PluginUi.Visible = true;
}
}