diff --git a/ChatTwo/Code/ChatTypeExt.cs b/ChatTwo/Code/ChatTypeExt.cs index c69a2c4..13a017e 100755 --- a/ChatTwo/Code/ChatTypeExt.cs +++ b/ChatTwo/Code/ChatTypeExt.cs @@ -1,8 +1,80 @@ +using ChatTwo.Resources; using ChatTwo.Util; namespace ChatTwo.Code; internal static class ChatTypeExt { + internal static readonly (string, ChatType[])[] SortOrder = { + (Language.Options_Tabs_ChannelTypes_Chat, new[] { + ChatType.Say, + ChatType.Yell, + ChatType.Shout, + ChatType.TellIncoming, + ChatType.TellOutgoing, + ChatType.Party, + ChatType.CrossParty, + ChatType.Alliance, + ChatType.FreeCompany, + ChatType.PvpTeam, + ChatType.CrossLinkshell1, + ChatType.CrossLinkshell2, + ChatType.CrossLinkshell3, + ChatType.CrossLinkshell4, + ChatType.CrossLinkshell5, + ChatType.CrossLinkshell6, + ChatType.CrossLinkshell7, + ChatType.CrossLinkshell8, + ChatType.Linkshell1, + ChatType.Linkshell2, + ChatType.Linkshell3, + ChatType.Linkshell4, + ChatType.Linkshell5, + ChatType.Linkshell6, + ChatType.Linkshell7, + ChatType.Linkshell8, + ChatType.NoviceNetwork, + ChatType.StandardEmote, + ChatType.CustomEmote, + }), + (Language.Options_Tabs_ChannelTypes_Battle, new[] { + ChatType.Damage, + ChatType.Miss, + ChatType.Action, + ChatType.Item, + ChatType.Healing, + ChatType.GainBuff, + ChatType.LoseBuff, + ChatType.GainDebuff, + ChatType.LoseDebuff, + }), + (Language.Options_Tabs_ChannelTypes_Announcements, new[] { + ChatType.System, + ChatType.BattleSystem, + ChatType.GatheringSystem, + ChatType.Error, + ChatType.Echo, + ChatType.NoviceNetworkSystem, + ChatType.FreeCompanyAnnouncement, + ChatType.PvpTeamAnnouncement, + ChatType.FreeCompanyLoginLogout, + ChatType.PvpTeamLoginLogout, + ChatType.RetainerSale, + ChatType.NpcDialogue, + ChatType.NpcAnnouncement, + ChatType.LootNotice, + ChatType.Progress, + ChatType.LootRoll, + ChatType.Crafting, + ChatType.Gathering, + ChatType.PeriodicRecruitmentNotification, + ChatType.Sign, + ChatType.RandomNumber, + ChatType.Orchestrion, + ChatType.MessageBook, + ChatType.Alarm, + }), + }; + internal static string Name(this ChatType type) { return type switch { ChatType.Debug => "Debug", @@ -235,4 +307,43 @@ internal static class ChatTypeExt { ChatType.Linkshell8 => InputChannel.Linkshell8, _ => null, }; + + internal static bool IsGm(this ChatType type) => type switch { + ChatType.GmTell => true, + ChatType.GmSay => true, + ChatType.GmShout => true, + ChatType.GmYell => true, + ChatType.GmParty => true, + ChatType.GmFreeCompany => true, + ChatType.GmLinkshell1 => true, + ChatType.GmLinkshell2 => true, + ChatType.GmLinkshell3 => true, + ChatType.GmLinkshell4 => true, + ChatType.GmLinkshell5 => true, + ChatType.GmLinkshell6 => true, + ChatType.GmLinkshell7 => true, + ChatType.GmLinkshell8 => true, + ChatType.GmNoviceNetwork => true, + _ => false, + }; + + internal static bool HasSource(this ChatType type) => type switch { + // Battle + ChatType.Damage => true, + ChatType.Miss => true, + ChatType.Action => true, + ChatType.Item => true, + ChatType.Healing => true, + ChatType.GainBuff => true, + ChatType.LoseBuff => true, + ChatType.GainDebuff => true, + ChatType.LoseDebuff => true, + + // Announcements + ChatType.Progress => true, + ChatType.LootRoll => true, + ChatType.Crafting => true, + ChatType.Gathering => true, + _ => false, + }; } diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index dd6e4d8..c2773d6 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -95,7 +95,7 @@ internal class Tab { } internal bool Matches(Message message) { - return this.ChatCodes.TryGetValue(message.Code.Type, out var sources) && (message.Code.Source is 0 or (ChatSource) 1 || sources.HasFlag(message.Code.Source)); + return message.Code.Type.IsGm() || this.ChatCodes.TryGetValue(message.Code.Type, out var sources) && (message.Code.Source is 0 or (ChatSource) 1 || sources.HasFlag(message.Code.Source)); } internal void AddMessage(Message message, bool unread = true) { diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 2783d9e..930fc45 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -39,7 +39,7 @@ namespace ChatTwo.Resources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChatTwo.resources.Language", typeof(Language).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChatTwo.Resources.Language", typeof(Language).Assembly); resourceMan = temp; } return resourceMan; @@ -330,6 +330,33 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Announcements. + /// + internal static string Options_Tabs_ChannelTypes_Announcements { + get { + return ResourceManager.GetString("Options_Tabs_ChannelTypes_Announcements", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Battle. + /// + internal static string Options_Tabs_ChannelTypes_Battle { + get { + return ResourceManager.GetString("Options_Tabs_ChannelTypes_Battle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Chat. + /// + internal static string Options_Tabs_ChannelTypes_Chat { + get { + return ResourceManager.GetString("Options_Tabs_ChannelTypes_Chat", resourceCulture); + } + } + /// /// Looks up a localized string similar to Delete. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 4b3bae1..725d983 100755 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -269,4 +269,13 @@ Move right + + Chat + + + Battle + + + Announcements + diff --git a/ChatTwo/Ui/SettingsTabs/Tabs.cs b/ChatTwo/Ui/SettingsTabs/Tabs.cs index 82044ee..63b159f 100755 --- a/ChatTwo/Ui/SettingsTabs/Tabs.cs +++ b/ChatTwo/Ui/SettingsTabs/Tabs.cs @@ -78,25 +78,39 @@ internal sealed class Tabs : ISettingsTab { } if (ImGui.TreeNodeEx(Language.Options_Tabs_Channels)) { - foreach (var type in Enum.GetValues()) { - var enabled = tab.ChatCodes.ContainsKey(type); - if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) { - if (enabled) { - tab.ChatCodes[type] = ChatSourceExt.All; - } else { - tab.ChatCodes.Remove(type); - } - } + foreach (var (header, types) in ChatTypeExt.SortOrder) { + if (ImGui.TreeNodeEx(header + $"##{i}")) { + foreach (var type in types) { + if (type.IsGm()) { + continue; + } - ImGui.SameLine(); + 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); + } + } - if (ImGui.TreeNodeEx($"{type.Name()}##{i}")) { - tab.ChatCodes.TryGetValue(type, out var sourcesEnum); - var sources = (uint) sourcesEnum; + ImGui.SameLine(); - foreach (var source in Enum.GetValues()) { - if (ImGui.CheckboxFlags(source.ToString(), ref sources, (uint) source)) { - tab.ChatCodes[type] = (ChatSource) sources; + 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()) { + if (ImGui.CheckboxFlags(source.ToString(), ref sources, (uint) source)) { + tab.ChatCodes[type] = (ChatSource) sources; + } + } + + ImGui.TreePop(); + } + } else { + ImGui.TextUnformatted(type.Name()); } } @@ -104,7 +118,6 @@ internal sealed class Tabs : ISettingsTab { } } - ImGui.TreePop(); }