feat: add custom dalamud link payload handling
This commit is contained in:
@@ -14,7 +14,7 @@ internal static class ChunkUtil {
|
||||
Payload? link = null;
|
||||
|
||||
void Append(string text) {
|
||||
chunks.Add(new TextChunk(link, text) {
|
||||
chunks.Add(new TextChunk(msg, link, text) {
|
||||
FallbackColour = defaultColour,
|
||||
Foreground = foreground.Count > 0 ? foreground.Peek() : null,
|
||||
Glow = glow.Count > 0 ? glow.Peek() : null,
|
||||
@@ -47,13 +47,13 @@ internal static class ChunkUtil {
|
||||
|
||||
break;
|
||||
case PayloadType.AutoTranslateText:
|
||||
chunks.Add(new IconChunk(link, BitmapFontIcon.AutoTranslateBegin));
|
||||
chunks.Add(new IconChunk(msg, link, BitmapFontIcon.AutoTranslateBegin));
|
||||
var autoText = ((AutoTranslatePayload) payload).Text;
|
||||
Append(autoText.Substring(2, autoText.Length - 4));
|
||||
chunks.Add(new IconChunk(link, BitmapFontIcon.AutoTranslateEnd));
|
||||
chunks.Add(new IconChunk(msg, link, BitmapFontIcon.AutoTranslateEnd));
|
||||
break;
|
||||
case PayloadType.Icon:
|
||||
chunks.Add(new IconChunk(link, ((IconPayload) payload).Icon));
|
||||
chunks.Add(new IconChunk(msg, link, ((IconPayload) payload).Icon));
|
||||
break;
|
||||
case PayloadType.MapLink:
|
||||
case PayloadType.Quest:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
|
||||
@@ -12,7 +11,8 @@ internal static class ImGuiUtil {
|
||||
ImGuiMouseButton.Right,
|
||||
};
|
||||
|
||||
internal static void PostPayload(Payload? payload, PayloadHandler? handler) {
|
||||
internal static void PostPayload(Chunk chunk, PayloadHandler? handler) {
|
||||
var payload = chunk.Link;
|
||||
if (payload != null && ImGui.IsItemHovered()) {
|
||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
handler?.Hover(payload);
|
||||
@@ -24,15 +24,15 @@ internal static class ImGuiUtil {
|
||||
|
||||
foreach (var button in Buttons) {
|
||||
if (ImGui.IsItemClicked(button)) {
|
||||
handler.Click(payload, button);
|
||||
handler.Click(chunk, payload, button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static unsafe void WrapText(string csText, Payload? payload, PayloadHandler? handler) {
|
||||
internal static unsafe void WrapText(string csText, Chunk chunk, PayloadHandler? handler) {
|
||||
void Text(byte* text, byte* textEnd) {
|
||||
ImGuiNative.igTextUnformatted(text, textEnd);
|
||||
PostPayload(payload, handler);
|
||||
PostPayload(chunk, handler);
|
||||
}
|
||||
|
||||
if (csText.Length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user