- API 15
- Migrate config for API 15 - Migrate database for API 15 - Allow usage of new target source - Implement first tell target option
This commit is contained in:
+35
-74
@@ -1,84 +1,24 @@
|
||||
using Dalamud.Game.Text;
|
||||
|
||||
namespace ChatTwo.Code;
|
||||
|
||||
internal class ChatCode
|
||||
public class ChatCode
|
||||
{
|
||||
private const ushort Clear7 = ~(~0 << 7);
|
||||
public ChatType Type { get; }
|
||||
public XivChatRelationKind Source { get; }
|
||||
public XivChatRelationKind Target { get; }
|
||||
|
||||
internal ushort Raw { get; }
|
||||
|
||||
internal ChatType Type { get; }
|
||||
internal ChatSource Source { get; }
|
||||
internal ChatSource Target { get; }
|
||||
private ChatSource SourceFrom(ushort shift) => (ChatSource) (1 << ((Raw >> shift) & 0xF));
|
||||
|
||||
internal ChatCode(ushort raw)
|
||||
public ChatCode(XivChatType type, XivChatRelationKind source, XivChatRelationKind target)
|
||||
{
|
||||
Raw = raw;
|
||||
Type = (ChatType) (Raw & Clear7);
|
||||
Source = SourceFrom(11);
|
||||
Target = SourceFrom(7);
|
||||
Type = (ChatType)type;
|
||||
Source = source;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
internal ChatType Parent() => Type switch
|
||||
{
|
||||
ChatType.Say => ChatType.Say,
|
||||
ChatType.GmSay => ChatType.Say,
|
||||
ChatType.Shout => ChatType.Shout,
|
||||
ChatType.GmShout => ChatType.Shout,
|
||||
ChatType.TellOutgoing => ChatType.TellOutgoing,
|
||||
ChatType.TellIncoming => ChatType.TellOutgoing,
|
||||
ChatType.GmTell => ChatType.TellOutgoing,
|
||||
ChatType.Party => ChatType.Party,
|
||||
ChatType.CrossParty => ChatType.Party,
|
||||
ChatType.GmParty => ChatType.Party,
|
||||
ChatType.Linkshell1 => ChatType.Linkshell1,
|
||||
ChatType.GmLinkshell1 => ChatType.Linkshell1,
|
||||
ChatType.Linkshell2 => ChatType.Linkshell2,
|
||||
ChatType.GmLinkshell2 => ChatType.Linkshell2,
|
||||
ChatType.Linkshell3 => ChatType.Linkshell3,
|
||||
ChatType.GmLinkshell3 => ChatType.Linkshell3,
|
||||
ChatType.Linkshell4 => ChatType.Linkshell4,
|
||||
ChatType.GmLinkshell4 => ChatType.Linkshell4,
|
||||
ChatType.Linkshell5 => ChatType.Linkshell5,
|
||||
ChatType.GmLinkshell5 => ChatType.Linkshell5,
|
||||
ChatType.Linkshell6 => ChatType.Linkshell6,
|
||||
ChatType.GmLinkshell6 => ChatType.Linkshell6,
|
||||
ChatType.Linkshell7 => ChatType.Linkshell7,
|
||||
ChatType.GmLinkshell7 => ChatType.Linkshell7,
|
||||
ChatType.Linkshell8 => ChatType.Linkshell8,
|
||||
ChatType.GmLinkshell8 => ChatType.Linkshell8,
|
||||
ChatType.FreeCompany => ChatType.FreeCompany,
|
||||
ChatType.GmFreeCompany => ChatType.FreeCompany,
|
||||
ChatType.NoviceNetwork => ChatType.NoviceNetwork,
|
||||
ChatType.GmNoviceNetwork => ChatType.NoviceNetwork,
|
||||
ChatType.CustomEmote => ChatType.CustomEmote,
|
||||
ChatType.StandardEmote => ChatType.StandardEmote,
|
||||
ChatType.Yell => ChatType.Yell,
|
||||
ChatType.GmYell => ChatType.Yell,
|
||||
ChatType.GainBuff => ChatType.GainBuff,
|
||||
ChatType.LoseBuff => ChatType.GainBuff,
|
||||
ChatType.GainDebuff => ChatType.GainDebuff,
|
||||
ChatType.LoseDebuff => ChatType.GainDebuff,
|
||||
ChatType.System => ChatType.System,
|
||||
ChatType.Alarm => ChatType.System,
|
||||
ChatType.GlamourNotifications => ChatType.System,
|
||||
ChatType.RetainerSale => ChatType.System,
|
||||
ChatType.PeriodicRecruitmentNotification => ChatType.System,
|
||||
ChatType.Sign => ChatType.System,
|
||||
ChatType.Orchestrion => ChatType.System,
|
||||
ChatType.MessageBook => ChatType.System,
|
||||
ChatType.NpcDialogue => ChatType.NpcDialogue,
|
||||
ChatType.NpcAnnouncement => ChatType.NpcDialogue,
|
||||
ChatType.LootRoll => ChatType.LootRoll,
|
||||
ChatType.RandomNumber => ChatType.LootRoll,
|
||||
ChatType.FreeCompanyAnnouncement => ChatType.FreeCompanyAnnouncement,
|
||||
ChatType.FreeCompanyLoginLogout => ChatType.FreeCompanyAnnouncement,
|
||||
ChatType.PvpTeamAnnouncement => ChatType.PvpTeamAnnouncement,
|
||||
ChatType.PvpTeamLoginLogout => ChatType.PvpTeamAnnouncement,
|
||||
_ => Type,
|
||||
};
|
||||
public ChatCode(byte type, byte source, byte target)
|
||||
: this((XivChatType)type, (XivChatRelationKind)source, (XivChatRelationKind)target) {}
|
||||
|
||||
internal bool IsBattle()
|
||||
public bool IsBattle()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
@@ -101,7 +41,7 @@ internal class ChatCode
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPlayerMessage()
|
||||
public bool IsPlayerMessage()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
@@ -143,4 +83,25 @@ internal class ChatCode
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int ToSortCodeV2()
|
||||
{
|
||||
return (byte)Type << 16 | (byte)Source << 8 | (byte)Target;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (obj is not ChatCode code)
|
||||
return false;
|
||||
|
||||
return GetHashCode() == code.GetHashCode();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (byte)Type << 16 | (byte)Source << 8 | (byte)Target;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-11
@@ -1,17 +1,42 @@
|
||||
using Dalamud.Game.Text;
|
||||
|
||||
namespace ChatTwo.Code;
|
||||
|
||||
[Flags]
|
||||
public enum ChatSource : ushort
|
||||
{
|
||||
Self = 2,
|
||||
PartyMember = 4,
|
||||
AllianceMember = 8,
|
||||
Other = 16,
|
||||
EngagedEnemy = 32,
|
||||
UnengagedEnemy = 64,
|
||||
FriendlyNpc = 128,
|
||||
SelfPet = 256,
|
||||
PartyPet = 512,
|
||||
AlliancePet = 1024,
|
||||
OtherPet = 2048,
|
||||
None = 0,
|
||||
|
||||
/// <summary>The player currently controlled by the local client.</summary>
|
||||
LocalPlayer = 1 << XivChatRelationKind.LocalPlayer,
|
||||
|
||||
/// <summary>A player in the same 4-man or 8-man party as the local player.</summary>
|
||||
PartyMember = 1 << XivChatRelationKind.PartyMember,
|
||||
|
||||
/// <summary>A player in the same alliance raid.</summary>
|
||||
AllianceMember = 1 << XivChatRelationKind.AllianceMember,
|
||||
|
||||
/// <summary>A player not in the local player's party or alliance.</summary>
|
||||
OtherPlayer = 1 << XivChatRelationKind.OtherPlayer,
|
||||
|
||||
/// <summary>An enemy entity that is currently in combat with the player or party.</summary>
|
||||
EngagedEnemy = 1 << XivChatRelationKind.EngagedEnemy,
|
||||
|
||||
/// <summary>An enemy entity that is not yet in combat or claimed.</summary>
|
||||
UnengagedEnemy = 1 << XivChatRelationKind.UnengagedEnemy,
|
||||
|
||||
/// <summary>An NPC that is friendly or neutral to the player (e.g., EventNPCs).</summary>
|
||||
FriendlyNpc = 1 << XivChatRelationKind.FriendlyNpc,
|
||||
|
||||
/// <summary>A pet (Summoner/Scholar) or companion (Chocobo) belonging to the local player.</summary>
|
||||
PetOrCompanion = 1 << XivChatRelationKind.PetOrCompanion,
|
||||
|
||||
/// <summary>A pet or companion belonging to a member of the local player's party.</summary>
|
||||
PetOrCompanionParty = 1 << XivChatRelationKind.PetOrCompanionParty,
|
||||
|
||||
/// <summary>A pet or companion belonging to a member of the alliance.</summary>
|
||||
PetOrCompanionAlliance = 1 << XivChatRelationKind.PetOrCompanionAlliance,
|
||||
|
||||
/// <summary>A pet or companion belonging to a player not in the party or alliance.</summary>
|
||||
PetOrCompanionOther = 1 << XivChatRelationKind.PetOrCompanionOther,
|
||||
}
|
||||
|
||||
@@ -5,24 +5,24 @@ namespace ChatTwo.Code;
|
||||
internal static class ChatSourceExt
|
||||
{
|
||||
internal const ChatSource All =
|
||||
ChatSource.Self | ChatSource.PartyMember | ChatSource.AllianceMember |
|
||||
ChatSource.Other | ChatSource.EngagedEnemy | ChatSource.UnengagedEnemy |
|
||||
ChatSource.FriendlyNpc | ChatSource.SelfPet | ChatSource.PartyPet |
|
||||
ChatSource.AlliancePet | ChatSource.OtherPet;
|
||||
ChatSource.LocalPlayer | ChatSource.PartyMember | ChatSource.AllianceMember |
|
||||
ChatSource.OtherPlayer | ChatSource.EngagedEnemy | ChatSource.UnengagedEnemy |
|
||||
ChatSource.FriendlyNpc | ChatSource.PetOrCompanion | ChatSource.PetOrCompanionParty |
|
||||
ChatSource.PetOrCompanionAlliance | ChatSource.PetOrCompanionOther;
|
||||
|
||||
internal static string Name(this ChatSource source) => source switch
|
||||
{
|
||||
ChatSource.Self => Language.ChatSource_Self,
|
||||
ChatSource.LocalPlayer => Language.ChatSource_Self,
|
||||
ChatSource.PartyMember => Language.ChatSource_PartyMember,
|
||||
ChatSource.AllianceMember => Language.ChatSource_AllianceMember,
|
||||
ChatSource.Other => Language.ChatSource_Other,
|
||||
ChatSource.OtherPlayer => Language.ChatSource_Other,
|
||||
ChatSource.EngagedEnemy => Language.ChatSource_EngagedEnemy,
|
||||
ChatSource.UnengagedEnemy => Language.ChatSource_UnengagedEnemy,
|
||||
ChatSource.FriendlyNpc => Language.ChatSource_FriendlyNpc,
|
||||
ChatSource.SelfPet => Language.ChatSource_SelfPet,
|
||||
ChatSource.PartyPet => Language.ChatSource_PartyPet,
|
||||
ChatSource.AlliancePet => Language.ChatSource_AlliancePet,
|
||||
ChatSource.OtherPet => Language.ChatSource_OtherPet,
|
||||
ChatSource.PetOrCompanion => Language.ChatSource_SelfPet,
|
||||
ChatSource.PetOrCompanionParty => Language.ChatSource_PartyPet,
|
||||
ChatSource.PetOrCompanionAlliance => Language.ChatSource_AlliancePet,
|
||||
ChatSource.PetOrCompanionOther => Language.ChatSource_OtherPet,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(source), source, null),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -424,4 +424,63 @@ internal static class ChatTypeExt
|
||||
ChatType.PvpTeamLoginLogout => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
internal static ChatType Parent(this ChatType type) => type switch
|
||||
{
|
||||
ChatType.Say => ChatType.Say,
|
||||
ChatType.GmSay => ChatType.Say,
|
||||
ChatType.Shout => ChatType.Shout,
|
||||
ChatType.GmShout => ChatType.Shout,
|
||||
ChatType.TellOutgoing => ChatType.TellOutgoing,
|
||||
ChatType.TellIncoming => ChatType.TellOutgoing,
|
||||
ChatType.GmTell => ChatType.TellOutgoing,
|
||||
ChatType.Party => ChatType.Party,
|
||||
ChatType.CrossParty => ChatType.Party,
|
||||
ChatType.GmParty => ChatType.Party,
|
||||
ChatType.Linkshell1 => ChatType.Linkshell1,
|
||||
ChatType.GmLinkshell1 => ChatType.Linkshell1,
|
||||
ChatType.Linkshell2 => ChatType.Linkshell2,
|
||||
ChatType.GmLinkshell2 => ChatType.Linkshell2,
|
||||
ChatType.Linkshell3 => ChatType.Linkshell3,
|
||||
ChatType.GmLinkshell3 => ChatType.Linkshell3,
|
||||
ChatType.Linkshell4 => ChatType.Linkshell4,
|
||||
ChatType.GmLinkshell4 => ChatType.Linkshell4,
|
||||
ChatType.Linkshell5 => ChatType.Linkshell5,
|
||||
ChatType.GmLinkshell5 => ChatType.Linkshell5,
|
||||
ChatType.Linkshell6 => ChatType.Linkshell6,
|
||||
ChatType.GmLinkshell6 => ChatType.Linkshell6,
|
||||
ChatType.Linkshell7 => ChatType.Linkshell7,
|
||||
ChatType.GmLinkshell7 => ChatType.Linkshell7,
|
||||
ChatType.Linkshell8 => ChatType.Linkshell8,
|
||||
ChatType.GmLinkshell8 => ChatType.Linkshell8,
|
||||
ChatType.FreeCompany => ChatType.FreeCompany,
|
||||
ChatType.GmFreeCompany => ChatType.FreeCompany,
|
||||
ChatType.NoviceNetwork => ChatType.NoviceNetwork,
|
||||
ChatType.GmNoviceNetwork => ChatType.NoviceNetwork,
|
||||
ChatType.CustomEmote => ChatType.CustomEmote,
|
||||
ChatType.StandardEmote => ChatType.StandardEmote,
|
||||
ChatType.Yell => ChatType.Yell,
|
||||
ChatType.GmYell => ChatType.Yell,
|
||||
ChatType.GainBuff => ChatType.GainBuff,
|
||||
ChatType.LoseBuff => ChatType.GainBuff,
|
||||
ChatType.GainDebuff => ChatType.GainDebuff,
|
||||
ChatType.LoseDebuff => ChatType.GainDebuff,
|
||||
ChatType.System => ChatType.System,
|
||||
ChatType.Alarm => ChatType.System,
|
||||
ChatType.GlamourNotifications => ChatType.System,
|
||||
ChatType.RetainerSale => ChatType.System,
|
||||
ChatType.PeriodicRecruitmentNotification => ChatType.System,
|
||||
ChatType.Sign => ChatType.System,
|
||||
ChatType.Orchestrion => ChatType.System,
|
||||
ChatType.MessageBook => ChatType.System,
|
||||
ChatType.NpcDialogue => ChatType.NpcDialogue,
|
||||
ChatType.NpcAnnouncement => ChatType.NpcDialogue,
|
||||
ChatType.LootRoll => ChatType.LootRoll,
|
||||
ChatType.RandomNumber => ChatType.LootRoll,
|
||||
ChatType.FreeCompanyAnnouncement => ChatType.FreeCompanyAnnouncement,
|
||||
ChatType.FreeCompanyLoginLogout => ChatType.FreeCompanyAnnouncement,
|
||||
ChatType.PvpTeamAnnouncement => ChatType.PvpTeamAnnouncement,
|
||||
ChatType.PvpTeamLoginLogout => ChatType.PvpTeamAnnouncement,
|
||||
_ => type,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -80,25 +80,25 @@ internal static class InputChannelExt
|
||||
InputChannel.Alliance => "/alliance",
|
||||
InputChannel.Yell => "/yell",
|
||||
InputChannel.Shout => "/shout",
|
||||
InputChannel.FreeCompany => "/freecompany",
|
||||
InputChannel.PvpTeam => "/pvpteam",
|
||||
InputChannel.NoviceNetwork => "/beginner",
|
||||
InputChannel.CrossLinkshell1 => "/cwlinkshell1",
|
||||
InputChannel.CrossLinkshell2 => "/cwlinkshell2",
|
||||
InputChannel.CrossLinkshell3 => "/cwlinkshell3",
|
||||
InputChannel.CrossLinkshell4 => "/cwlinkshell4",
|
||||
InputChannel.CrossLinkshell5 => "/cwlinkshell5",
|
||||
InputChannel.CrossLinkshell6 => "/cwlinkshell6",
|
||||
InputChannel.CrossLinkshell7 => "/cwlinkshell7",
|
||||
InputChannel.CrossLinkshell8 => "/cwlinkshell8",
|
||||
InputChannel.Linkshell1 => "/linkshell1",
|
||||
InputChannel.Linkshell2 => "/linkshell2",
|
||||
InputChannel.Linkshell3 => "/linkshell3",
|
||||
InputChannel.Linkshell4 => "/linkshell4",
|
||||
InputChannel.Linkshell5 => "/linkshell5",
|
||||
InputChannel.Linkshell6 => "/linkshell6",
|
||||
InputChannel.Linkshell7 => "/linkshell7",
|
||||
InputChannel.Linkshell8 => "/linkshell8",
|
||||
InputChannel.FreeCompany => "/fc",
|
||||
InputChannel.PvpTeam => "/pt",
|
||||
InputChannel.NoviceNetwork => "/n",
|
||||
InputChannel.CrossLinkshell1 => "/cwl1",
|
||||
InputChannel.CrossLinkshell2 => "/cwl2",
|
||||
InputChannel.CrossLinkshell3 => "/cwl3",
|
||||
InputChannel.CrossLinkshell4 => "/cwl4",
|
||||
InputChannel.CrossLinkshell5 => "/cwl5",
|
||||
InputChannel.CrossLinkshell6 => "/cwl6",
|
||||
InputChannel.CrossLinkshell7 => "/cwl7",
|
||||
InputChannel.CrossLinkshell8 => "/cwl8",
|
||||
InputChannel.Linkshell1 => "/l1",
|
||||
InputChannel.Linkshell2 => "/l2",
|
||||
InputChannel.Linkshell3 => "/l3",
|
||||
InputChannel.Linkshell4 => "/l4",
|
||||
InputChannel.Linkshell5 => "/l5",
|
||||
InputChannel.Linkshell6 => "/l6",
|
||||
InputChannel.Linkshell7 => "/l7",
|
||||
InputChannel.Linkshell8 => "/l8",
|
||||
InputChannel.ExtraChatLinkshell1 => "/ecl1",
|
||||
InputChannel.ExtraChatLinkshell2 => "/ecl2",
|
||||
InputChannel.ExtraChatLinkshell3 => "/ecl3",
|
||||
@@ -112,7 +112,7 @@ internal static class InputChannelExt
|
||||
|
||||
public static IEnumerable<TextCommand>? TextCommands(this InputChannel channel)
|
||||
{
|
||||
var ids = channel switch
|
||||
uint[] ids = channel switch
|
||||
{
|
||||
InputChannel.Tell => [104, 118],
|
||||
InputChannel.Say => [102],
|
||||
@@ -139,7 +139,7 @@ internal static class InputChannelExt
|
||||
InputChannel.Linkshell6 => [112],
|
||||
InputChannel.Linkshell7 => [113],
|
||||
InputChannel.Linkshell8 => [114],
|
||||
_ => Array.Empty<uint>(),
|
||||
_ => []
|
||||
};
|
||||
|
||||
if (ids.Length == 0)
|
||||
|
||||
Reference in New Issue
Block a user