Skip to content

Commit

Permalink
added more bothers and SelectOk support (#109)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Jaksuhn authored Nov 8, 2023
1 parent 0cef58a commit f98136d
Show file tree
Hide file tree
Showing 12 changed files with 474 additions and 8 deletions.
23 changes: 23 additions & 0 deletions YesAlready/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -62,10 +66,12 @@ public IEnumerable<ITextNode> GetAllNodes()
return new ITextNode[]
{
RootFolder,
OkRootFolder,
ListRootFolder,
TalkRootFolder,
}
.Concat(GetAllNodes(RootFolder.Children))
.Concat(GetAllNodes(OkRootFolder.Children))
.Concat(GetAllNodes(ListRootFolder.Children))
.Concat(GetAllNodes(TalkRootFolder.Children));
}
Expand Down Expand Up @@ -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);
}
}
1 change: 0 additions & 1 deletion YesAlready/Features/AddonFGSEnterDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using ClickLib.Clicks;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using ECommons.Automation;
Expand Down
1 change: 0 additions & 1 deletion YesAlready/Features/AddonFGSExitDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using ClickLib.Clicks;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using ECommons.Automation;
Expand Down
1 change: 0 additions & 1 deletion YesAlready/Features/AddonItemInspectionResultFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 39 additions & 0 deletions YesAlready/Features/AddonPurifyResult.cs
Original file line number Diff line number Diff line change
@@ -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<Addon>().First(x => x.RowId == 2171).Text.RawString)
{
Svc.Log.Debug("Closing Purify Results menu");
Callback.Fire(addon, true, -1);
}
}
}
40 changes: 40 additions & 0 deletions YesAlready/Features/AddonRetainerItemTransferProgressFeature.cs
Original file line number Diff line number Diff line change
@@ -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<Addon>().First(x => x.RowId == 13528).Text.RawString)
{
Svc.Log.Debug("Closing Entrust Duplicates menu");
Callback.Fire(addon, true, -1);
}
}
}
37 changes: 37 additions & 0 deletions YesAlready/Features/AddonSalvageResult.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
56 changes: 56 additions & 0 deletions YesAlready/Features/AddonSelectOkFeature.cs
Original file line number Diff line number Diff line change
@@ -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<OkEntryNode>();
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));
}
}
4 changes: 0 additions & 4 deletions YesAlready/IPC/BlockListHandler.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Loading

0 comments on commit f98136d

Please sign in to comment.