From 193e25d3240117627ec32dd406117c1dd4b2383f Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Fri, 8 Dec 2023 15:48:20 +0900 Subject: [PATCH] Use RenderChar instead of AddText --- Dalamud/Interface/Internal/DalamudIme.cs | 24 +++++++++--------- .../Internal/Windows/DalamudImeWindow.cs | 25 +++++++++++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Dalamud/Interface/Internal/DalamudIme.cs b/Dalamud/Interface/Internal/DalamudIme.cs index 9e0466e661..f44c885cee 100644 --- a/Dalamud/Interface/Internal/DalamudIme.cs +++ b/Dalamud/Interface/Internal/DalamudIme.cs @@ -105,7 +105,7 @@ internal static bool ShowCursorInInputText /// /// Gets the input mode icon from . /// - internal string? InputModeIcon { get; private set; } + internal char InputModeIcon { get; private set; } private static ref ImGuiInputTextState TextState => ref *(ImGuiInputTextState*)(ImGui.GetCurrentContext() + 0x4588); @@ -251,37 +251,37 @@ private void UpdateInputLanguage(HIMC hImc) { case LANG.LANG_KOREAN: if (native) - this.InputModeIcon = $"{(char)SeIconChar.ImeKoreanHangul}"; + this.InputModeIcon = (char)SeIconChar.ImeKoreanHangul; else if (fullwidth) - this.InputModeIcon = $"{(char)SeIconChar.ImeAlphanumeric}"; + this.InputModeIcon = (char)SeIconChar.ImeAlphanumeric; else - this.InputModeIcon = $"{(char)SeIconChar.ImeAlphanumericHalfWidth}"; + this.InputModeIcon = (char)SeIconChar.ImeAlphanumericHalfWidth; break; case LANG.LANG_JAPANESE: // wtf // see the function called from: 48 8b 0d ?? ?? ?? ?? e8 ?? ?? ?? ?? 8b d8 e9 ?? 00 00 0 if (open && native && katakana && fullwidth) - this.InputModeIcon = $"{(char)SeIconChar.ImeKatakana}"; + this.InputModeIcon = (char)SeIconChar.ImeKatakana; else if (open && native && katakana) - this.InputModeIcon = $"{(char)SeIconChar.ImeKatakanaHalfWidth}"; + this.InputModeIcon = (char)SeIconChar.ImeKatakanaHalfWidth; else if (open && native) - this.InputModeIcon = $"{(char)SeIconChar.ImeHiragana}"; + this.InputModeIcon = (char)SeIconChar.ImeHiragana; else if (open && fullwidth) - this.InputModeIcon = $"{(char)SeIconChar.ImeAlphanumeric}"; + this.InputModeIcon = (char)SeIconChar.ImeAlphanumeric; else - this.InputModeIcon = $"{(char)SeIconChar.ImeAlphanumericHalfWidth}"; + this.InputModeIcon = (char)SeIconChar.ImeAlphanumericHalfWidth; break; case LANG.LANG_CHINESE: if (native) - this.InputModeIcon = $"{(char)SeIconChar.ImeChineseHan}"; + this.InputModeIcon = (char)SeIconChar.ImeChineseHan; else - this.InputModeIcon = $"{(char)SeIconChar.ImeChineseLatin}"; + this.InputModeIcon = (char)SeIconChar.ImeChineseLatin; break; default: - this.InputModeIcon = null; + this.InputModeIcon = default; break; } diff --git a/Dalamud/Interface/Internal/Windows/DalamudImeWindow.cs b/Dalamud/Interface/Internal/Windows/DalamudImeWindow.cs index 7417afd911..ecaa522e5d 100644 --- a/Dalamud/Interface/Internal/Windows/DalamudImeWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DalamudImeWindow.cs @@ -43,7 +43,8 @@ public override void PostDraw() var drawCand = ime.ImmCand.Count != 0; var drawConv = drawCand || ime.ShowPartialConversion; - var drawIme = ime.InputModeIcon != null; + var drawIme = ime.InputModeIcon != 0; + var imeIconFont = InterfaceManager.DefaultFont; var pad = ImGui.GetStyle().WindowPadding; var candTextSize = ImGui.CalcTextSize(ime.ImmComp == string.Empty ? " " : ime.ImmComp); @@ -139,7 +140,9 @@ public override void PostDraw() { if (dx != 0 || dy != 0) { - drawList.AddText( + imeIconFont.RenderChar( + drawList, + imeIconFont.FontSize, cursor + new Vector2(dx, dy), ImGui.GetColorU32(ImGuiCol.WindowBg), ime.InputModeIcon); @@ -147,7 +150,12 @@ public override void PostDraw() } } - drawList.AddText(cursor, ImGui.GetColorU32(ImGuiCol.Text), ime.InputModeIcon); + imeIconFont.RenderChar( + drawList, + imeIconFont.FontSize, + cursor, + ImGui.GetColorU32(ImGuiCol.Text), + ime.InputModeIcon); cursor.Y += candTextSize.Y + spaceY; } @@ -199,7 +207,9 @@ public override void PostDraw() { if (dx != 0 || dy != 0) { - drawList.AddText( + imeIconFont.RenderChar( + drawList, + imeIconFont.FontSize, cursor + new Vector2(dx, dy), ImGui.GetColorU32(ImGuiCol.WindowBg), ime.InputModeIcon); @@ -207,7 +217,12 @@ public override void PostDraw() } } - drawList.AddText(cursor, ImGui.GetColorU32(ImGuiCol.Text), ime.InputModeIcon); + imeIconFont.RenderChar( + drawList, + imeIconFont.FontSize, + cursor, + ImGui.GetColorU32(ImGuiCol.Text), + ime.InputModeIcon); } return;