- More ImRaii

- Cleanup
- Spanish, French, Dutch, Chinese loc update
This commit is contained in:
Infi
2024-11-21 11:58:22 +01:00
parent 1a1995759a
commit 3cfe65d2d4
23 changed files with 283 additions and 332 deletions
+40 -96
View File
@@ -12,7 +12,6 @@ using Lumina.Text.ReadOnly;
using Pidgin;
using static Pidgin.Parser;
using static Pidgin.Parser<char>;
using TextPayload = Lumina.Text.Payloads.TextPayload;
namespace ChatTwo.Util;
@@ -27,71 +26,28 @@ internal static class AutoTranslate
.AtLeastOnceUntil(Lookahead(Char('[').IgnoreResult().Or(End)))
.Select(string.Concat)
.Labelled("sheetName");
var numPair = Map(
(first, second) => (ISelectorPart) new IndexRange(
uint.Parse(string.Concat(first)),
uint.Parse(string.Concat(second))
),
var numPair = Map(ISelectorPart (first, second) =>
new IndexRange(uint.Parse(string.Concat(first)), uint.Parse(string.Concat(second))),
Digit.AtLeastOnce().Before(Char('-')),
Digit.AtLeastOnce()
)
Digit.AtLeastOnce())
.Labelled("numPair");
var singleRow = Digit
.AtLeastOnce()
.Select(string.Concat)
.Select(num => (ISelectorPart) new SingleRow(uint.Parse(num)));
.Select(ISelectorPart (num) => new SingleRow(uint.Parse(num)));
var column = String("col-")
.Then(Digit.AtLeastOnce())
.Select(string.Concat)
.Select(num => (ISelectorPart) new ColumnSpecifier(uint.Parse(num)));
.Select(ISelectorPart (num) => new ColumnSpecifier(uint.Parse(num)));
var noun = String("noun")
.Select(_ => (ISelectorPart) new NounMarker());
var selectorItems = OneOf(
Try(numPair),
singleRow,
column,
noun
)
.Select(ISelectorPart (_) => new NounMarker());
var selectorItems = OneOf(Try(numPair), singleRow, column, noun)
.Separated(Char(','))
.Labelled("selectorItems");
var selector = selectorItems
.Between(Char('['), Char(']'))
.Labelled("selector");
return Map(
(name, sel) => (name, sel),
sheetName,
selector.Optional()
);
}
private static string TextValue(this Lumina.Text.SeString str)
{
var payloads = str.Payloads
.Select(p => {
if (p is TextPayload text) {
return p.Data[0] == 0x03
? text.RawString[1..]
: text.RawString;
}
if (p.Data.Length <= 1) {
return "";
}
if (p.Data[1] == 0x1F) {
return "-";
}
if (p.Data.Length > 2 && p.Data[1] == 0x20) {
var value = p.Data.Length > 4
? p.Data[3] - 1
: p.Data[2];
return ((char) (48 + value)).ToString();
}
return "";
});
return string.Join("", payloads);
return Map((name, sel) => (name, sel), sheetName, selector.Optional());
}
/// <summary>
@@ -131,7 +87,7 @@ internal static class AutoTranslate
var sheet = Plugin.DataManager.Excel.GetSheet<WorkingRawRow>(name: sheetName);
var columns = new List<int>();
var rows = new List<Range>();
var rows = new List<Range>();
if (selector.HasValue)
{
columns.Clear();
@@ -179,21 +135,17 @@ internal static class AutoTranslate
// See above.
for (var i = range.Start.Value; i < range.End.Value; i++)
{
if (!sheet.TryGetRow((uint)i, out var rowParser)) continue;
if (!sheet.TryGetRow((uint)i, out var rowParser))
continue;
foreach (var col in columns)
{
var rawName = rowParser.RawRow.ReadStringColumn(col)!;
var name = rawName.ToDalamudString();
var text = name.TextValue;
var rawName = rowParser.RawRow.ReadStringColumn(col);
var name = rawName.ToDalamudString();
var text = name.TextValue;
if (text.Length > 0)
{
list.Add(new AutoTranslateEntry(
row.Group,
(uint)i,
text,
name
));
list.Add(new AutoTranslateEntry(row.Group, (uint)i, text, name));
if (shouldAdd)
ValidEntries.Add((row.Group, (uint)i));
@@ -205,12 +157,7 @@ internal static class AutoTranslate
else if (lookup is not "@")
{
var text = row.Text.ToDalamudString();
list.Add(new AutoTranslateEntry(
row.Group,
row.RowId,
text.TextValue,
text
));
list.Add(new AutoTranslateEntry(row.Group, row.RowId, text.TextValue, text));
if (shouldAdd)
ValidEntries.Add((row.Group, row.RowId));
@@ -271,33 +218,30 @@ internal static class AutoTranslate
var start = -1;
for (var i = 0; i < bytes.Length; i++)
{
if (start != -1) {
if (bytes[i] == '>')
{
var tag = Encoding.UTF8.GetString(bytes[start..(i + 1)]);
var parts = tag[4..^1].Split(',', 2);
if (parts.Length == 2 && uint.TryParse(parts[0], out var group) && uint.TryParse(parts[1], out var key))
{
var payload = ValidEntries.Contains((group, key))
? new AutoTranslatePayload(group, key).Encode()
: [];
var oldBytes = bytes.ToArray();
var lengthDiff = payload.Length - (i - start);
bytes = new byte[oldBytes.Length + lengthDiff];
Array.Copy(oldBytes, bytes, start);
Array.Copy(payload, 0, bytes, start, payload.Length);
Array.Copy(oldBytes, i + 1, bytes, start + payload.Length, oldBytes.Length - (i + 1));
i += lengthDiff;
}
start = -1;
}
else
{
if (start != -1)
{
if (bytes[i] != '>')
continue;
var tag = Encoding.UTF8.GetString(bytes[start..(i + 1)]);
var parts = tag[4..^1].Split(',', 2);
if (parts.Length == 2 && uint.TryParse(parts[0], out var group) && uint.TryParse(parts[1], out var key))
{
var payload = ValidEntries.Contains((group, key))
? new AutoTranslatePayload(group, key).Encode()
: [];
var oldBytes = bytes.ToArray();
var lengthDiff = payload.Length - (i - start);
bytes = new byte[oldBytes.Length + lengthDiff];
Array.Copy(oldBytes, bytes, start);
Array.Copy(payload, 0, bytes, start, payload.Length);
Array.Copy(oldBytes, i + 1, bytes, start + payload.Length, oldBytes.Length - (i + 1));
i += lengthDiff;
}
start = -1;
}
if (i + search.Length < bytes.Length && memcmp(bytes[i..], search, (nuint) search.Length) == 0)
@@ -311,9 +255,9 @@ public readonly struct WorkingRawRow(RawRow row) : IExcelRow<WorkingRawRow>
{
public uint RowId => row.RowId;
public RawRow RawRow => row;
static WorkingRawRow IExcelRow<WorkingRawRow>.Create(ExcelPage page, uint offset, uint row) =>
new(new(page, offset, row));
new(new RawRow(page, offset, row));
}
internal interface ISelectorPart { }
+8 -4
View File
@@ -4,7 +4,8 @@ using System.Numerics;
namespace ChatTwo.Util;
internal static class ColourUtil {
internal static (byte r, byte g, byte b, byte a) RgbaToComponents(uint rgba) {
internal static (byte r, byte g, byte b, byte a) RgbaToComponents(uint rgba)
{
var r = (byte) ((rgba & 0xFF000000) >> 24);
var g = (byte) ((rgba & 0xFF0000) >> 16);
var b = (byte) ((rgba & 0xFF00) >> 8);
@@ -14,12 +15,14 @@ internal static class ColourUtil {
internal static uint RgbaToAbgr(uint rgba) => BinaryPrimitives.ReverseEndianness(rgba);
internal static Vector3 RgbaToVector3(uint rgba) {
internal static Vector3 RgbaToVector3(uint rgba)
{
var (r, g, b, _) = RgbaToComponents(rgba);
return new Vector3((float) r / 255, (float) g / 255, (float) b / 255);
}
internal static uint Vector3ToRgba(Vector3 col) {
internal static uint Vector3ToRgba(Vector3 col)
{
return ComponentsToRgba(
(byte) Math.Round(col.X * 255),
(byte) Math.Round(col.Y * 255),
@@ -27,7 +30,8 @@ internal static class ColourUtil {
);
}
internal static uint Vector4ToAbgr(Vector4 col) {
internal static uint Vector4ToAbgr(Vector4 col)
{
return RgbaToAbgr(ComponentsToRgba(
(byte) Math.Round(col.X * 255),
(byte) Math.Round(col.Y * 255),
+10 -14
View File
@@ -24,17 +24,14 @@ public class ColorPayload
payload.Enabled = false;
return payload;
case 0xE9:
{
var param = stream.ReadByte();
var value = (uint) GlobalParametersCache.GetValue(param - 2);
var globalValue = (uint) GlobalParametersCache.GetValue(param - 2);
payload.Enabled = true;
payload.UnshiftedColor = value;
payload.Color = ColourUtil.ArgbToRgba(value);
payload.UnshiftedColor = globalValue;
payload.Color = ColourUtil.ArgbToRgba(globalValue);
return payload;
}
case >= 0xF0 and <= 0xFE:
{
// From: https://github.com/NotAdam/Lumina/blob/master/src/Lumina/Text/Expressions/IntegerExpression.cs#L119-L128
uint ShiftAndThrowIfZero(int v, int shift)
{
@@ -47,21 +44,20 @@ public class ColorPayload
}
typeByte += 1;
var value = 0u;
var argbValue = 0u;
if ((typeByte & 8) != 0)
value |= ShiftAndThrowIfZero(stream.ReadByte(), 24);
argbValue |= ShiftAndThrowIfZero(stream.ReadByte(), 24);
else
value |= 0xff000000u;
argbValue |= 0xff000000u;
if( (typeByte & 4) != 0 ) value |= ShiftAndThrowIfZero( stream.ReadByte(), 16 );
if( (typeByte & 2) != 0 ) value |= ShiftAndThrowIfZero( stream.ReadByte(), 8 );
if( (typeByte & 1) != 0 ) value |= ShiftAndThrowIfZero( stream.ReadByte(), 0 );
if( (typeByte & 4) != 0 ) argbValue |= ShiftAndThrowIfZero( stream.ReadByte(), 16 );
if( (typeByte & 2) != 0 ) argbValue |= ShiftAndThrowIfZero( stream.ReadByte(), 8 );
if( (typeByte & 1) != 0 ) argbValue |= ShiftAndThrowIfZero( stream.ReadByte(), 0 );
payload.Enabled = true;
payload.Color = ColourUtil.ArgbToRgba(value);
payload.Color = ColourUtil.ArgbToRgba(argbValue);
return payload;
}
default:
return null;
}
+2 -1
View File
@@ -12,6 +12,7 @@ public static class GlobalParametersCache
{
if (index < 0 || index >= Cache.Length)
return 0;
return Cache[index];
}
@@ -31,9 +32,9 @@ public static class GlobalParametersCache
return;
ref var gp = ref rtm->TextModule.MacroDecoder.GlobalParameters;
if (Cache.Length != (int)gp.MySize)
Cache = new int[gp.MySize];
for (ulong i = 0; i < gp.MySize; i++)
{
var p = gp[(long)i];
+2 -1
View File
@@ -137,7 +137,8 @@ public readonly unsafe ref struct GfdFileView
internal static class IconUtil {
internal static class IconUtil
{
private static byte[]? GfdFile;
public static unsafe GfdFileView GfdFileView
{
+38 -29
View File
@@ -186,15 +186,16 @@ internal static class ImGuiUtil
Plugin.FontManager.FontAwesome.Push();
var size = new Vector2(0, 0);
if (width > 0)
{
var style = ImGui.GetStyle();
size.X = width - 2 * style.CellPadding.X;
}
size.X = width - 2 * ImGui.GetStyle().CellPadding.X;
var ret = ImGui.Button(label, size);
Plugin.FontManager.FontAwesome.Pop();
if (tooltip != null && ImGui.IsItemHovered())
ImGui.SetTooltip(tooltip);
{
using var startedTooltip = ImRaii.Tooltip();
ImGuiHelpers.SafeTextWrapped(tooltip);
}
return ret;
}
@@ -224,11 +225,8 @@ internal static class ImGuiUtil
var style = StyleModel.GetConfiguredStyle() ?? StyleModel.GetFromCurrent();
var dalamudOrange = style.BuiltInColors?.DalamudOrange;
var push = dalamudOrange != null;
var color = dalamudOrange ?? Vector4.Zero;
using (TextWrapPos(wrap))
using (ImRaii.PushColor(ImGuiCol.Text, color, push))
using (ImRaii.PushColor(ImGuiCol.Text, dalamudOrange ?? Vector4.Zero, dalamudOrange != null))
{
ImGui.TextUnformatted(text);
}
@@ -305,18 +303,17 @@ internal static class ImGuiUtil
if (combo)
{
foreach (var size in FontManager.AxisFontSizeList)
if (ImGui.Selectable($"{size:###.##}pt", currentSize == size))
if (ImGui.Selectable($"{size:###.##}pt", currentSize.Equals(size)))
currentSize = size;
}
}
public static bool Button(string id, FontAwesomeIcon icon, bool disabled)
{
var clicked = false;
using (ImRaii.Disabled(disabled))
clicked = ImGuiComponents.IconButton(id, icon);
return clicked;
{
return ImGuiComponents.IconButton(id, icon);
}
}
internal static bool CtrlShiftButton(string label, string tooltip = "")
@@ -328,7 +325,10 @@ internal static class ImGuiUtil
ret = ImGui.Button(label) && ctrlShiftHeld;
if (!string.IsNullOrEmpty(tooltip) && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
ImGui.SetTooltip(tooltip);
{
using var startedTooltip = ImRaii.Tooltip();
ImGuiHelpers.SafeTextWrapped(tooltip);
}
return ret;
}
@@ -345,15 +345,19 @@ internal static class ImGuiUtil
var ret = ImGui.Button(label) && ctrlShiftHeld;
if (!string.IsNullOrEmpty(tooltip) && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
ImGui.SetTooltip(tooltip);
{
using var startedTooltip = ImRaii.Tooltip();
ImGuiHelpers.SafeTextWrapped(tooltip);
}
return ret;
}
}
internal static bool KeybindInput(string id, ref ConfigKeyBind? keybind)
internal static void KeybindInput(string id, ref ConfigKeyBind? keybind)
{
var idUint = ImGui.GetID(id);
using var pushedId = ImRaii.PushId(id);
if (ImGui.GetStateStorage().GetBool(idUint))
{
@@ -387,7 +391,7 @@ internal static class ImGuiUtil
{
keybind = null;
ImGui.GetStateStorage().SetBool(idUint, false);
return false;
return;
}
foreach (var vk in Enum.GetValues(typeof(VirtualKey)).Cast<VirtualKey>())
@@ -404,7 +408,7 @@ internal static class ImGuiUtil
Key = vk
};
ImGui.GetStateStorage().SetBool(idUint, false);
return true;
return;
}
}
else
@@ -415,8 +419,6 @@ internal static class ImGuiUtil
if (ImGui.Button(text, new Vector2(-1, 0)))
ImGui.GetStateStorage().SetBool(idUint, true);
}
return false;
}
public static void DrawArrows(ref int selected, int min, int max, float spacing, int id = 0)
@@ -428,13 +430,15 @@ internal static class ImGuiUtil
ImGui.SameLine(0, spacing);
using (ImRaii.Disabled(isMin))
{
if (IconButton(FontAwesomeIcon.ArrowLeft, id.ToString())) selected--;
if (IconButton(FontAwesomeIcon.ArrowLeft, id.ToString()))
selected--;
}
ImGui.SameLine(0, spacing);
using (ImRaii.Disabled(isMax))
{
if (IconButton(FontAwesomeIcon.ArrowRight, id+1.ToString())) selected++;
if (IconButton(FontAwesomeIcon.ArrowRight, id+1.ToString()))
selected++;
}
}
@@ -447,7 +451,8 @@ internal static class ImGuiUtil
internal static bool TryToImGui(this VirtualKey key, out ImGuiKey result)
{
result = key switch {
result = key switch
{
VirtualKey.NO_KEY => ImGuiKey.None,
VirtualKey.BACK => ImGuiKey.Backspace,
VirtualKey.TAB => ImGuiKey.Tab,
@@ -561,13 +566,12 @@ internal static class ImGuiUtil
return result != 0 || key == VirtualKey.NO_KEY;
}
private struct EndUnconditionally(Action endAction, bool success) : ImRaii.IEndObject
public struct EndUnconditionally(Action endAction, bool success) : ImRaii.IEndObject
{
private Action EndAction { get; } = endAction;
public bool Success { get; } = success;
public bool Disposed { get; private set; } = false;
private bool Disposed { get; set; } = false;
private Action EndAction { get; } = endAction;
public void Dispose()
{
@@ -594,10 +598,15 @@ internal static class ImGuiUtil
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
}
public static ImRaii.IEndObject Menu(string label)
{
return new EndUnconditionally(ImGui.EndMenu, ImGui.BeginMenu(label));
}
public static void ChannelSelector(string headerText, Dictionary<ChatType, ChatSource> chatCodes)
{
using var channelNode = ImRaii.TreeNode(headerText);
if (!channelNode)
if (!channelNode.Success)
return;
foreach (var (header, types) in ChatTypeExt.SortOrder)
+16 -13
View File
@@ -1,23 +1,26 @@
namespace ChatTwo.Util;
internal class Lender<T> {
private readonly Func<T> _ctor;
private readonly List<T> _items = new();
private int _counter;
internal class Lender<T>
{
private readonly Func<T> Ctor;
private readonly List<T> Items = [];
private int Counter;
internal Lender(Func<T> ctor) {
_ctor = ctor;
internal Lender(Func<T> ctor)
{
Ctor = ctor;
}
internal void ResetCounter() {
_counter = 0;
internal void ResetCounter()
{
Counter = 0;
}
internal T Borrow() {
if (_items.Count <= _counter) {
_items.Add(_ctor());
}
internal T Borrow()
{
if (Items.Count <= Counter)
Items.Add(Ctor());
return _items[_counter++];
return Items[Counter++];
}
}
+22 -20
View File
@@ -2,38 +2,46 @@ using Dalamud.Game.Text.SeStringHandling;
namespace ChatTwo.Util;
internal class PartyFinderPayload : Payload {
internal class PartyFinderPayload : Payload
{
public override PayloadType Type => (PayloadType) 0x50;
internal uint Id { get; }
internal PartyFinderPayload(uint id) {
internal PartyFinderPayload(uint id)
{
Id = id;
}
protected override byte[] EncodeImpl() {
protected override byte[] EncodeImpl()
{
throw new NotImplementedException();
}
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
throw new NotImplementedException();
}
}
internal class AchievementPayload : Payload {
internal class AchievementPayload : Payload
{
public override PayloadType Type => (PayloadType) 0x51;
internal uint Id { get; }
internal AchievementPayload(uint id) {
internal AchievementPayload(uint id)
{
Id = id;
}
protected override byte[] EncodeImpl() {
protected override byte[] EncodeImpl()
{
throw new NotImplementedException();
}
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
throw new NotImplementedException();
}
}
@@ -45,8 +53,8 @@ internal class UriPayload(Uri uri) : Payload
public Uri Uri { get; } = uri;
private const string DefaultScheme = "https";
private static readonly string[] ExpectedSchemes = ["http", "https"];
private static readonly string DefaultScheme = "https";
/// <summary>
/// Create a URIPayload from a raw URI string. If the URI does not have a
@@ -59,18 +67,12 @@ internal class UriPayload(Uri uri) : Payload
{
ArgumentNullException.ThrowIfNull(rawURI);
// Check for expected scheme ://, if not add https://
foreach (var scheme in ExpectedSchemes)
{
if (rawURI.StartsWith($"{scheme}://"))
{
return new UriPayload(new Uri(rawURI));
}
}
// Check for an expected scheme '://', if not add 'https://'
if (ExpectedSchemes.Any(scheme => rawURI.StartsWith($"{scheme}://")))
return new UriPayload(new Uri(rawURI));
if (rawURI.Contains("://"))
{
throw new UriFormatException($"Unsupported scheme in URL: {rawURI}");
}
return new UriPayload(new Uri($"{DefaultScheme}://{rawURI}"));
}
@@ -90,7 +92,7 @@ internal class EmotePayload : Payload
{
public override PayloadType Type => (PayloadType) 0x53;
public string Code;
public string Code = string.Empty;
public static EmotePayload ResolveEmote(string code)
{
+10 -8
View File
@@ -2,6 +2,7 @@
using Dalamud.Interface.Utility;
using ImGuiNET;
using System.Collections;
using Dalamud.Interface.Utility.Raii;
namespace ChatTwo.Util;
@@ -58,7 +59,6 @@ public static class SearchSelector
public static bool SelectorPopup(string id, out string selected, SelectorPopupOptions? options = null, bool close = false)
{
options ??= new SelectorPopupOptions();
var sheet = options.FilteredSheet;
selected = string.Empty;
@@ -67,12 +67,15 @@ public static class SearchSelector
return false;
ImGui.SetNextWindowSize(options.Size ?? new Vector2(0, 250 * ImGuiHelpers.GlobalScale));
if (!ImGui.BeginPopupContextItem(id, options.PopupFlags))
using var popup = ImRaii.ContextPopupItem(id, options.PopupFlags);
if (!popup.Success)
return false;
SearchInput(id, sheet, options.SearchPredicate ?? ((row, s) => options.FormatRow(row).Contains(s, StringComparison.CurrentCultureIgnoreCase)));
ImGui.BeginChild("SearchList", Vector2.Zero, true);
using var child = ImRaii.Child("SearchList", Vector2.Zero, true);
if (!child.Success)
return false;
var ret = false;
var drawSelectable = options.DrawSelectable ?? ((row, selected) => ImGui.Selectable(options.FormatRow(row), selected));
@@ -81,11 +84,12 @@ public static class SearchSelector
foreach (var i in clipper.Rows)
{
var searched = FilteredSearchSheet[i];
ImGui.PushID(id);
if (!drawSelectable(searched, options.IsSelected(searched))) continue;
using var pushedId = ImRaii.PushId(id);
if (!drawSelectable(searched, options.IsSelected(searched)))
continue;
selected = searched;
ret = true;
ImGui.PopID();
}
}
@@ -93,8 +97,6 @@ public static class SearchSelector
if (ret && options.CloseOnSelection)
ImGui.CloseCurrentPopup();
ImGui.EndChild();
ImGui.EndPopup();
return ret;
}
}
+6 -3
View File
@@ -2,8 +2,10 @@ using System.Text;
namespace ChatTwo.Util;
internal static class StringUtil {
internal static byte[] ToTerminatedBytes(this string s) {
internal static class StringUtil
{
internal static byte[] ToTerminatedBytes(this string s)
{
var utf8 = Encoding.UTF8;
var bytes = new byte[utf8.GetByteCount(s) + 1];
utf8.GetBytes(s, 0, s.Length, bytes, 0);
@@ -12,7 +14,8 @@ internal static class StringUtil {
}
// Taken from https://stackoverflow.com/a/4975942
internal static string BytesToString(long byteCount) {
internal static string BytesToString(long byteCount)
{
string[] suf = ["B", "KB", "MB", "GB", "TB", "PB", "EB"]; // Longs run out around EB
if (byteCount == 0)
return "0" + suf[0];
+9 -7
View File
@@ -3,7 +3,8 @@ using ChatTwo.Resources;
namespace ChatTwo.Util;
internal static class TabsUtil {
internal static class TabsUtil
{
internal static Dictionary<ChatType, ChatSource> AllChannels()
{
var channels = new Dictionary<ChatType, ChatSource>();
@@ -12,9 +13,11 @@ internal static class TabsUtil {
return channels;
}
internal static Tab VanillaGeneral => new() {
internal static Tab VanillaGeneral => new()
{
Name = Language.Tabs_Presets_General,
ChatCodes = new Dictionary<ChatType, ChatSource> {
ChatCodes = new Dictionary<ChatType, ChatSource>
{
// Special
[ChatType.Debug] = ChatSourceExt.All,
[ChatType.Urgent] = ChatSourceExt.All,
@@ -75,11 +78,10 @@ internal static class TabsUtil {
},
};
internal static Tab VanillaEvent => new() {
internal static Tab VanillaEvent => new()
{
Name = Language.Tabs_Presets_Event,
ChatCodes = new Dictionary<ChatType, ChatSource> {
[ChatType.NpcDialogue] = ChatSourceExt.All,
},
ChatCodes = new Dictionary<ChatType, ChatSource> { [ChatType.NpcDialogue] = ChatSourceExt.All, },
};
internal static Dictionary<ChatType, ChatSource> MostlyPlayer => new()
+15 -15
View File
@@ -36,21 +36,21 @@ public static class Tokenizer
static PrecedenceBasedRegexTokenizer()
{
TokenDefinitions = new List<TokenDefinition>
{
new(TokenType.CloseParenthesis, "\\)", 1),
new(TokenType.Comma, ",", 1),
new(TokenType.Dot, "\\.", 1),
new(TokenType.QuestionMark, "\\?", 1),
new(TokenType.ExclamationMark, "!", 1),
new(TokenType.Semicolon, ";", 1),
new(TokenType.Whitespace, "\\s", 1),
new(TokenType.Equals, "=", 1),
new(TokenType.OpenParenthesis, "\\(", 1),
new(TokenType.UrlString, URLRegex, 1),
new(TokenType.StringValue, "\\p{IsBasicLatin}", 2),
new(TokenType.Leftover, ".", 3)
};
TokenDefinitions =
[
new TokenDefinition(TokenType.CloseParenthesis, "\\)", 1),
new TokenDefinition(TokenType.Comma, ",", 1),
new TokenDefinition(TokenType.Dot, "\\.", 1),
new TokenDefinition(TokenType.QuestionMark, "\\?", 1),
new TokenDefinition(TokenType.ExclamationMark, "!", 1),
new TokenDefinition(TokenType.Semicolon, ";", 1),
new TokenDefinition(TokenType.Whitespace, "\\s", 1),
new TokenDefinition(TokenType.Equals, "=", 1),
new TokenDefinition(TokenType.OpenParenthesis, "\\(", 1),
new TokenDefinition(TokenType.UrlString, URLRegex, 1),
new TokenDefinition(TokenType.StringValue, "\\p{IsBasicLatin}", 2),
new TokenDefinition(TokenType.Leftover, ".", 3)
];
}
public static IEnumerable<Token> Tokenize(string lqlText)
+1 -1
View File
@@ -1,6 +1,6 @@
namespace ChatTwo.Util;
public class WebinterfaceUtil
public static class WebinterfaceUtil
{
private static readonly Random Rng = new();