use ImRaii in settings window
This commit is contained in:
@@ -23,7 +23,7 @@ using Lumina.Excel.GeneratedSheets;
|
|||||||
|
|
||||||
namespace ChatTwo.Ui;
|
namespace ChatTwo.Ui;
|
||||||
|
|
||||||
public sealed class ChatLogWindow : Window, IUiComponent
|
public sealed class ChatLogWindow : Window
|
||||||
{
|
{
|
||||||
private const string ChatChannelPicker = "chat-channel-picker";
|
private const string ChatChannelPicker = "chat-channel-picker";
|
||||||
private const string AutoCompleteId = "##chat2-autocomplete";
|
private const string AutoCompleteId = "##chat2-autocomplete";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Interface.Style;
|
using Dalamud.Interface.Style;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ internal class Popout : Window
|
|||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
ImGui.PushID($"popout-{Tab.Name}");
|
using var id = ImRaii.PushId($"popout-{Tab.Name}");
|
||||||
|
|
||||||
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar) {
|
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar) {
|
||||||
ImGui.TextUnformatted(Tab.Name);
|
ImGui.TextUnformatted(Tab.Name);
|
||||||
@@ -56,8 +57,6 @@ internal class Popout : Window
|
|||||||
|
|
||||||
var handler = ChatLogWindow.HandlerLender.Borrow();
|
var handler = ChatLogWindow.HandlerLender.Borrow();
|
||||||
ChatLogWindow.DrawMessageLog(Tab, handler, ImGui.GetContentRegionAvail().Y, false);
|
ChatLogWindow.DrawMessageLog(Tab, handler, ImGui.GetContentRegionAvail().Y, false);
|
||||||
|
|
||||||
ImGui.PopID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PostDraw()
|
public override void PostDraw()
|
||||||
|
|||||||
+44
-52
@@ -2,13 +2,14 @@ using System.Numerics;
|
|||||||
using ChatTwo.Resources;
|
using ChatTwo.Resources;
|
||||||
using ChatTwo.Ui.SettingsTabs;
|
using ChatTwo.Ui.SettingsTabs;
|
||||||
using ChatTwo.Util;
|
using ChatTwo.Util;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace ChatTwo.Ui;
|
namespace ChatTwo.Ui;
|
||||||
|
|
||||||
public sealed class SettingsWindow : Window, IUiComponent
|
public sealed class SettingsWindow : Window
|
||||||
{
|
{
|
||||||
private readonly Plugin Plugin;
|
private readonly Plugin Plugin;
|
||||||
|
|
||||||
@@ -30,7 +31,8 @@ public sealed class SettingsWindow : Window, IUiComponent
|
|||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
Mutable = new Configuration();
|
Mutable = new Configuration();
|
||||||
|
|
||||||
Tabs = new List<ISettingsTab> {
|
Tabs = new List<ISettingsTab>
|
||||||
|
{
|
||||||
new Display(Mutable),
|
new Display(Mutable),
|
||||||
new Ui.SettingsTabs.Fonts(Mutable),
|
new Ui.SettingsTabs.Fonts(Mutable),
|
||||||
new ChatColours(Mutable, Plugin),
|
new ChatColours(Mutable, Plugin),
|
||||||
@@ -49,17 +51,20 @@ public sealed class SettingsWindow : Window, IUiComponent
|
|||||||
Plugin.Interface.UiBuilder.OpenConfigUi += Toggle;
|
Plugin.Interface.UiBuilder.OpenConfigUi += Toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose()
|
||||||
|
{
|
||||||
Plugin.Interface.UiBuilder.OpenConfigUi -= Toggle;
|
Plugin.Interface.UiBuilder.OpenConfigUi -= Toggle;
|
||||||
Plugin.Commands.Register("/chat2").Execute -= Command;
|
Plugin.Commands.Register("/chat2").Execute -= Command;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Command(string command, string args) {
|
private void Command(string command, string args)
|
||||||
|
{
|
||||||
if (string.IsNullOrWhiteSpace(args))
|
if (string.IsNullOrWhiteSpace(args))
|
||||||
Toggle();
|
Toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Initialise() {
|
private void Initialise()
|
||||||
|
{
|
||||||
Mutable.UpdateFrom(Plugin.Config);
|
Mutable.UpdateFrom(Plugin.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,33 +73,33 @@ public sealed class SettingsWindow : Window, IUiComponent
|
|||||||
if (ImGui.IsWindowAppearing())
|
if (ImGui.IsWindowAppearing())
|
||||||
Initialise();
|
Initialise();
|
||||||
|
|
||||||
if (ImGui.BeginTable("##chat2-settings-table", 2)) {
|
using (var table = ImRaii.Table("##chat2-settings-table", 2))
|
||||||
|
{
|
||||||
|
if (table)
|
||||||
|
{
|
||||||
ImGui.TableSetupColumn("tab", ImGuiTableColumnFlags.WidthFixed);
|
ImGui.TableSetupColumn("tab", ImGuiTableColumnFlags.WidthFixed);
|
||||||
ImGui.TableSetupColumn("settings", ImGuiTableColumnFlags.WidthStretch);
|
ImGui.TableSetupColumn("settings", ImGuiTableColumnFlags.WidthStretch);
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
var changed = false;
|
var changed = false;
|
||||||
for (var i = 0; i < Tabs.Count; i++) {
|
for (var i = 0; i < Tabs.Count; i++)
|
||||||
if (ImGui.Selectable($"{Tabs[i].Name}###tab-{i}", CurrentTab == i)) {
|
{
|
||||||
|
if (!ImGui.Selectable($"{Tabs[i].Name}###tab-{i}", CurrentTab == i))
|
||||||
|
continue;
|
||||||
|
|
||||||
CurrentTab = i;
|
CurrentTab = i;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
||||||
var height = ImGui.GetContentRegionAvail().Y
|
var height = ImGui.GetContentRegionAvail().Y - ImGui.GetStyle().FramePadding.Y * 2 - ImGui.GetStyle().ItemSpacing.Y
|
||||||
- ImGui.GetStyle().FramePadding.Y * 2
|
- ImGui.GetStyle().ItemInnerSpacing.Y * 2 - ImGui.CalcTextSize("A").Y;
|
||||||
- ImGui.GetStyle().ItemSpacing.Y
|
using var child = ImRaii.Child("##chat2-settings", new Vector2(-1, height));
|
||||||
- ImGui.GetStyle().ItemInnerSpacing.Y * 2
|
if (child)
|
||||||
- ImGui.CalcTextSize("A").Y;
|
|
||||||
if (ImGui.BeginChild("##chat2-settings", new Vector2(-1, height))) {
|
|
||||||
Tabs[CurrentTab].Draw(changed);
|
Tabs[CurrentTab].Draw(changed);
|
||||||
ImGui.EndChild();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
@@ -114,65 +119,52 @@ public sealed class SettingsWindow : Window, IUiComponent
|
|||||||
IsOpen = false;
|
IsOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonLabel = "Anna's Ko-fi";
|
const string buttonLabel = "Anna's Ko-fi";
|
||||||
var buttonLabel2 = "Infi's Ko-fi";
|
const string buttonLabel2 = "Infi's Ko-fi";
|
||||||
|
|
||||||
ImGui.PushStyleColor(ImGuiCol.Button, ColourUtil.RgbaToAbgr(0xFF5E5BFF));
|
using (ImRaii.PushColor(ImGuiCol.Button, ColourUtil.RgbaToAbgr(0xFF5E5BFF)))
|
||||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF));
|
using (ImRaii.PushColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF)))
|
||||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, ColourUtil.RgbaToAbgr(0xFF4542FF));
|
using (ImRaii.PushColor(ImGuiCol.ButtonActive, ColourUtil.RgbaToAbgr(0xFF4542FF)))
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFFFFFF);
|
using (ImRaii.PushColor(ImGuiCol.Text, 0xFFFFFFFF))
|
||||||
|
{
|
||||||
try {
|
|
||||||
var buttonWidth = ImGui.CalcTextSize(buttonLabel).X + ImGui.GetStyle().FramePadding.X * 2;
|
var buttonWidth = ImGui.CalcTextSize(buttonLabel).X + ImGui.GetStyle().FramePadding.X * 2;
|
||||||
var buttonWidth2 = ImGui.CalcTextSize(buttonLabel2).X + ImGui.GetStyle().FramePadding.X * 2;
|
var buttonWidth2 = ImGui.CalcTextSize(buttonLabel2).X + ImGui.GetStyle().FramePadding.X * 2;
|
||||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X - buttonWidth - buttonWidth2);
|
ImGui.SameLine(ImGui.GetContentRegionAvail().X - buttonWidth - buttonWidth2);
|
||||||
|
|
||||||
if (ImGui.Button(buttonLabel2)) {
|
if (ImGui.Button(buttonLabel2))
|
||||||
Dalamud.Utility.Util.OpenLink("https://ko-fi.com/infiii");
|
Dalamud.Utility.Util.OpenLink("https://ko-fi.com/infiii");
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGui.Button(buttonLabel)) {
|
if (ImGui.Button(buttonLabel))
|
||||||
Dalamud.Utility.Util.OpenLink("https://ko-fi.com/lojewalo");
|
Dalamud.Utility.Util.OpenLink("https://ko-fi.com/lojewalo");
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
ImGui.PopStyleColor(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (save) {
|
if (!save)
|
||||||
var config = Plugin.Config;
|
return;
|
||||||
|
|
||||||
|
Plugin.Config.UpdateFrom(Mutable);
|
||||||
|
|
||||||
|
// save after 60 frames have passed, which should hopefully not
|
||||||
|
// commit any changes that cause a crash
|
||||||
|
Plugin.DeferredSaveFrames = 60;
|
||||||
|
Plugin.MessageManager.FilterAllTabs(false);
|
||||||
|
|
||||||
var hideChatChanged = Mutable.HideChat != Plugin.Config.HideChat;
|
|
||||||
var fontChanged = Mutable.GlobalFont != Plugin.Config.GlobalFont
|
var fontChanged = Mutable.GlobalFont != Plugin.Config.GlobalFont
|
||||||
|| Mutable.JapaneseFont != Plugin.Config.JapaneseFont
|
|| Mutable.JapaneseFont != Plugin.Config.JapaneseFont
|
||||||
|| Mutable.ExtraGlyphRanges != Plugin.Config.ExtraGlyphRanges;
|
|| Mutable.ExtraGlyphRanges != Plugin.Config.ExtraGlyphRanges;
|
||||||
var fontSizeChanged = Math.Abs(Mutable.FontSize - Plugin.Config.FontSize) > 0.001
|
var fontSizeChanged = Math.Abs(Mutable.FontSize - Plugin.Config.FontSize) > 0.001
|
||||||
|| Math.Abs(Mutable.JapaneseFontSize - Plugin.Config.JapaneseFontSize) > 0.001
|
|| Math.Abs(Mutable.JapaneseFontSize - Plugin.Config.JapaneseFontSize) > 0.001
|
||||||
|| Math.Abs(Mutable.SymbolsFontSize - Plugin.Config.SymbolsFontSize) > 0.001;
|
|| Math.Abs(Mutable.SymbolsFontSize - Plugin.Config.SymbolsFontSize) > 0.001;
|
||||||
var langChanged = Mutable.LanguageOverride != Plugin.Config.LanguageOverride;
|
if (fontChanged || fontSizeChanged)
|
||||||
|
|
||||||
config.UpdateFrom(Mutable);
|
|
||||||
|
|
||||||
// save after 60 frames have passed, which should hopefully not
|
|
||||||
// commit any changes that cause a crash
|
|
||||||
Plugin.DeferredSaveFrames = 60;
|
|
||||||
|
|
||||||
Plugin.MessageManager.FilterAllTabs(false);
|
|
||||||
|
|
||||||
if (fontChanged || fontSizeChanged) {
|
|
||||||
Plugin.FontManager.BuildFonts();
|
Plugin.FontManager.BuildFonts();
|
||||||
}
|
|
||||||
|
|
||||||
if (langChanged) {
|
if (Mutable.LanguageOverride != Plugin.Config.LanguageOverride)
|
||||||
Plugin.LanguageChanged(Plugin.Interface.UiLanguage);
|
Plugin.LanguageChanged(Plugin.Interface.UiLanguage);
|
||||||
}
|
|
||||||
|
|
||||||
if (!Mutable.HideChat && hideChatChanged) {
|
if (!Mutable.HideChat && Mutable.HideChat != Plugin.Config.HideChat)
|
||||||
GameFunctions.GameFunctions.SetChatInteractable(true);
|
GameFunctions.GameFunctions.SetChatInteractable(true);
|
||||||
}
|
|
||||||
|
|
||||||
Initialise();
|
Initialise();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ using ImGuiNET;
|
|||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal sealed class About : ISettingsTab {
|
internal sealed class About : ISettingsTab
|
||||||
|
{
|
||||||
public string Name => string.Format(Language.Options_About_Tab, Plugin.PluginName) + "###tabs-about";
|
public string Name => string.Format(Language.Options_About_Tab, Plugin.PluginName) + "###tabs-about";
|
||||||
|
|
||||||
private readonly List<string> _translators =
|
private readonly List<string> _translators =
|
||||||
@@ -25,11 +26,13 @@ internal sealed class About : ISettingsTab {
|
|||||||
"zomsakura", "Sirayuki"
|
"zomsakura", "Sirayuki"
|
||||||
];
|
];
|
||||||
|
|
||||||
internal About() {
|
internal About()
|
||||||
|
{
|
||||||
_translators.Sort((a, b) => string.Compare(a.ToLowerInvariant(), b.ToLowerInvariant(), StringComparison.Ordinal));
|
_translators.Sort((a, b) => string.Compare(a.ToLowerInvariant(), b.ToLowerInvariant(), StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
|
{
|
||||||
ImGui.PushTextWrapPos();
|
ImGui.PushTextWrapPos();
|
||||||
|
|
||||||
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
||||||
|
|||||||
@@ -6,46 +6,50 @@ using ImGuiNET;
|
|||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal sealed class ChatColours : ISettingsTab {
|
internal sealed class ChatColours : ISettingsTab
|
||||||
|
{
|
||||||
private Configuration Mutable { get; }
|
private Configuration Mutable { get; }
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
public string Name => Language.Options_ChatColours_Tab + "###tabs-chat-colours";
|
public string Name => Language.Options_ChatColours_Tab + "###tabs-chat-colours";
|
||||||
|
|
||||||
internal ChatColours(Configuration mutable, Plugin plugin) {
|
internal ChatColours(Configuration mutable, Plugin plugin)
|
||||||
|
{
|
||||||
Mutable = mutable;
|
Mutable = mutable;
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
// Users can set colours for ExtraChat linkshells in the ExtraChat plugin directly.
|
||||||
var sortable = ChatTypeExt.SortOrder
|
var sortable = ChatTypeExt.SortOrder
|
||||||
.SelectMany(entry => entry.Item2)
|
.SelectMany(entry => entry.Item2)
|
||||||
// Users can set colours for ExtraChat linkshells in the ExtraChat
|
|
||||||
// plugin directly.
|
|
||||||
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
||||||
.ToHashSet();
|
.ToHashSet();
|
||||||
var total = Enum.GetValues<ChatType>()
|
var total = Enum.GetValues<ChatType>()
|
||||||
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
||||||
.ToHashSet();
|
.ToHashSet();
|
||||||
if (sortable.Count != total.Count) {
|
if (sortable.Count != total.Count)
|
||||||
|
{
|
||||||
Plugin.Log.Warning($"There are {sortable.Count} sortable channels, but there are {total.Count} total channels.");
|
Plugin.Log.Warning($"There are {sortable.Count} sortable channels, but there are {total.Count} total channels.");
|
||||||
total.ExceptWith(sortable);
|
total.ExceptWith(sortable);
|
||||||
foreach (var missing in total) {
|
foreach (var missing in total)
|
||||||
Plugin.Log.Information($"Missing {missing}");
|
Plugin.Log.Information($"Missing {missing}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
foreach (var (_, types) in ChatTypeExt.SortOrder) {
|
{
|
||||||
foreach (var type in types) {
|
foreach (var (_, types) in ChatTypeExt.SortOrder)
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset)) {
|
{
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset))
|
||||||
Mutable.ChatColours.Remove(type);
|
Mutable.ChatColours.Remove(type);
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", Language.Options_ChatColours_Import)) {
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", Language.Options_ChatColours_Import))
|
||||||
|
{
|
||||||
var gameColour = Plugin.Functions.Chat.GetChannelColour(type);
|
var gameColour = Plugin.Functions.Chat.GetChannelColour(type);
|
||||||
Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0;
|
Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0;
|
||||||
}
|
}
|
||||||
@@ -55,11 +59,10 @@ internal sealed class ChatColours : ISettingsTab {
|
|||||||
var vec = Mutable.ChatColours.TryGetValue(type, out var colour)
|
var vec = Mutable.ChatColours.TryGetValue(type, out var colour)
|
||||||
? ColourUtil.RgbaToVector3(colour)
|
? ColourUtil.RgbaToVector3(colour)
|
||||||
: ColourUtil.RgbaToVector3(type.DefaultColour() ?? 0);
|
: ColourUtil.RgbaToVector3(type.DefaultColour() ?? 0);
|
||||||
if (ImGui.ColorEdit3(type.Name(), ref vec, ImGuiColorEditFlags.NoInputs)) {
|
if (ImGui.ColorEdit3(type.Name(), ref vec, ImGuiColorEditFlags.NoInputs))
|
||||||
Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec);
|
Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using ChatTwo.Util;
|
|||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using Dalamud.Interface.Internal.Notifications;
|
using Dalamud.Interface.Internal.Notifications;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
@@ -29,7 +30,8 @@ internal sealed class Database : ISettingsTab
|
|||||||
private long DatabaseLogSize;
|
private long DatabaseLogSize;
|
||||||
private int DatabaseMessageCount;
|
private int DatabaseMessageCount;
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
|
{
|
||||||
if (changed)
|
if (changed)
|
||||||
ShowAdvanced = ImGui.GetIO().KeyShift;
|
ShowAdvanced = ImGui.GetIO().KeyShift;
|
||||||
|
|
||||||
@@ -37,18 +39,14 @@ internal sealed class Database : ISettingsTab
|
|||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.OptionCheckbox(ref Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description))
|
if (ImGuiUtil.OptionCheckbox(ref Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description))
|
||||||
{
|
|
||||||
if (Mutable.LoadPreviousSession)
|
if (Mutable.LoadPreviousSession)
|
||||||
Mutable.FilterIncludePreviousSessions = true;
|
Mutable.FilterIncludePreviousSessions = true;
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.OptionCheckbox(ref Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description))
|
if (ImGuiUtil.OptionCheckbox(ref Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description))
|
||||||
{
|
|
||||||
if (!Mutable.FilterIncludePreviousSessions)
|
if (!Mutable.FilterIncludePreviousSessions)
|
||||||
Mutable.LoadPreviousSession = false;
|
Mutable.LoadPreviousSession = false;
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
@@ -80,9 +78,8 @@ internal sealed class Database : ISettingsTab
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TextUnformatted(Language.Options_Database_Metadata_Heading);
|
ImGui.TextUnformatted(Language.Options_Database_Metadata_Heading);
|
||||||
var style = ImGui.GetStyle();
|
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
|
||||||
ImGui.Indent(style.IndentSpacing);
|
{
|
||||||
|
|
||||||
// Refresh the database size and message count every 5 seconds to avoid
|
// Refresh the database size and message count every 5 seconds to avoid
|
||||||
// constant stat calls and spamming the database.
|
// constant stat calls and spamming the database.
|
||||||
if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64)
|
if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64)
|
||||||
@@ -93,11 +90,11 @@ internal sealed class Database : ISettingsTab
|
|||||||
DatabaseLastRefreshTicks = Environment.TickCount64;
|
DatabaseLastRefreshTicks = Environment.TickCount64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy the directory path instead of the file path so people can
|
||||||
|
// paste it into their file explorer.
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath()));
|
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath()));
|
||||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||||
{
|
{
|
||||||
// Copy the directory path instead of the file path so people can
|
|
||||||
// paste it into their file explorer.
|
|
||||||
var path = Path.GetDirectoryName(MessageManager.DatabasePath());
|
var path = Path.GetDirectoryName(MessageManager.DatabasePath());
|
||||||
ImGui.SetClipboardText(path);
|
ImGui.SetClipboardText(path);
|
||||||
WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info);
|
WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info);
|
||||||
@@ -130,22 +127,25 @@ internal sealed class Database : ISettingsTab
|
|||||||
DatabaseLastRefreshTicks = 0;
|
DatabaseLastRefreshTicks = 0;
|
||||||
WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info);
|
WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.Unindent(style.IndentSpacing);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ShowAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced))
|
if (!ShowAdvanced)
|
||||||
{
|
return;
|
||||||
|
|
||||||
|
using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced);
|
||||||
ImGui.PushTextWrapPos();
|
ImGui.PushTextWrapPos();
|
||||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||||
|
|
||||||
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
||||||
Plugin.MessageManager.Store.PerformMaintenance();
|
Plugin.MessageManager.Store.PerformMaintenance();
|
||||||
|
|
||||||
if (ImGuiUtil.CtrlShiftButton("Reload messages from database",
|
if (ImGuiUtil.CtrlShiftButton("Reload messages from database", "Ctrl+Shift: MessageManager.FilterAllTabs(false)"))
|
||||||
"Ctrl+Shift: MessageManager.FilterAllTabs(false)")) {
|
{
|
||||||
foreach (var tab in Plugin.Config.Tabs)
|
foreach (var tab in Plugin.Config.Tabs)
|
||||||
tab.Clear();
|
tab.Clear();
|
||||||
|
|
||||||
Plugin.MessageManager.FilterAllTabs(false);
|
Plugin.MessageManager.FilterAllTabs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,13 +153,11 @@ internal sealed class Database : ISettingsTab
|
|||||||
new Thread(() => InsertMessages(10_000)).Start();
|
new Thread(() => InsertMessages(10_000)).Start();
|
||||||
|
|
||||||
ImGui.PopTextWrapPos();
|
ImGui.PopTextWrapPos();
|
||||||
ImGui.TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertMessages(int count) {
|
private void InsertMessages(int count)
|
||||||
|
{
|
||||||
Plugin.Log.Info($"Inserting {count} messages due to user request");
|
Plugin.Log.Info($"Inserting {count} messages due to user request");
|
||||||
|
|
||||||
// Generate
|
// Generate
|
||||||
@@ -175,7 +173,8 @@ internal sealed class Database : ISettingsTab
|
|||||||
.Build();
|
.Build();
|
||||||
var senderChunks = ChunkUtil.ToChunks(senderSource, ChunkSource.Sender, ChatType.Debug).ToList();
|
var senderChunks = ChunkUtil.ToChunks(senderSource, ChunkSource.Sender, ChatType.Debug).ToList();
|
||||||
var messages = new List<Message>(count);
|
var messages = new List<Message>(count);
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++)
|
||||||
|
{
|
||||||
var contentSource = new SeStringBuilder()
|
var contentSource = new SeStringBuilder()
|
||||||
.AddText("Random message payload - ")
|
.AddText("Random message payload - ")
|
||||||
.AddItalics(Guid.NewGuid().ToString())
|
.AddItalics(Guid.NewGuid().ToString())
|
||||||
@@ -203,28 +202,28 @@ internal sealed class Database : ISettingsTab
|
|||||||
|
|
||||||
// Insert
|
// Insert
|
||||||
stopwatch = Stopwatch.StartNew();
|
stopwatch = Stopwatch.StartNew();
|
||||||
foreach (var message in messages) {
|
foreach (var message in messages)
|
||||||
Plugin.MessageManager.Store.UpsertMessage(message);
|
Plugin.MessageManager.Store.UpsertMessage(message);
|
||||||
}
|
|
||||||
|
|
||||||
elapsedTicks = stopwatch.ElapsedTicks;
|
elapsedTicks = stopwatch.ElapsedTicks;
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Plugin.Log.Info($"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
Plugin.Log.Info($"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
||||||
|
|
||||||
// Clear tabs during framework frame
|
// Clear tabs during framework frame
|
||||||
Plugin.Framework.Run(() => {
|
Plugin.Framework.Run(() =>
|
||||||
|
{
|
||||||
stopwatch = Stopwatch.StartNew();
|
stopwatch = Stopwatch.StartNew();
|
||||||
foreach (var tab in Plugin.Config.Tabs)
|
foreach (var tab in Plugin.Config.Tabs)
|
||||||
tab.Clear();
|
tab.Clear();
|
||||||
|
|
||||||
elapsedTicks = stopwatch.ElapsedTicks;
|
elapsedTicks = stopwatch.ElapsedTicks;
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Plugin.Log.Info(
|
Plugin.Log.Info($"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
||||||
$"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
|
||||||
}).Wait();
|
}).Wait();
|
||||||
|
|
||||||
// Fetch and filter during framework frame
|
// Fetch and filter during framework frame
|
||||||
Plugin.Framework.Run(() => {
|
Plugin.Framework.Run(() =>
|
||||||
|
{
|
||||||
stopwatch = Stopwatch.StartNew();
|
stopwatch = Stopwatch.StartNew();
|
||||||
Plugin.MessageManager.FilterAllTabs(false);
|
Plugin.MessageManager.FilterAllTabs(false);
|
||||||
elapsedTicks = stopwatch.ElapsedTicks;
|
elapsedTicks = stopwatch.ElapsedTicks;
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
using ChatTwo.Resources;
|
using ChatTwo.Resources;
|
||||||
using ChatTwo.Util;
|
using ChatTwo.Util;
|
||||||
using Dalamud.Interface.Style;
|
using Dalamud.Interface.Style;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal sealed class Display : ISettingsTab {
|
internal sealed class Display : ISettingsTab
|
||||||
|
{
|
||||||
private Configuration Mutable { get; }
|
private Configuration Mutable { get; }
|
||||||
|
|
||||||
public string Name => Language.Options_Display_Tab + "###tabs-display";
|
public string Name => Language.Options_Display_Tab + "###tabs-display";
|
||||||
|
|
||||||
internal Display(Configuration mutable) {
|
internal Display(Configuration mutable)
|
||||||
|
{
|
||||||
Mutable = mutable;
|
Mutable = mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
|
{
|
||||||
ImGui.PushTextWrapPos();
|
ImGui.PushTextWrapPos();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.PlaySounds, Language.Options_PlaySounds_Name, Language.Options_PlaySounds_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.PlaySounds, Language.Options_PlaySounds_Name, Language.Options_PlaySounds_Description);
|
||||||
@@ -23,56 +27,33 @@ internal sealed class Display : ISettingsTab {
|
|||||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideDuringCutscenes, Language.Options_HideDuringCutscenes_Name, string.Format(Language.Options_HideDuringCutscenes_Description, Plugin.PluginName));
|
||||||
ref Mutable.HideDuringCutscenes,
|
|
||||||
Language.Options_HideDuringCutscenes_Name,
|
|
||||||
string.Format(Language.Options_HideDuringCutscenes_Description, Plugin.PluginName)
|
|
||||||
);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideWhenNotLoggedIn, Language.Options_HideWhenNotLoggedIn_Name, string.Format(Language.Options_HideWhenNotLoggedIn_Description, Plugin.PluginName));
|
||||||
ref Mutable.HideWhenNotLoggedIn,
|
|
||||||
Language.Options_HideWhenNotLoggedIn_Name,
|
|
||||||
string.Format(Language.Options_HideWhenNotLoggedIn_Description, Plugin.PluginName)
|
|
||||||
);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideWhenUiHidden, Language.Options_HideWhenUiHidden_Name, string.Format(Language.Options_HideWhenUiHidden_Description, Plugin.PluginName));
|
||||||
ref Mutable.HideWhenUiHidden,
|
|
||||||
Language.Options_HideWhenUiHidden_Name,
|
|
||||||
string.Format(Language.Options_HideWhenUiHidden_Description, Plugin.PluginName)
|
|
||||||
);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideInLoadingScreens, Language.Options_HideInLoadingScreens_Name, string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName));
|
||||||
ref Mutable.HideInLoadingScreens,
|
|
||||||
Language.Options_HideInLoadingScreens_Name,
|
|
||||||
string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName));
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName));
|
||||||
ref Mutable.NativeItemTooltips,
|
|
||||||
Language.Options_NativeItemTooltips_Name,
|
|
||||||
string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName)
|
|
||||||
);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(
|
ImGuiUtil.OptionCheckbox(ref Mutable.SidebarTabView, Language.Options_SidebarTabView_Name, string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName));
|
||||||
ref Mutable.SidebarTabView,
|
|
||||||
Language.Options_SidebarTabView_Name,
|
|
||||||
string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName)
|
|
||||||
);
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.PrettierTimestamps, Language.Options_PrettierTimestamps_Name, Language.Options_PrettierTimestamps_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.PrettierTimestamps, Language.Options_PrettierTimestamps_Name, Language.Options_PrettierTimestamps_Description);
|
||||||
|
|
||||||
if (Mutable.PrettierTimestamps) {
|
if (Mutable.PrettierTimestamps)
|
||||||
|
{
|
||||||
ImGui.TreePush();
|
ImGui.TreePush();
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.MoreCompactPretty, Language.Options_MoreCompactPretty_Name, Language.Options_MoreCompactPretty_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.MoreCompactPretty, Language.Options_MoreCompactPretty_Name, Language.Options_MoreCompactPretty_Description);
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideSameTimestamps, Language.Options_HideSameTimestamps_Name, Language.Options_HideSameTimestamps_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideSameTimestamps, Language.Options_HideSameTimestamps_Name, Language.Options_HideSameTimestamps_Description);
|
||||||
ImGui.TreePop();
|
ImGui.TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
||||||
@@ -106,29 +87,26 @@ internal sealed class Display : ISettingsTab {
|
|||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.OverrideStyle, Language.Options_OverrideStyle_Name, Language.Options_OverrideStyle_Name_Desc);
|
ImGuiUtil.OptionCheckbox(ref Mutable.OverrideStyle, Language.Options_OverrideStyle_Name, Language.Options_OverrideStyle_Name_Desc);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
ImGui.PopTextWrapPos();
|
||||||
|
|
||||||
|
if (!Mutable.OverrideStyle)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Mutable.OverrideStyle)
|
|
||||||
{
|
|
||||||
var styles = StyleModel.GetConfiguredStyles();
|
var styles = StyleModel.GetConfiguredStyles();
|
||||||
if (styles != null)
|
if (styles == null)
|
||||||
{
|
{
|
||||||
|
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
||||||
|
ImGui.Spacing();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var currentStyle = Mutable.ChosenStyle ?? Language.Options_OverrideStyle_NotSelected;
|
var currentStyle = Mutable.ChosenStyle ?? Language.Options_OverrideStyle_NotSelected;
|
||||||
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle))
|
using var combo = ImRaii.Combo(Language.Options_OverrideStyleDropdown_Name, currentStyle);
|
||||||
{
|
if (combo)
|
||||||
foreach (var style in styles)
|
foreach (var style in styles)
|
||||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name))
|
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name))
|
||||||
Mutable.ChosenStyle = style.Name;
|
Mutable.ChosenStyle = style.Name;
|
||||||
|
|
||||||
ImGui.EndCombo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,56 +4,59 @@ using ImGuiNET;
|
|||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
public class Fonts : ISettingsTab {
|
public class Fonts : ISettingsTab
|
||||||
|
{
|
||||||
private Configuration Mutable { get; }
|
private Configuration Mutable { get; }
|
||||||
|
|
||||||
public string Name => Language.Options_Fonts_Tab + "###tabs-fonts";
|
public string Name => Language.Options_Fonts_Tab + "###tabs-fonts";
|
||||||
private List<string> GlobalFonts { get; set; } = new();
|
private List<string> GlobalFonts { get; set; } = [];
|
||||||
private List<string> JpFonts { get; set; } = new();
|
private List<string> JpFonts { get; set; } = [];
|
||||||
|
|
||||||
internal Fonts(Configuration mutable) {
|
internal Fonts(Configuration mutable)
|
||||||
|
{
|
||||||
Mutable = mutable;
|
Mutable = mutable;
|
||||||
UpdateFonts();
|
UpdateFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateFonts() {
|
private void UpdateFonts()
|
||||||
|
{
|
||||||
GlobalFonts = Ui.Fonts.GetFonts();
|
GlobalFonts = Ui.Fonts.GetFonts();
|
||||||
JpFonts = Ui.Fonts.GetJpFonts();
|
JpFonts = Ui.Fonts.GetJpFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
if (changed) {
|
{
|
||||||
|
if (changed)
|
||||||
UpdateFonts();
|
UpdateFonts();
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.PushTextWrapPos();
|
ImGui.PushTextWrapPos();
|
||||||
|
|
||||||
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (Mutable.FontsEnabled) {
|
if (Mutable.FontsEnabled)
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont)) {
|
{
|
||||||
foreach (var font in Ui.Fonts.GlobalFonts) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont))
|
||||||
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name)) {
|
{
|
||||||
|
foreach (var font in Ui.Fonts.GlobalFonts)
|
||||||
|
{
|
||||||
|
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name))
|
||||||
Mutable.GlobalFont = font.Name;
|
Mutable.GlobalFont = font.Name;
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name) {
|
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
ImGui.SetScrollHereY(0.5f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
foreach (var name in GlobalFonts) {
|
foreach (var name in GlobalFonts)
|
||||||
if (ImGui.Selectable(name, Mutable.GlobalFont == name)) {
|
{
|
||||||
|
if (ImGui.Selectable(name, Mutable.GlobalFont == name))
|
||||||
Mutable.GlobalFont = name;
|
Mutable.GlobalFont = name;
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name) {
|
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
ImGui.SetScrollHereY(0.5f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
@@ -62,28 +65,27 @@ public class Fonts : ISettingsTab {
|
|||||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont)) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont))
|
||||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts) {
|
{
|
||||||
if (ImGui.Selectable(name, Mutable.JapaneseFont == name)) {
|
foreach (var (name, _) in Ui.Fonts.JapaneseFonts)
|
||||||
|
{
|
||||||
|
if (ImGui.Selectable(name, Mutable.JapaneseFont == name))
|
||||||
Mutable.JapaneseFont = name;
|
Mutable.JapaneseFont = name;
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name) {
|
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
ImGui.SetScrollHereY(0.5f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
foreach (var family in JpFonts) {
|
foreach (var family in JpFonts)
|
||||||
if (ImGui.Selectable(family, Mutable.JapaneseFont == family)) {
|
{
|
||||||
|
if (ImGui.Selectable(family, Mutable.JapaneseFont == family))
|
||||||
Mutable.JapaneseFont = family;
|
Mutable.JapaneseFont = family;
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family) {
|
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
ImGui.SetScrollHereY(0.5f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
@@ -91,13 +93,13 @@ public class Fonts : ISettingsTab {
|
|||||||
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGui.CollapsingHeader(Language.Options_ExtraGlyphs_Name)) {
|
if (ImGui.CollapsingHeader(Language.Options_ExtraGlyphs_Name))
|
||||||
|
{
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_ExtraGlyphs_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_ExtraGlyphs_Description, Plugin.PluginName));
|
||||||
|
|
||||||
var range = (int) Mutable.ExtraGlyphRanges;
|
var range = (int) Mutable.ExtraGlyphRanges;
|
||||||
foreach (var extra in Enum.GetValues<ExtraGlyphRanges>()) {
|
foreach (var extra in Enum.GetValues<ExtraGlyphRanges>())
|
||||||
ImGui.CheckboxFlags(extra.Name(), ref range, (int) extra);
|
ImGui.CheckboxFlags(extra.Name(), ref range, (int) extra);
|
||||||
}
|
|
||||||
|
|
||||||
Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range;
|
Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal interface ISettingsTab {
|
internal interface ISettingsTab
|
||||||
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
void Draw(bool changed);
|
void Draw(bool changed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,22 +4,18 @@ using ImGuiNET;
|
|||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal sealed class Miscellaneous : ISettingsTab {
|
internal sealed class Miscellaneous(Configuration mutable) : ISettingsTab
|
||||||
private Configuration Mutable { get; }
|
{
|
||||||
|
private Configuration Mutable { get; } = mutable;
|
||||||
public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous";
|
public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous";
|
||||||
|
|
||||||
public Miscellaneous(Configuration mutable) {
|
public void Draw(bool changed)
|
||||||
Mutable = mutable;
|
{
|
||||||
}
|
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name()))
|
||||||
|
{
|
||||||
public void Draw(bool changed) {
|
foreach (var language in Enum.GetValues<LanguageOverride>())
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name())) {
|
if (ImGui.Selectable(language.Name()))
|
||||||
foreach (var language in Enum.GetValues<LanguageOverride>()) {
|
|
||||||
if (ImGui.Selectable(language.Name())) {
|
|
||||||
Mutable.LanguageOverride = language;
|
Mutable.LanguageOverride = language;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
@@ -27,12 +23,11 @@ internal sealed class Miscellaneous : ISettingsTab {
|
|||||||
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name())) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name()))
|
||||||
foreach (var side in Enum.GetValues<CommandHelpSide>()) {
|
{
|
||||||
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side)) {
|
foreach (var side in Enum.GetValues<CommandHelpSide>())
|
||||||
|
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
|
||||||
Mutable.CommandHelpSide = side;
|
Mutable.CommandHelpSide = side;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
@@ -40,17 +35,15 @@ internal sealed class Miscellaneous : ISettingsTab {
|
|||||||
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name())) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name()))
|
||||||
foreach (var mode in Enum.GetValues<KeybindMode>()) {
|
{
|
||||||
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode)) {
|
foreach (var mode in Enum.GetValues<KeybindMode>())
|
||||||
|
{
|
||||||
|
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode))
|
||||||
Mutable.KeybindMode = mode;
|
Mutable.KeybindMode = mode;
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.IsItemHovered()) {
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.BeginTooltip();
|
ImGui.SetTooltip(mode.Tooltip());
|
||||||
ImGui.TextUnformatted(mode.Tooltip());
|
|
||||||
ImGui.EndTooltip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
@@ -61,7 +54,6 @@ internal sealed class Miscellaneous : ISettingsTab {
|
|||||||
|
|
||||||
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
||||||
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+104
-104
@@ -2,11 +2,13 @@ using ChatTwo.Code;
|
|||||||
using ChatTwo.Resources;
|
using ChatTwo.Resources;
|
||||||
using ChatTwo.Util;
|
using ChatTwo.Util;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace ChatTwo.Ui.SettingsTabs;
|
namespace ChatTwo.Ui.SettingsTabs;
|
||||||
|
|
||||||
internal sealed class Tabs : ISettingsTab {
|
internal sealed class Tabs : ISettingsTab
|
||||||
|
{
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
private Configuration Mutable { get; }
|
private Configuration Mutable { get; }
|
||||||
|
|
||||||
@@ -14,63 +16,69 @@ internal sealed class Tabs : ISettingsTab {
|
|||||||
|
|
||||||
private int _toOpen = -2;
|
private int _toOpen = -2;
|
||||||
|
|
||||||
internal Tabs(Plugin plugin, Configuration mutable) {
|
internal Tabs(Plugin plugin, Configuration mutable)
|
||||||
|
{
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
Mutable = mutable;
|
Mutable = mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(bool changed) {
|
public void Draw(bool changed)
|
||||||
|
{
|
||||||
const string addTabPopup = "add-tab-popup";
|
const string addTabPopup = "add-tab-popup";
|
||||||
|
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.Plus, tooltip: Language.Options_Tabs_Add)) {
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.Plus, tooltip: Language.Options_Tabs_Add))
|
||||||
ImGui.OpenPopup(addTabPopup);
|
ImGui.OpenPopup(addTabPopup);
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.BeginPopup(addTabPopup)) {
|
using (var popup = ImRaii.Popup(addTabPopup))
|
||||||
if (ImGui.Selectable(Language.Options_Tabs_NewTab)) {
|
{
|
||||||
|
if (popup)
|
||||||
|
{
|
||||||
|
if (ImGui.Selectable(Language.Options_Tabs_NewTab))
|
||||||
Mutable.Tabs.Add(new Tab());
|
Mutable.Tabs.Add(new Tab());
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General))) {
|
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General)))
|
||||||
Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
|
Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event))) {
|
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event)))
|
||||||
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
|
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndPopup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var toRemove = -1;
|
var toRemove = -1;
|
||||||
var doOpens = _toOpen > -2;
|
var doOpens = _toOpen > -2;
|
||||||
for (var i = 0; i < Mutable.Tabs.Count; i++) {
|
for (var i = 0; i < Mutable.Tabs.Count; i++)
|
||||||
|
{
|
||||||
var tab = Mutable.Tabs[i];
|
var tab = Mutable.Tabs[i];
|
||||||
|
|
||||||
if (doOpens) {
|
if (doOpens)
|
||||||
ImGui.SetNextItemOpen(i == _toOpen);
|
ImGui.SetNextItemOpen(i == _toOpen);
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) {
|
using var treeNode = ImRaii.TreeNode($"{tab.Name}###tab-{i}");
|
||||||
ImGui.PushID($"tab-{i}");
|
if (!treeNode.Success)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete)) {
|
using var pushedId = ImRaii.PushId($"tab-{i}");
|
||||||
|
|
||||||
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete))
|
||||||
|
{
|
||||||
toRemove = i;
|
toRemove = i;
|
||||||
_toOpen = -1;
|
_toOpen = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0) {
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0)
|
||||||
|
{
|
||||||
(Mutable.Tabs[i - 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i - 1]);
|
(Mutable.Tabs[i - 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i - 1]);
|
||||||
_toOpen = i - 1;
|
_toOpen = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < Mutable.Tabs.Count - 1) {
|
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < Mutable.Tabs.Count - 1)
|
||||||
|
{
|
||||||
(Mutable.Tabs[i + 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i + 1]);
|
(Mutable.Tabs[i + 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i + 1]);
|
||||||
_toOpen = i + 1;
|
_toOpen = i + 1;
|
||||||
}
|
}
|
||||||
@@ -78,129 +86,121 @@ internal sealed class Tabs : ISettingsTab {
|
|||||||
ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue);
|
ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||||
ImGui.Checkbox(Language.Options_Tabs_ShowTimestamps, ref tab.DisplayTimestamp);
|
ImGui.Checkbox(Language.Options_Tabs_ShowTimestamps, ref tab.DisplayTimestamp);
|
||||||
ImGui.Checkbox(Language.Options_Tabs_PopOut, ref tab.PopOut);
|
ImGui.Checkbox(Language.Options_Tabs_PopOut, ref tab.PopOut);
|
||||||
if (tab.PopOut) {
|
if (tab.PopOut)
|
||||||
|
{
|
||||||
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
||||||
if (tab.IndependentOpacity) {
|
if (tab.IndependentOpacity)
|
||||||
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.25f, 0f, 100f, $"{tab.Opacity:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.25f, 0f, 100f, $"{tab.Opacity:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name())) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name()))
|
||||||
foreach (var mode in Enum.GetValues<UnreadMode>()) {
|
{
|
||||||
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode)) {
|
foreach (var mode in Enum.GetValues<UnreadMode>())
|
||||||
|
{
|
||||||
|
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode))
|
||||||
tab.UnreadMode = mode;
|
tab.UnreadMode = mode;
|
||||||
}
|
|
||||||
|
|
||||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered()) {
|
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
||||||
ImGui.BeginTooltip();
|
ImGui.SetTooltip(tooltip);
|
||||||
ImGui.TextUnformatted(tooltip);
|
|
||||||
ImGui.EndTooltip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
||||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input)) {
|
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input))
|
||||||
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null)) {
|
{
|
||||||
|
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
|
||||||
tab.Channel = null;
|
tab.Channel = null;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var channel in Enum.GetValues<InputChannel>()) {
|
foreach (var channel in Enum.GetValues<InputChannel>())
|
||||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel)) {
|
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
||||||
tab.Channel = channel;
|
tab.Channel = channel;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.TreeNodeEx(Language.Options_Tabs_Channels)) {
|
using (var channelNode = ImRaii.TreeNode(Language.Options_Tabs_Channels))
|
||||||
foreach (var (header, types) in ChatTypeExt.SortOrder) {
|
{
|
||||||
if (ImGui.TreeNodeEx(header + $"##{i}")) {
|
if (channelNode)
|
||||||
foreach (var type in types) {
|
{
|
||||||
if (type.IsGm()) {
|
foreach (var (header, types) in ChatTypeExt.SortOrder)
|
||||||
|
{
|
||||||
|
using var headerNode = ImRaii.TreeNode(header + $"##{i}");
|
||||||
|
if (!headerNode.Success)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsGm())
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
var enabled = tab.ChatCodes.ContainsKey(type);
|
var enabled = tab.ChatCodes.ContainsKey(type);
|
||||||
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) {
|
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled))
|
||||||
if (enabled) {
|
{
|
||||||
|
if (enabled)
|
||||||
tab.ChatCodes[type] = ChatSourceExt.All;
|
tab.ChatCodes[type] = ChatSourceExt.All;
|
||||||
} else {
|
else
|
||||||
tab.ChatCodes.Remove(type);
|
tab.ChatCodes.Remove(type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (type.HasSource()) {
|
if (!type.HasSource())
|
||||||
if (ImGui.TreeNodeEx($"{type.Name()}##{i}")) {
|
{
|
||||||
tab.ChatCodes.TryGetValue(type, out var sourcesEnum);
|
|
||||||
var sources = (uint) sourcesEnum;
|
|
||||||
|
|
||||||
foreach (var source in Enum.GetValues<ChatSource>()) {
|
|
||||||
if (ImGui.CheckboxFlags(source.Name(), ref sources, (uint) source)) {
|
|
||||||
tab.ChatCodes[type] = (ChatSource) sources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.TreePop();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ImGui.TextUnformatted(type.Name());
|
ImGui.TextUnformatted(type.Name());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.TreePop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Plugin.ExtraChat.ChannelNames.Count > 0 && ImGui.TreeNodeEx(Language.Options_Tabs_ExtraChatChannels)) {
|
|
||||||
ImGui.Checkbox(Language.Options_Tabs_ExtraChatAll, ref tab.ExtraChatAll);
|
|
||||||
|
|
||||||
ImGui.Separator();
|
|
||||||
|
|
||||||
if (tab.ExtraChatAll) {
|
|
||||||
ImGui.BeginDisabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var (id, name) in Plugin.ExtraChat.ChannelNames) {
|
|
||||||
var enabled = tab.ExtraChatChannels.Contains(id);
|
|
||||||
if (!ImGui.Checkbox($"{name}##ec-{id}", ref enabled)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled) {
|
using var typeNode = ImRaii.TreeNode($"{type.Name()}##{i}");
|
||||||
tab.ExtraChatChannels.Add(id);
|
if (!typeNode.Success)
|
||||||
} else {
|
continue;
|
||||||
tab.ExtraChatChannels.Remove(id);
|
|
||||||
|
tab.ChatCodes.TryGetValue(type, out var sourcesEnum);
|
||||||
|
var sources = (uint) sourcesEnum;
|
||||||
|
|
||||||
|
foreach (var source in Enum.GetValues<ChatSource>())
|
||||||
|
if (ImGui.CheckboxFlags(source.Name(), ref sources, (uint) source))
|
||||||
|
tab.ChatCodes[type] = (ChatSource) sources;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab.ExtraChatAll) {
|
|
||||||
|
if (Plugin.ExtraChat.ChannelNames.Count <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
using var extraTree = ImRaii.TreeNode(Language.Options_Tabs_ExtraChatChannels);
|
||||||
|
if (!extraTree.Success)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ImGui.Checkbox(Language.Options_Tabs_ExtraChatAll, ref tab.ExtraChatAll);
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
|
if (tab.ExtraChatAll)
|
||||||
|
ImGui.BeginDisabled();
|
||||||
|
|
||||||
|
foreach (var (id, name) in Plugin.ExtraChat.ChannelNames)
|
||||||
|
{
|
||||||
|
var enabled = tab.ExtraChatChannels.Contains(id);
|
||||||
|
if (!ImGui.Checkbox($"{name}##ec-{id}", ref enabled))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
tab.ExtraChatChannels.Add(id);
|
||||||
|
else
|
||||||
|
tab.ExtraChatChannels.Remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tab.ExtraChatAll)
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TreePop();
|
if (toRemove > -1)
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.TreePop();
|
|
||||||
|
|
||||||
ImGui.PopID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toRemove > -1) {
|
|
||||||
Mutable.Tabs.RemoveAt(toRemove);
|
Mutable.Tabs.RemoveAt(toRemove);
|
||||||
}
|
|
||||||
|
|
||||||
if (doOpens) {
|
if (doOpens)
|
||||||
_toOpen = -2;
|
_toOpen = -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
namespace ChatTwo.Ui;
|
|
||||||
|
|
||||||
internal interface IUiComponent : IDisposable {
|
|
||||||
void Draw();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user