feat: update for 6.11

This commit is contained in:
Anna
2022-05-12 18:50:05 -04:00
parent 327a40f63c
commit f195f55274
11 changed files with 147 additions and 72 deletions
+40 -3
View File
@@ -39,12 +39,14 @@ internal sealed class ChatLog : IUiComponent {
private PayloadHandler PayloadHandler { get; }
private Dictionary<string, ChatType> TextCommandChannels { get; } = new();
private HashSet<string> AllCommands { get; } = new();
internal ChatLog(PluginUi ui) {
this.Ui = ui;
this.PayloadHandler = new PayloadHandler(this.Ui, this);
this.SetUpTextCommandChannels();
this.SetUpAllCommands();
this.Ui.Plugin.Commands.Register("/clearlog2", "Clear the Chat 2 chat log").Execute += this.ClearLog;
this.Ui.Plugin.Commands.Register("/chat2").Execute += this.ToggleChat;
@@ -137,6 +139,11 @@ internal sealed class ChatLog : IUiComponent {
}
}
private bool IsValidCommand(string command) {
return this.Ui.Plugin.CommandManager.Commands.ContainsKey(command)
|| this.AllCommands.Contains(command);
}
private void ClearLog(string command, string arguments) {
switch (arguments) {
case "all":
@@ -213,6 +220,23 @@ internal sealed class ChatLog : IUiComponent {
this.TextCommandChannels[command.ShortAlias] = type;
}
private void SetUpAllCommands() {
if (this.Ui.Plugin.DataManager.GetExcelSheet<TextCommand>() is not { } commands) {
return;
}
var commandNames = commands.SelectMany(cmd => new[] {
cmd.Command.RawString,
cmd.ShortCommand.RawString,
cmd.Alias.RawString,
cmd.ShortAlias.RawString,
});
foreach (var command in commandNames) {
this.AllCommands.Add(command);
}
}
private void AddBacklog(string message) {
for (var i = 0; i < this._inputBacklog.Count; i++) {
if (this._inputBacklog[i] != message) {
@@ -479,6 +503,10 @@ internal sealed class ChatLog : IUiComponent {
if (this.TextCommandChannels.TryGetValue(command, out var channel)) {
inputType = channel;
}
if (!this.IsValidCommand(command)) {
inputType = ChatType.Error;
}
}
var normalColour = *ImGui.GetStyleColorVec4(ImGuiCol.Text);
@@ -1040,8 +1068,17 @@ internal sealed class ChatLog : IUiComponent {
ImGui.PushStyleColor(ImGuiCol.Text, colour.Value);
}
if (text.Italic && this.Ui.ItalicFont.HasValue) {
ImGui.PushFont(this.Ui.ItalicFont.Value);
var pushed = false;
if (text.Italic) {
if (this.Ui.ItalicFont.HasValue && this.Ui.Plugin.Config.FontsEnabled) {
ImGui.PushFont(this.Ui.ItalicFont.Value);
pushed = true;
}
if (!this.Ui.Plugin.Config.FontsEnabled && this.Ui.AxisItalic.Available) {
ImGui.PushFont(this.Ui.AxisItalic.ImFont);
pushed = true;
}
}
var content = text.Content;
@@ -1062,7 +1099,7 @@ internal sealed class ChatLog : IUiComponent {
ImGuiUtil.PostPayload(chunk, handler);
}
if (text.Italic && this.Ui.ItalicFont.HasValue) {
if (pushed) {
ImGui.PopFont();
}
+50 -45
View File
@@ -27,66 +27,71 @@ public class Fonts : ISettingsTab {
}
ImGui.PushTextWrapPos();
if (ImGuiUtil.BeginComboVertical(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(string.Format(Language.Options_Font_Description, Plugin.PluginName));
ImGuiUtil.WarningText(Language.Options_Font_Warning);
ImGui.Checkbox(Language.Options_FontsEnabled, ref this.Mutable.FontsEnabled);
ImGui.Spacing();
if (ImGuiUtil.BeginComboVertical(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 (this.Mutable.FontsEnabled) {
if (ImGuiUtil.BeginComboVertical(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);
}
}
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == 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();
}
ImGui.Separator();
ImGuiUtil.HelpText(string.Format(Language.Options_Font_Description, Plugin.PluginName));
ImGuiUtil.WarningText(Language.Options_Font_Warning);
ImGui.Spacing();
foreach (var family in this.JpFonts) {
if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
this.Mutable.JapaneseFont = family;
if (ImGuiUtil.BeginComboVertical(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);
}
}
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
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();
}
ImGui.EndCombo();
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
ImGui.Spacing();
}
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
ImGui.Spacing();
const float speed = .0125f;
const float min = 8f;
const float max = 36f;