- 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
+41 -44
View File
@@ -1,11 +1,8 @@
using System.Runtime.CompilerServices;
using ChatTwo.Code;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using System.Text;
using Lumina.Text.Expressions;
using Lumina.Text.Payloads;
using Lumina.Text.ReadOnly;
using PayloadType = Dalamud.Game.Text.SeStringHandling.PayloadType;
@@ -417,46 +414,46 @@ internal static class ChunkUtil
return BitConverter.ToUInt32(numArray, 0);
}
private static bool TryResolveUInt(in ReadOnlySeExpressionSpan expression, out uint value)
{
if (expression.TryGetUInt(out value))
return true;
// private static bool TryResolveUInt(in ReadOnlySeExpressionSpan expression, out uint value)
// {
// if (expression.TryGetUInt(out value))
// return true;
//
// if (expression.TryGetParameterExpression(out var exprType, out var operand1))
// {
// if (!TryResolveUInt(operand1, out var paramIndex))
// return false;
//
// if (paramIndex == 0)
// return false;
//
// paramIndex--;
// if ((ExpressionType)exprType == ExpressionType.GlobalNumber)
// {
// value = (uint) GlobalParametersCache.GetValue((int)paramIndex);
// return true;
// }
// // return (ExpressionType)exprType switch
// // {
// // // ExpressionType.LocalNumber => context.TryGetLNum((int)paramIndex, out value), // lnum
// // ExpressionType.GlobalNumber => (uint) GlobalParametersCache.GetValue((int)paramIndex), // gnum
// // _ => false, // gstr, lstr
// // };
// }
//
// return false;
// }
if (expression.TryGetParameterExpression(out var exprType, out var operand1))
{
if (!TryResolveUInt(operand1, out var paramIndex))
return false;
if (paramIndex == 0)
return false;
paramIndex--;
if ((ExpressionType)exprType == ExpressionType.GlobalNumber)
{
value = (uint) GlobalParametersCache.GetValue((int)paramIndex);
return true;
}
// return (ExpressionType)exprType switch
// {
// // ExpressionType.LocalNumber => context.TryGetLNum((int)paramIndex, out value), // lnum
// ExpressionType.GlobalNumber => (uint) GlobalParametersCache.GetValue((int)paramIndex), // gnum
// _ => false, // gstr, lstr
// };
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool TryResolveInt(in ReadOnlySeExpressionSpan expression, out int value)
{
if (TryResolveUInt(expression, out var u32))
{
value = (int)u32;
return true;
}
value = 0;
return false;
}
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// private static bool TryResolveInt(in ReadOnlySeExpressionSpan expression, out int value)
// {
// if (TryResolveUInt(expression, out var u32))
// {
// value = (int)u32;
// return true;
// }
//
// value = 0;
// return false;
// }
}
+3 -4
View File
@@ -4,20 +4,19 @@ using System.Numerics;
namespace ChatTwo.Util;
internal static class ColourUtil {
private static (byte r, byte g, byte b, byte a) RgbaToComponents(uint rgba)
private static (byte r, byte g, byte b) RgbaToRgbComponents(uint rgba)
{
var r = (byte) ((rgba & 0xFF000000) >> 24);
var g = (byte) ((rgba & 0xFF0000) >> 16);
var b = (byte) ((rgba & 0xFF00) >> 8);
var a = (byte) (rgba & 0xFF);
return (r, g, b, a);
return (r, g, b);
}
internal static uint RgbaToAbgr(uint rgba) => BinaryPrimitives.ReverseEndianness(rgba);
internal static Vector3 RgbaToVector3(uint rgba)
{
var (r, g, b, _) = RgbaToComponents(rgba);
var (r, g, b) = RgbaToRgbComponents(rgba);
return new Vector3((float) r / 255, (float) g / 255, (float) b / 255);
}
+2
View File
@@ -37,7 +37,9 @@ public class ColorPayload
{
return v switch
{
// ReSharper disable once LocalizableElement
-1 => throw new ArgumentException("Encountered premature end of input (unexpected EOF).", nameof(v)),
// ReSharper disable once LocalizableElement
0 => throw new ArgumentException("Encountered premature end of input (unexpected null character).", nameof(v)),
_ => (uint)v << shift
};
+20 -8
View File
@@ -225,7 +225,7 @@ internal static class ImGuiUtil
ImGui.TextUnformatted(text);
}
internal static ImRaii.IEndObject BeginComboVertical(string label, string previewValue, ImGuiComboFlags flags = ImGuiComboFlags.None)
internal static ImRaii.ComboDisposable BeginComboVertical(string label, string previewValue, ImGuiComboFlags flags = ImGuiComboFlags.None)
{
ImGui.TextUnformatted(label);
ImGui.SetNextItemWidth(-1);
@@ -542,7 +542,7 @@ internal static class ImGuiUtil
return result != 0 || key == VirtualKey.NO_KEY;
}
public static void ChannelSelector(string headerText, Dictionary<ChatType, ChatSource> chatCodes)
public static void ChannelSelector(string headerText, Dictionary<ChatType, (ChatSource Source, ChatSource Target)> chatCodes)
{
using var channelNode = ImRaii.TreeNode(headerText);
if (!channelNode.Success)
@@ -563,7 +563,7 @@ internal static class ImGuiUtil
if (ImGui.Checkbox($"##{type.Name()}", ref enabled))
{
if (enabled)
chatCodes[type] = ChatSourceExt.All;
chatCodes[type] = (ChatSourceExt.All, ChatSourceExt.All);
else
chatCodes.Remove(type);
}
@@ -580,12 +580,24 @@ internal static class ImGuiUtil
if (!typeNode.Success)
continue;
chatCodes.TryGetValue(type, out var sourcesEnum);
var sources = (uint)sourcesEnum;
ImGui.Text(Language.ImGuiUtil_ChannelSelector_Source);
ImGui.SameLine(400.0f * ImGuiHelpers.GlobalScale);
ImGui.Text(Language.ImGuiUtil_ChannelSelector_Target);
foreach (var source in Enum.GetValues<ChatSource>())
if (ImGui.CheckboxFlags(source.Name(), ref sources, (uint)source))
chatCodes[type] = (ChatSource)sources;
chatCodes.TryGetValue(type, out var sourcesEnum);
var sources = (uint)sourcesEnum.Source;
var targets = (uint)sourcesEnum.Target;
foreach (var kind in Enum.GetValues<ChatSource>().Where(s => s != ChatSource.None))
{
if (ImGui.CheckboxFlags($"{kind.Name()}##source", ref sources, (uint)kind))
chatCodes[type] = ((ChatSource)sources, sourcesEnum.Target);
ImGui.SameLine(400.0f * ImGuiHelpers.GlobalScale);
if (ImGui.CheckboxFlags($"{kind.Name()}##target", ref targets, (uint)kind))
chatCodes[type] = (sourcesEnum.Source, (ChatSource)targets);
}
}
}
}
+118 -106
View File
@@ -3,135 +3,147 @@ using ChatTwo.Resources;
namespace ChatTwo.Util;
internal static class TabsUtil
public static class TabsUtil
{
internal static Dictionary<ChatType, ChatSource> AllChannels()
public static Dictionary<ChatType, (ChatSource, ChatSource)> AllChannels()
{
var channels = new Dictionary<ChatType, ChatSource>();
var channels = new Dictionary<ChatType, (ChatSource, ChatSource)>();
foreach (var chatType in Enum.GetValues<ChatType>())
channels[chatType] = ChatSourceExt.All;
channels[chatType] = (ChatSourceExt.All, ChatSourceExt.All);
return channels;
}
internal static Tab VanillaGeneral => new()
public static Tab VanillaGeneral => new()
{
Name = Language.Tabs_Presets_General,
ChatCodes = new Dictionary<ChatType, ChatSource>
SelectedChannels = new Dictionary<ChatType, (ChatSource, ChatSource)>
{
// Special
[ChatType.Debug] = ChatSourceExt.All,
[ChatType.Urgent] = ChatSourceExt.All,
[ChatType.Notice] = ChatSourceExt.All,
[ChatType.Debug] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Urgent] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Notice] = (ChatSourceExt.All, ChatSourceExt.All),
// Chat
[ChatType.Say] = ChatSourceExt.All,
[ChatType.Yell] = ChatSourceExt.All,
[ChatType.Shout] = ChatSourceExt.All,
[ChatType.TellIncoming] = ChatSourceExt.All,
[ChatType.TellOutgoing] = ChatSourceExt.All,
[ChatType.Party] = ChatSourceExt.All,
[ChatType.CrossParty] = ChatSourceExt.All,
[ChatType.Alliance] = ChatSourceExt.All,
[ChatType.FreeCompany] = ChatSourceExt.All,
[ChatType.PvpTeam] = ChatSourceExt.All,
[ChatType.CrossLinkshell1] = ChatSourceExt.All,
[ChatType.CrossLinkshell2] = ChatSourceExt.All,
[ChatType.CrossLinkshell3] = ChatSourceExt.All,
[ChatType.CrossLinkshell4] = ChatSourceExt.All,
[ChatType.CrossLinkshell5] = ChatSourceExt.All,
[ChatType.CrossLinkshell6] = ChatSourceExt.All,
[ChatType.CrossLinkshell7] = ChatSourceExt.All,
[ChatType.CrossLinkshell8] = ChatSourceExt.All,
[ChatType.Linkshell1] = ChatSourceExt.All,
[ChatType.Linkshell2] = ChatSourceExt.All,
[ChatType.Linkshell3] = ChatSourceExt.All,
[ChatType.Linkshell4] = ChatSourceExt.All,
[ChatType.Linkshell5] = ChatSourceExt.All,
[ChatType.Linkshell6] = ChatSourceExt.All,
[ChatType.Linkshell7] = ChatSourceExt.All,
[ChatType.Linkshell8] = ChatSourceExt.All,
[ChatType.NoviceNetwork] = ChatSourceExt.All,
[ChatType.StandardEmote] = ChatSourceExt.All,
[ChatType.CustomEmote] = ChatSourceExt.All,
[ChatType.Say] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Yell] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Shout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.TellIncoming] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.TellOutgoing] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Party] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossParty] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Alliance] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompany] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeam] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell1] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell2] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell3] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell4] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell5] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell6] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell7] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell8] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell1] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell2] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell3] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell4] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell5] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell6] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell7] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell8] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.NoviceNetwork] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.StandardEmote] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CustomEmote] = (ChatSourceExt.All, ChatSourceExt.All),
// Announcements
[ChatType.System] = ChatSourceExt.All,
[ChatType.GatheringSystem] = ChatSourceExt.All,
[ChatType.Error] = ChatSourceExt.All,
[ChatType.Echo] = ChatSourceExt.All,
[ChatType.NoviceNetworkSystem] = ChatSourceExt.All,
[ChatType.FreeCompanyAnnouncement] = ChatSourceExt.All,
[ChatType.PvpTeamAnnouncement] = ChatSourceExt.All,
[ChatType.FreeCompanyLoginLogout] = ChatSourceExt.All,
[ChatType.PvpTeamLoginLogout] = ChatSourceExt.All,
[ChatType.RetainerSale] = ChatSourceExt.All,
[ChatType.NpcAnnouncement] = ChatSourceExt.All,
[ChatType.LootNotice] = ChatSourceExt.All,
[ChatType.Progress] = ChatSourceExt.All,
[ChatType.LootRoll] = ChatSourceExt.All,
[ChatType.Crafting] = ChatSourceExt.All,
[ChatType.Gathering] = ChatSource.Self,
[ChatType.PeriodicRecruitmentNotification] = ChatSourceExt.All,
[ChatType.Sign] = ChatSourceExt.All,
[ChatType.RandomNumber] = ChatSourceExt.All,
[ChatType.Orchestrion] = ChatSourceExt.All,
[ChatType.MessageBook] = ChatSourceExt.All,
[ChatType.Alarm] = ChatSourceExt.All,
[ChatType.GlamourNotifications] = ChatSourceExt.All,
[ChatType.System] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.GatheringSystem] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Error] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Echo] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.NoviceNetworkSystem] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompanyAnnouncement] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeamAnnouncement] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompanyLoginLogout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeamLoginLogout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.RetainerSale] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.NpcAnnouncement] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.LootNotice] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Progress] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.LootRoll] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Crafting] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Gathering] = (ChatSource.LocalPlayer, ChatSource.LocalPlayer),
[ChatType.PeriodicRecruitmentNotification] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Sign] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.RandomNumber] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Orchestrion] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.MessageBook] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Alarm] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.GlamourNotifications] = (ChatSourceExt.All, ChatSourceExt.All),
}
};
internal static Tab VanillaEvent => new()
public static Tab VanillaEvent => new()
{
Name = Language.Tabs_Presets_Event,
ChatCodes = new Dictionary<ChatType, ChatSource> { [ChatType.NpcDialogue] = ChatSourceExt.All, },
SelectedChannels = new Dictionary<ChatType, (ChatSource, ChatSource)> { [ChatType.NpcDialogue] = (ChatSourceExt.All, ChatSourceExt.All), },
};
internal static Dictionary<ChatType, ChatSource> MostlyPlayer => new()
public static Tab VanillaTellExclusive => new()
{
Name = Language.Tabs_Presets_Tell,
SelectedChannels = new Dictionary<ChatType, (ChatSource, ChatSource)>
{
[ChatType.TellIncoming] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.TellOutgoing] = (ChatSourceExt.All, ChatSourceExt.All),
},
Channel = InputChannel.Tell,
AllSenderMessages = true,
};
public static Dictionary<ChatType, (ChatSource, ChatSource)> MostlyPlayer => new()
{
// Special
[ChatType.Debug] = ChatSourceExt.All,
[ChatType.Urgent] = ChatSourceExt.All,
[ChatType.Notice] = ChatSourceExt.All,
[ChatType.Debug] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Urgent] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Notice] = (ChatSourceExt.All, ChatSourceExt.All),
// Chat
[ChatType.Say] = ChatSourceExt.All,
[ChatType.Yell] = ChatSourceExt.All,
[ChatType.Shout] = ChatSourceExt.All,
[ChatType.TellIncoming] = ChatSourceExt.All,
[ChatType.TellOutgoing] = ChatSourceExt.All,
[ChatType.Party] = ChatSourceExt.All,
[ChatType.CrossParty] = ChatSourceExt.All,
[ChatType.Alliance] = ChatSourceExt.All,
[ChatType.FreeCompany] = ChatSourceExt.All,
[ChatType.PvpTeam] = ChatSourceExt.All,
[ChatType.CrossLinkshell1] = ChatSourceExt.All,
[ChatType.CrossLinkshell2] = ChatSourceExt.All,
[ChatType.CrossLinkshell3] = ChatSourceExt.All,
[ChatType.CrossLinkshell4] = ChatSourceExt.All,
[ChatType.CrossLinkshell5] = ChatSourceExt.All,
[ChatType.CrossLinkshell6] = ChatSourceExt.All,
[ChatType.CrossLinkshell7] = ChatSourceExt.All,
[ChatType.CrossLinkshell8] = ChatSourceExt.All,
[ChatType.Linkshell1] = ChatSourceExt.All,
[ChatType.Linkshell2] = ChatSourceExt.All,
[ChatType.Linkshell3] = ChatSourceExt.All,
[ChatType.Linkshell4] = ChatSourceExt.All,
[ChatType.Linkshell5] = ChatSourceExt.All,
[ChatType.Linkshell6] = ChatSourceExt.All,
[ChatType.Linkshell7] = ChatSourceExt.All,
[ChatType.Linkshell8] = ChatSourceExt.All,
[ChatType.NoviceNetwork] = ChatSourceExt.All,
[ChatType.StandardEmote] = ChatSourceExt.All,
[ChatType.CustomEmote] = ChatSourceExt.All,
[ChatType.Say] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Yell] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Shout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.TellIncoming] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.TellOutgoing] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Party] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossParty] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Alliance] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompany] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeam] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell1] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell2] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell3] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell4] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell5] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell6] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell7] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CrossLinkshell8] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell1] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell2] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell3] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell4] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell5] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell6] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell7] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Linkshell8] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.NoviceNetwork] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.StandardEmote] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.CustomEmote] = (ChatSourceExt.All, ChatSourceExt.All),
// Announcements
[ChatType.System] = ChatSourceExt.All,
[ChatType.Error] = ChatSourceExt.All,
[ChatType.Echo] = ChatSourceExt.All,
[ChatType.NoviceNetworkSystem] = ChatSourceExt.All,
[ChatType.FreeCompanyAnnouncement] = ChatSourceExt.All,
[ChatType.PvpTeamAnnouncement] = ChatSourceExt.All,
[ChatType.FreeCompanyLoginLogout] = ChatSourceExt.All,
[ChatType.PvpTeamLoginLogout] = ChatSourceExt.All,
[ChatType.RandomNumber] = ChatSourceExt.All,
[ChatType.MessageBook] = ChatSourceExt.All,
[ChatType.System] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Error] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.Echo] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.NoviceNetworkSystem] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompanyAnnouncement] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeamAnnouncement] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.FreeCompanyLoginLogout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.PvpTeamLoginLogout] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.RandomNumber] = (ChatSourceExt.All, ChatSourceExt.All),
[ChatType.MessageBook] = (ChatSourceExt.All, ChatSourceExt.All),
};
}