- 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
+66 -47
View File
@@ -12,7 +12,7 @@ using Dalamud.Bindings.ImGui;
namespace ChatTwo;
[Serializable]
internal class ConfigKeyBind
public class ConfigKeyBind
{
public ModifierFlag Modifier;
public VirtualKey Key;
@@ -31,9 +31,9 @@ internal class ConfigKeyBind
}
[Serializable]
internal class Configuration : IPluginConfiguration
public class Configuration : IPluginConfiguration
{
private const int LatestVersion = 5;
private const int LatestVersion = 6;
public int Version { get; set; } = LatestVersion;
@@ -46,7 +46,11 @@ internal class Configuration : IPluginConfiguration
public bool HideWhenInactive;
public int InactivityHideTimeout = 10;
public bool InactivityHideActiveDuringBattle = true;
public Dictionary<ChatType, ChatSource>? InactivityHideChannels;
[Obsolete("Use InactivityHideChannelsV2 instead")]
public Dictionary<ChatType, ChatSource> InactivityHideChannels = [];
public Dictionary<ChatType, (ChatSource, ChatSource)> InactivityHideChannelsV2 = [];
public bool InactivityHideExtraChatAll = true;
public HashSet<Guid> InactivityHideExtraChatChannels = [];
public bool ShowHideButton = true;
@@ -88,18 +92,18 @@ internal class Configuration : IPluginConfiguration
public SingleFontSpec GlobalFontV2 = new()
{
// dalamud only ships KR as regular, which chat2 used previously for global fonts
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular),
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkRegular),
SizePt = 12.75f,
};
public SingleFontSpec JapaneseFontV2 = new()
{
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium),
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkMedium),
SizePt = 12.75f,
};
public bool ItalicEnabled;
public SingleFontSpec ItalicFontV2 = new()
{
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular),
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansCjkRegular),
SizePt = 12.75f,
};
@@ -122,7 +126,7 @@ internal class Configuration : IPluginConfiguration
public HashSet<string> AuthStore = [];
public int WebinterfaceMaxLinesToSend = 1000; // 1-10000
internal void UpdateFrom(Configuration other, bool backToOriginal)
public void UpdateFrom(Configuration other, bool backToOriginal)
{
if (backToOriginal)
foreach (var tab in Tabs.Where(t => t.PopOut))
@@ -137,7 +141,7 @@ internal class Configuration : IPluginConfiguration
HideWhenInactive = other.HideWhenInactive;
InactivityHideTimeout = other.InactivityHideTimeout;
InactivityHideActiveDuringBattle = other.InactivityHideActiveDuringBattle;
InactivityHideChannels = other.InactivityHideChannels?.ToDictionary(entry => entry.Key, entry => entry.Value);
InactivityHideChannelsV2 = other.InactivityHideChannelsV2.ToDictionary(pair => pair.Key, pair => pair.Value);
InactivityHideExtraChatAll = other.InactivityHideExtraChatAll;
InactivityHideExtraChatChannels = other.InactivityHideExtraChatChannels.ToHashSet();
ShowHideButton = other.ShowHideButton;
@@ -195,14 +199,14 @@ internal class Configuration : IPluginConfiguration
}
[Serializable]
internal enum UnreadMode
public enum UnreadMode
{
All,
Unseen,
None,
}
internal static class UnreadModeExt
public static class UnreadModeExt
{
internal static string Name(this UnreadMode mode) => mode switch
{
@@ -222,10 +226,14 @@ internal static class UnreadModeExt
}
[Serializable]
internal class Tab
public class Tab
{
public string Name = Language.Tab_DefaultName;
[Obsolete("Removed in favor of SelectedChannels")]
public Dictionary<ChatType, ChatSource> ChatCodes = new();
public Dictionary<ChatType, (ChatSource, ChatSource)> SelectedChannels = new();
public bool ExtraChatAll;
public HashSet<Guid> ExtraChatChannels = [];
@@ -249,6 +257,10 @@ internal class Tab
public bool HideInBattle;
public bool HideWhenInactive;
public bool IsTempTab;
public bool AllSenderMessages;
public TellTarget TellTarget = TellTarget.Empty();
[NonSerialized] public uint Unread;
[NonSerialized] public uint LastSendUnread;
[NonSerialized] public long LastActivity;
@@ -258,27 +270,31 @@ internal class Tab
[NonSerialized] public Guid Identifier = Guid.NewGuid();
internal bool Matches(Message message) => message.Matches(ChatCodes, ExtraChatAll, ExtraChatChannels);
public bool Matches(Message message)
{
return message.Matches(SelectedChannels, ExtraChatAll, ExtraChatChannels);
}
internal void AddMessage(Message message, bool unread = true)
public void AddMessage(Message message, bool unread = true)
{
Messages.AddPrune(message, MessageManager.MessageDisplayLimit);
if (!unread)
return;
Unread += 1;
if (message.Matches(Plugin.Config.InactivityHideChannels!, Plugin.Config.InactivityHideExtraChatAll, Plugin.Config.InactivityHideExtraChatChannels))
if (message.Matches(Plugin.Config.InactivityHideChannelsV2, Plugin.Config.InactivityHideExtraChatAll, Plugin.Config.InactivityHideExtraChatChannels))
LastActivity = Environment.TickCount64;
}
internal void Clear() => Messages.Clear();
public void Clear()
=> Messages.Clear();
internal Tab Clone()
public Tab Clone()
{
return new Tab
{
Name = Name,
ChatCodes = ChatCodes.ToDictionary(entry => entry.Key, entry => entry.Value),
SelectedChannels = SelectedChannels.ToDictionary(pair => pair.Key, pair => pair.Value),
ExtraChatAll = ExtraChatAll,
ExtraChatChannels = ExtraChatChannels.ToHashSet(),
UnreadMode = UnreadMode,
@@ -302,6 +318,9 @@ internal class Tab
HideInLoadingScreens = HideInLoadingScreens,
HideInBattle = HideInBattle,
HideWhenInactive = HideWhenInactive,
IsTempTab = IsTempTab,
AllSenderMessages = AllSenderMessages,
TellTarget = TellTarget.From(TellTarget),
};
}
@@ -309,7 +328,7 @@ internal class Tab
/// MessageList provides an ordered list of messages with duplicate ID
/// tracking, sorting and mutex protection.
/// </summary>
internal class MessageList
public class MessageList
{
private readonly SemaphoreSlim LockSlim = new(1, 1);
@@ -422,7 +441,7 @@ internal class Tab
return new RLockedMessageList(LockSlim, Messages);
}
internal class RLockedMessageList(SemaphoreSlim lockSlim, List<Message> messages) : IReadOnlyList<Message>, IDisposable
public class RLockedMessageList(SemaphoreSlim lockSlim, List<Message> messages) : IReadOnlyList<Message>, IDisposable
{
public IEnumerator<Message> GetEnumerator()
{
@@ -446,31 +465,31 @@ internal class Tab
}
}
internal class UsedChannel
public class UsedChannel
{
internal InputChannel Channel = InputChannel.Invalid;
internal List<Chunk> Name = [];
internal TellTarget? TellTarget;
public InputChannel Channel = InputChannel.Invalid;
public List<Chunk> Name = [];
public TellTarget? TellTarget;
internal bool UseTempChannel;
internal InputChannel TempChannel = InputChannel.Invalid;
internal TellTarget? TempTellTarget;
public bool UseTempChannel;
public InputChannel TempChannel = InputChannel.Invalid;
public TellTarget? TempTellTarget;
internal void ResetTempChannel()
public void ResetTempChannel()
{
UseTempChannel = false;
TempTellTarget = null;
TempChannel = InputChannel.Invalid;
}
internal void SetChannel(InputChannel channel)
public void SetChannel(InputChannel channel)
{
Channel = channel;
}
}
[Serializable]
internal enum PreviewPosition
public enum PreviewPosition
{
None,
Inside,
@@ -479,9 +498,9 @@ internal enum PreviewPosition
Tooltip,
}
internal static class PreviewPositionExt
public static class PreviewPositionExt
{
internal static string Name(this PreviewPosition position) => position switch
public static string Name(this PreviewPosition position) => position switch
{
PreviewPosition.None => Language.Options_Preview_None,
PreviewPosition.Inside => Language.Options_Preview_Inside,
@@ -493,16 +512,16 @@ internal static class PreviewPositionExt
}
[Serializable]
internal enum CommandHelpSide
public enum CommandHelpSide
{
None,
Left,
Right,
}
internal static class CommandHelpSideExt
public static class CommandHelpSideExt
{
internal static string Name(this CommandHelpSide side) => side switch
public static string Name(this CommandHelpSide side) => side switch
{
CommandHelpSide.None => Language.CommandHelpSide_None,
CommandHelpSide.Left => Language.CommandHelpSide_Left,
@@ -512,22 +531,22 @@ internal static class CommandHelpSideExt
}
[Serializable]
internal enum KeybindMode
public enum KeybindMode
{
Flexible,
Strict,
}
internal static class KeybindModeExt
public static class KeybindModeExt
{
internal static string Name(this KeybindMode mode) => mode switch
public static string Name(this KeybindMode mode) => mode switch
{
KeybindMode.Flexible => Language.KeybindMode_Flexible_Name,
KeybindMode.Strict => Language.KeybindMode_Strict_Name,
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),
};
internal static string? Tooltip(this KeybindMode mode) => mode switch
public static string? Tooltip(this KeybindMode mode) => mode switch
{
KeybindMode.Flexible => Language.KeybindMode_Flexible_Tooltip,
KeybindMode.Strict => Language.KeybindMode_Strict_Tooltip,
@@ -536,7 +555,7 @@ internal static class KeybindModeExt
}
[Serializable]
internal enum LanguageOverride
public enum LanguageOverride
{
None,
ChineseSimplified,
@@ -559,9 +578,9 @@ internal enum LanguageOverride
Swedish,
}
internal static class LanguageOverrideExt
public static class LanguageOverrideExt
{
internal static string Name(this LanguageOverride mode) => mode switch
public static string Name(this LanguageOverride mode) => mode switch
{
LanguageOverride.None => Language.LanguageOverride_None,
LanguageOverride.ChineseSimplified => "简体中文",
@@ -583,7 +602,7 @@ internal static class LanguageOverrideExt
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),
};
internal static string Code(this LanguageOverride mode) => mode switch
public static string Code(this LanguageOverride mode) => mode switch
{
LanguageOverride.None => "",
LanguageOverride.ChineseSimplified => "zh-hans",
@@ -608,7 +627,7 @@ internal static class LanguageOverrideExt
[Serializable]
[Flags]
internal enum ExtraGlyphRanges
public enum ExtraGlyphRanges
{
ChineseFull = 1 << 0,
ChineseSimplifiedCommon = 1 << 1,
@@ -619,9 +638,9 @@ internal enum ExtraGlyphRanges
Vietnamese = 1 << 6,
}
internal static class ExtraGlyphRangesExt
public static class ExtraGlyphRangesExt
{
internal static string Name(this ExtraGlyphRanges ranges) => ranges switch
public static string Name(this ExtraGlyphRanges ranges) => ranges switch
{
ExtraGlyphRanges.ChineseFull => Language.ExtraGlyphRanges_ChineseFull_Name,
ExtraGlyphRanges.ChineseSimplifiedCommon => Language.ExtraGlyphRanges_ChineseSimplifiedCommon_Name,
@@ -633,7 +652,7 @@ internal static class ExtraGlyphRangesExt
_ => throw new ArgumentOutOfRangeException(nameof(ranges), ranges, null),
};
internal static unsafe nint Range(this ExtraGlyphRanges ranges) => ranges switch
public static unsafe nint Range(this ExtraGlyphRanges ranges) => ranges switch
{
ExtraGlyphRanges.ChineseFull => (nint)ImGui.GetIO().Fonts.GetGlyphRangesChineseFull(),
ExtraGlyphRanges.ChineseSimplifiedCommon => (nint)ImGui.GetIO().Fonts.GetGlyphRangesChineseSimplifiedCommon(),