From d2896266e1eeb70add33f3a224b79c409b609efb Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 10 Apr 2024 18:10:23 +0200 Subject: [PATCH] Use hi-res icons by shifting the texture 340 (170*2)px --- ChatTwo/Ui/ChatLogWindow.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 3c12d81..1df0de7 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -1346,17 +1346,19 @@ public sealed class ChatLogWindow : Window, IUiComponent { private void DrawChunk(Chunk chunk, bool wrap = true, PayloadHandler? handler = null, float lineWidth = 0f) { if (chunk is IconChunk icon && _fontIcon != null) { var bounds = IconUtil.GfdFileView.TryGetEntry((uint) icon.Icon, out var entry); - if (bounds) { - var texSize = new Vector2(_fontIcon.Width, _fontIcon.Height); + if (!bounds) + return; - var sizeRatio = Plugin.Config.FontSize / entry.Height; - var size = new Vector2(entry.Width, entry.Height) * sizeRatio * ImGuiHelpers.GlobalScale; + var texSize = new Vector2(_fontIcon.Width, _fontIcon.Height); - var uv0 = new Vector2(entry.Left, entry.Top) / texSize; - var uv1 = new Vector2(entry.Left + entry.Width, entry.Top + entry.Height) / texSize; - ImGui.Image(_fontIcon.ImGuiHandle, size, uv0, uv1); - ImGuiUtil.PostPayload(chunk, handler); - } + var sizeRatio = Plugin.Config.FontSize / 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(_fontIcon.ImGuiHandle, size, uv0, uv1); + ImGuiUtil.PostPayload(chunk, handler); return; }