From bf742cd5a468bcd2d49c9d143872d6a69f05c2df Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 4 Feb 2022 05:46:13 -0500 Subject: [PATCH] feat: prettier settings, start using resources file --- ChatTwo/ChatTwo.csproj | 15 + ChatTwo/Configuration.cs | 9 +- ChatTwo/Plugin.cs | 12 +- ChatTwo/Resources/Language.Designer.cs | 504 +++++++++++++++++++++++++ ChatTwo/Resources/Language.resx | 272 +++++++++++++ ChatTwo/Ui/ChatLog.cs | 13 +- ChatTwo/Ui/Settings.cs | 14 +- ChatTwo/Ui/SettingsTabs/ChatColours.cs | 7 +- ChatTwo/Ui/SettingsTabs/Display.cs | 32 +- ChatTwo/Ui/SettingsTabs/Tabs.cs | 25 +- ChatTwo/Util/ImGuiUtil.cs | 19 + 11 files changed, 877 insertions(+), 45 deletions(-) create mode 100755 ChatTwo/Resources/Language.Designer.cs create mode 100755 ChatTwo/Resources/Language.resx diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 13a2877..c517b5a 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -58,4 +58,19 @@ + + + True + True + Language.resx + + + + + + ResXFileCodeGenerator + Language.Designer.cs + + + diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index eb410fb..dd6e4d8 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -1,4 +1,5 @@ using ChatTwo.Code; +using ChatTwo.Resources; using Dalamud.Configuration; namespace ChatTwo; @@ -61,16 +62,16 @@ internal enum UnreadMode { internal static class UnreadModeExt { internal static string? Tooltip(this UnreadMode mode) => mode switch { - UnreadMode.All => "Always show unread indicators.", - UnreadMode.Unseen => "Only show unread indicators for messages you haven't seen.", - UnreadMode.None => "Never show unread indicators.", + UnreadMode.All => Language.UnreadMode_All_Tooltip, + UnreadMode.Unseen => Language.UnreadMode_Unseen_Tooltip, + UnreadMode.None => Language.UnreadMode_None_Tooltip, _ => null, }; } [Serializable] internal class Tab { - public string Name = "New tab"; + public string Name = Language.Tab_DefaultName; public Dictionary ChatCodes = new(); [Obsolete("Use UnreadMode instead")] diff --git a/ChatTwo/Plugin.cs b/ChatTwo/Plugin.cs index b096d4b..0ff6280 100755 --- a/ChatTwo/Plugin.cs +++ b/ChatTwo/Plugin.cs @@ -1,4 +1,6 @@ -using Dalamud.Data; +using System.Globalization; +using ChatTwo.Resources; +using Dalamud.Data; using Dalamud.Game; using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Conditions; @@ -65,6 +67,8 @@ public sealed class Plugin : IDalamudPlugin { #pragma warning disable CS8618 public Plugin() { + LanguageChanged(this.Interface!.UiLanguage); + this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration(); this.Config.Migrate(); this.Common = new XivCommonBase(); @@ -74,10 +78,12 @@ public sealed class Plugin : IDalamudPlugin { this.Ui = new PluginUi(this); this.Framework!.Update += this.FrameworkUpdate; + this.Interface.LanguageChanged += LanguageChanged; } #pragma warning restore CS8618 public void Dispose() { + this.Interface.LanguageChanged -= LanguageChanged; this.Framework.Update -= this.FrameworkUpdate; GameFunctions.GameFunctions.SetChatInteractable(true); @@ -92,6 +98,10 @@ public sealed class Plugin : IDalamudPlugin { this.Interface.SavePluginConfig(this.Config); } + private static void LanguageChanged(string langCode) { + Language.Culture = new CultureInfo(langCode); + } + private static readonly string[] ChatAddonNames = { "ChatLog", "ChatLogPanel_0", diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs new file mode 100755 index 0000000..2783d9e --- /dev/null +++ b/ChatTwo/Resources/Language.Designer.cs @@ -0,0 +1,504 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ChatTwo.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Language { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Language() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChatTwo.resources.Language", typeof(Language).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Hide chat. + /// + internal static string ChatLog_HideChat { + get { + return ResourceManager.GetString("ChatLog_HideChat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Disabled for this tab.. + /// + internal static string ChatLog_SwitcherDisabled { + get { + return ResourceManager.GetString("ChatLog_SwitcherDisabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move down. + /// + internal static string ChatLog_Tabs_MoveDown { + get { + return ResourceManager.GetString("ChatLog_Tabs_MoveDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move left. + /// + internal static string ChatLog_Tabs_MoveLeft { + get { + return ResourceManager.GetString("ChatLog_Tabs_MoveLeft", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move right. + /// + internal static string ChatLog_Tabs_MoveRight { + get { + return ResourceManager.GetString("ChatLog_Tabs_MoveRight", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move up. + /// + internal static string ChatLog_Tabs_MoveUp { + get { + return ResourceManager.GetString("ChatLog_Tabs_MoveUp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allow moving chat. + /// + internal static string Options_CanMove_Name { + get { + return ResourceManager.GetString("Options_CanMove_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allow resizing chat. + /// + internal static string Options_CanResize_Name { + get { + return ResourceManager.GetString("Options_CanResize_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Import from game. + /// + internal static string Options_ChatColours_Import { + get { + return ResourceManager.GetString("Options_ChatColours_Import", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reset to default. + /// + internal static string Options_ChatColours_Reset { + get { + return ResourceManager.GetString("Options_ChatColours_Reset", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Chat colours. + /// + internal static string Options_ChatColours_Tab { + get { + return ResourceManager.GetString("Options_ChatColours_Tab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Display. + /// + internal static string Options_Display_Tab { + get { + return ResourceManager.GetString("Options_Display_Tab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Font size. + /// + internal static string Options_FontSize_Name { + get { + return ResourceManager.GetString("Options_FontSize_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide the in-game chat window when the plugin is active.. + /// + internal static string Options_HideChat_Description { + get { + return ResourceManager.GetString("Options_HideChat_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide vanilla chat. + /// + internal static string Options_HideChat_Name { + get { + return ResourceManager.GetString("Options_HideChat_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide Chat 2 during cutscenes.. + /// + internal static string Options_HideDuringCutscenes_Description { + get { + return ResourceManager.GetString("Options_HideDuringCutscenes_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide chat during cutscenes. + /// + internal static string Options_HideDuringCutscenes_Name { + get { + return ResourceManager.GetString("Options_HideDuringCutscenes_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reduce the spacing between messages.. + /// + internal static string Options_MoreCompactPretty_Description { + get { + return ResourceManager.GetString("Options_MoreCompactPretty_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to More compact modern layout. + /// + internal static string Options_MoreCompactPretty_Name { + get { + return ResourceManager.GetString("Options_MoreCompactPretty_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show in-game item tooltips when hovering over items in Chat 2.. + /// + internal static string Options_NativeItemTooltips_Description { + get { + return ResourceManager.GetString("Options_NativeItemTooltips_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show native item tooltips. + /// + internal static string Options_NativeItemTooltips_Name { + get { + return ResourceManager.GetString("Options_NativeItemTooltips_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use a more modern style of displaying messages.. + /// + internal static string Options_PrettierTimestamps_Description { + get { + return ResourceManager.GetString("Options_PrettierTimestamps_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use modern timestamp layout. + /// + internal static string Options_PrettierTimestamps_Name { + get { + return ResourceManager.GetString("Options_PrettierTimestamps_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show the Novice Network join button next to the settings button if logged in as a mentor.. + /// + internal static string Options_ShowNoviceNetwork_Description { + get { + return ResourceManager.GetString("Options_ShowNoviceNetwork_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show Novice Network join button. + /// + internal static string Options_ShowNoviceNetwork_Name { + get { + return ResourceManager.GetString("Options_ShowNoviceNetwork_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show title bar for chat. + /// + internal static string Options_ShowTitleBar_Name { + get { + return ResourceManager.GetString("Options_ShowTitleBar_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show tabs in Chat 2 as a sidebar instead of a bar at the top.. + /// + internal static string Options_SidebarTabView_Description { + get { + return ResourceManager.GetString("Options_SidebarTabView_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show tabs in a sidebar. + /// + internal static string Options_SidebarTabView_Name { + get { + return ResourceManager.GetString("Options_SidebarTabView_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add. + /// + internal static string Options_Tabs_Add { + get { + return ResourceManager.GetString("Options_Tabs_Add", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Channels. + /// + internal static string Options_Tabs_Channels { + get { + return ResourceManager.GetString("Options_Tabs_Channels", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + internal static string Options_Tabs_Delete { + get { + return ResourceManager.GetString("Options_Tabs_Delete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Input channel. + /// + internal static string Options_Tabs_InputChannel { + get { + return ResourceManager.GetString("Options_Tabs_InputChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move down. + /// + internal static string Options_Tabs_MoveDown { + get { + return ResourceManager.GetString("Options_Tabs_MoveDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move up. + /// + internal static string Options_Tabs_MoveUp { + get { + return ResourceManager.GetString("Options_Tabs_MoveUp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name. + /// + internal static string Options_Tabs_Name { + get { + return ResourceManager.GetString("Options_Tabs_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to <None>. + /// + internal static string Options_Tabs_NoInputChannel { + get { + return ResourceManager.GetString("Options_Tabs_NoInputChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show timestamps. + /// + internal static string Options_Tabs_ShowTimestamps { + get { + return ResourceManager.GetString("Options_Tabs_ShowTimestamps", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tabs. + /// + internal static string Options_Tabs_Tab { + get { + return ResourceManager.GetString("Options_Tabs_Tab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unread mode. + /// + internal static string Options_Tabs_UnreadMode { + get { + return ResourceManager.GetString("Options_Tabs_UnreadMode", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Window opacity. + /// + internal static string Options_WindowOpacity_Name { + get { + return ResourceManager.GetString("Options_WindowOpacity_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Discard. + /// + internal static string Settings_Discard { + get { + return ResourceManager.GetString("Settings_Discard", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Support {0} on Ko-fi. + /// + internal static string Settings_Kofi { + get { + return ResourceManager.GetString("Settings_Kofi", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save. + /// + internal static string Settings_Save { + get { + return ResourceManager.GetString("Settings_Save", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save and close. + /// + internal static string Settings_SaveAndClose { + get { + return ResourceManager.GetString("Settings_SaveAndClose", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} settings. + /// + internal static string Settings_Title { + get { + return ResourceManager.GetString("Settings_Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New tab. + /// + internal static string Tab_DefaultName { + get { + return ResourceManager.GetString("Tab_DefaultName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Always show unread indicators.. + /// + internal static string UnreadMode_All_Tooltip { + get { + return ResourceManager.GetString("UnreadMode_All_Tooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Never show unread indicators.. + /// + internal static string UnreadMode_None_Tooltip { + get { + return ResourceManager.GetString("UnreadMode_None_Tooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Only show unread indicators for messages you haven't seen.. + /// + internal static string UnreadMode_Unseen_Tooltip { + get { + return ResourceManager.GetString("UnreadMode_Unseen_Tooltip", resourceCulture); + } + } + } +} diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx new file mode 100755 index 0000000..4b3bae1 --- /dev/null +++ b/ChatTwo/Resources/Language.resx @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + Hide vanilla chat + + + Hide the in-game chat window when the plugin is active. + + + Hide chat during cutscenes + + + Hide Chat 2 during cutscenes. + + + Show native item tooltips + + + Show in-game item tooltips when hovering over items in Chat 2. + + + Show tabs in a sidebar + + + Show tabs in Chat 2 as a sidebar instead of a bar at the top. + + + Use modern timestamp layout + + + Use a more modern style of displaying messages. + + + More compact modern layout + + + Reduce the spacing between messages. + + + Show Novice Network join button + + + Show the Novice Network join button next to the settings button if logged in as a mentor. + + + Font size + + + Window opacity + + + Allow moving chat + + + Allow resizing chat + + + Show title bar for chat + + + Display + + + Chat colours + + + Reset to default + + + Import from game + + + Tabs + + + Add + + + Delete + + + Move up + + + Move down + + + Name + + + Show timestamps + + + Unread mode + + + <None> + + + Input channel + + + Channels + + + Always show unread indicators. + + + Only show unread indicators for messages you haven't seen. + + + Never show unread indicators. + + + New tab + + + Support {0} on Ko-fi + + + Save and close + + + Save + + + Discard + + + {0} settings + + + Disabled for this tab. + + + Hide chat + + + Move up + + + Move left + + + Move down + + + Move right + + diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index 56111b3..fa95ef6 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -2,6 +2,7 @@ using System.Numerics; using ChatTwo.Code; using ChatTwo.GameFunctions.Types; +using ChatTwo.Resources; using ChatTwo.Util; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Keys; @@ -383,7 +384,7 @@ internal sealed class ChatLog : IUiComponent { if (activeTab is { Channel: { } } && ImGui.IsItemHovered()) { ImGui.BeginTooltip(); - ImGui.TextUnformatted("Disabled for this tab."); + ImGui.TextUnformatted(Language.ChatLog_SwitcherDisabled); ImGui.EndTooltip(); } @@ -486,7 +487,7 @@ internal sealed class ChatLog : IUiComponent { ImGui.PushStyleColor(ImGuiCol.Text, normalColour); try { - if (ImGui.Selectable("Hide chat")) { + if (ImGui.Selectable(Language.ChatLog_HideChat)) { this.UserHide(); } } finally { @@ -754,8 +755,8 @@ internal sealed class ChatLog : IUiComponent { ImGui.SameLine(); var (leftIcon, leftTooltip) = this.Ui.Plugin.Config.SidebarTabView - ? (FontAwesomeIcon.ArrowUp, "Move up") - : ((FontAwesomeIcon) 61536, "Move left"); + ? (FontAwesomeIcon.ArrowUp, Language.ChatLog_Tabs_MoveUp) + : (FontAwesomeIcon.ArrowLeft, Language.ChatLog_Tabs_MoveLeft); if (ImGuiUtil.IconButton(leftIcon, tooltip: leftTooltip) && i > 0) { (tabs[i - 1], tabs[i]) = (tabs[i], tabs[i - 1]); ImGui.CloseCurrentPopup(); @@ -765,8 +766,8 @@ internal sealed class ChatLog : IUiComponent { ImGui.SameLine(); var (rightIcon, rightTooltip) = this.Ui.Plugin.Config.SidebarTabView - ? (FontAwesomeIcon.ArrowDown, "Move down") - : (FontAwesomeIcon.ArrowRight, "Move right"); + ? (FontAwesomeIcon.ArrowDown, Language.ChatLog_Tabs_MoveDown) + : (FontAwesomeIcon.ArrowRight, Language.ChatLog_Tabs_MoveRight); if (ImGuiUtil.IconButton(rightIcon, tooltip: rightTooltip) && i < tabs.Count - 1) { (tabs[i + 1], tabs[i]) = (tabs[i], tabs[i + 1]); ImGui.CloseCurrentPopup(); diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index 21e861f..04b86e4 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -1,8 +1,10 @@ using System.Diagnostics; using System.Numerics; +using ChatTwo.Resources; using ChatTwo.Ui.SettingsTabs; using ChatTwo.Util; using Dalamud.Game.Command; +using Dalamud.Interface; using ImGuiNET; namespace ChatTwo.Ui; @@ -45,7 +47,9 @@ internal sealed class Settings : IUiComponent { return; } - if (!ImGui.Begin($"{this.Ui.Plugin.Name} settings", ref this.Ui.SettingsVisible)) { + ImGui.SetNextWindowSize(new Vector2(500, 650) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); + + if (!ImGui.Begin(string.Format(Language.Settings_Title, this.Ui.Plugin.Name), ref this.Ui.SettingsVisible)) { ImGui.End(); return; } @@ -78,22 +82,22 @@ internal sealed class Settings : IUiComponent { ImGui.Separator(); - var save = ImGui.Button("Save"); + var save = ImGui.Button(Language.Settings_Save); ImGui.SameLine(); - if (ImGui.Button("Save and close")) { + if (ImGui.Button(Language.Settings_SaveAndClose)) { save = true; this.Ui.SettingsVisible = false; } ImGui.SameLine(); - if (ImGui.Button("Discard")) { + if (ImGui.Button(Language.Settings_Discard)) { this.Ui.SettingsVisible = false; } - var buttonLabel = $"Support {this.Ui.Plugin.Name} on Ko-fi"; + var buttonLabel = string.Format(Language.Settings_Kofi, this.Ui.Plugin.Name); ImGui.PushStyleColor(ImGuiCol.Button, ColourUtil.RgbaToAbgr(0xFF5E5BFF)); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF)); diff --git a/ChatTwo/Ui/SettingsTabs/ChatColours.cs b/ChatTwo/Ui/SettingsTabs/ChatColours.cs index cb89330..4fb25df 100755 --- a/ChatTwo/Ui/SettingsTabs/ChatColours.cs +++ b/ChatTwo/Ui/SettingsTabs/ChatColours.cs @@ -1,4 +1,5 @@ using ChatTwo.Code; +using ChatTwo.Resources; using ChatTwo.Util; using Dalamud.Interface; using ImGuiNET; @@ -9,7 +10,7 @@ internal sealed class ChatColours : ISettingsTab { private Configuration Mutable { get; } private Plugin Plugin { get; } - public string Name => "Chat colours"; + public string Name => Language.Options_ChatColours_Tab; internal ChatColours(Configuration mutable, Plugin plugin) { this.Mutable = mutable; @@ -18,13 +19,13 @@ internal sealed class ChatColours : ISettingsTab { public void Draw() { foreach (var type in Enum.GetValues()) { - if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", "Reset to default")) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset)) { this.Mutable.ChatColours.Remove(type); } ImGui.SameLine(); - if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", "Import from game")) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", Language.Options_ChatColours_Import)) { var gameColour = this.Plugin.Functions.Chat.GetChannelColour(type); this.Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0; } diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index d4cb29d..a687e0c 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -1,31 +1,35 @@ -using ImGuiNET; +using ChatTwo.Resources; +using ChatTwo.Util; +using ImGuiNET; namespace ChatTwo.Ui.SettingsTabs; internal sealed class Display : ISettingsTab { private Configuration Mutable { get; } - public string Name => "Display"; + public string Name => Language.Options_Display_Tab; internal Display(Configuration mutable) { this.Mutable = mutable; } public void Draw() { - ImGui.Checkbox("Hide vanilla chat", ref this.Mutable.HideChat); - ImGui.Checkbox("Hide chat during cutscenes", ref this.Mutable.HideDuringCutscenes); - ImGui.Checkbox("Show native item tooltips", ref this.Mutable.NativeItemTooltips); - ImGui.Checkbox("Show tabs in a sidebar", ref this.Mutable.SidebarTabView); - ImGui.Checkbox("Use modern timestamp layout", ref this.Mutable.PrettierTimestamps); + ImGuiUtil.OptionCheckbox(ref this.Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description); + ImGuiUtil.OptionCheckbox(ref this.Mutable.HideDuringCutscenes, Language.Options_HideDuringCutscenes_Name, Language.Options_HideDuringCutscenes_Description); + ImGuiUtil.OptionCheckbox(ref this.Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, Language.Options_NativeItemTooltips_Description); + ImGuiUtil.OptionCheckbox(ref this.Mutable.SidebarTabView, Language.Options_SidebarTabView_Name, Language.Options_SidebarTabView_Description); + ImGuiUtil.OptionCheckbox(ref this.Mutable.PrettierTimestamps, Language.Options_PrettierTimestamps_Name, Language.Options_PrettierTimestamps_Description); if (this.Mutable.PrettierTimestamps) { - ImGui.Checkbox("More compact modern layout", ref this.Mutable.MoreCompactPretty); + ImGui.TreePush(); + ImGuiUtil.OptionCheckbox(ref this.Mutable.MoreCompactPretty, Language.Options_MoreCompactPretty_Name, Language.Options_MoreCompactPretty_Description); + ImGui.TreePop(); } - ImGui.Checkbox("Show Novice Network join button", ref this.Mutable.ShowNoviceNetwork); + ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description); - ImGui.DragFloat("Font size", ref this.Mutable.FontSize, .0125f, 12f, 36f, $"{this.Mutable.FontSize:N1}"); - if (ImGui.DragFloat("Window opacity", ref this.Mutable.WindowAlpha, .0025f, 0f, 1f, $"{this.Mutable.WindowAlpha * 100f:N2}%%")) { + 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: this.Mutable.WindowAlpha /= 100f; @@ -36,8 +40,8 @@ internal sealed class Display : ISettingsTab { } } - ImGui.Checkbox("Allow moving main window", ref this.Mutable.CanMove); - ImGui.Checkbox("Allow resizing main window", ref this.Mutable.CanResize); - ImGui.Checkbox("Show title bar for main window", ref this.Mutable.ShowTitleBar); + ImGuiUtil.OptionCheckbox(ref this.Mutable.CanMove, Language.Options_CanMove_Name); + ImGuiUtil.OptionCheckbox(ref this.Mutable.CanResize, Language.Options_CanResize_Name); + ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowTitleBar, Language.Options_ShowTitleBar_Name); } } diff --git a/ChatTwo/Ui/SettingsTabs/Tabs.cs b/ChatTwo/Ui/SettingsTabs/Tabs.cs index 250fb1f..f2b1012 100755 --- a/ChatTwo/Ui/SettingsTabs/Tabs.cs +++ b/ChatTwo/Ui/SettingsTabs/Tabs.cs @@ -1,4 +1,5 @@ using ChatTwo.Code; +using ChatTwo.Resources; using ChatTwo.Util; using Dalamud.Interface; using ImGuiNET; @@ -8,14 +9,14 @@ namespace ChatTwo.Ui.SettingsTabs; internal sealed class Tabs : ISettingsTab { private Configuration Mutable { get; } - public string Name => "Tabs"; + public string Name => Language.Options_Tabs_Tab; internal Tabs(Configuration mutable) { this.Mutable = mutable; } public void Draw() { - if (ImGuiUtil.IconButton(FontAwesomeIcon.Plus, tooltip: "Add")) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.Plus, tooltip: Language.Options_Tabs_Add)) { this.Mutable.Tabs.Add(new Tab()); } @@ -26,26 +27,26 @@ internal sealed class Tabs : ISettingsTab { if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) { ImGui.PushID($"tab-{i}"); - if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: "Delete")) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete)) { toRemove = i; } ImGui.SameLine(); - if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: "Move up") && i > 0) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0) { (this.Mutable.Tabs[i - 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i - 1]); } ImGui.SameLine(); - if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: "Move down") && i < this.Mutable.Tabs.Count - 1) { + if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < this.Mutable.Tabs.Count - 1) { (this.Mutable.Tabs[i + 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i + 1]); } - ImGui.InputText("Name", ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue); - ImGui.Checkbox("Show timestamps", ref tab.DisplayTimestamp); + ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.Checkbox(Language.Options_Tabs_ShowTimestamps, ref tab.DisplayTimestamp); - if (ImGui.BeginCombo("Unread mode", tab.UnreadMode.ToString())) { + if (ImGui.BeginCombo(Language.Options_Tabs_UnreadMode, tab.UnreadMode.ToString())) { foreach (var mode in Enum.GetValues()) { if (ImGui.Selectable(mode.ToString(), tab.UnreadMode == mode)) { tab.UnreadMode = mode; @@ -61,9 +62,9 @@ internal sealed class Tabs : ISettingsTab { ImGui.EndCombo(); } - var input = tab.Channel?.ToChatType().Name() ?? ""; - if (ImGui.BeginCombo("Input channel", input)) { - if (ImGui.Selectable("", tab.Channel == null)) { + var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel; + if (ImGui.BeginCombo(Language.Options_Tabs_InputChannel, input)) { + if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null)) { tab.Channel = null; } @@ -76,7 +77,7 @@ internal sealed class Tabs : ISettingsTab { ImGui.EndCombo(); } - if (ImGui.TreeNodeEx("Channels")) { + if (ImGui.TreeNodeEx(Language.Options_Tabs_Channels)) { foreach (var type in Enum.GetValues()) { var enabled = tab.ChatCodes.ContainsKey(type); if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) { diff --git a/ChatTwo/Util/ImGuiUtil.cs b/ChatTwo/Util/ImGuiUtil.cs index 7543c18..9636def 100755 --- a/ChatTwo/Util/ImGuiUtil.cs +++ b/ChatTwo/Util/ImGuiUtil.cs @@ -105,4 +105,23 @@ internal static class ImGuiUtil { return ret; } + + internal static bool OptionCheckbox(ref bool value, string label, string? description = null) { + var ret = ImGui.Checkbox(label, ref value); + + if (description != null) { + var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]; + ImGui.PushStyleColor(ImGuiCol.Text, colour); + ImGui.PushTextWrapPos(); + + try { + ImGui.TextUnformatted(description); + } finally { + ImGui.PopTextWrapPos(); + ImGui.PopStyleColor(); + } + } + + return ret; + } }