diff --git a/BurntToast/BurntToast.cs b/BurntToast/BurntToast.cs
index 455edbb..7cfa5c1 100755
--- a/BurntToast/BurntToast.cs
+++ b/BurntToast/BurntToast.cs
@@ -1,5 +1,5 @@
-using System;
-using Dalamud.Plugin;
+using Dalamud.Plugin;
+using XivCommon;
namespace BurntToast {
public class BurntToast : IDalamudPlugin {
@@ -8,6 +8,7 @@ namespace BurntToast {
internal DalamudPluginInterface Interface { get; private set; } = null!;
internal Configuration Config { get; private set; } = null!;
internal PluginUi Ui { get; private set; } = null!;
+ internal XivCommonBase Common { get; private set; } = null!;
private Commands Commands { get; set; } = null!;
private Filter Filter { get; set; } = null!;
@@ -19,11 +20,13 @@ namespace BurntToast {
this.Ui = new PluginUi(this);
this.Commands = new Commands(this);
+ this.Common = new XivCommonBase(this.Interface, Hooks.BattleTalk);
this.Filter = new Filter(this);
}
public void Dispose() {
this.Filter.Dispose();
+ this.Common.Dispose();
this.Commands.Dispose();
this.Ui.Dispose();
}
diff --git a/BurntToast/BurntToast.csproj b/BurntToast/BurntToast.csproj
index 06649e0..5d0400e 100755
--- a/BurntToast/BurntToast.csproj
+++ b/BurntToast/BurntToast.csproj
@@ -10,22 +10,25 @@
-
- ..\..\Dalamud\bin\Dalamud.dll
+
+ D:\code\Dalamud\bin\Dalamud.dll
False
-
- ..\..\Dalamud\bin\ImGui.NET.dll
+
+ D:\code\Dalamud\bin\ImGui.NET.dll
False
-
- ..\..\Dalamud\bin\ImGuiScene.dll
+
+ D:\code\Dalamud\bin\ImGuiScene.dll
False
-
+
+
+
+
diff --git a/BurntToast/Configuration.cs b/BurntToast/Configuration.cs
index c72e153..5784637 100755
--- a/BurntToast/Configuration.cs
+++ b/BurntToast/Configuration.cs
@@ -1,14 +1,18 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Text.RegularExpressions;
using Dalamud.Configuration;
namespace BurntToast {
+ [Serializable]
public class Configuration : IPluginConfiguration {
private BurntToast Plugin { get; set; } = null!;
public int Version { get; set; } = 1;
- public List Patterns { get; set; } = new List();
+ public List Patterns { get; set; } = new();
+
+ public List BattleTalkPatterns { get; set; } = new();
internal void Initialise(BurntToast plugin) {
this.Plugin = plugin;
@@ -18,4 +22,15 @@ namespace BurntToast {
this.Plugin.Interface.SavePluginConfig(this);
}
}
+
+ [Serializable]
+ public class BattleTalkPattern {
+ public Regex Pattern { get; set; }
+ public bool ShowMessage { get; set; }
+
+ public BattleTalkPattern(Regex pattern, bool showMessage) {
+ this.Pattern = pattern;
+ this.ShowMessage = showMessage;
+ }
+ }
}
diff --git a/BurntToast/Filter.cs b/BurntToast/Filter.cs
index 676883e..e848e2c 100755
--- a/BurntToast/Filter.cs
+++ b/BurntToast/Filter.cs
@@ -1,7 +1,9 @@
using System;
using System.Linq;
using Dalamud.Game.Internal.Gui.Toast;
+using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
+using XivCommon.Functions;
namespace BurntToast {
public class Filter : IDisposable {
@@ -13,14 +15,20 @@ namespace BurntToast {
this.Plugin.Interface.Framework.Gui.Toast.OnToast += this.OnToast;
this.Plugin.Interface.Framework.Gui.Toast.OnQuestToast += this.OnQuestToast;
this.Plugin.Interface.Framework.Gui.Toast.OnErrorToast += this.OnErrorToast;
+ this.Plugin.Common.Functions.BattleTalk.OnBattleTalk += this.OnBattleTalk;
}
public void Dispose() {
+ this.Plugin.Common.Functions.BattleTalk.OnBattleTalk -= this.OnBattleTalk;
this.Plugin.Interface.Framework.Gui.Toast.OnErrorToast -= this.OnErrorToast;
this.Plugin.Interface.Framework.Gui.Toast.OnQuestToast -= this.OnQuestToast;
this.Plugin.Interface.Framework.Gui.Toast.OnToast -= this.OnToast;
}
+ private bool AnyMatches(string text) {
+ return this.Plugin.Config.Patterns.Any(regex => regex.IsMatch(text));
+ }
+
private void OnToast(ref SeString message, ref ToastOptions options, ref bool isHandled) {
this.DoFilter(message, ref isHandled);
}
@@ -38,10 +46,31 @@ namespace BurntToast {
return;
}
- var text = message.TextValue;
- if (this.Plugin.Config.Patterns.Any(regex => regex.IsMatch(text))) {
+ if (this.AnyMatches(message.TextValue)) {
isHandled = true;
}
}
+
+ private void OnBattleTalk(ref SeString sender, ref SeString message, ref BattleTalkOptions options, ref bool isHandled) {
+ if (isHandled) {
+ return;
+ }
+
+ var text = message.TextValue;
+ var pattern = this.Plugin.Config.BattleTalkPatterns.Find(pattern => pattern.Pattern.IsMatch(text));
+ if (pattern == null) {
+ return;
+ }
+
+ isHandled = true;
+
+ if (pattern.ShowMessage) {
+ this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
+ Type = (XivChatType) 68,
+ Name = sender.TextValue,
+ MessageBytes = message.Encode(),
+ });
+ }
+ }
}
}
diff --git a/BurntToast/FodyWeavers.xml b/BurntToast/FodyWeavers.xml
new file mode 100755
index 0000000..2dfb1f4
--- /dev/null
+++ b/BurntToast/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/BurntToast/PluginUi.cs b/BurntToast/PluginUi.cs
index 8c8fff1..042d82a 100755
--- a/BurntToast/PluginUi.cs
+++ b/BurntToast/PluginUi.cs
@@ -46,6 +46,28 @@ namespace BurntToast {
return;
}
+ if (!ImGui.BeginTabBar("burnt-toast-tabs")) {
+ return;
+ }
+
+ if (ImGui.BeginTabItem("Toasts")) {
+ this.DrawToastTab();
+ ImGui.EndTabItem();
+ }
+
+ if (ImGui.BeginTabItem("Battle talk")) {
+ this.DrawBattleTalkTab();
+ ImGui.EndTabItem();
+ }
+
+ ImGui.EndTabBar();
+
+
+
+ ImGui.End();
+ }
+
+ private void DrawToastTab() {
ImGui.PushTextWrapPos();
ImGui.TextUnformatted("Add regular expressions to filter below. Any toast matching a regular expression on the list will be hidden.");
ImGui.PopTextWrapPos();
@@ -96,8 +118,66 @@ namespace BurntToast {
if (toRemove != null) {
this.Plugin.Config.Patterns.RemoveAt(toRemove.Value);
}
+ }
- ImGui.End();
+ private void DrawBattleTalkTab() {
+ ImGui.PushTextWrapPos();
+ ImGui.TextUnformatted("Add regular expressions to filter below. Any battle talk matching a regular expression on the list will be hidden.");
+ ImGui.PopTextWrapPos();
+
+ if (ImGui.Button("Add")) {
+ this.Plugin.Config.BattleTalkPatterns.Add(new BattleTalkPattern(new Regex(""), true));
+ }
+
+ ImGui.Separator();
+
+ int? toRemove = null;
+
+ for (var i = 0; i < this.Plugin.Config.BattleTalkPatterns.Count; i++) {
+ var pattern = this.Plugin.Config.BattleTalkPatterns[i];
+ var patternText = pattern.Pattern.ToString();
+ var textResult = ImGui.InputText($"##pattern-{i}", ref patternText, 250);
+
+ ImGui.SameLine();
+ var show = pattern.ShowMessage;
+ if (ImGui.Checkbox("Show in chat", ref show)) {
+ pattern.ShowMessage = show;
+ this.Plugin.Config.Save();
+ }
+
+ ImGui.SameLine();
+ if (ImGui.Button($"Delete##{i}")) {
+ toRemove = i;
+ }
+
+ if (!textResult) {
+ continue;
+ }
+
+ if (string.IsNullOrWhiteSpace(patternText)) {
+ continue;
+ }
+
+ Regex? regex = null;
+ try {
+ regex = new Regex(patternText, RegexOptions.Compiled);
+ } catch (ArgumentException) {
+ ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1f, 0f, 0f, 1f));
+ ImGui.TextUnformatted("Invalid regular expression.");
+ ImGui.PopStyleColor();
+ }
+
+ if (regex == null) {
+ continue;
+ }
+
+ pattern.Pattern = regex;
+ this.Plugin.Config.Save();
+ }
+
+ if (toRemove != null) {
+ this.Plugin.Config.BattleTalkPatterns.RemoveAt(toRemove.Value);
+ }
}
}
}