Move common code to LLib
This commit is contained in:
parent
a3fe0d2d26
commit
ca8f30404a
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>2.6</Version>
|
<Version>2.7</Version>
|
||||||
<LangVersion>11.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Deliveroo.GameData;
|
using Deliveroo.GameData;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
using LLib.GameUI;
|
||||||
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
@ -47,8 +48,8 @@ partial class DeliverooPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
IsAddonReady(addonExchange))
|
LAddon.IsAddonReady(addonExchange))
|
||||||
{
|
{
|
||||||
_pluginLog.Information($"Selecting tier 1, {(int)item.Tier - 1}");
|
_pluginLog.Information($"Selecting tier 1, {(int)item.Tier - 1}");
|
||||||
var selectRank = stackalloc AtkValue[]
|
var selectRank = stackalloc AtkValue[]
|
||||||
@ -78,8 +79,8 @@ partial class DeliverooPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
IsAddonReady(addonExchange))
|
LAddon.IsAddonReady(addonExchange))
|
||||||
{
|
{
|
||||||
_pluginLog.Information($"Selecting subcategory 2, {(int)item.SubCategory}");
|
_pluginLog.Information($"Selecting subcategory 2, {(int)item.SubCategory}");
|
||||||
var selectType = stackalloc AtkValue[]
|
var selectType = stackalloc AtkValue[]
|
||||||
@ -102,8 +103,8 @@ partial class DeliverooPlugin
|
|||||||
|
|
||||||
private unsafe void SelectReward()
|
private unsafe void SelectReward()
|
||||||
{
|
{
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
IsAddonReady(addonExchange))
|
LAddon.IsAddonReady(addonExchange))
|
||||||
{
|
{
|
||||||
if (SelectRewardItem(addonExchange))
|
if (SelectRewardItem(addonExchange))
|
||||||
{
|
{
|
||||||
@ -167,8 +168,8 @@ partial class DeliverooPlugin
|
|||||||
|
|
||||||
private unsafe void CloseGcExchange()
|
private unsafe void CloseGcExchange()
|
||||||
{
|
{
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
IsAddonReady(addonExchange))
|
LAddon.IsAddonReady(addonExchange))
|
||||||
{
|
{
|
||||||
addonExchange->FireCallbackInt(-1);
|
addonExchange->FireCallbackInt(-1);
|
||||||
CurrentStage = Stage.TargetPersonnelOfficer;
|
CurrentStage = Stage.TargetPersonnelOfficer;
|
||||||
|
@ -165,52 +165,4 @@ partial class DeliverooPlugin
|
|||||||
.ThenBy(x => x.ItemId)
|
.ThenBy(x => x.ItemId)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int UnitListCount = 18;
|
|
||||||
private unsafe AtkUnitBase* GetAddonById(uint id)
|
|
||||||
{
|
|
||||||
var unitManagers = &AtkStage.GetSingleton()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList;
|
|
||||||
for (var i = 0; i < UnitListCount; i++)
|
|
||||||
{
|
|
||||||
var unitManager = &unitManagers[i];
|
|
||||||
foreach (var j in Enumerable.Range(0, Math.Min(unitManager->Count, unitManager->EntriesSpan.Length)))
|
|
||||||
{
|
|
||||||
var unitBase = unitManager->EntriesSpan[j].Value;
|
|
||||||
if (unitBase != null && unitBase->ID == id)
|
|
||||||
{
|
|
||||||
return unitBase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe bool TryGetAddonByName<T>(string addonName, out T* addonPtr)
|
|
||||||
where T : unmanaged
|
|
||||||
{
|
|
||||||
var a = _gameGui.GetAddonByName(addonName);
|
|
||||||
if (a != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
addonPtr = (T*)a;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addonPtr = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe bool IsAddonReady(AtkUnitBase* addon)
|
|
||||||
{
|
|
||||||
return addon->IsVisible && addon->UldManager.LoadedState == AtkLoadState.Loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe string? ReadAtkString(AtkValue atkValue)
|
|
||||||
{
|
|
||||||
if (atkValue.String != null)
|
|
||||||
return MemoryHelper.ReadSeStringNullTerminated(new nint(atkValue.String)).ToString();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Memory;
|
|
||||||
using Deliveroo.GameData;
|
using Deliveroo.GameData;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
using LLib.GameUI;
|
||||||
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
@ -30,8 +30,8 @@ partial class DeliverooPlugin
|
|||||||
if (addonId == 0)
|
if (addonId == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AtkUnitBase* addon = GetAddonById(addonId);
|
AtkUnitBase* addon = LAddon.GetAddonById(addonId);
|
||||||
if (addon == null || !IsAddonReady(addon))
|
if (addon == null || !LAddon.IsAddonReady(addon))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if using haseltweaks, this *can* be the default
|
// if using haseltweaks, this *can* be the default
|
||||||
@ -73,8 +73,8 @@ partial class DeliverooPlugin
|
|||||||
if (addonId == 0)
|
if (addonId == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AtkUnitBase* addon = GetAddonById(addonId);
|
AtkUnitBase* addon = LAddon.GetAddonById(addonId);
|
||||||
if (addon == null || !IsAddonReady(addon))
|
if (addon == null || !LAddon.IsAddonReady(addon))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
||||||
@ -173,10 +173,10 @@ partial class DeliverooPlugin
|
|||||||
|
|
||||||
private unsafe void TurnInSelectedItem()
|
private unsafe void TurnInSelectedItem()
|
||||||
{
|
{
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
||||||
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
out var addonSupplyReward) && LAddon.IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
||||||
{
|
{
|
||||||
_pluginLog.Information($"Turning in '{ReadAtkString(addonSupplyReward->AtkUnitBase.AtkValues[4])}'");
|
_pluginLog.Information($"Turning in '{addonSupplyReward->AtkUnitBase.AtkValues[4].ReadAtkString()}'");
|
||||||
|
|
||||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.58);
|
_continueAt = DateTime.Now.AddSeconds(0.58);
|
||||||
@ -186,8 +186,8 @@ partial class DeliverooPlugin
|
|||||||
|
|
||||||
private unsafe void FinalizeTurnInItem()
|
private unsafe void FinalizeTurnInItem()
|
||||||
{
|
{
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
|
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
|
||||||
out var addonSupplyList) && IsAddonReady(&addonSupplyList->AtkUnitBase))
|
out var addonSupplyList) && LAddon.IsAddonReady(&addonSupplyList->AtkUnitBase))
|
||||||
{
|
{
|
||||||
var updateFilter = stackalloc AtkValue[]
|
var updateFilter = stackalloc AtkValue[]
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ using Deliveroo.GameData;
|
|||||||
using Deliveroo.Windows;
|
using Deliveroo.Windows;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
using LLib.GameUI;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
@ -207,12 +208,12 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
if (nextItem != null && GetCurrentSealCount() >= _configuration.ReservedSealCount + nextItem.SealCost)
|
if (nextItem != null && GetCurrentSealCount() >= _configuration.ReservedSealCount + nextItem.SealCost)
|
||||||
CurrentStage = Stage.TargetQuartermaster;
|
CurrentStage = Stage.TargetQuartermaster;
|
||||||
|
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
|
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
|
||||||
IsAddonReady(&gcSupplyList->AtkUnitBase))
|
LAddon.IsAddonReady(&gcSupplyList->AtkUnitBase))
|
||||||
CurrentStage = Stage.SelectExpertDeliveryTab;
|
CurrentStage = Stage.SelectExpertDeliveryTab;
|
||||||
|
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
|
if (_gameGui.TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
|
||||||
IsAddonReady(gcExchange))
|
LAddon.IsAddonReady(gcExchange))
|
||||||
CurrentStage = Stage.SelectRewardTier;
|
CurrentStage = Stage.SelectRewardTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
LLib
2
LLib
@ -1 +1 @@
|
|||||||
Subproject commit e7f5017cbfb0f52b767640cfd4eb1bc913df248c
|
Subproject commit abbbec4f26b1a8903b0cd7aa04f00d557602eaf3
|
Loading…
Reference in New Issue
Block a user