From f98136de8d85d5c7f3adc5439b40da32e603bb5b Mon Sep 17 00:00:00 2001 From: Jackson <9527380+Jaksuhn@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:52:12 +0000 Subject: [PATCH] added more bothers and SelectOk support (#109) * added clicklib as submodule * added dtrbar support * redundant dtr setting removal & tooltip fix * add ipc * added punishlib * disabled the about tab, kawaii pls fix * disable hotkey fix? * revert the readme * fixed lootboxes results not printing to chat * fixed logs that were supposed to be chat prints * fixed multi line handling in selectyesno * fixed zonelistwindow * added bothers and selectOk support Bothers: RetainerItemTransferProgress auto confirm PurifyResult auto confirm SalvageResult auto confirm added Ok menu to deal with SelectOk addons in the same way as SelectYesno * description clarification * changed from framework update to addonlifecycle --- YesAlready/Configuration.cs | 23 ++ YesAlready/Features/AddonFGSEnterDialog.cs | 1 - YesAlready/Features/AddonFGSExitDialog.cs | 1 - .../AddonItemInspectionResultFeature.cs | 1 - YesAlready/Features/AddonPurifyResult.cs | 39 ++++ ...ddonRetainerItemTransferProgressFeature.cs | 40 ++++ YesAlready/Features/AddonSalvageResult.cs | 37 +++ YesAlready/Features/AddonSelectOkFeature.cs | 56 +++++ YesAlready/IPC/BlockListHandler.cs | 4 - YesAlready/UI/MainWindow.cs | 220 +++++++++++++++++- YesAlready/YesAlready.cs | 21 ++ YesAlready/YesAlreadyConfigurationTypes.cs | 39 ++++ 12 files changed, 474 insertions(+), 8 deletions(-) create mode 100644 YesAlready/Features/AddonPurifyResult.cs create mode 100644 YesAlready/Features/AddonRetainerItemTransferProgressFeature.cs create mode 100644 YesAlready/Features/AddonSalvageResult.cs create mode 100644 YesAlready/Features/AddonSelectOkFeature.cs diff --git a/YesAlready/Configuration.cs b/YesAlready/Configuration.cs index d919aed..2cb4085 100644 --- a/YesAlready/Configuration.cs +++ b/YesAlready/Configuration.cs @@ -18,6 +18,7 @@ public partial class Configuration() : IPluginConfiguration public VirtualKey ForcedYesKey { get; set; } = VirtualKey.NO_KEY; public VirtualKey DisableKey { get; set; } = VirtualKey.NO_KEY; public TextFolderNode RootFolder { get; private set; } = new TextFolderNode { Name = "/" }; + public TextFolderNode OkRootFolder { get; private set; } = new TextFolderNode { Name = "/" }; public TextFolderNode ListRootFolder { get; private set; } = new TextFolderNode { Name = "/" }; public TextFolderNode TalkRootFolder { get; private set; } = new TextFolderNode { Name = "/" }; public bool DesynthDialogEnabled { get; set; } = false; @@ -40,6 +41,9 @@ public partial class Configuration() : IPluginConfiguration public bool GuildLeveDifficultyConfirm { get; set; } = false; public bool FallGuysRegisterConfirm { get; set; } = false; public bool FallGuysExitConfirm { get; set; } = false; + public bool RetainerTransferProgressConfirm { get; set; } = false; + public bool DesynthesisResults { get; set; } = false; + public bool AetherialReductionResults { get; set; } = false; public static Configuration Load(DirectoryInfo configDirectory) { @@ -62,10 +66,12 @@ public IEnumerable GetAllNodes() return new ITextNode[] { RootFolder, + OkRootFolder, ListRootFolder, TalkRootFolder, } .Concat(GetAllNodes(RootFolder.Children)) + .Concat(GetAllNodes(OkRootFolder.Children)) .Concat(GetAllNodes(ListRootFolder.Children)) .Concat(GetAllNodes(TalkRootFolder.Children)); } @@ -135,4 +141,21 @@ public static void CreateTextNode(TextFolderNode folder, bool zoneRestricted, bo chosenFolder.Children.Add(newNode); } + + public static void CreateOkNode(TextFolderNode folder, bool createFolder) + { + var newNode = new OkEntryNode() { Enabled = true, Text = P.LastSeenOkText }; + var chosenFolder = folder; + + if (createFolder) + { + if (chosenFolder == default) + { + chosenFolder = new TextFolderNode { Name = chosenFolder.Name }; + folder.Children.Add(chosenFolder); + } + } + + chosenFolder.Children.Add(newNode); + } } diff --git a/YesAlready/Features/AddonFGSEnterDialog.cs b/YesAlready/Features/AddonFGSEnterDialog.cs index 2ed1236..6b29607 100644 --- a/YesAlready/Features/AddonFGSEnterDialog.cs +++ b/YesAlready/Features/AddonFGSEnterDialog.cs @@ -1,4 +1,3 @@ -using ClickLib.Clicks; using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using ECommons.Automation; diff --git a/YesAlready/Features/AddonFGSExitDialog.cs b/YesAlready/Features/AddonFGSExitDialog.cs index 84802f8..cd2fc58 100644 --- a/YesAlready/Features/AddonFGSExitDialog.cs +++ b/YesAlready/Features/AddonFGSExitDialog.cs @@ -1,4 +1,3 @@ -using ClickLib.Clicks; using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using ECommons.Automation; diff --git a/YesAlready/Features/AddonItemInspectionResultFeature.cs b/YesAlready/Features/AddonItemInspectionResultFeature.cs index f3bfbc7..7333385 100644 --- a/YesAlready/Features/AddonItemInspectionResultFeature.cs +++ b/YesAlready/Features/AddonItemInspectionResultFeature.cs @@ -2,7 +2,6 @@ using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using Dalamud.Game.Text.SeStringHandling.Payloads; -using ECommons.DalamudServices; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Component.GUI; using YesAlready.BaseFeatures; diff --git a/YesAlready/Features/AddonPurifyResult.cs b/YesAlready/Features/AddonPurifyResult.cs new file mode 100644 index 0000000..56f5975 --- /dev/null +++ b/YesAlready/Features/AddonPurifyResult.cs @@ -0,0 +1,39 @@ +using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using Dalamud.Game.Addon.Lifecycle; +using ECommons.Automation; +using ECommons.DalamudServices; +using FFXIVClientStructs.FFXIV.Component.GUI; +using Lumina.Excel.GeneratedSheets; +using System.Linq; +using YesAlready.BaseFeatures; + +namespace YesAlready.Features; + +internal class AddonPurifyResult : BaseFeature +{ + public override void Enable() + { + base.Enable(); + AddonLifecycle.RegisterListener(AddonEvent.PostUpdate, "PurifyResult", AddonUpdate); + } + + public override void Disable() + { + base.Disable(); + AddonLifecycle.UnregisterListener(AddonUpdate); + } + + protected static unsafe void AddonUpdate(AddonEvent eventType, AddonArgs addonInfo) + { + var addon = (AtkUnitBase*)addonInfo.Addon; + + if (!P.Active || !P.Config.AetherialReductionResults) + return; + + if (addon->UldManager.NodeList[17]->GetAsAtkTextNode()->NodeText.ToString() == Svc.Data.GetExcelSheet().First(x => x.RowId == 2171).Text.RawString) + { + Svc.Log.Debug("Closing Purify Results menu"); + Callback.Fire(addon, true, -1); + } + } +} diff --git a/YesAlready/Features/AddonRetainerItemTransferProgressFeature.cs b/YesAlready/Features/AddonRetainerItemTransferProgressFeature.cs new file mode 100644 index 0000000..ba46f83 --- /dev/null +++ b/YesAlready/Features/AddonRetainerItemTransferProgressFeature.cs @@ -0,0 +1,40 @@ +using Dalamud.Game.Addon.Lifecycle; +using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using Dalamud.Memory; +using ECommons.Automation; +using ECommons.DalamudServices; +using FFXIVClientStructs.FFXIV.Component.GUI; +using Lumina.Excel.GeneratedSheets; +using System.Linq; +using YesAlready.BaseFeatures; + +namespace YesAlready.Features; + +internal class AddonRetainerItemTransferProgressFeature : BaseFeature +{ + public override void Enable() + { + base.Enable(); + AddonLifecycle.RegisterListener(AddonEvent.PostUpdate, "RetainerItemTransferProgress", AddonUpdate); + } + + public override void Disable() + { + base.Disable(); + AddonLifecycle.UnregisterListener(AddonUpdate); + } + + protected static unsafe void AddonUpdate(AddonEvent eventType, AddonArgs addonInfo) + { + var addon = (AtkUnitBase*)addonInfo.Addon; + + if (!P.Active || !P.Config.RetainerTransferProgressConfirm) + return; + + if (MemoryHelper.ReadSeStringNullTerminated(new nint(addon->AtkValues[0].String)).ToString() == Svc.Data.GetExcelSheet().First(x => x.RowId == 13528).Text.RawString) + { + Svc.Log.Debug("Closing Entrust Duplicates menu"); + Callback.Fire(addon, true, -1); + } + } +} diff --git a/YesAlready/Features/AddonSalvageResult.cs b/YesAlready/Features/AddonSalvageResult.cs new file mode 100644 index 0000000..83e88c5 --- /dev/null +++ b/YesAlready/Features/AddonSalvageResult.cs @@ -0,0 +1,37 @@ +using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using Dalamud.Game.Addon.Lifecycle; +using ECommons.Automation; +using ECommons.DalamudServices; +using FFXIVClientStructs.FFXIV.Component.GUI; +using YesAlready.BaseFeatures; + +namespace YesAlready.Features; + +internal class AddonSalvageResult : BaseFeature +{ + public override void Enable() + { + base.Enable(); + AddonLifecycle.RegisterListener(AddonEvent.PostUpdate, "SalvageResult", AddonUpdate); + } + + public override void Disable() + { + base.Disable(); + AddonLifecycle.UnregisterListener(AddonUpdate); + } + + protected static unsafe void AddonUpdate(AddonEvent eventType, AddonArgs addonInfo) + { + var addon = (AtkUnitBase*)addonInfo.Addon; + + if (!P.Active || !P.Config.DesynthesisResults) + return; + + if (addon->AtkValues[17].Byte == 0) + { + Svc.Log.Debug("Closing Salvage Auto Results menu"); + Callback.Fire(addon, true, 1); + } + } +} diff --git a/YesAlready/Features/AddonSelectOkFeature.cs b/YesAlready/Features/AddonSelectOkFeature.cs new file mode 100644 index 0000000..661ec28 --- /dev/null +++ b/YesAlready/Features/AddonSelectOkFeature.cs @@ -0,0 +1,56 @@ +using System.Linq; + +using ClickLib.Clicks; +using Dalamud.Game.Addon.Lifecycle; +using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using ECommons.DalamudServices; +using FFXIVClientStructs.FFXIV.Component.GUI; +using YesAlready.BaseFeatures; + +namespace YesAlready.Features; + +internal class AddonSelectOkFeature : BaseFeature +{ + public override void Enable() + { + base.Enable(); + AddonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectOk", AddonSetup); + } + + public override void Disable() + { + base.Disable(); + AddonLifecycle.UnregisterListener(AddonSetup); + } + + protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo) + { + var addon = (AtkUnitBase*)addonInfo.Addon; + + if (!P.Active) + return; + + var text = P.LastSeenOkText = Utils.SEString.GetSeStringText(new nint(addon->AtkValues[0].String)); + Svc.Log.Debug($"AddonSelectOk: text={text}"); + + var nodes = P.Config.GetAllNodes().OfType(); + foreach (var node in nodes) + { + if (!node.Enabled || string.IsNullOrEmpty(node.Text)) + continue; + + if (!EntryMatchesText(node, text)) + continue; + + Svc.Log.Debug("AddonSelectYesNo: Selecting yes"); + ClickSelectOk.Using(new nint(addon)).Ok(); + return; + } + } + + private static bool EntryMatchesText(OkEntryNode node, string text) + { + return (node.IsTextRegex && (node.TextRegex?.IsMatch(text) ?? false)) || + (!node.IsTextRegex && text.Contains(node.Text)); + } +} diff --git a/YesAlready/IPC/BlockListHandler.cs b/YesAlready/IPC/BlockListHandler.cs index 60cf2db..1f40d98 100644 --- a/YesAlready/IPC/BlockListHandler.cs +++ b/YesAlready/IPC/BlockListHandler.cs @@ -1,9 +1,5 @@ using ECommons.DalamudServices; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace YesAlready.IPC { diff --git a/YesAlready/UI/MainWindow.cs b/YesAlready/UI/MainWindow.cs index 6c72abd..98816b0 100644 --- a/YesAlready/UI/MainWindow.cs +++ b/YesAlready/UI/MainWindow.cs @@ -10,7 +10,6 @@ using ECommons.DalamudServices; using ClickLib.Exceptions; using System.Linq; -using PunishLib.ImGuiMethods; using Dalamud.Interface.Colors; using ECommons; using ECommons.Reflection; @@ -49,6 +48,8 @@ public MainWindow() : base($"{Name} {P.GetType().Assembly.GetName().Version}###{ private static TextFolderNode RootFolder => P.Config.RootFolder; + private static TextFolderNode OkRootFolder => P.Config.OkRootFolder; + private static TextFolderNode ListRootFolder => P.Config.ListRootFolder; private static TextFolderNode TalkRootFolder => P.Config.TalkRootFolder; @@ -85,6 +86,7 @@ public override void Draw() if (ImGui.BeginTabBar("Settings")) { DisplayTextOptions(); + DisplayOkOptions(); DisplayListOptions(); DisplayTalkOptions(); DisplayBotherOptions(); @@ -183,6 +185,21 @@ private void DisplayTextOptions() ImGui.EndTabItem(); } + private void DisplayOkOptions() + { + if (!ImGui.BeginTabItem("Ok")) + return; + + ImGui.PushID("OkOptions"); + + DisplayOkButtons(); + DisplayOkNodes(); + + ImGui.PopID(); + + ImGui.EndTabItem(); + } + private void DisplayListOptions() { if (!ImGui.BeginTabItem("Lists")) @@ -293,6 +310,30 @@ static void IndentedTextColored(Vector4 color, string text) IndentedTextColored(shadedColor, "Check the bulk desynthesis button when using the SalvageDialog feature."); + #endregion + #region SalvageResult + + var desynthResultsDialog = P.Config.DesynthesisResults; + if (ImGui.Checkbox("SalvageResults", ref desynthResultsDialog)) + { + P.Config.DesynthesisResults = desynthResultsDialog; + P.Config.Save(); + } + + IndentedTextColored(shadedColor, "Automatically closes the SalvageResults window when done desynthing."); + + #endregion + #region PurifyResult + + var purifyResultsDialog = P.Config.AetherialReductionResults; + if (ImGui.Checkbox("PurifyResult", ref purifyResultsDialog)) + { + P.Config.AetherialReductionResults = purifyResultsDialog; + P.Config.Save(); + } + + IndentedTextColored(shadedColor, "Automatically closes the PurifyResult window when done reducing."); + #endregion #region MaterializeDialog @@ -371,6 +412,18 @@ static void IndentedTextColored(Vector4 color, string text) IndentedTextColored(shadedColor, "Automatically send a retainer on the same venture as before when receiving an item."); + #endregion + #region RetainerProgress + + var retainerProgressDialog = P.Config.RetainerTransferProgressConfirm; + if (ImGui.Checkbox("RetainerItemTransferProgress", ref retainerProgressDialog)) + { + P.Config.RetainerTransferProgressConfirm = retainerProgressDialog; + P.Config.Save(); + } + + IndentedTextColored(shadedColor, "Automatically closes the RetainerItemTransferProgress window when finished entrusting items."); + #endregion #region GrandCompanySupplyReward @@ -590,6 +643,82 @@ private void DisplayTextNodes() // ==================================================================================================== + private static void DisplayOkButtons() + { + var style = ImGui.GetStyle(); + var newStyle = new Vector2(style.ItemSpacing.X / 2, style.ItemSpacing.Y); + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newStyle); + + if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.Plus, "Add new entry")) + { + var newNode = new OkEntryNode { Enabled = false, Text = "Your text goes here" }; + OkRootFolder.Children.Add(newNode); + P.Config.Save(); + } + + ImGui.SameLine(); + if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.SearchPlus, "Add last seen as new entry")) + { + var io = ImGui.GetIO(); + var createFolder = io.KeyShift; + + Configuration.CreateOkNode(OkRootFolder, createFolder); + P.Config.Save(); + } + + ImGui.SameLine(); + if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.FolderPlus, "Add folder")) + { + var newNode = new TextFolderNode { Name = "Untitled folder" }; + OkRootFolder.Children.Add(newNode); + P.Config.Save(); + } + + var sb = new StringBuilder(); + sb.AppendLine("Enter into the input all or part of the text inside a dialog."); + sb.AppendLine("For example: \"You cannot carry any more letters\" for the full mailbox dialog."); + sb.AppendLine(); + sb.AppendLine("Alternatively, wrap your text in forward slashes to use as a regex."); + sb.AppendLine("As such: \"/.* carry any more letters .*/\""); + sb.AppendLine(); + sb.AppendLine("If it matches, the ok button will be clicked."); + sb.AppendLine(); + sb.AppendLine("Right click a line to view options."); + sb.AppendLine("Double click an entry for quick enable/disable."); + sb.AppendLine("Ctrl-Shift right click a line to delete it and any children."); + sb.AppendLine(); + sb.AppendLine("\"Add last seen as new entry\" button modifiers:"); + sb.AppendLine(" Shift-Click to add to a new or first existing folder with the current zone name, restricted to that zone."); + sb.AppendLine(); + sb.AppendLine("Currently supported text addons:"); + sb.AppendLine(" - SelectOk"); + + ImGui.SameLine(); + Utils.ImGuiEx.IconButton(FontAwesomeIcon.QuestionCircle, sb.ToString()); + if (ImGui.IsItemHovered()) ImGui.SetTooltip(sb.ToString()); + + ImGui.PopStyleVar(); // ItemSpacing + } + + private void DisplayOkNodes() + { + var root = OkRootFolder; + TextNodeDragDrop(root); + + if (root.Children.Count == 0) + { + root.Children.Add(new OkEntryNode() { Enabled = false, Text = "Add some text here!" }); + P.Config.Save(); + } + + foreach (var node in root.Children.ToArray()) + { + DisplayTextNode(node, root); + } + } + + // ==================================================================================================== + private static void DisplayListButtons() { var style = ImGui.GetStyle(); @@ -746,6 +875,10 @@ private void DisplayTextNode(ITextNode node, TextFolderNode rootNode) { DisplayTextEntryNode(textNode); } + else if (node is OkEntryNode okNode) + { + DisplayOkEntryNode(okNode); + } else if (node is ListEntryNode listNode) { DisplayListEntryNode(listNode); @@ -813,6 +946,58 @@ private void DisplayTextEntryNode(TextEntryNode node) TextNodeDragDrop(node); } + private void DisplayOkEntryNode(OkEntryNode node) + { + var validRegex = (node.IsTextRegex && node.TextRegex != null) || !node.IsTextRegex; + + if (!node.Enabled && !validRegex) + ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(.5f, 0, 0, 1)); + else if (!node.Enabled) + ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(.5f, .5f, .5f, 1)); + else if (!validRegex) + ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 0, 0, 1)); + + ImGui.TreeNodeEx($"{node.Name}##{node.Name}-tree", ImGuiTreeNodeFlags.Leaf); + ImGui.TreePop(); + + if (!node.Enabled || !validRegex) + ImGui.PopStyleColor(); + + if (!validRegex) + Utils.ImGuiEx.TextTooltip("Invalid Text Regex"); + + if (ImGui.IsItemHovered()) + { + if (ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left)) + { + node.Enabled = !node.Enabled; + P.Config.Save(); + return; + } + else if (ImGui.IsMouseClicked(ImGuiMouseButton.Right)) + { + var io = ImGui.GetIO(); + if (io.KeyCtrl && io.KeyShift) + { + if (P.Config.TryFindParent(node, out var parent)) + { + parent!.Children.Remove(node); + P.Config.Save(); + } + + return; + } + else + { + ImGui.OpenPopup($"{node.GetHashCode()}-popup"); + } + } + } + + TextNodePopup(node); + TextNodeDragDrop(node); + } + private void DisplayListEntryNode(ListEntryNode node) { var validRegex = (node.IsTextRegex && node.TextRegex != null) || !node.IsTextRegex; @@ -1050,6 +1235,39 @@ private static void TextNodePopup(ITextNode node, TextFolderNode? root = null) } } + if (node is OkEntryNode okNode) + { + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newItemSpacing); + + var enabled = okNode.Enabled; + if (ImGui.Checkbox("Enabled", ref enabled)) + { + okNode.Enabled = enabled; + P.Config.Save(); + } + + var trashAltWidth = Utils.ImGuiEx.GetIconButtonWidth(FontAwesomeIcon.TrashAlt); + + ImGui.SameLine(ImGui.GetContentRegionMax().X - trashAltWidth); + if (Utils.ImGuiEx.IconButton(FontAwesomeIcon.TrashAlt, "Delete")) + { + if (P.Config.TryFindParent(node, out var parentNode)) + { + parentNode!.Children.Remove(node); + P.Config.Save(); + } + } + + var matchText = okNode.Text; + if (ImGui.InputText($"##{node.Name}-matchText", ref matchText, 10_000, ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.EnterReturnsTrue)) + { + okNode.Text = matchText; + P.Config.Save(); + } + + ImGui.PopStyleVar(); // ItemSpacing + } + if (node is ListEntryNode listNode) { ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, newItemSpacing); diff --git a/YesAlready/YesAlready.cs b/YesAlready/YesAlready.cs index 66ebd4b..87b418f 100644 --- a/YesAlready/YesAlready.cs +++ b/YesAlready/YesAlready.cs @@ -18,6 +18,7 @@ using Dalamud.IoC; using Dalamud.Plugin.Services; using YesAlready.IPC; + namespace YesAlready; public class YesAlready : IDalamudPlugin @@ -133,6 +134,7 @@ public void Dispose() internal Dictionary TerritoryNames { get; } = new(); internal string LastSeenDialogText { get; set; } = string.Empty; + internal string LastSeenOkText { get; set; } = string.Empty; internal string LastSeenListSelection { get; set; } = string.Empty; internal string LastSeenListTarget { get; set; } = string.Empty; internal string LastSeenTalkTarget { get; set; } = string.Empty; @@ -238,6 +240,9 @@ private void OnCommand(string command, string arguments) case "last zone folder no": CommandAddNode(true, true, true); break; + case "lastok": + CommandAddOkNode(false); + break; case "lastlist": CommandAddListNode(); break; @@ -291,6 +296,22 @@ private void CommandAddNode(bool zoneRestricted, bool createFolder, bool selectN Utils.SEString.PrintPluginMessage("Added a new text entry."); } + private void CommandAddOkNode(bool createFolder) + { + var text = LastSeenOkText; + + if (text.IsNullOrEmpty()) + { + Svc.Log.Error("No dialog has been seen."); + return; + } + + Configuration.CreateOkNode(Config.RootFolder, createFolder); + Config.Save(); + + Utils.SEString.PrintPluginMessage("Added a new text entry."); + } + private void CommandAddListNode() { var text = LastSeenListSelection; diff --git a/YesAlready/YesAlreadyConfigurationTypes.cs b/YesAlready/YesAlreadyConfigurationTypes.cs index 850d451..fe5d13d 100644 --- a/YesAlready/YesAlreadyConfigurationTypes.cs +++ b/YesAlready/YesAlreadyConfigurationTypes.cs @@ -74,6 +74,41 @@ public Regex? ZoneRegex public bool IsYes { get; set; } = true; } +public class OkEntryNode : ITextNode +{ + public bool Enabled { get; set; } = true; + + [JsonIgnore] + public string Name + { + get + { + return Text; + } + } + + public string Text { get; set; } = string.Empty; + + [JsonIgnore] + public bool IsTextRegex => Text.StartsWith("/") && Text.EndsWith("/"); + + [JsonIgnore] + public Regex? TextRegex + { + get + { + try + { + return new(Text.Trim('/'), RegexOptions.Compiled | RegexOptions.IgnoreCase); + } + catch + { + return null; + } + } + } +} + public class ListEntryNode : ITextNode { public bool Enabled { get; set; } = true; @@ -194,6 +229,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis { return CreateObject(jObject, serializer); } + else if (jType == SimpleName(typeof(OkEntryNode))) + { + return CreateObject(jObject, serializer); + } else if (jType == SimpleName(typeof(ListEntryNode))) { return CreateObject(jObject, serializer);