Allow starting Deliveroo from SelectString window

This commit is contained in:
Liza 2024-05-31 10:10:29 +02:00
parent 45423c0cc3
commit 4290e1432d
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 20 additions and 9 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<Version>4.8</Version> <Version>4.9</Version>
<LangVersion>12</LangVersion> <LangVersion>12</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -9,31 +9,36 @@ namespace Deliveroo;
partial class DeliverooPlugin partial class DeliverooPlugin
{ {
private unsafe void SelectStringPostSetup(AddonEvent type, AddonArgs args) private unsafe void SelectStringPostSetup(AddonEvent type, AddonArgs args)
{
AddonSelectString* addonSelectString = (AddonSelectString*)args.Addon;
SelectStringPostSetup(addonSelectString, CurrentStage);
}
private unsafe bool SelectStringPostSetup(AddonSelectString* addonSelectString, Stage stage)
{ {
_pluginLog.Verbose("SelectString post-setup"); _pluginLog.Verbose("SelectString post-setup");
string desiredText; string desiredText;
Action followUp; Action followUp;
if (CurrentStage == Stage.OpenGcSupply) if (stage == Stage.OpenGcSupply)
{ {
desiredText = _gameStrings.UndertakeSupplyAndProvisioningMission; desiredText = _gameStrings.UndertakeSupplyAndProvisioningMission;
followUp = OpenGcSupplySelectStringFollowUp; followUp = OpenGcSupplySelectStringFollowUp;
} }
else if (CurrentStage == Stage.CloseGcSupplySelectString) else if (stage == Stage.CloseGcSupplySelectString)
{ {
desiredText = _gameStrings.ClosePersonnelOfficerTalk; desiredText = _gameStrings.ClosePersonnelOfficerTalk;
followUp = CloseGcSupplySelectStringFollowUp; followUp = CloseGcSupplySelectStringFollowUp;
} }
else if (CurrentStage == Stage.CloseGcSupplySelectStringThenStop) else if (stage == Stage.CloseGcSupplySelectStringThenStop)
{ {
desiredText = _gameStrings.ClosePersonnelOfficerTalk; desiredText = _gameStrings.ClosePersonnelOfficerTalk;
followUp = CloseGcSupplySelectStringThenStopFollowUp; followUp = CloseGcSupplySelectStringThenStopFollowUp;
} }
else else
return; return false;
_pluginLog.Verbose($"Looking for '{desiredText}' in prompt"); _pluginLog.Verbose($"Looking for '{desiredText}' in prompt");
AddonSelectString* addonSelectString = (AddonSelectString*)args.Addon;
int entries = addonSelectString->PopupMenu.PopupMenu.EntryCount; int entries = addonSelectString->PopupMenu.PopupMenu.EntryCount;
for (int i = 0; i < entries; ++i) for (int i = 0; i < entries; ++i)
@ -50,11 +55,12 @@ partial class DeliverooPlugin
addonSelectString->AtkUnitBase.FireCallbackInt(i); addonSelectString->AtkUnitBase.FireCallbackInt(i);
followUp(); followUp();
return; return true;
} }
} }
_pluginLog.Verbose($"Text '{desiredText}' was not found in prompt."); _pluginLog.Verbose($"Text '{desiredText}' was not found in prompt.");
return false;
} }
private void OpenGcSupplySelectStringFollowUp() private void OpenGcSupplySelectStringFollowUp()

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects;
@ -281,6 +279,13 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) && if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
LAddon.IsAddonReady(gcExchange)) LAddon.IsAddonReady(gcExchange))
CurrentStage = Stage.SelectRewardTier; CurrentStage = Stage.SelectRewardTier;
if (_gameGui.TryGetAddonByName<AddonSelectString>("SelectString", out var addonSelectString) &&
LAddon.IsAddonReady(&addonSelectString->AtkUnitBase))
{
if (SelectStringPostSetup(addonSelectString, Stage.OpenGcSupply))
return;
}
} }
if (CurrentStage != Stage.Stopped && CurrentStage != Stage.RequestStop && !_externalPluginHandler.Saved) if (CurrentStage != Stage.Stopped && CurrentStage != Stage.RequestStop && !_externalPluginHandler.Saved)