Selectyesno predicates

This commit is contained in:
Liza 2023-09-22 22:51:56 +02:00
parent 37adccad11
commit 5d81b293b7
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 6 additions and 13 deletions

View File

@ -92,7 +92,7 @@ partial class DeliverooPlugin
private void ConfirmReward() private void ConfirmReward()
{ {
if (SelectSelectYesno(0)) if (SelectSelectYesno(0, s => s.StartsWith("Exchange ")))
{ {
CurrentStage = Stage.CloseGcExchange; CurrentStage = Stage.CloseGcExchange;
_continueAt = DateTime.Now.AddSeconds(0.5); _continueAt = DateTime.Now.AddSeconds(0.5);

View File

@ -118,16 +118,8 @@ partial class DeliverooPlugin
private unsafe void TurnInSelectedItem() private unsafe void TurnInSelectedItem()
{ {
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) && if (SelectSelectYesno(0, s => s == "Do you really want to trade a high-quality item?"))
IsAddonReady(&addonSelectYesno->AtkUnitBase)) return;
{
if (MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText).ToString()
.StartsWith("Do you really want to trade a high-quality item?"))
{
addonSelectYesno->AtkUnitBase.FireCallbackInt(0);
return;
}
}
if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward", if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase)) out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))

View File

@ -442,10 +442,11 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
return false; return false;
} }
private unsafe bool SelectSelectYesno(int choice) private unsafe bool SelectSelectYesno(int choice, Predicate<string> predicate)
{ {
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) && if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) &&
IsAddonReady(&addonSelectYesno->AtkUnitBase)) IsAddonReady(&addonSelectYesno->AtkUnitBase) &&
predicate(MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText).ToString()))
{ {
PluginLog.Information( PluginLog.Information(
$"Selecting choice={choice} for '{MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText)}'"); $"Selecting choice={choice} for '{MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText)}'");