diff --git a/Addons/DataToColor/DataToColor.lua b/Addons/DataToColor/DataToColor.lua index 7307b3e6..0c0c5643 100644 --- a/Addons/DataToColor/DataToColor.lua +++ b/Addons/DataToColor/DataToColor.lua @@ -456,6 +456,17 @@ function DataToColor:CreateFrames() Pixel(int, DataToColor.globalTime, GLOBAL_TIME_CELL) end + local function IdxToRadix(input) + if input == 1 then + return 10000 + elseif input == 2 then + return 100 + elseif input == 3 then + return 1 + end + return 0 + end + local function updateFrames() if not SETUP_SEQUENCE and globalCounter >= initPhase then Pixel(int, 0, 0) @@ -873,22 +884,20 @@ function DataToColor:CreateFrames() DataToColor.ChatQueue:shift() chatMsgHead = -2 else - local s = sub(e.msg, chatMsgHead, chatMsgHead + 2) - local ASCII = '' - for i = 1, len(s) do - local c = upper(sub(s, i)) - local b = byte(c) or 32 - - if b == 32 or b > 100 then -- space has no upper - b = byte('@') + local part = sub(e.msg, chatMsgHead, chatMsgHead + 2) + local number = 0 + local length = len(part) + for i = 1, length do + local c = upper(sub(part, i)) + local b = byte(c) or 32 -- SPACE character fallback + if b > 100 then + b = 32 end - - ASCII = ASCII .. b + number = number + (b * IdxToRadix(i + (3 - length))) end - --print(e.length, chatMsgHead, "'" .. s .. "'", ASCII) - - Pixel(int, tonumber(ASCII), 98) + --print(e.length, chatMsgHead, "'" .. part .. "'", number) + Pixel(int, number, 98) Pixel(int, e.type * 1000000 + 1000 * e.length + chatMsgHead, 99) end end diff --git a/Addons/DataToColor/DataToColor.toc b/Addons/DataToColor/DataToColor.toc index 7d775e1e..5327cad0 100644 --- a/Addons/DataToColor/DataToColor.toc +++ b/Addons/DataToColor/DataToColor.toc @@ -3,7 +3,7 @@ ## Title: DataToColor ## Author: FreeHongKongMMO ## Notes: Displays data as colors -## Version: 1.7.48 +## Version: 1.7.49 ## RequiredDeps: ## OptionalDeps: Ace3, LibRangeCheck, LibClassicCasterino ## SavedVariables: diff --git a/Core/Addon/AddonReader.cs b/Core/Addon/AddonReader.cs index 90931b86..291e5f8a 100644 --- a/Core/Addon/AddonReader.cs +++ b/Core/Addon/AddonReader.cs @@ -80,7 +80,7 @@ public void Update() TargetName = creatureDb.Entries.TryGetValue(playerReader.TargetId, out string? name) ? name - : reader.GetString(16) + reader.GetString(17); + : reader.GetString(16).Trim() + reader.GetString(17).Trim(); } if (lastMouseOverId != playerReader.MouseOverId) diff --git a/Core/AddonDataProvider/IAddonDataProvider.cs b/Core/AddonDataProvider/IAddonDataProvider.cs index e6aeb7fa..82f99944 100644 --- a/Core/AddonDataProvider/IAddonDataProvider.cs +++ b/Core/AddonDataProvider/IAddonDataProvider.cs @@ -71,6 +71,6 @@ string GetString(int index) n = color % 100; if (n > 0) TextBuilder.Append((char)n); - return TextBuilder.ToString().Trim(); + return TextBuilder.ToString(); } } diff --git a/Core/Chat/ChatReader.cs b/Core/Chat/ChatReader.cs index 58732cd8..c98c455c 100644 --- a/Core/Chat/ChatReader.cs +++ b/Core/Chat/ChatReader.cs @@ -56,7 +56,7 @@ public void Update(IAddonDataProvider reader) else if (_head == head) return; - string part = reader.GetString(cMsg).Replace('@', ' '); + string part = reader.GetString(cMsg); sb.Append(part); @@ -68,9 +68,9 @@ public void Update(IAddonDataProvider reader) int firstSpaceIdx = text.AsSpan().IndexOf(' '); string author = text.AsSpan(0, firstSpaceIdx).ToString(); - text = text.AsSpan(firstSpaceIdx + 1).ToString(); + string msg = text.AsSpan(firstSpaceIdx + 1).ToString(); - ChatMessageEntry entry = new(DateTime.Now, type, author, text); + ChatMessageEntry entry = new(DateTime.Now, type, author, msg); Messages.Add(entry); logger.LogInformation(entry.ToString()); }