diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index a2a8436..01054ee 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -3,6 +3,7 @@ using ChatTwo.Resources; using ChatTwo.Ui; using Dalamud.Configuration; using Dalamud.Logging; +using ImGuiNET; namespace ChatTwo; @@ -36,7 +37,7 @@ internal class Configuration : IPluginConfiguration { public bool SortAutoTranslate; public bool FontsEnabled = true; - public bool EnableChineseRange; + public ExtraGlyphRanges ExtraGlyphRanges = 0; public float FontSize = 17f; public float JapaneseFontSize = 17f; public float SymbolsFontSize = 17f; @@ -71,7 +72,7 @@ internal class Configuration : IPluginConfiguration { this.SharedMode = other.SharedMode; this.SortAutoTranslate = other.SortAutoTranslate; this.FontsEnabled = other.FontsEnabled; - this.EnableChineseRange = other.EnableChineseRange; + this.ExtraGlyphRanges = other.ExtraGlyphRanges; this.FontSize = other.FontSize; this.JapaneseFontSize = other.JapaneseFontSize; this.SymbolsFontSize = other.SymbolsFontSize; @@ -306,3 +307,39 @@ internal static class LanguageOverrideExt { _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null), }; } + +[Serializable] +[Flags] +internal enum ExtraGlyphRanges { + ChineseFull = 1 << 0, + ChineseSimplifiedCommon = 1 << 1, + Cyrillic = 1 << 2, + Japanese = 1 << 3, + Korean = 1 << 4, + Thai = 1 << 5, + Vietnamese = 1 << 6, +} + +internal static class ExtraGlyphRangesExt { + internal static string Name(this ExtraGlyphRanges ranges) => ranges switch { + ExtraGlyphRanges.ChineseFull => "Chinese (full)", + ExtraGlyphRanges.ChineseSimplifiedCommon => "Chinese (common simplified)", + ExtraGlyphRanges.Cyrillic => "Cyrillic", + ExtraGlyphRanges.Japanese => "Japanese", + ExtraGlyphRanges.Korean => "Korean", + ExtraGlyphRanges.Thai => "Thai", + ExtraGlyphRanges.Vietnamese => "Vietnamese", + _ => throw new ArgumentOutOfRangeException(nameof(ranges), ranges, null), + }; + + internal static IntPtr Range(this ExtraGlyphRanges ranges) => ranges switch { + ExtraGlyphRanges.ChineseFull => ImGui.GetIO().Fonts.GetGlyphRangesChineseFull(), + ExtraGlyphRanges.ChineseSimplifiedCommon => ImGui.GetIO().Fonts.GetGlyphRangesChineseSimplifiedCommon(), + ExtraGlyphRanges.Cyrillic => ImGui.GetIO().Fonts.GetGlyphRangesCyrillic(), + ExtraGlyphRanges.Japanese => ImGui.GetIO().Fonts.GetGlyphRangesJapanese(), + ExtraGlyphRanges.Korean => ImGui.GetIO().Fonts.GetGlyphRangesKorean(), + ExtraGlyphRanges.Thai => ImGui.GetIO().Fonts.GetGlyphRangesThai(), + ExtraGlyphRanges.Vietnamese => ImGui.GetIO().Fonts.GetGlyphRangesVietnamese(), + _ => throw new ArgumentOutOfRangeException(nameof(ranges), ranges, null), + }; +} diff --git a/ChatTwo/PluginUi.cs b/ChatTwo/PluginUi.cs index ac7e3e3..79a39c8 100755 --- a/ChatTwo/PluginUi.cs +++ b/ChatTwo/PluginUi.cs @@ -116,8 +116,10 @@ internal sealed class PluginUi : IDisposable { ImGui.GetIO().Fonts.GetGlyphRangesDefault(), }; - if (this.Plugin.Config.EnableChineseRange) { - ranges.Add(ImGui.GetIO().Fonts.GetGlyphRangesChineseFull()); + foreach (var extraRange in Enum.GetValues()) { + if (this.Plugin.Config.ExtraGlyphRanges.HasFlag(extraRange)) { + ranges.Add(extraRange.Range()); + } } BuildRange(out this._ranges, null, ranges.ToArray()); diff --git a/ChatTwo/Ui/SettingsTabs/Fonts.cs b/ChatTwo/Ui/SettingsTabs/Fonts.cs index c43050e..97ea014 100755 --- a/ChatTwo/Ui/SettingsTabs/Fonts.cs +++ b/ChatTwo/Ui/SettingsTabs/Fonts.cs @@ -91,8 +91,17 @@ public class Fonts : ISettingsTab { ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName)); ImGui.Spacing(); - ImGui.Checkbox(Language.Options_EnableChineseRange_Name, ref this.Mutable.EnableChineseRange); - ImGuiUtil.HelpText(Language.Options_EnableChineseRange_Description); + if (ImGui.CollapsingHeader("Extra font glyphs")) { + ImGuiUtil.HelpText("Extra glyphs can be added to {0}'s font global font by enabling the checkboxes below. This will likely require increasing Dalamud's font atlas size."); + + var range = (int) this.Mutable.ExtraGlyphRanges; + foreach (var extra in Enum.GetValues()) { + ImGui.CheckboxFlags(extra.Name(), ref range, (int) extra); + } + + this.Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range; + } + ImGui.Spacing(); }