From e835ad088b0ef91bf580d199f5ddf13c18c7291b Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Sat, 15 Jan 2022 13:55:43 -0500 Subject: [PATCH] fix: account for global scale --- ChatTwo/PayloadHandler.cs | 12 ++++++++---- ChatTwo/Ui/ChatLog.cs | 4 ++-- ChatTwo/Util/ImGuiUtil.cs | 5 ++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ChatTwo/PayloadHandler.cs b/ChatTwo/PayloadHandler.cs index 05274ae..82902cb 100755 --- a/ChatTwo/PayloadHandler.cs +++ b/ChatTwo/PayloadHandler.cs @@ -6,6 +6,7 @@ using ChatTwo.Util; using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; +using Dalamud.Interface; using Dalamud.Logging; using Dalamud.Utility; using ImGuiNET; @@ -85,9 +86,11 @@ internal sealed class PayloadHandler { } internal void Hover(Payload payload) { + var hoverSize = 250f * ImGuiHelpers.GlobalScale; + switch (payload) { case StatusPayload status: { - this.DoHover(() => this.HoverStatus(status), 250f); + this.DoHover(() => this.HoverStatus(status), hoverSize); break; } case ItemPayload item: { @@ -105,7 +108,7 @@ internal sealed class PayloadHandler { break; } - this.DoHover(() => this.HoverItem(item), 250f); + this.DoHover(() => this.HoverItem(item), hoverSize); break; } } @@ -131,9 +134,10 @@ internal sealed class PayloadHandler { var lineHeight = ImGui.CalcTextSize("A").Y; var cursor = ImGui.GetCursorPos(); - ImGui.Image(icon.ImGuiHandle, new Vector2(icon.Width, icon.Height)); + var size = new Vector2(icon.Width, icon.Height) * ImGuiHelpers.GlobalScale; + ImGui.Image(icon.ImGuiHandle, size); ImGui.SameLine(); - ImGui.SetCursorPos(cursor + new Vector2(icon.Width + 4, (float) icon.Height / 2 - lineHeight / 2)); + ImGui.SetCursorPos(cursor + new Vector2(size.X + 4, size.Y / 2 - lineHeight / 2)); } private void HoverStatus(StatusPayload status) { diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index dd96062..d4cc229 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -351,7 +351,7 @@ internal sealed class ChatLog : IUiComponent { ImGui.PushID($"tab-context-menu-{i}"); - ImGui.SetNextItemWidth(250f); + ImGui.SetNextItemWidth(250f * ImGuiHelpers.GlobalScale); if (ImGui.InputText("##tab-name", ref tab.Name, 128)) { anyChanged = true; } @@ -474,7 +474,7 @@ internal sealed class ChatLog : IUiComponent { var texSize = new Vector2(this._fontIcon.Width, this._fontIcon.Height); var sizeRatio = this.Ui.Plugin.Config.FontSize / bounds.Value.W; - var size = new Vector2(bounds.Value.Z, bounds.Value.W) * sizeRatio; + var size = new Vector2(bounds.Value.Z, bounds.Value.W) * sizeRatio * ImGuiHelpers.GlobalScale; var uv0 = new Vector2(bounds.Value.X, bounds.Value.Y - 2) / texSize; var uv1 = new Vector2(bounds.Value.X + bounds.Value.Z, bounds.Value.Y - 2 + bounds.Value.W) / texSize; diff --git a/ChatTwo/Util/ImGuiUtil.cs b/ChatTwo/Util/ImGuiUtil.cs index c5a618c..e5adb8e 100755 --- a/ChatTwo/Util/ImGuiUtil.cs +++ b/ChatTwo/Util/ImGuiUtil.cs @@ -52,9 +52,8 @@ internal static class ImGuiUtil { return; } - const float scale = 1.0f; var widthLeft = ImGui.GetContentRegionAvail().X; - var endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, scale, text, textEnd, widthLeft); + var endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, ImGuiHelpers.GlobalScale, text, textEnd, widthLeft); if (endPrevLine == null) { return; } @@ -68,7 +67,7 @@ internal static class ImGuiUtil { ++text; } // skip a space at start of line - endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, scale, text, textEnd, widthLeft); + endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, ImGuiHelpers.GlobalScale, text, textEnd, widthLeft); if (endPrevLine == null) { ImGui.TextUnformatted(""); ImGui.TextUnformatted("");