- 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:
Infi
2026-04-30 02:59:58 +02:00
parent 68810e23c1
commit b4cb8b25ec
56 changed files with 1286 additions and 616 deletions
+17 -11
View File
@@ -639,8 +639,7 @@ public sealed class ChatLogWindow : Window
{
ImGui.SetNextWindowSize(new Vector2(500 * ImGuiHelpers.GlobalScale, -1));
using var tooltip = ImRaii.Tooltip();
if (tooltip)
Plugin.InputPreview.DrawPreview();
Plugin.InputPreview.DrawPreview();
}
if (ImGui.IsItemDeactivated())
@@ -775,7 +774,7 @@ public sealed class ChatLogWindow : Window
if (!currentChannel.SequenceEqual(PreviousChannel))
{
PreviousChannel = currentChannel;
Plugin.ServerCore?.SendChannelSwitch(currentChannel);
Plugin.ServerCore.SendChannelSwitch(currentChannel);
}
DrawChunks(currentChannel);
@@ -820,12 +819,19 @@ public sealed class ChatLogWindow : Window
}
else if (activeTab is { Channel: { } channel })
{
// We cannot lookup ExtraChat channel names from index over
// IPC so we just don't show the name if it's the tabs channel.
//
// We don't call channel.ToChatType().Name() as it has the
// long name as used in the settings window.
channelNameChunks = [new TextChunk(ChunkSource.None, null, channel.IsExtraChatLinkshell() ? $"ECLS [{channel.LinkshellIndex() + 1}]" : channel.ToChatType().Name())];
if (channel == InputChannel.Tell && activeTab.TellTarget.IsSet())
{
channelNameChunks = GenerateTellTargetName(activeTab.TellTarget);
}
else
{
// We cannot lookup ExtraChat channel names from index over
// IPC so we just don't show the name if it's the tabs channel.
//
// We don't call channel.ToChatType().Name() as it has the
// long name as used in the settings window.
channelNameChunks = [new TextChunk(ChunkSource.None, null, channel.IsExtraChatLinkshell() ? $"ECLS [{channel.LinkshellIndex() + 1}]" : channel.ToChatType().Name())];
}
}
else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _))
{
@@ -912,7 +918,7 @@ public sealed class ChatLogWindow : Window
playerName = HashPlayer(tellTarget.Name, tellTarget.World);
var world = Sheets.WorldSheet.TryGetRow(tellTarget.World, out var worldRow)
? worldRow.Name.ExtractText()
? worldRow.Name.ToString()
: "???";
return
@@ -954,7 +960,7 @@ public sealed class ChatLogWindow : Window
if (!trimmed.StartsWith('/'))
{
var target = activeTab.CurrentChannel.TempTellTarget ?? activeTab.CurrentChannel.TellTarget;
var target = activeTab.TellTarget.IsSet() ? activeTab.TellTarget : activeTab.CurrentChannel.TempTellTarget ?? activeTab.CurrentChannel.TellTarget;
if (target != null)
{
// ContentId 0 is a case where we can't directly send messages, so we send a /tell formatted message and let the game handle it
+13 -13
View File
@@ -35,7 +35,7 @@ public class DbViewer : Window
private int CurrentPage = 1;
private string SimpleSearchTerm = "";
private bool OnlyCurrentCharacter = true;
private readonly Dictionary<ChatType, ChatSource> ChatCodes;
private readonly Dictionary<ChatType, (ChatSource, ChatSource)> SelectedChannels;
private bool IsProcessing;
private long ProcessingStart = Environment.TickCount64;
@@ -58,12 +58,12 @@ public class DbViewer : Window
public DbViewer(Plugin plugin) : base("DBViewer###chat2-dbviewer")
{
Plugin = plugin;
ChatCodes = TabsUtil.MostlyPlayer;
SelectedChannels = TabsUtil.MostlyPlayer;
DateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
DateTimeFormat = "ddd, dd MMM yyy HH:mm:ss";
LastProcessed = (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, ChatCodes.Count);
LastProcessed = (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, SelectedChannels.Count);
DateReset();
SizeConstraints = new WindowSizeConstraints
@@ -196,7 +196,7 @@ public class DbViewer : Window
if (DateWidget.Validate(MinimalDate, ref AfterDate, ref BeforeDate))
DateRefresh();
if (!IsProcessing && LastProcessed != (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, ChatCodes.Count))
if (!IsProcessing && LastProcessed != (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, SelectedChannels.Count))
{
// Page hasn't changed, so we reset it back to 1
if (LastProcessed.Page == CurrentPage)
@@ -205,13 +205,13 @@ public class DbViewer : Window
AdjustDates();
IsProcessing = true;
ProcessingStart = Environment.TickCount64 + 1_000; // + 1 second
LastProcessed = (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, ChatCodes.Count);
LastProcessed = (AfterDate, BeforeDate, CurrentPage, OnlyCurrentCharacter, SelectedChannels.Count);
Task.Run(() =>
{
try
{
ulong? character = OnlyCurrentCharacter ? Plugin.PlayerState.ContentId : null;
var channels = ChatCodes.Select(c => (uint) c.Key).ToArray();
var channels = SelectedChannels.Select(pair => (byte) pair.Key).ToArray();
// We only want to fetch count if this is the first page
if (CurrentPage == 1)
@@ -263,7 +263,7 @@ public class DbViewer : Window
ImGui.TableNextColumn();
var pos = ImGui.GetCursorPos();
ImGuiUtil.CenterText($"{message.Code.Raw}");
ImGuiUtil.CenterText($"{(byte)message.Code.Type}");
ImGui.SetCursorPos(pos);
ImGui.Dummy(columnWidth);
if (ImGui.IsItemHovered())
@@ -303,13 +303,13 @@ public class DbViewer : Window
if (type.IsGm())
continue;
var enabled = ChatCodes.ContainsKey(type);
var enabled = SelectedChannels.ContainsKey(type);
if (ImGui.Checkbox($"##{type.Name()}", ref enabled))
{
if (enabled)
ChatCodes[type] = ChatSourceExt.All;
SelectedChannels[type] = (ChatSourceExt.All, ChatSourceExt.All);
else
ChatCodes.Remove(type);
SelectedChannels.Remove(type);
}
ImGui.SameLine();
@@ -359,7 +359,7 @@ public class DbViewer : Window
try
{
ulong? character = OnlyCurrentCharacter ? Plugin.PlayerState.ContentId : null;
var channels = ChatCodes.Select(c => (uint)c.Key).ToArray();
var channels = SelectedChannels.Select(pair => (byte)pair.Key).ToArray();
var rangeMessageEnumerator = Plugin.MessageManager.Store.GetDateRange(AfterDate, BeforeDate, channels, character);
var messageHistory = rangeMessageEnumerator.ToArray();
@@ -426,7 +426,7 @@ public class DbViewer : Window
{
try
{
var channels = ChatCodes.Select(c => (uint)c.Key).ToArray();
var channels = SelectedChannels.Select(pair => (byte)pair.Key).ToArray();
var rangeMessageEnumerator = Plugin.MessageManager.Store.GetDateRange(AfterDate, BeforeDate, channels);
var messageHistory = rangeMessageEnumerator.ToArray();
@@ -536,7 +536,7 @@ public class DbViewer : Window
color ??= 0;
var userContent = text.Content ?? string.Empty;
var userContent = text.Content;
if (Plugin.ChatLogWindow.ScreenshotMode)
{
if (chunk.Link is PlayerPayload playerPayload)
+1 -1
View File
@@ -71,7 +71,7 @@ public partial class InputPreview : Window
AutoTranslate.ReplaceWithPayload(ref bytes);
var chunks = ChunkUtil.ToChunks(SeString.Parse(bytes), ChunkSource.Content, ChatType.Say).ToList();
PreviewMessage = Message.FakeMessage(chunks, new ChatCode((ushort)XivChatType.Say));
PreviewMessage = Message.FakeMessage(chunks, new ChatCode(XivChatType.Say, 0, 0));
PreviewMessage.DecodeTextParam();
}
HasEvaluation = !Plugin.Config.OnlyPreviewIf || PreviewMessage.Content.Count > 1;
+3 -2
View File
@@ -7,6 +7,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
namespace ChatTwo.Ui.SettingsTabs;
@@ -180,17 +181,17 @@ internal sealed class Database : ISettingsTab
.Build();
var contentChunks = ChunkUtil.ToChunks(contentSource, ChunkSource.Content, ChatType.Debug).ToList();
var chatCode = new ChatCode(XivChatType.Say, 0, 0);
messages.Add(new Message(
Guid.NewGuid(),
Plugin.MessageManager.CurrentContentId,
Plugin.MessageManager.CurrentContentId,
DateTimeOffset.UtcNow,
new ChatCode(10),
chatCode,
senderChunks,
contentChunks,
senderSource,
contentSource,
new SortCode(ChatType.Debug, ChatSource.Self),
Guid.Empty
));
}
+5 -8
View File
@@ -1,4 +1,3 @@
using ChatTwo.Code;
using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Interface.Utility.Raii;
@@ -67,26 +66,24 @@ internal sealed class Display : ISettingsTab
using var channelTree = ImRaii.TreeNode(Language.Options_InactivityHideChannels_Name);
if (channelTree.Success)
{
if (ImGuiUtil.CtrlShiftButton(Language.Options_InactivityHideChannels_All_Label,
Language.Options_InactivityHideChannels_Button_Tooltip))
if (ImGuiUtil.CtrlShiftButton(Language.Options_InactivityHideChannels_All_Label, Language.Options_InactivityHideChannels_Button_Tooltip))
{
Mutable.InactivityHideChannels = TabsUtil.AllChannels();
Mutable.InactivityHideChannelsV2 = TabsUtil.AllChannels();
Mutable.InactivityHideExtraChatAll = true;
Mutable.InactivityHideExtraChatChannels = [];
}
ImGui.SameLine();
if (ImGuiUtil.CtrlShiftButton(Language.Options_InactivityHideChannels_None_Label,
Language.Options_InactivityHideChannels_Button_Tooltip))
if (ImGuiUtil.CtrlShiftButton(Language.Options_InactivityHideChannels_None_Label, Language.Options_InactivityHideChannels_Button_Tooltip))
{
Mutable.InactivityHideChannels = new Dictionary<ChatType, ChatSource>();
Mutable.InactivityHideChannelsV2 = [];
Mutable.InactivityHideExtraChatAll = false;
Mutable.InactivityHideExtraChatChannels = [];
}
ImGui.Spacing();
ImGuiUtil.ChannelSelector(Language.Options_Tabs_Channels, Mutable.InactivityHideChannels!);
ImGuiUtil.ChannelSelector(Language.Options_Tabs_Channels, Mutable.InactivityHideChannelsV2);
ImGuiUtil.ExtraChatSelector(Language.Options_Tabs_ExtraChatChannels,
ref Mutable.InactivityHideExtraChatAll, Mutable.InactivityHideExtraChatChannels);
}
+3 -3
View File
@@ -39,7 +39,7 @@ public class Fonts : ISettingsTab
});
ImGui.SameLine();
if (ImGui.Button("Reset##global"))
Mutable.GlobalFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), SizePt = 12.75f };
Mutable.GlobalFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkRegular), SizePt = 12.75f };
ImGuiUtil.HelpText(string.Format(Language.Options_Font_Description, Plugin.PluginName));
ImGuiUtil.WarningText(Language.Options_Font_Warning);
@@ -54,7 +54,7 @@ public class Fonts : ISettingsTab
});
ImGui.SameLine();
if (ImGui.Button("Reset##japanese"))
Mutable.JapaneseFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium), SizePt = 12.75f };
Mutable.JapaneseFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkMedium), SizePt = 12.75f };
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
ImGui.Spacing();
@@ -69,7 +69,7 @@ public class Fonts : ISettingsTab
if (ImGui.Button("Reset##italic"))
{
Mutable.ItalicEnabled = false;
Mutable.ItalicFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), SizePt = 12.75f };
Mutable.ItalicFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkRegular), SizePt = 12.75f };
}
ImGuiUtil.HelpText(string.Format(Language.Options_Italic_Description, Plugin.PluginName));
+69 -9
View File
@@ -4,6 +4,7 @@ using ChatTwo.Util;
using Dalamud.Interface;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Objects.SubKinds;
namespace ChatTwo.Ui.SettingsTabs;
@@ -43,6 +44,9 @@ internal sealed class Tabs : ISettingsTab
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event)))
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Tell)))
Mutable.Tabs.Add(TabsUtil.VanillaTellExclusive);
}
}
@@ -122,7 +126,7 @@ internal sealed class Tabs : ISettingsTab
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name()))
{
if (combo)
if (combo.Success)
{
foreach (var mode in Enum.GetValues<UnreadMode>())
{
@@ -142,19 +146,75 @@ internal sealed class Tabs : ISettingsTab
if (!tab.InputDisabled)
{
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
using var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input);
if (combo)
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input))
{
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
tab.Channel = null;
if (combo.Success)
{
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
tab.Channel = null;
foreach (var channel in Enum.GetValues<InputChannel>())
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
tab.Channel = channel;
foreach (var channel in Enum.GetValues<InputChannel>())
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
tab.Channel = channel;
}
}
ImGui.Checkbox(Language.Options_Tabs_SenderMessages, ref tab.AllSenderMessages);
ImGuiUtil.HelpText(Language.Options_Help_SenderMessages);
var player = Plugin.ObjectTable.LocalPlayer;
if (tab.Channel == InputChannel.Tell && player != null)
{
var worlds = Sheets.WorldsOnDatacenter(player).OrderByDescending(world => world.DataCenter.RowId).ThenBy(world => world.Name.ToString()).ToList();
using (ImRaii.ItemWidth(ImGui.GetWindowWidth() / 3f))
{
ImGui.Text(Language.Options_Header_Target);
ImGui.SameLine();
var name = tab.TellTarget.Name;
if (ImGui.InputText("##targetInput", ref name, 21))
tab.TellTarget.Name = name;
ImGui.SameLine();
var selectedWorld = worlds.FindIndex(world => world.RowId == tab.TellTarget.World);
if (selectedWorld == -1)
selectedWorld = 0;
using (var combo = ImRaii.Combo("###player-world", worlds[selectedWorld].Name.ToString()))
{
if (combo.Success)
{
var lastDc = worlds.First().DataCenter.RowId;
foreach (var (idx, world) in worlds.Index())
{
if (ImGui.Selectable(world.Name.ToString(), selectedWorld == idx))
{
selectedWorld = idx;
tab.TellTarget.World = worlds[selectedWorld].RowId;
}
if (lastDc == world.DataCenter.RowId)
continue;
lastDc = world.DataCenter.RowId;
ImGui.Separator();
}
}
}
}
var target = (Plugin.TargetManager.SoftTarget ?? Plugin.TargetManager.Target) as IPlayerCharacter;
using (ImRaii.Disabled(target == null))
{
if (ImGui.Button("Set to target") && target != null)
tab.TellTarget.FromTarget(target);
}
}
}
ImGuiUtil.ChannelSelector(Language.Options_Tabs_Channels, tab.ChatCodes);
ImGuiUtil.ChannelSelector(Language.Options_Tabs_Channels, tab.SelectedChannels);
ImGuiUtil.ExtraChatSelector(Language.Options_Tabs_ExtraChatChannels, ref tab.ExtraChatAll, tab.ExtraChatChannels);
}