feat: add symbol and japanese font sizes

This commit is contained in:
Anna
2022-02-05 19:31:26 -05:00
parent a7b9c50759
commit 2ef42aa211
7 changed files with 185 additions and 86 deletions
+4 -1
View File
@@ -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);
-74
View File
@@ -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();
+100
View File
@@ -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();
}
}