feat: add symbol and japanese font sizes
This commit is contained in:
parent
a7b9c50759
commit
2ef42aa211
|
@ -2,12 +2,15 @@
|
|||
using ChatTwo.Resources;
|
||||
using ChatTwo.Ui;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Logging;
|
||||
|
||||
namespace ChatTwo;
|
||||
|
||||
[Serializable]
|
||||
internal class Configuration : IPluginConfiguration {
|
||||
public int Version { get; set; } = 2;
|
||||
private const int LatestVersion = 3;
|
||||
|
||||
public int Version { get; set; } = LatestVersion;
|
||||
|
||||
public bool HideChat = true;
|
||||
public bool HideDuringCutscenes = true;
|
||||
|
@ -21,6 +24,8 @@ internal class Configuration : IPluginConfiguration {
|
|||
public bool ShowTitleBar;
|
||||
|
||||
public float FontSize = 17f;
|
||||
public float JapaneseFontSize = 17f;
|
||||
public float SymbolsFontSize = 17f;
|
||||
public string GlobalFont = Fonts.GlobalFonts[0].Name;
|
||||
public string JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
||||
|
||||
|
@ -40,6 +45,8 @@ internal class Configuration : IPluginConfiguration {
|
|||
this.CanResize = other.CanResize;
|
||||
this.ShowTitleBar = other.ShowTitleBar;
|
||||
this.FontSize = other.FontSize;
|
||||
this.JapaneseFontSize = other.JapaneseFontSize;
|
||||
this.SymbolsFontSize = other.SymbolsFontSize;
|
||||
this.GlobalFont = other.GlobalFont;
|
||||
this.JapaneseFont = other.JapaneseFont;
|
||||
this.WindowAlpha = other.WindowAlpha;
|
||||
|
@ -48,13 +55,28 @@ internal class Configuration : IPluginConfiguration {
|
|||
}
|
||||
|
||||
public void Migrate() {
|
||||
if (this.Version == 1) {
|
||||
this.Version = 2;
|
||||
while (this.Version < LatestVersion) {
|
||||
switch (this.Version) {
|
||||
case 1: {
|
||||
this.Version = 2;
|
||||
|
||||
foreach (var tab in this.Tabs) {
|
||||
#pragma warning disable CS0618
|
||||
tab.UnreadMode = tab.DisplayUnread ? UnreadMode.Unseen : UnreadMode.None;
|
||||
#pragma warning restore CS0618
|
||||
foreach (var tab in this.Tabs) {
|
||||
#pragma warning disable CS0618
|
||||
tab.UnreadMode = tab.DisplayUnread ? UnreadMode.Unseen : UnreadMode.None;
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
this.Version = 3;
|
||||
|
||||
this.JapaneseFontSize = this.FontSize;
|
||||
this.SymbolsFontSize = this.FontSize;
|
||||
break;
|
||||
default:
|
||||
PluginLog.Warning($"Couldn't migrate config version {this.Version}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ internal sealed class PluginUi : IDisposable {
|
|||
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
|
||||
this._jpFont.Item1.AddrOfPinnedObject(),
|
||||
this._jpFont.Item2,
|
||||
this.Plugin.Config.FontSize,
|
||||
this.Plugin.Config.JapaneseFontSize,
|
||||
this._fontCfgMerge,
|
||||
this._jpRange.AddrOfPinnedObject()
|
||||
);
|
||||
|
@ -251,7 +251,7 @@ internal sealed class PluginUi : IDisposable {
|
|||
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
|
||||
this._gameSymFont.Item1.AddrOfPinnedObject(),
|
||||
this._gameSymFont.Item2,
|
||||
this.Plugin.Config.FontSize,
|
||||
this.Plugin.Config.SymbolsFontSize,
|
||||
this._fontCfgMerge,
|
||||
this._symRange.AddrOfPinnedObject()
|
||||
);
|
||||
|
@ -268,7 +268,7 @@ internal sealed class PluginUi : IDisposable {
|
|||
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
|
||||
this._jpFont.Item1.AddrOfPinnedObject(),
|
||||
this._jpFont.Item2,
|
||||
this.Plugin.Config.FontSize,
|
||||
this.Plugin.Config.JapaneseFontSize,
|
||||
this._fontCfgMerge,
|
||||
this._jpRange.AddrOfPinnedObject()
|
||||
);
|
||||
|
@ -276,7 +276,7 @@ internal sealed class PluginUi : IDisposable {
|
|||
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
|
||||
this._gameSymFont.Item1.AddrOfPinnedObject(),
|
||||
this._gameSymFont.Item2,
|
||||
this.Plugin.Config.FontSize,
|
||||
this.Plugin.Config.SymbolsFontSize,
|
||||
this._fontCfgMerge,
|
||||
this._symRange.AddrOfPinnedObject()
|
||||
);
|
||||
|
|
|
@ -294,6 +294,15 @@ namespace ChatTwo.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fonts.
|
||||
/// </summary>
|
||||
internal static string Options_Fonts_Tab {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_Fonts_Tab", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Font size.
|
||||
/// </summary>
|
||||
|
@ -357,6 +366,15 @@ namespace ChatTwo.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Japanese font size.
|
||||
/// </summary>
|
||||
internal static string Options_JapaneseFontSize_Name {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_JapaneseFontSize_Name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Reduce the spacing between messages..
|
||||
/// </summary>
|
||||
|
@ -456,6 +474,24 @@ namespace ChatTwo.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The font size to use for game symbols..
|
||||
/// </summary>
|
||||
internal static string Options_SymbolsFontSize_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_SymbolsFontSize_Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Symbols font size.
|
||||
/// </summary>
|
||||
internal static string Options_SymbolsFontSize_Name {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_SymbolsFontSize_Name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add.
|
||||
/// </summary>
|
||||
|
|
|
@ -338,4 +338,16 @@
|
|||
<data name="Options_Tabs_ChannelTypes_Special" xml:space="preserve">
|
||||
<value>Special</value>
|
||||
</data>
|
||||
<data name="Options_Fonts_Tab" xml:space="preserve">
|
||||
<value>Fonts</value>
|
||||
</data>
|
||||
<data name="Options_SymbolsFontSize_Name" xml:space="preserve">
|
||||
<value>Symbols font size</value>
|
||||
</data>
|
||||
<data name="Options_JapaneseFontSize_Name" xml:space="preserve">
|
||||
<value>Japanese font size</value>
|
||||
</data>
|
||||
<data name="Options_SymbolsFontSize_Description" xml:space="preserve">
|
||||
<value>The font size to use for game symbols.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -21,6 +21,7 @@ internal sealed class Settings : IUiComponent {
|
|||
|
||||
this.Tabs = new List<ISettingsTab> {
|
||||
new Display(this.Mutable),
|
||||
new Ui.SettingsTabs.Fonts(this.Mutable),
|
||||
new ChatColours(this.Mutable, this.Ui.Plugin),
|
||||
new Tabs(this.Mutable),
|
||||
};
|
||||
|
@ -125,7 +126,9 @@ internal sealed class Settings : IUiComponent {
|
|||
var hideChatChanged = this.Mutable.HideChat != this.Ui.Plugin.Config.HideChat;
|
||||
var fontChanged = this.Mutable.GlobalFont != this.Ui.Plugin.Config.GlobalFont
|
||||
|| this.Mutable.JapaneseFont != this.Ui.Plugin.Config.JapaneseFont;
|
||||
var fontSizeChanged = Math.Abs(this.Mutable.FontSize - this.Ui.Plugin.Config.FontSize) > 0.001;
|
||||
var fontSizeChanged = Math.Abs(this.Mutable.FontSize - this.Ui.Plugin.Config.FontSize) > 0.001
|
||||
|| Math.Abs(this.Mutable.JapaneseFontSize - this.Ui.Plugin.Config.JapaneseFontSize) > 0.001
|
||||
|| Math.Abs(this.Mutable.SymbolsFontSize - this.Ui.Plugin.Config.SymbolsFontSize) > 0.001;
|
||||
|
||||
config.UpdateFrom(this.Mutable);
|
||||
|
||||
|
|
|
@ -6,26 +6,14 @@ namespace ChatTwo.Ui.SettingsTabs;
|
|||
|
||||
internal sealed class Display : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
private List<string> Fonts { get; set; } = new();
|
||||
private List<string> JpFonts { get; set; } = new();
|
||||
|
||||
public string Name => Language.Options_Display_Tab + "###tabs-display";
|
||||
|
||||
internal Display(Configuration mutable) {
|
||||
this.Mutable = mutable;
|
||||
this.UpdateFonts();
|
||||
}
|
||||
|
||||
private void UpdateFonts() {
|
||||
this.Fonts = Ui.Fonts.GetFonts();
|
||||
this.JpFonts = Ui.Fonts.GetJpFonts();
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
if (ImGui.IsWindowAppearing()) {
|
||||
this.UpdateFonts();
|
||||
}
|
||||
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
||||
|
@ -53,66 +41,6 @@ internal sealed class Display : ISettingsTab {
|
|||
ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.BeginCombo(Language.Options_Font_Name, this.Mutable.GlobalFont)) {
|
||||
foreach (var font in Ui.Fonts.GlobalFonts) {
|
||||
if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) {
|
||||
this.Mutable.GlobalFont = font.Name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == font.Name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var name in this.Fonts) {
|
||||
if (ImGui.Selectable(name, this.Mutable.GlobalFont == name)) {
|
||||
this.Mutable.GlobalFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(Language.Options_Font_Description);
|
||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.BeginCombo(Language.Options_JapaneseFont_Name, this.Mutable.JapaneseFont)) {
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts) {
|
||||
if (ImGui.Selectable(name, this.Mutable.JapaneseFont == name)) {
|
||||
this.Mutable.JapaneseFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
// ImGui.Separator();
|
||||
//
|
||||
// foreach (var family in this.JpFonts) {
|
||||
// if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
|
||||
// this.Mutable.JapaneseFont = family;
|
||||
// }
|
||||
//
|
||||
// if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
|
||||
// ImGui.SetScrollHereY(0.5f);
|
||||
// }
|
||||
// }
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(Language.Options_JapaneseFont_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.DragFloat(Language.Options_FontSize_Name, ref this.Mutable.FontSize, .0125f, 12f, 36f, $"{this.Mutable.FontSize:N1}");
|
||||
if (ImGui.DragFloat(Language.Options_WindowOpacity_Name, ref this.Mutable.WindowAlpha, .0025f, 0f, 1f, $"{this.Mutable.WindowAlpha * 100f:N2}%%")) {
|
||||
switch (this.Mutable.WindowAlpha) {
|
||||
case > 1f and <= 100f:
|
||||
|
@ -124,8 +52,6 @@ internal sealed class Display : ISettingsTab {
|
|||
}
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.CanMove, Language.Options_CanMove_Name);
|
||||
ImGui.Spacing();
|
||||
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
public class Fonts : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => Language.Options_Fonts_Tab + "###tabs-fonts";
|
||||
private List<string> GlobalFonts { get; set; } = new();
|
||||
private List<string> JpFonts { get; set; } = new();
|
||||
|
||||
internal Fonts(Configuration mutable) {
|
||||
this.Mutable = mutable;
|
||||
this.UpdateFonts();
|
||||
}
|
||||
|
||||
private void UpdateFonts() {
|
||||
this.GlobalFonts = Ui.Fonts.GetFonts();
|
||||
this.JpFonts = Ui.Fonts.GetJpFonts();
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
if (ImGui.IsWindowAppearing()) {
|
||||
this.UpdateFonts();
|
||||
}
|
||||
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
if (ImGui.BeginCombo(Language.Options_Font_Name, this.Mutable.GlobalFont)) {
|
||||
foreach (var font in Ui.Fonts.GlobalFonts) {
|
||||
if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) {
|
||||
this.Mutable.GlobalFont = font.Name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == font.Name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var name in this.GlobalFonts) {
|
||||
if (ImGui.Selectable(name, this.Mutable.GlobalFont == name)) {
|
||||
this.Mutable.GlobalFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(Language.Options_Font_Description);
|
||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.BeginCombo(Language.Options_JapaneseFont_Name, this.Mutable.JapaneseFont)) {
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts) {
|
||||
if (ImGui.Selectable(name, this.Mutable.JapaneseFont == name)) {
|
||||
this.Mutable.JapaneseFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == name) {
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
// ImGui.Separator();
|
||||
//
|
||||
// foreach (var family in this.JpFonts) {
|
||||
// if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
|
||||
// this.Mutable.JapaneseFont = family;
|
||||
// }
|
||||
//
|
||||
// if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
|
||||
// ImGui.SetScrollHereY(0.5f);
|
||||
// }
|
||||
// }
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(Language.Options_JapaneseFont_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
const float speed = .0125f;
|
||||
const float min = 8f;
|
||||
const float max = 36f;
|
||||
ImGui.DragFloat(Language.Options_FontSize_Name, ref this.Mutable.FontSize, speed, min, max, $"{this.Mutable.FontSize:N1}");
|
||||
ImGui.DragFloat(Language.Options_JapaneseFontSize_Name, ref this.Mutable.JapaneseFontSize, speed, min, max, $"{this.Mutable.JapaneseFontSize:N1}");
|
||||
ImGui.DragFloat(Language.Options_SymbolsFontSize_Name, ref this.Mutable.SymbolsFontSize, speed, min, max, $"{this.Mutable.SymbolsFontSize:N1}");
|
||||
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue