From 5ed92b9a0d700e8e6e3b9920c89ec4e3c5b81f17 Mon Sep 17 00:00:00 2001 From: "joshua.software.dev" Date: Wed, 9 Aug 2023 14:20:27 -0700 Subject: [PATCH] Fix occasional text doubling in cactbot popups (alarms, alerts, info) --- LMeter/src/Cactbot/CactbotState.cs | 35 +++++++++++++++++++++++++++--- Version/Version.csproj | 2 +- deps/txt/changelog.md | 3 +++ repo.json | 12 +++++----- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/LMeter/src/Cactbot/CactbotState.cs b/LMeter/src/Cactbot/CactbotState.cs index a7d749a..57c3ff6 100644 --- a/LMeter/src/Cactbot/CactbotState.cs +++ b/LMeter/src/Cactbot/CactbotState.cs @@ -1,8 +1,11 @@ +using AngleSharp.Dom; using AngleSharp.Html.Dom; using Dalamud.Game.Text; using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; namespace LMeter.Cactbot; @@ -109,6 +112,32 @@ private void UpdateTimeline(IHtmlDocument html) } } + private string GetHolderTextContent(IElement? holder) + { + if (holder == null || holder.ChildElementCount < 1) return string.Empty; + if (holder.ChildElementCount > 1) + { + var set = new OrderedDictionary(); + foreach (var child in holder.Children) + { + set[child.TextContent.Trim()] = string.Empty; + } + + var sb = new StringBuilder(); + var i = 0; + foreach (var result in set) + { + if (i > 0) sb.Append('\n'); + sb.Append(((System.Collections.DictionaryEntry) result).Key); + i += 1; + } + + return sb.ToString(); + } + + return holder.TextContent.Trim(); + } + public void UpdateState(IHtmlDocument? html) { if (html == null) @@ -130,7 +159,7 @@ public void UpdateState(IHtmlDocument? html) var info = infoContainer?.GetElementsByClassName("holder")?[0]; var alarmWasEmpty = string.IsNullOrEmpty(Alarm); - Alarm = alarm?.TextContent.Trim(); + Alarm = GetHolderTextContent(alarm); if (alarmWasEmpty && !string.IsNullOrEmpty(Alarm)) { AlarmStateChanged?.Invoke(this, EventArgs.Empty); @@ -141,7 +170,7 @@ public void UpdateState(IHtmlDocument? html) } var alertWasEmpty = string.IsNullOrEmpty(Alert); - Alert = alert?.TextContent.Trim(); + Alert = GetHolderTextContent(alert); if (alertWasEmpty && !string.IsNullOrEmpty(Alert)) { AlertStateChanged?.Invoke(this, EventArgs.Empty); @@ -152,7 +181,7 @@ public void UpdateState(IHtmlDocument? html) } var infoWasEmpty = string.IsNullOrEmpty(Info); - Info = info?.TextContent.Trim(); + Info = GetHolderTextContent(info); if (infoWasEmpty && !string.IsNullOrEmpty(Info)) { InfoStateChanged?.Invoke(this, EventArgs.Empty); diff --git a/Version/Version.csproj b/Version/Version.csproj index 21b1fc8..c386933 100644 --- a/Version/Version.csproj +++ b/Version/Version.csproj @@ -1,5 +1,5 @@ - 0.2.0.18 + 0.2.0.19 diff --git a/deps/txt/changelog.md b/deps/txt/changelog.md index a66a066..4651db5 100644 --- a/deps/txt/changelog.md +++ b/deps/txt/changelog.md @@ -1,3 +1,6 @@ +# Version 0.2.0.19 +- Fix occasional text doubling in cactbot popups (alarms, alerts, info) + # Version 0.2.0.18 - Add option to write all responses from background web browser to log file for debugging purposes. diff --git a/repo.json b/repo.json index f16221e..836c242 100644 --- a/repo.json +++ b/repo.json @@ -25,8 +25,8 @@ "Name": "LMeter", "Description": "Plugin to display ACT combat log data. Now with Cactbot integration!", "InternalName": "LMeter", - "AssemblyVersion": "0.2.0.18", - "TestingAssemblyVersion": "0.2.0.18", + "AssemblyVersion": "0.2.0.19", + "TestingAssemblyVersion": "0.2.0.19", "RepoUrl": "https://github.com/joshua-software-dev/LMeter", "ApplicableVersion": "any", "DalamudApiLevel": 8, @@ -35,10 +35,10 @@ "DownloadCount": 0, "LastUpdate": 0, "LoadPriority": 69420, - "DownloadLinkInstall": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.18/latest.zip", - "DownloadLinkTesting": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.18/latest.zip", - "DownloadLinkUpdate": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.18/latest.zip", + "DownloadLinkInstall": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.19/latest.zip", + "DownloadLinkTesting": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.19/latest.zip", + "DownloadLinkUpdate": "https://github.com/joshua-software-dev/LMeter/releases/download/v0.2.0.19/latest.zip", "IconUrl": "https://raw.githubusercontent.com/joshua-software-dev/LMeter/master/deps/img/icon.png", - "Changelog": "# Version 0.2.0.18\n- Add option to write all responses from background web browser to log file for\n debugging purposes." + "Changelog": "# Version 0.2.0.19\n- Fix occasional text doubling in cactbot popups (alarms, alerts, info)" } ]