diff --git a/HellionChat/Ui/Components/ChunkRenderer.cs b/HellionChat/Ui/Components/ChunkRenderer.cs index 89a501d..e6ae5e3 100644 --- a/HellionChat/Ui/Components/ChunkRenderer.cs +++ b/HellionChat/Ui/Components/ChunkRenderer.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Numerics; using Dalamud.Bindings.ImGui; using Dalamud.Game.Text.SeStringHandling.Payloads; +using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using HellionChat.Code; using HellionChat.Themes; @@ -33,6 +34,7 @@ internal sealed class ChunkRenderer // names change every plugin reload to avoid stable cross-session linkage. _salt = new Random().Next().ToString(); + // Not yet consumed in C2/C3; E-task wiring will likely add log call-sites later. _ = _logger; } @@ -82,9 +84,9 @@ internal sealed class ChunkRenderer float lineWidth = 0f ) { - if (chunk is IconChunk) + if (chunk is IconChunk iconChunk) { - // TODO(C3): wire DrawIcon dispatch + EmotePayload image path here. + DrawIcon(chunk, iconChunk, handler); return; } @@ -173,6 +175,30 @@ internal sealed class ChunkRenderer (useCustomItalicFont ? _fonts.ItalicFont! : _fonts.AxisItalic).Pop(); } + internal void DrawIcon(Chunk chunk, IconChunk icon, PayloadHandler? handler) + { + if (!IconUtil.GfdFileView.TryGetEntry((uint)icon.Icon, out var entry)) + return; + + var iconTexture = Plugin + .TextureProvider.GetFromGame("common/font/fonticon_ps5.tex") + .GetWrapOrDefault(); + if (iconTexture == null) + return; + + var texSize = new Vector2(iconTexture.Width, iconTexture.Height); + + var sizeRatio = FontManager.GetFontSize() / entry.Height; + var size = new Vector2(entry.Width, entry.Height) * sizeRatio * ImGuiHelpers.GlobalScale; + + var uv0 = new Vector2(entry.Left, entry.Top + 170) * 2 / texSize; + var uv1 = + new Vector2(entry.Left + entry.Width, entry.Top + entry.Height + 170) * 2 / texSize; + + ImGui.Image(iconTexture.Handle, size, uv0, uv1); + ImGuiUtil.PostPayload(chunk, handler); + } + private string HidePlayerInString(string str, string playerName, uint worldId) { var expected = _gameFunctions.Chat.AbbreviatePlayerName(playerName);