use ImRaii in settings window
This commit is contained in:
@@ -9,7 +9,8 @@ using ImGuiNET;
|
||||
|
||||
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";
|
||||
|
||||
private readonly List<string> _translators =
|
||||
@@ -25,11 +26,13 @@ internal sealed class About : ISettingsTab {
|
||||
"zomsakura", "Sirayuki"
|
||||
];
|
||||
|
||||
internal About() {
|
||||
internal About()
|
||||
{
|
||||
_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.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
||||
|
||||
@@ -6,46 +6,50 @@ using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class ChatColours : ISettingsTab {
|
||||
internal sealed class ChatColours : ISettingsTab
|
||||
{
|
||||
private Configuration Mutable { get; }
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
public string Name => Language.Options_ChatColours_Tab + "###tabs-chat-colours";
|
||||
|
||||
internal ChatColours(Configuration mutable, Plugin plugin) {
|
||||
internal ChatColours(Configuration mutable, Plugin plugin)
|
||||
{
|
||||
Mutable = mutable;
|
||||
Plugin = plugin;
|
||||
|
||||
#if DEBUG
|
||||
// Users can set colours for ExtraChat linkshells in the ExtraChat plugin directly.
|
||||
var sortable = ChatTypeExt.SortOrder
|
||||
.SelectMany(entry => entry.Item2)
|
||||
// Users can set colours for ExtraChat linkshells in the ExtraChat
|
||||
// plugin directly.
|
||||
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
||||
.ToHashSet();
|
||||
var total = Enum.GetValues<ChatType>()
|
||||
.Where(type => !type.IsGm() && !type.IsExtraChatLinkshell())
|
||||
.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.");
|
||||
total.ExceptWith(sortable);
|
||||
foreach (var missing in total) {
|
||||
foreach (var missing in total)
|
||||
Plugin.Log.Information($"Missing {missing}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Draw(bool changed) {
|
||||
foreach (var (_, types) in ChatTypeExt.SortOrder) {
|
||||
foreach (var type in types) {
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset)) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
foreach (var (_, types) in ChatTypeExt.SortOrder)
|
||||
{
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset))
|
||||
Mutable.ChatColours.Remove(type);
|
||||
}
|
||||
|
||||
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);
|
||||
Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0;
|
||||
}
|
||||
@@ -55,9 +59,8 @@ internal sealed class ChatColours : ISettingsTab {
|
||||
var vec = Mutable.ChatColours.TryGetValue(type, out var colour)
|
||||
? ColourUtil.RgbaToVector3(colour)
|
||||
: 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using ChatTwo.Util;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
@@ -29,7 +30,8 @@ internal sealed class Database : ISettingsTab
|
||||
private long DatabaseLogSize;
|
||||
private int DatabaseMessageCount;
|
||||
|
||||
public void Draw(bool changed) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
if (changed)
|
||||
ShowAdvanced = ImGui.GetIO().KeyShift;
|
||||
|
||||
@@ -37,18 +39,14 @@ internal sealed class Database : ISettingsTab
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.OptionCheckbox(ref Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description))
|
||||
{
|
||||
if (Mutable.LoadPreviousSession)
|
||||
Mutable.FilterIncludePreviousSessions = true;
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.OptionCheckbox(ref Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description))
|
||||
{
|
||||
if (!Mutable.FilterIncludePreviousSessions)
|
||||
Mutable.LoadPreviousSession = false;
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
@@ -80,86 +78,86 @@ internal sealed class Database : ISettingsTab
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(Language.Options_Database_Metadata_Heading);
|
||||
var style = ImGui.GetStyle();
|
||||
ImGui.Indent(style.IndentSpacing);
|
||||
|
||||
// Refresh the database size and message count every 5 seconds to avoid
|
||||
// constant stat calls and spamming the database.
|
||||
if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64)
|
||||
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
|
||||
{
|
||||
DatabaseSize = Plugin.MessageManager.Store.DatabaseSize();
|
||||
DatabaseLogSize = Plugin.MessageManager.Store.DatabaseLogSize();
|
||||
DatabaseMessageCount = Plugin.MessageManager.Store.MessageCount();
|
||||
DatabaseLastRefreshTicks = Environment.TickCount64;
|
||||
}
|
||||
// Refresh the database size and message count every 5 seconds to avoid
|
||||
// constant stat calls and spamming the database.
|
||||
if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64)
|
||||
{
|
||||
DatabaseSize = Plugin.MessageManager.Store.DatabaseSize();
|
||||
DatabaseLogSize = Plugin.MessageManager.Store.DatabaseLogSize();
|
||||
DatabaseMessageCount = Plugin.MessageManager.Store.MessageCount();
|
||||
DatabaseLastRefreshTicks = Environment.TickCount64;
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath()));
|
||||
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());
|
||||
ImGui.SetClipboardText(path);
|
||||
WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info);
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath()));
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
var path = Path.GetDirectoryName(MessageManager.DatabasePath());
|
||||
ImGui.SetClipboardText(path);
|
||||
WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info);
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
ImGui.SetTooltip(Language.Options_Database_Metadata_CopyConfigPath);
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Size, StringUtil.BytesToString(DatabaseSize)));
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(DatabaseSize.ToString("N0") + "B");
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_LogSize, StringUtil.BytesToString(DatabaseLogSize)));
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(DatabaseLogSize.ToString("N0") + "B");
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_MessageCount, DatabaseMessageCount));
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton(Language.Options_ClearDatabase_Button, Language.Options_ClearDatabase_Tooltip))
|
||||
{
|
||||
Plugin.Log.Warning("Clearing messages from database");
|
||||
Plugin.MessageManager.Store.ClearMessages();
|
||||
foreach (var tab in Plugin.Config.Tabs)
|
||||
tab.Clear();
|
||||
|
||||
// Refresh on next draw
|
||||
DatabaseLastRefreshTicks = 0;
|
||||
WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.Spacing();
|
||||
|
||||
if (!ShowAdvanced)
|
||||
return;
|
||||
|
||||
using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced);
|
||||
ImGui.PushTextWrapPos();
|
||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
||||
Plugin.MessageManager.Store.PerformMaintenance();
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Reload messages from database", "Ctrl+Shift: MessageManager.FilterAllTabs(false)"))
|
||||
{
|
||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
ImGui.SetTooltip(Language.Options_Database_Metadata_CopyConfigPath);
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Size, StringUtil.BytesToString(DatabaseSize)));
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(DatabaseSize.ToString("N0") + "B");
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_LogSize, StringUtil.BytesToString(DatabaseLogSize)));
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(DatabaseLogSize.ToString("N0") + "B");
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_MessageCount, DatabaseMessageCount));
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton(Language.Options_ClearDatabase_Button, Language.Options_ClearDatabase_Tooltip))
|
||||
{
|
||||
Plugin.Log.Warning("Clearing messages from database");
|
||||
Plugin.MessageManager.Store.ClearMessages();
|
||||
foreach (var tab in Plugin.Config.Tabs)
|
||||
tab.Clear();
|
||||
|
||||
// Refresh on next draw
|
||||
DatabaseLastRefreshTicks = 0;
|
||||
WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info);
|
||||
Plugin.MessageManager.FilterAllTabs(false);
|
||||
}
|
||||
|
||||
ImGui.Unindent(style.IndentSpacing);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ShowAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced))
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
||||
Plugin.MessageManager.Store.PerformMaintenance();
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Reload messages from database",
|
||||
"Ctrl+Shift: MessageManager.FilterAllTabs(false)")) {
|
||||
foreach (var tab in Plugin.Config.Tabs)
|
||||
tab.Clear();
|
||||
Plugin.MessageManager.FilterAllTabs(false);
|
||||
}
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Inject 10,000 messages", "Ctrl+Shift: creates 10,000 unique messages (async)"))
|
||||
new Thread(() => InsertMessages(10_000)).Start();
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.TreePop();
|
||||
}
|
||||
if (ImGuiUtil.CtrlShiftButton("Inject 10,000 messages", "Ctrl+Shift: creates 10,000 unique messages (async)"))
|
||||
new Thread(() => InsertMessages(10_000)).Start();
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
private void InsertMessages(int count) {
|
||||
private void InsertMessages(int count)
|
||||
{
|
||||
Plugin.Log.Info($"Inserting {count} messages due to user request");
|
||||
|
||||
// Generate
|
||||
@@ -175,7 +173,8 @@ internal sealed class Database : ISettingsTab
|
||||
.Build();
|
||||
var senderChunks = ChunkUtil.ToChunks(senderSource, ChunkSource.Sender, ChatType.Debug).ToList();
|
||||
var messages = new List<Message>(count);
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var contentSource = new SeStringBuilder()
|
||||
.AddText("Random message payload - ")
|
||||
.AddItalics(Guid.NewGuid().ToString())
|
||||
@@ -203,28 +202,28 @@ internal sealed class Database : ISettingsTab
|
||||
|
||||
// Insert
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
foreach (var message in messages) {
|
||||
foreach (var message in messages)
|
||||
Plugin.MessageManager.Store.UpsertMessage(message);
|
||||
}
|
||||
|
||||
elapsedTicks = stopwatch.ElapsedTicks;
|
||||
stopwatch.Stop();
|
||||
Plugin.Log.Info($"Upserted {count} messages in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
||||
|
||||
// Clear tabs during framework frame
|
||||
Plugin.Framework.Run(() => {
|
||||
Plugin.Framework.Run(() =>
|
||||
{
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
foreach (var tab in Plugin.Config.Tabs)
|
||||
tab.Clear();
|
||||
|
||||
elapsedTicks = stopwatch.ElapsedTicks;
|
||||
stopwatch.Stop();
|
||||
Plugin.Log.Info(
|
||||
$"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
||||
Plugin.Log.Info($"Cleared {Plugin.Config.Tabs.Count} tabs in {elapsedTicks} ticks ({elapsedTicks / TimeSpan.TicksPerMillisecond}ms)");
|
||||
}).Wait();
|
||||
|
||||
// Fetch and filter during framework frame
|
||||
Plugin.Framework.Run(() => {
|
||||
Plugin.Framework.Run(() =>
|
||||
{
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
Plugin.MessageManager.FilterAllTabs(false);
|
||||
elapsedTicks = stopwatch.ElapsedTicks;
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Interface.Style;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Display : ISettingsTab {
|
||||
internal sealed class Display : ISettingsTab
|
||||
{
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => Language.Options_Display_Tab + "###tabs-display";
|
||||
|
||||
internal Display(Configuration mutable) {
|
||||
internal Display(Configuration mutable)
|
||||
{
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
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);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.HideDuringCutscenes,
|
||||
Language.Options_HideDuringCutscenes_Name,
|
||||
string.Format(Language.Options_HideDuringCutscenes_Description, Plugin.PluginName)
|
||||
);
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideDuringCutscenes, Language.Options_HideDuringCutscenes_Name, string.Format(Language.Options_HideDuringCutscenes_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.HideWhenNotLoggedIn,
|
||||
Language.Options_HideWhenNotLoggedIn_Name,
|
||||
string.Format(Language.Options_HideWhenNotLoggedIn_Description, Plugin.PluginName)
|
||||
);
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideWhenNotLoggedIn, Language.Options_HideWhenNotLoggedIn_Name, string.Format(Language.Options_HideWhenNotLoggedIn_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.HideWhenUiHidden,
|
||||
Language.Options_HideWhenUiHidden_Name,
|
||||
string.Format(Language.Options_HideWhenUiHidden_Description, Plugin.PluginName)
|
||||
);
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideWhenUiHidden, Language.Options_HideWhenUiHidden_Name, string.Format(Language.Options_HideWhenUiHidden_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.HideInLoadingScreens,
|
||||
Language.Options_HideInLoadingScreens_Name,
|
||||
string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName));
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideInLoadingScreens, Language.Options_HideInLoadingScreens_Name, string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.NativeItemTooltips,
|
||||
Language.Options_NativeItemTooltips_Name,
|
||||
string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName)
|
||||
);
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(
|
||||
ref Mutable.SidebarTabView,
|
||||
Language.Options_SidebarTabView_Name,
|
||||
string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName)
|
||||
);
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.SidebarTabView, Language.Options_SidebarTabView_Name, string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.PrettierTimestamps, Language.Options_PrettierTimestamps_Name, Language.Options_PrettierTimestamps_Description);
|
||||
|
||||
if (Mutable.PrettierTimestamps) {
|
||||
if (Mutable.PrettierTimestamps)
|
||||
{
|
||||
ImGui.TreePush();
|
||||
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);
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
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);
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
|
||||
if (Mutable.OverrideStyle)
|
||||
if (!Mutable.OverrideStyle)
|
||||
return;
|
||||
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
if (styles == null)
|
||||
{
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
if (styles != null)
|
||||
{
|
||||
var currentStyle = Mutable.ChosenStyle ?? Language.Options_OverrideStyle_NotSelected;
|
||||
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle))
|
||||
{
|
||||
foreach (var style in styles)
|
||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name))
|
||||
Mutable.ChosenStyle = style.Name;
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
||||
}
|
||||
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
||||
ImGui.Spacing();
|
||||
return;
|
||||
}
|
||||
|
||||
var currentStyle = Mutable.ChosenStyle ?? Language.Options_OverrideStyle_NotSelected;
|
||||
using var combo = ImRaii.Combo(Language.Options_OverrideStyleDropdown_Name, currentStyle);
|
||||
if (combo)
|
||||
foreach (var style in styles)
|
||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name))
|
||||
Mutable.ChosenStyle = style.Name;
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,55 +4,58 @@ using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
public class Fonts : ISettingsTab {
|
||||
public class Fonts : ISettingsTab
|
||||
{
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => Language.Options_Fonts_Tab + "###tabs-fonts";
|
||||
private List<string> GlobalFonts { get; set; } = new();
|
||||
private List<string> JpFonts { get; set; } = new();
|
||||
private List<string> GlobalFonts { get; set; } = [];
|
||||
private List<string> JpFonts { get; set; } = [];
|
||||
|
||||
internal Fonts(Configuration mutable) {
|
||||
internal Fonts(Configuration mutable)
|
||||
{
|
||||
Mutable = mutable;
|
||||
UpdateFonts();
|
||||
}
|
||||
|
||||
private void UpdateFonts() {
|
||||
private void UpdateFonts()
|
||||
{
|
||||
GlobalFonts = Ui.Fonts.GetFonts();
|
||||
JpFonts = Ui.Fonts.GetJpFonts();
|
||||
}
|
||||
|
||||
public void Draw(bool changed) {
|
||||
if (changed) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
if (changed)
|
||||
UpdateFonts();
|
||||
}
|
||||
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (Mutable.FontsEnabled) {
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont)) {
|
||||
foreach (var font in Ui.Fonts.GlobalFonts) {
|
||||
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name)) {
|
||||
if (Mutable.FontsEnabled)
|
||||
{
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont))
|
||||
{
|
||||
foreach (var font in Ui.Fonts.GlobalFonts)
|
||||
{
|
||||
if (ImGui.Selectable(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.Separator();
|
||||
|
||||
foreach (var name in GlobalFonts) {
|
||||
if (ImGui.Selectable(name, Mutable.GlobalFont == name)) {
|
||||
foreach (var name in GlobalFonts)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.GlobalFont == name))
|
||||
Mutable.GlobalFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name) {
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
@@ -62,27 +65,26 @@ public class Fonts : ISettingsTab {
|
||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont)) {
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts) {
|
||||
if (ImGui.Selectable(name, Mutable.JapaneseFont == name)) {
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont))
|
||||
{
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.JapaneseFont == name))
|
||||
Mutable.JapaneseFont = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name) {
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var family in JpFonts) {
|
||||
if (ImGui.Selectable(family, Mutable.JapaneseFont == family)) {
|
||||
foreach (var family in JpFonts)
|
||||
{
|
||||
if (ImGui.Selectable(family, Mutable.JapaneseFont == family))
|
||||
Mutable.JapaneseFont = family;
|
||||
}
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family) {
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
@@ -91,13 +93,13 @@ public class Fonts : ISettingsTab {
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal interface ISettingsTab {
|
||||
internal interface ISettingsTab
|
||||
{
|
||||
string Name { get; }
|
||||
void Draw(bool changed);
|
||||
}
|
||||
|
||||
@@ -4,22 +4,18 @@ using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Miscellaneous : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
internal sealed class Miscellaneous(Configuration mutable) : ISettingsTab
|
||||
{
|
||||
private Configuration Mutable { get; } = mutable;
|
||||
public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous";
|
||||
|
||||
public Miscellaneous(Configuration mutable) {
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed) {
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name())) {
|
||||
foreach (var language in Enum.GetValues<LanguageOverride>()) {
|
||||
if (ImGui.Selectable(language.Name())) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name()))
|
||||
{
|
||||
foreach (var language in Enum.GetValues<LanguageOverride>())
|
||||
if (ImGui.Selectable(language.Name()))
|
||||
Mutable.LanguageOverride = language;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
@@ -27,12 +23,11 @@ internal sealed class Miscellaneous : ISettingsTab {
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
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)) {
|
||||
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))
|
||||
Mutable.CommandHelpSide = side;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
@@ -40,17 +35,15 @@ internal sealed class Miscellaneous : ISettingsTab {
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
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)) {
|
||||
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))
|
||||
Mutable.KeybindMode = mode;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered()) {
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.TextUnformatted(mode.Tooltip());
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(mode.Tooltip());
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
@@ -61,7 +54,6 @@ internal sealed class Miscellaneous : ISettingsTab {
|
||||
|
||||
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
||||
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
||||
|
||||
ImGui.Spacing();
|
||||
}
|
||||
}
|
||||
|
||||
+151
-151
@@ -2,11 +2,13 @@ using ChatTwo.Code;
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Tabs : ISettingsTab {
|
||||
internal sealed class Tabs : ISettingsTab
|
||||
{
|
||||
private Plugin Plugin { get; }
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
@@ -14,193 +16,191 @@ internal sealed class Tabs : ISettingsTab {
|
||||
|
||||
private int _toOpen = -2;
|
||||
|
||||
internal Tabs(Plugin plugin, Configuration mutable) {
|
||||
internal Tabs(Plugin plugin, Configuration mutable)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed) {
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopup(addTabPopup)) {
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NewTab)) {
|
||||
Mutable.Tabs.Add(new Tab());
|
||||
using (var popup = ImRaii.Popup(addTabPopup))
|
||||
{
|
||||
if (popup)
|
||||
{
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NewTab))
|
||||
Mutable.Tabs.Add(new Tab());
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General)))
|
||||
Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
|
||||
|
||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event)))
|
||||
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General))) {
|
||||
Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
|
||||
}
|
||||
|
||||
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event))) {
|
||||
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
var toRemove = -1;
|
||||
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];
|
||||
|
||||
if (doOpens) {
|
||||
if (doOpens)
|
||||
ImGui.SetNextItemOpen(i == _toOpen);
|
||||
|
||||
using var treeNode = ImRaii.TreeNode($"{tab.Name}###tab-{i}");
|
||||
if (!treeNode.Success)
|
||||
continue;
|
||||
|
||||
using var pushedId = ImRaii.PushId($"tab-{i}");
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete))
|
||||
{
|
||||
toRemove = i;
|
||||
_toOpen = -1;
|
||||
}
|
||||
|
||||
if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) {
|
||||
ImGui.PushID($"tab-{i}");
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete)) {
|
||||
toRemove = i;
|
||||
_toOpen = -1;
|
||||
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]);
|
||||
_toOpen = i - 1;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
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]);
|
||||
_toOpen = i + 1;
|
||||
}
|
||||
|
||||
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_PopOut, ref tab.PopOut);
|
||||
if (tab.PopOut)
|
||||
{
|
||||
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
||||
if (tab.IndependentOpacity)
|
||||
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()))
|
||||
{
|
||||
foreach (var mode in Enum.GetValues<UnreadMode>())
|
||||
{
|
||||
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode))
|
||||
tab.UnreadMode = mode;
|
||||
|
||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(tooltip);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
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]);
|
||||
_toOpen = i - 1;
|
||||
}
|
||||
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input))
|
||||
{
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
|
||||
tab.Channel = null;
|
||||
|
||||
ImGui.SameLine();
|
||||
foreach (var channel in Enum.GetValues<InputChannel>())
|
||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
||||
tab.Channel = channel;
|
||||
|
||||
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]);
|
||||
_toOpen = i + 1;
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
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_PopOut, ref tab.PopOut);
|
||||
if (tab.PopOut) {
|
||||
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
||||
if (tab.IndependentOpacity) {
|
||||
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.25f, 0f, 100f, $"{tab.Opacity:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||
}
|
||||
}
|
||||
using (var channelNode = ImRaii.TreeNode(Language.Options_Tabs_Channels))
|
||||
{
|
||||
if (channelNode)
|
||||
{
|
||||
foreach (var (header, types) in ChatTypeExt.SortOrder)
|
||||
{
|
||||
using var headerNode = ImRaii.TreeNode(header + $"##{i}");
|
||||
if (!headerNode.Success)
|
||||
continue;
|
||||
|
||||
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)) {
|
||||
tab.UnreadMode = mode;
|
||||
}
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsGm())
|
||||
continue;
|
||||
|
||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered()) {
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.TextUnformatted(tooltip);
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input)) {
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null)) {
|
||||
tab.Channel = null;
|
||||
}
|
||||
|
||||
foreach (var channel in Enum.GetValues<InputChannel>()) {
|
||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel)) {
|
||||
tab.Channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
if (ImGui.TreeNodeEx(Language.Options_Tabs_Channels)) {
|
||||
foreach (var (header, types) in ChatTypeExt.SortOrder) {
|
||||
if (ImGui.TreeNodeEx(header + $"##{i}")) {
|
||||
foreach (var type in types) {
|
||||
if (type.IsGm()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var enabled = tab.ChatCodes.ContainsKey(type);
|
||||
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) {
|
||||
if (enabled) {
|
||||
tab.ChatCodes[type] = ChatSourceExt.All;
|
||||
} else {
|
||||
tab.ChatCodes.Remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
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());
|
||||
}
|
||||
var enabled = tab.ChatCodes.ContainsKey(type);
|
||||
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled))
|
||||
{
|
||||
if (enabled)
|
||||
tab.ChatCodes[type] = ChatSourceExt.All;
|
||||
else
|
||||
tab.ChatCodes.Remove(type);
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
ImGui.SameLine();
|
||||
|
||||
if (!type.HasSource())
|
||||
{
|
||||
ImGui.TextUnformatted(type.Name());
|
||||
continue;
|
||||
}
|
||||
|
||||
using var typeNode = ImRaii.TreeNode($"{type.Name()}##{i}");
|
||||
if (!typeNode.Success)
|
||||
continue;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
tab.ExtraChatChannels.Add(id);
|
||||
} else {
|
||||
tab.ExtraChatChannels.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (tab.ExtraChatAll) {
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (toRemove > -1) {
|
||||
if (toRemove > -1)
|
||||
Mutable.Tabs.RemoveAt(toRemove);
|
||||
}
|
||||
|
||||
if (doOpens) {
|
||||
if (doOpens)
|
||||
_toOpen = -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user