Workship/Workshoppa/WorkshopPlugin.SelectYesNo.cs

82 lines
3.3 KiB
C#
Raw Normal View History

2023-10-13 20:08:22 +00:00
using System;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.UI;
namespace Workshoppa;
partial class WorkshopPlugin
{
private unsafe void SelectYesNoPostSetup(AddonEvent type, AddonArgs args)
{
_pluginLog.Verbose("SelectYesNo post-setup");
AddonSelectYesno* addonSelectYesNo = (AddonSelectYesno*)args.Addon;
2024-03-20 18:52:54 +00:00
string text = MemoryHelper.ReadSeString(&addonSelectYesNo->PromptText->NodeText).ToString()
.Replace("\n", "", StringComparison.Ordinal)
.Replace("\r", "", StringComparison.Ordinal);
2023-10-13 20:08:22 +00:00
_pluginLog.Verbose($"YesNo prompt: '{text}'");
if (_repairKitWindow.IsOpen)
{
_pluginLog.Verbose($"Checking for Repair Kit YesNo ({_repairKitWindow.AutoBuyEnabled}, {_repairKitWindow.IsAwaitingYesNo})");
2023-10-24 22:19:42 +00:00
if (_repairKitWindow.AutoBuyEnabled && _repairKitWindow.IsAwaitingYesNo && _gameStrings.PurchaseItemForGil.IsMatch(text))
2023-10-13 20:08:22 +00:00
{
_pluginLog.Information($"Selecting 'yes' ({text})");
_repairKitWindow.IsAwaitingYesNo = false;
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
}
else
{
_pluginLog.Verbose("Not a purchase confirmation match");
}
}
2023-10-24 22:19:42 +00:00
else if (_ceruleumTankWindow.IsOpen)
{
_pluginLog.Verbose($"Checking for Ceruleum Tank YesNo ({_ceruleumTankWindow.AutoBuyEnabled}, {_ceruleumTankWindow.IsAwaitingYesNo})");
if (_ceruleumTankWindow.AutoBuyEnabled && _ceruleumTankWindow.IsAwaitingYesNo && _gameStrings.PurchaseItemForCompanyCredits.IsMatch(text))
{
_pluginLog.Information($"Selecting 'yes' ({text})");
_ceruleumTankWindow.IsAwaitingYesNo = false;
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
}
else
{
_pluginLog.Verbose("Not a purchase confirmation match");
}
}
2023-10-19 18:46:01 +00:00
else if (CurrentStage != Stage.Stopped)
2023-10-13 20:08:22 +00:00
{
2023-10-19 18:46:01 +00:00
if (CurrentStage == Stage.ConfirmMaterialDelivery && _gameStrings.TurnInHighQualityItem == text)
{
_pluginLog.Information($"Selecting 'yes' ({text})");
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
}
else if (CurrentStage == Stage.ConfirmMaterialDelivery && _gameStrings.ContributeItems.IsMatch(text))
{
_pluginLog.Information($"Selecting 'yes' ({text})");
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
ConfirmMaterialDeliveryFollowUp();
}
else if (CurrentStage == Stage.ConfirmCollectProduct && _gameStrings.RetrieveFinishedItem.IsMatch(text))
{
_pluginLog.Information($"Selecting 'yes' ({text})");
addonSelectYesNo->AtkUnitBase.FireCallbackInt(0);
ConfirmCollectProductFollowUp();
}
2023-10-13 20:08:22 +00:00
}
}
private void ConfirmCollectProductFollowUp()
{
_configuration.CurrentlyCraftedItem = null;
_pluginInterface.SavePluginConfig(_configuration);
CurrentStage = Stage.TakeItemFromQueue;
_continueAt = DateTime.Now.AddSeconds(0.5);
}
2023-10-13 20:08:22 +00:00
}