feat: prettier settings, start using resources file

This commit is contained in:
Anna
2022-02-04 05:46:13 -05:00
parent 61243096ec
commit bf742cd5a4
11 changed files with 877 additions and 45 deletions
+7 -6
View File
@@ -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();
+9 -5
View File
@@ -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));
+4 -3
View File
@@ -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<ChatType>()) {
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;
}
+18 -14
View File
@@ -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);
}
}
+13 -12
View File
@@ -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<UnreadMode>()) {
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() ?? "<None>";
if (ImGui.BeginCombo("Input channel", input)) {
if (ImGui.Selectable("<None>", 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<ChatType>()) {
var enabled = tab.ChatCodes.ContainsKey(type);
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) {