From 97a8b96326020459f5ea7ab306cc645a67626b75 Mon Sep 17 00:00:00 2001 From: Infi Date: Sat, 14 Dec 2024 14:54:20 +0100 Subject: [PATCH] - Display name even if invalid channel is selected - Add NoMove & NoResize to tabs --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/Configuration.cs | 5 +++++ ChatTwo/GameFunctions/Chat.cs | 12 +++++------- ChatTwo/Resources/Language.Designer.cs | 4 ++-- ChatTwo/Resources/Language.ca.resx | 8 +++++++- ChatTwo/Resources/Language.de.resx | 8 +++++++- ChatTwo/Resources/Language.es.resx | 8 +++++++- ChatTwo/Resources/Language.fr.resx | 8 +++++++- ChatTwo/Resources/Language.it.resx | 8 +++++++- ChatTwo/Resources/Language.ja.resx | 8 +++++++- ChatTwo/Resources/Language.ko.resx | 8 +++++++- ChatTwo/Resources/Language.nl.resx | 8 +++++++- ChatTwo/Resources/Language.pt-BR.resx | 8 +++++++- ChatTwo/Resources/Language.resx | 6 ++++++ ChatTwo/Resources/Language.ro.resx | 8 +++++++- ChatTwo/Resources/Language.ru.resx | 8 +++++++- ChatTwo/Resources/Language.sv.resx | 8 +++++++- ChatTwo/Resources/Language.zh-Hans.resx | 8 +++++++- ChatTwo/Resources/Language.zh-Hant.resx | 8 +++++++- ChatTwo/Ui/ChatLogWindow.cs | 24 +++++++++++------------- ChatTwo/Ui/Debugger.cs | 23 +++++++++++++++++++++++ ChatTwo/Ui/Popout.cs | 6 ++++++ ChatTwo/Ui/Settings.cs | 2 +- ChatTwo/Ui/SettingsTabs/ChatLog.cs | 2 +- ChatTwo/Ui/SettingsTabs/Tabs.cs | 13 ++++++++++++- 25 files changed, 171 insertions(+), 40 deletions(-) diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index c12cce7..dd91d5d 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.29.11 + 1.29.12 net8.0-windows enable enable diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 7f7678b..a64accf 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -237,6 +237,9 @@ internal class Tab public float Opacity = 100f; public bool InputDisabled; + public bool CanMove = true; + public bool CanResize = true; + [NonSerialized] public uint Unread; [NonSerialized] public long LastActivity; [NonSerialized] public MessageList Messages = new(); @@ -280,6 +283,8 @@ internal class Tab Identifier = Identifier, InputDisabled = InputDisabled, CurrentChannel = CurrentChannel, + CanMove = CanMove, + CanResize = CanResize, }; } diff --git a/ChatTwo/GameFunctions/Chat.cs b/ChatTwo/GameFunctions/Chat.cs index dcd0f2e..44176ac 100755 --- a/ChatTwo/GameFunctions/Chat.cs +++ b/ChatTwo/GameFunctions/Chat.cs @@ -540,7 +540,7 @@ internal sealed unsafe class Chat : IDisposable internal string AbbreviatePlayerName(string playerName) { - if (LastPlayerNameDisplayTypeRefresh + 5 * 1000 < Environment.TickCount64) + if (LastPlayerNameDisplayTypeRefresh + 5_000 < Environment.TickCount64) { LastPlayerNameDisplayTypeRefresh = Environment.TickCount64; CurrentPlayerNameDisplayType = GetNameDisplayType(); @@ -552,14 +552,12 @@ internal sealed unsafe class Chat : IDisposable var split = playerName.Split(' '); if (split.Length != 2) return playerName; + return CurrentPlayerNameDisplayType switch { - PlayerNameDisplayType.SurnameAbbreviated => - $"{split.First()} {split.Last().FirstOrDefault('A')}.", - PlayerNameDisplayType.ForenameAbbreviated => - $"{split.First().FirstOrDefault('A')}. {split.Last()}", - PlayerNameDisplayType.Initials => - $"{split.First().FirstOrDefault('A')}. {split.Last().FirstOrDefault('A')}.", + PlayerNameDisplayType.SurnameAbbreviated => $"{split.First()} {split.Last().FirstOrDefault('A')}.", + PlayerNameDisplayType.ForenameAbbreviated => $"{split.First().FirstOrDefault('A')}. {split.Last()}", + PlayerNameDisplayType.Initials => $"{split.First().FirstOrDefault('A')}. {split.Last().FirstOrDefault('A')}.", _ => playerName }; } diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 8c70b88..15fac79 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1914,7 +1914,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Allow moving chat. + /// Looks up a localized string similar to Allow moving window. /// internal static string Options_CanMove_Name { get { @@ -1923,7 +1923,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Allow resizing chat. + /// Looks up a localized string similar to Allow resizing window. /// internal static string Options_CanResize_Name { get { diff --git a/ChatTwo/Resources/Language.ca.resx b/ChatTwo/Resources/Language.ca.resx index ffecb1c..d2bc941 100644 --- a/ChatTwo/Resources/Language.ca.resx +++ b/ChatTwo/Resources/Language.ca.resx @@ -187,6 +187,12 @@ Permetre canviar la mida del xat + + Allow moving window + + + Allow resizing window + Mostrar la barra del títol a la part superior esquerre del xat @@ -1286,7 +1292,7 @@ Date - Tipus de xat + Channel Sender diff --git a/ChatTwo/Resources/Language.de.resx b/ChatTwo/Resources/Language.de.resx index a75baa1..4e54d5a 100644 --- a/ChatTwo/Resources/Language.de.resx +++ b/ChatTwo/Resources/Language.de.resx @@ -187,6 +187,12 @@ Chatfenstergröße anpassen erlauben + + Allow moving window + + + Allow resizing window + Titelleiste für den Chat anzeigen @@ -1287,7 +1293,7 @@ Sie wurden gewarnt. Datum / Uhrzeit - Chat Typ + Channel Absender diff --git a/ChatTwo/Resources/Language.es.resx b/ChatTwo/Resources/Language.es.resx index 09e4bca..c09245c 100644 --- a/ChatTwo/Resources/Language.es.resx +++ b/ChatTwo/Resources/Language.es.resx @@ -187,6 +187,12 @@ Permitir cambiar el tamaño del chat + + Allow moving window + + + Allow resizing window + Mostrar la barra de título en la parte superior izquierda del chat @@ -1286,7 +1292,7 @@ Fecha - Tipo de chat + Channel Remitente diff --git a/ChatTwo/Resources/Language.fr.resx b/ChatTwo/Resources/Language.fr.resx index 8067203..398fdd0 100644 --- a/ChatTwo/Resources/Language.fr.resx +++ b/ChatTwo/Resources/Language.fr.resx @@ -187,6 +187,12 @@ Permettre le redimensionnement du chat + + Allow moving window + + + Allow resizing window + Afficher la barre de titre du chat @@ -1286,7 +1292,7 @@ Date - Type de Discussions + Channel Expéditeur diff --git a/ChatTwo/Resources/Language.it.resx b/ChatTwo/Resources/Language.it.resx index 0ee2b6c..3c83493 100644 --- a/ChatTwo/Resources/Language.it.resx +++ b/ChatTwo/Resources/Language.it.resx @@ -187,6 +187,12 @@ Consenti il ridimensionamento della chat + + Allow moving window + + + Allow resizing window + Show title bar for chat @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.ja.resx b/ChatTwo/Resources/Language.ja.resx index f23c881..e14b46e 100644 --- a/ChatTwo/Resources/Language.ja.resx +++ b/ChatTwo/Resources/Language.ja.resx @@ -187,6 +187,12 @@ Allow resizing chat + + Allow moving window + + + Allow resizing window + Show title bar for chat @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.ko.resx b/ChatTwo/Resources/Language.ko.resx index 2bc9d88..933e003 100644 --- a/ChatTwo/Resources/Language.ko.resx +++ b/ChatTwo/Resources/Language.ko.resx @@ -187,6 +187,12 @@ 채팅창 크기 조절 허용 + + Allow moving window + + + Allow resizing window + 채팅창에 타이틀바 표시 @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.nl.resx b/ChatTwo/Resources/Language.nl.resx index d81d1e6..82798cc 100644 --- a/ChatTwo/Resources/Language.nl.resx +++ b/ChatTwo/Resources/Language.nl.resx @@ -187,6 +187,12 @@ Grootte van chat wijzigen toestaan + + Allow moving window + + + Allow resizing window + Titelbalk voor chat weergeven @@ -1286,7 +1292,7 @@ Datum - Chat Type + Channel Afzender diff --git a/ChatTwo/Resources/Language.pt-BR.resx b/ChatTwo/Resources/Language.pt-BR.resx index 8c70615..bd9cd70 100644 --- a/ChatTwo/Resources/Language.pt-BR.resx +++ b/ChatTwo/Resources/Language.pt-BR.resx @@ -187,6 +187,12 @@ Permitir redimensionar o bate-papo + + Allow moving window + + + Allow resizing window + Mostrar barra de título para bate-papo @@ -1286,7 +1292,7 @@ Data - Chat Type + Channel Remetente diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 5abd122..f1a10a2 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -187,6 +187,12 @@ Allow resizing chat + + Allow moving window + + + Allow resizing window + Show title bar for chat diff --git a/ChatTwo/Resources/Language.ro.resx b/ChatTwo/Resources/Language.ro.resx index 33ec492..6c6abb5 100644 --- a/ChatTwo/Resources/Language.ro.resx +++ b/ChatTwo/Resources/Language.ro.resx @@ -187,6 +187,12 @@ Permite redimensionarea chat-ului + + Allow moving window + + + Allow resizing window + Afișează bara de titlu pentru chat @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.ru.resx b/ChatTwo/Resources/Language.ru.resx index 79b7f56..b320087 100644 --- a/ChatTwo/Resources/Language.ru.resx +++ b/ChatTwo/Resources/Language.ru.resx @@ -187,6 +187,12 @@ Разрешить изменение размера окна чата + + Allow moving window + + + Allow resizing window + Показывать заголовок для окна чата @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.sv.resx b/ChatTwo/Resources/Language.sv.resx index b252664..ae2fe74 100644 --- a/ChatTwo/Resources/Language.sv.resx +++ b/ChatTwo/Resources/Language.sv.resx @@ -187,6 +187,12 @@ Tillåt att ändra chattfönstrets storlek + + Allow moving window + + + Allow resizing window + Visa titelfältet för chattfönstret @@ -1286,7 +1292,7 @@ Date - Chat Type + Channel Sender diff --git a/ChatTwo/Resources/Language.zh-Hans.resx b/ChatTwo/Resources/Language.zh-Hans.resx index 3071f5b..731c876 100644 --- a/ChatTwo/Resources/Language.zh-Hans.resx +++ b/ChatTwo/Resources/Language.zh-Hans.resx @@ -187,6 +187,12 @@ 允许调整聊天窗口大小 + + Allow moving window + + + Allow resizing window + 显示聊天窗口标题栏 @@ -1286,7 +1292,7 @@ 日期 - 对话类型 + Channel 发送人 diff --git a/ChatTwo/Resources/Language.zh-Hant.resx b/ChatTwo/Resources/Language.zh-Hant.resx index 2d03ba7..7851104 100644 --- a/ChatTwo/Resources/Language.zh-Hant.resx +++ b/ChatTwo/Resources/Language.zh-Hant.resx @@ -187,6 +187,12 @@ 允許調整聊天窗口大小 + + Allow moving window + + + Allow resizing window + 顯示聊天視窗標題欄 @@ -1287,7 +1293,7 @@ 日期 - Chat Type + Channel 發送者 diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 2322eda..cef664e 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -813,8 +813,7 @@ public sealed class ChatLogWindow : Window { if (!string.IsNullOrWhiteSpace(activeTab.CurrentChannel.TellTarget.Name) && activeTab.CurrentChannel.TellTarget.World != 0) { - // Note: don't use HidePlayerInString here because - // abbreviation settings do not affect this. + // Note: don't use HidePlayerInString here because abbreviation settings do not affect this. var playerName = HashPlayer(activeTab.CurrentChannel.TellTarget.Name, activeTab.CurrentChannel.TellTarget.World); var world = Sheets.WorldSheet.TryGetRow(activeTab.CurrentChannel.TellTarget.World, out var worldRow) ? worldRow.Name.ExtractText() @@ -830,14 +829,15 @@ public sealed class ChatLogWindow : Window } else { - // We still need to censor the name if we couldn't read - // valid data. + // We still need to censor the name if we couldn't read valid data. channelNameChunks = [new TextChunk(ChunkSource.None, null, "Tell")]; } } else { - channelNameChunks = activeTab.CurrentChannel.Name.ToArray(); + channelNameChunks = activeTab.CurrentChannel.Name.Count > 0 + ? activeTab.CurrentChannel.Name.ToArray() + : [new TextChunk(ChunkSource.None, null, activeTab.CurrentChannel.Channel.ToChatType().Name())]; } return channelNameChunks; @@ -913,8 +913,8 @@ public sealed class ChatLogWindow : Window Plugin.Functions.Chat.SendTellUsingCommandInner(tellBytes); TellSpecial = false; - activeTab.CurrentChannel.ResetTempChannel(); + activeTab.CurrentChannel.ResetTempChannel(); Chat = string.Empty; return; } @@ -933,6 +933,7 @@ public sealed class ChatLogWindow : Window ChatBox.SendMessageUnsafe(tellBytes); + activeTab.CurrentChannel.ResetTempChannel(); Chat = string.Empty; return; } @@ -950,9 +951,7 @@ public sealed class ChatLogWindow : Window Plugin.Functions.Chat.SendTell(reason, target.ContentId, target.Name, (ushort) world.RowId, tellBytes, trimmed); } - if (activeTab.CurrentChannel.TempChannel is InputChannel.Tell) - activeTab.CurrentChannel.TempTellTarget = null; - + activeTab.CurrentChannel.ResetTempChannel(); Chat = string.Empty; return; } @@ -969,6 +968,7 @@ public sealed class ChatLogWindow : Window ChatBox.SendMessageUnsafe(bytes); } + activeTab.CurrentChannel.ResetTempChannel(); Chat = string.Empty; } @@ -1315,6 +1315,8 @@ public sealed class ChatLogWindow : Window if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.ChatLog_Tabs_Delete)) { tabs.RemoveAt(i); + Plugin.WantedTab = 0; + anyChanged = true; } @@ -1746,10 +1748,6 @@ public sealed class ChatLogWindow : Window var content = text.Content ?? ""; if (ScreenshotMode) { - // TODO: the result of hashing the player name should be cached. - // Currently we recalculate the abbreviated player names, the - // hashes and the string replacements every frame when they - // never change. if (chunk.Link is PlayerPayload playerPayload) content = HidePlayerInString(content, playerPayload.PlayerName, playerPayload.World.RowId); else if (Plugin.ClientState.LocalPlayer is { } player) diff --git a/ChatTwo/Ui/Debugger.cs b/ChatTwo/Ui/Debugger.cs index 82eaa5b..5ea4f40 100644 --- a/ChatTwo/Ui/Debugger.cs +++ b/ChatTwo/Ui/Debugger.cs @@ -1,7 +1,11 @@ using System.Numerics; +using ChatTwo.Code; +using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using ImGuiNET; +using Lumina.Text.ReadOnly; namespace ChatTwo.Ui; @@ -45,9 +49,28 @@ public class DebuggerWindow : Window if (ImGui.Selectable($"Agent Address: {agent:X}")) ImGui.SetClipboardText(agent.ToString("X")); + ImGuiHelpers.ScaledDummy(5.0f); + ImGui.TextUnformatted($"Handle Tooltips: {ChatLogWindow.PayloadHandler.HandleTooltips}"); ImGui.TextUnformatted($"Hovered Item: {ChatLogWindow.PayloadHandler.HoveredItem}"); ImGui.TextUnformatted($"Hover Counter: {ChatLogWindow.PayloadHandler.HoverCounter}"); ImGui.TextUnformatted($"Last Hover Counter: {ChatLogWindow.PayloadHandler.LastHoverCounter}"); + + ImGuiHelpers.ScaledDummy(5.0f); + + ImGui.TextColored(ImGuiColors.DalamudOrange, "Current Tab"); + ImGui.TextUnformatted($"Name: {Plugin.CurrentTab.Name}"); + ImGui.TextUnformatted($"Channel: {Plugin.CurrentTab.CurrentChannel.Channel.ToChatType().Name()}"); + ImGui.TextUnformatted($"Tell Target: {Plugin.CurrentTab.CurrentChannel.TellTarget?.ToTargetString() ?? "Null"}"); + ImGui.TextUnformatted($"Use Temp? {Plugin.CurrentTab.CurrentChannel.UseTempChannel}"); + ImGui.TextUnformatted($"Temp Channel: {Plugin.CurrentTab.CurrentChannel.TempChannel.ToChatType().Name()}"); + ImGui.TextUnformatted($"Temp Tell Target: {Plugin.CurrentTab.CurrentChannel.TempTellTarget?.ToTargetString() ?? "Null"}"); + ImGui.TextUnformatted($"Name Set? {Plugin.CurrentTab.CurrentChannel.Name.Count > 0}"); + ImGui.TextUnformatted($"Name {string.Join(" ", Plugin.CurrentTab.CurrentChannel.Name.Select(c => c.StringValue()))}"); + + ImGuiHelpers.ScaledDummy(5.0f); + + ImGui.TextColored(ImGuiColors.DalamudOrange, "Vanilla Chat"); + ImGui.TextUnformatted($"Channel: {new ReadOnlySeString(AgentChatLog.Instance()->ChannelLabel).ExtractText()}"); } } diff --git a/ChatTwo/Ui/Popout.cs b/ChatTwo/Ui/Popout.cs index b713c06..e6c9d98 100644 --- a/ChatTwo/Ui/Popout.cs +++ b/ChatTwo/Ui/Popout.cs @@ -62,6 +62,12 @@ internal class Popout : Window if (!Plugin.Config.ShowPopOutTitleBar) Flags |= ImGuiWindowFlags.NoTitleBar; + if (!Tab.CanMove) + Flags |= ImGuiWindowFlags.NoMove; + + if (!Tab.CanResize) + Flags |= ImGuiWindowFlags.NoResize; + if (!ChatLogWindow.PopOutDocked[Idx]) { var alpha = Tab.IndependentOpacity ? Tab.Opacity : Plugin.Config.WindowAlpha; diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index b93efae..190e11b 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -39,7 +39,7 @@ public sealed class SettingsWindow : Window new Preview(Mutable), new Fonts(Mutable), new ChatColours(Plugin, Mutable), - new Tabs(Mutable), + new Tabs(Plugin, Mutable), new Database(Plugin, Mutable), new Webinterface(Plugin, Mutable), new Miscellaneous(Mutable), diff --git a/ChatTwo/Ui/SettingsTabs/ChatLog.cs b/ChatTwo/Ui/SettingsTabs/ChatLog.cs index 46455c8..50d432d 100644 --- a/ChatTwo/Ui/SettingsTabs/ChatLog.cs +++ b/ChatTwo/Ui/SettingsTabs/ChatLog.cs @@ -86,8 +86,8 @@ internal sealed class ChatLog : ISettingsTab ImGui.Spacing(); ImGui.TextUnformatted(Language.Options_AdjustPosition_Name); - var pos = Plugin.ChatLogWindow.LastWindowPos; ImGui.SetNextItemWidth(-1); + var pos = Plugin.ChatLogWindow.LastWindowPos; if (ImGui.DragFloat2($"##{Language.Options_AdjustPosition_Name}", ref pos, 1, 0, float.MaxValue, "%.0fpx")) Plugin.ChatLogWindow.Position = pos; ImGuiUtil.WarningText(Language.Options_AdjustPosition_Warning); diff --git a/ChatTwo/Ui/SettingsTabs/Tabs.cs b/ChatTwo/Ui/SettingsTabs/Tabs.cs index b152055..86945ec 100755 --- a/ChatTwo/Ui/SettingsTabs/Tabs.cs +++ b/ChatTwo/Ui/SettingsTabs/Tabs.cs @@ -9,14 +9,16 @@ namespace ChatTwo.Ui.SettingsTabs; internal sealed class Tabs : ISettingsTab { + private readonly Plugin Plugin; private Configuration Mutable { get; } public string Name => Language.Options_Tabs_Tab + "###tabs-tabs"; private int ToOpen = -2; - internal Tabs(Configuration mutable) + internal Tabs(Plugin plugin, Configuration mutable) { + Plugin = plugin; Mutable = mutable; } @@ -89,6 +91,12 @@ internal sealed class Tabs : ISettingsTab 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); + + ImGuiUtil.OptionCheckbox(ref tab.CanMove, Language.Options_CanMove_Name); + ImGui.Spacing(); + + ImGuiUtil.OptionCheckbox(ref tab.CanResize, Language.Options_CanResize_Name); + ImGui.Spacing(); } using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name())) @@ -130,7 +138,10 @@ internal sealed class Tabs : ISettingsTab } if (toRemove > -1) + { Mutable.Tabs.RemoveAt(toRemove); + Plugin.WantedTab = 0; + } if (doOpens) ToOpen = -2;