diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 99d7a13..77b9f2e 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.29.13 + 1.29.14 net8.0-windows enable enable diff --git a/ChatTwo/GameFunctions/GameFunctions.cs b/ChatTwo/GameFunctions/GameFunctions.cs index 14844f4..99ead69 100755 --- a/ChatTwo/GameFunctions/GameFunctions.cs +++ b/ChatTwo/GameFunctions/GameFunctions.cs @@ -1,6 +1,7 @@ using System.Globalization; using System.Runtime.InteropServices; using Dalamud.Game.ClientState.Conditions; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Dalamud.Memory; @@ -61,6 +62,16 @@ internal unsafe class GameFunctions : IDisposable ListCommand(name, world, "blist"); } + internal void AddToMuteList(ulong accountId, ulong contentId, string name, short worldId) + { + AgentMutelist.Instance()->Add(accountId, contentId, name, worldId); + } + + internal void AddToTermsList(SeString content) + { + AgentTermFilter.Instance()->OpenNewFilterWindow(content.EncodeWithNullTerminator()); + } + private void ListCommand(string name, ushort world, string commandName) { var row = Plugin.DataManager.GetExcelSheet().GetRow(world); diff --git a/ChatTwo/Message.cs b/ChatTwo/Message.cs index 4ba93fa..c246198 100755 --- a/ChatTwo/Message.cs +++ b/ChatTwo/Message.cs @@ -60,6 +60,7 @@ internal partial class Message internal Guid Id { get; } = Guid.NewGuid(); internal ulong Receiver { get; } internal ulong ContentId { get; set; } + internal ulong AccountId { get; set; } // 0 if not set internal DateTimeOffset Date { get; } internal ChatCode Code { get; } @@ -77,11 +78,12 @@ internal partial class Message internal Dictionary Height { get; } = new(); internal Dictionary IsVisible { get; } = new(); - internal Message(ulong receiver, ulong contentId, ChatCode code, List sender, List content, SeString senderSource, SeString contentSource) + internal Message(ulong receiver, ulong contentId, ulong accountId, ChatCode code, List sender, List content, SeString senderSource, SeString contentSource) { var extraChatChannel = ExtractExtraChatChannel(contentSource); Receiver = receiver; ContentId = contentId; + AccountId = accountId; Date = DateTimeOffset.UtcNow; Code = code; Sender = sender; @@ -119,7 +121,7 @@ internal partial class Message internal static Message FakeMessage(List content, ChatCode code) { - return new Message(0, 0, code, [], content, new SeString(), new SeString()); + return new Message(0, 0, 0, code, [], content, new SeString(), new SeString()); } internal bool Matches(Dictionary channels, bool allExtraChatChannels, HashSet extraChatChannels) diff --git a/ChatTwo/MessageManager.cs b/ChatTwo/MessageManager.cs index 183ef6c..9104c1c 100644 --- a/ChatTwo/MessageManager.cs +++ b/ChatTwo/MessageManager.cs @@ -196,6 +196,7 @@ internal class MessageManager : IAsyncDisposable { ReceiverId = CurrentContentId, ContentId = 0, + AccountId = 0, Type = type, Timestamp = timestamp, Sender = sender, @@ -222,6 +223,7 @@ internal class MessageManager : IAsyncDisposable return; PendingSync.Last().ContentId = contentId; + PendingSync.Last().AccountId = accountId; } private void ProcessMessage(PendingMessage pendingMessage) @@ -247,7 +249,7 @@ internal class MessageManager : IAsyncDisposable } var contentChunks = ChunkUtil.ToChunks(pendingMessage.Content, ChunkSource.Content, chatCode.Type).ToList(); - var message = new Message(CurrentContentId, pendingMessage.ContentId, chatCode, senderChunks, contentChunks, pendingMessage.Sender, pendingMessage.Content); + var message = new Message(CurrentContentId, pendingMessage.ContentId, pendingMessage.AccountId, chatCode, senderChunks, contentChunks, pendingMessage.Sender, pendingMessage.Content); if (Plugin.Config.DatabaseBattleMessages || !message.Code.IsBattle()) Store.UpsertMessage(message); @@ -331,6 +333,7 @@ internal class MessageManager : IAsyncDisposable { internal ulong ReceiverId { get; set; } internal ulong ContentId { get; set; } // 0 if unknown + internal ulong AccountId { get; set; } // 0 if unknown internal XivChatType Type { get; set; } internal int Timestamp { get; set; } internal SeString Sender { get; set; } diff --git a/ChatTwo/PayloadHandler.cs b/ChatTwo/PayloadHandler.cs index ac61e4d..5bc05fc 100755 --- a/ChatTwo/PayloadHandler.cs +++ b/ChatTwo/PayloadHandler.cs @@ -565,7 +565,7 @@ public sealed class PayloadHandler var leader = (ulong?) party[(int) party.PartyLeaderIndex]?.ContentId; var isLeader = party.Length == 0 || Plugin.ClientState.LocalContentId == leader; var member = party.FirstOrDefault(member => member.Name.TextValue == player.PlayerName && member.World.RowId == world.RowId); - var isInParty = member != default; + var isInParty = member != null; var inInstance = GameFunctions.GameFunctions.IsInInstance(); var inPartyInstance = Sheets.TerritorySheet.GetRow(Plugin.ClientState.TerritoryType).TerritoryIntendedUse.RowId is (41 or 47 or 48 or 52 or 53); if (isLeader) @@ -605,8 +605,22 @@ public sealed class PayloadHandler if (!isFriend && ImGui.Selectable(Language.Context_SendFriendRequest)) LogWindow.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId); - if (ImGui.Selectable(Language.Context_AddToBlacklist)) - LogWindow.Plugin.Functions.AddToBlacklist(player.PlayerName, (ushort) world.RowId); + using var menuBlockFunctions = ImGuiUtil.Menu(Language.Context_BlockFunctions); + if (menuBlockFunctions.Success) + { + if (ImGui.Selectable(Language.Context_AddToBlacklist)) + LogWindow.Plugin.Functions.AddToBlacklist(player.PlayerName, (ushort)world.RowId); + + if (chunk.Message != null) + { + var message = chunk.Message; + if (ImGui.Selectable(Language.Context_AddToMuteList)) + LogWindow.Plugin.Functions.AddToMuteList(message.AccountId, message.ContentId, player.PlayerName, (short) world.RowId); + + if (ImGui.Selectable(Language.Context_AddToTermsFilter)) + LogWindow.Plugin.Functions.AddToTermsList(message.ContentSource); + } + } if (GameFunctions.GameFunctions.IsMentor() && ImGui.Selectable(Language.Context_InviteToNoviceNetwork)) GameFunctions.Context.InviteToNoviceNetwork(player.PlayerName, (ushort) world.RowId); diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 85d3a3e..227769a 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1094,6 +1094,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Register to Mute List. + /// + internal static string Context_AddToMuteList { + get { + return ResourceManager.GetString("Context_AddToMuteList", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add to Term Filters. + /// + internal static string Context_AddToTermsFilter { + get { + return ResourceManager.GetString("Context_AddToTermsFilter", resourceCulture); + } + } + /// /// Looks up a localized string similar to View Adventurer Plate. /// @@ -1112,6 +1130,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Block Functions. + /// + internal static string Context_BlockFunctions { + get { + return ResourceManager.GetString("Context_BlockFunctions", resourceCulture); + } + } + /// /// Looks up a localized string similar to Copy. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 218ea20..b1bc373 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -679,6 +679,9 @@ Invite to Party + + Block Functions + Same world @@ -697,6 +700,12 @@ Add to Blacklist + + Register to Mute List + + + Add to Term Filters + Invite to Novice Network