feat: order channels and always show GM

This commit is contained in:
Anna 2022-02-04 19:27:50 -05:00
parent 9a38e3a440
commit 8e7a50e3f3
5 changed files with 179 additions and 19 deletions

View File

@ -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,
};
}

View File

@ -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) {

View File

@ -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 {
}
}
/// <summary>
/// Looks up a localized string similar to Announcements.
/// </summary>
internal static string Options_Tabs_ChannelTypes_Announcements {
get {
return ResourceManager.GetString("Options_Tabs_ChannelTypes_Announcements", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Battle.
/// </summary>
internal static string Options_Tabs_ChannelTypes_Battle {
get {
return ResourceManager.GetString("Options_Tabs_ChannelTypes_Battle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Chat.
/// </summary>
internal static string Options_Tabs_ChannelTypes_Chat {
get {
return ResourceManager.GetString("Options_Tabs_ChannelTypes_Chat", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>

View File

@ -269,4 +269,13 @@
<data name="ChatLog_Tabs_MoveRight" xml:space="preserve">
<value>Move right</value>
</data>
<data name="Options_Tabs_ChannelTypes_Chat" xml:space="preserve">
<value>Chat</value>
</data>
<data name="Options_Tabs_ChannelTypes_Battle" xml:space="preserve">
<value>Battle</value>
</data>
<data name="Options_Tabs_ChannelTypes_Announcements" xml:space="preserve">
<value>Announcements</value>
</data>
</root>

View File

@ -78,25 +78,39 @@ internal sealed class Tabs : ISettingsTab {
}
if (ImGui.TreeNodeEx(Language.Options_Tabs_Channels)) {
foreach (var type in Enum.GetValues<ChatType>()) {
var enabled = tab.ChatCodes.ContainsKey(type);
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) {
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<ChatSource>()) {
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<ChatSource>()) {
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();
}