forked from liza/Deliveroo
Split main file, add item filter config, remove haseltweaks requirement
This commit is contained in:
parent
c663c03b10
commit
37adccad11
@ -11,4 +11,12 @@ internal sealed class Configuration : IPluginConfiguration
|
|||||||
public uint SelectedPurchaseItemId { get; set; } = 0;
|
public uint SelectedPurchaseItemId { get; set; } = 0;
|
||||||
|
|
||||||
public int ReservedSealCount { get; set; } = 0;
|
public int ReservedSealCount { get; set; } = 0;
|
||||||
|
public ItemFilterType ItemFilter { get; set; } = ItemFilterType.HideGearSetItems;
|
||||||
|
|
||||||
|
public enum ItemFilterType
|
||||||
|
{
|
||||||
|
ShowAllItems = 0,
|
||||||
|
HideGearSetItems = 1,
|
||||||
|
HideArmouryChestItems = 2,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
111
Deliveroo/DeliverooPlugin.Exchange.cs
Normal file
111
Deliveroo/DeliverooPlugin.Exchange.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using System;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
|
using Dalamud.Logging;
|
||||||
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||||
|
|
||||||
|
namespace Deliveroo;
|
||||||
|
|
||||||
|
partial class DeliverooPlugin
|
||||||
|
{
|
||||||
|
private void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster)
|
||||||
|
{
|
||||||
|
if (GetCurrentSealCount() < _configuration.ReservedSealCount)
|
||||||
|
{
|
||||||
|
CurrentStage = Stage.RequestStop;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_targetManager.Target == personnelOfficer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
InteractWithTarget(quartermaster);
|
||||||
|
CurrentStage = Stage.SelectRewardTier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void SelectRewardTier()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
|
IsAddonReady(addonExchange))
|
||||||
|
{
|
||||||
|
PluginLog.Information($"Selecting tier 1, {(int)_selectedRewardItem.Tier - 1}");
|
||||||
|
var selectRank = stackalloc AtkValue[]
|
||||||
|
{
|
||||||
|
new() { Type = ValueType.Int, Int = 1 },
|
||||||
|
new() { Type = ValueType.Int, Int = (int)_selectedRewardItem.Tier - 1 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 }
|
||||||
|
};
|
||||||
|
addonExchange->FireCallback(9, selectRank);
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
CurrentStage = Stage.SelectRewardSubCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void SelectRewardSubCategory()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
|
IsAddonReady(addonExchange))
|
||||||
|
{
|
||||||
|
PluginLog.Information($"Selecting subcategory 2, {(int)_selectedRewardItem.SubCategory}");
|
||||||
|
var selectType = stackalloc AtkValue[]
|
||||||
|
{
|
||||||
|
new() { Type = ValueType.Int, Int = 2 },
|
||||||
|
new() { Type = ValueType.Int, Int = (int)_selectedRewardItem.SubCategory },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 },
|
||||||
|
new() { Type = 0, Int = 0 }
|
||||||
|
};
|
||||||
|
addonExchange->FireCallback(9, selectType);
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
CurrentStage = Stage.SelectReward;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void SelectReward()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
|
IsAddonReady(addonExchange))
|
||||||
|
{
|
||||||
|
if (SelectRewardItem(addonExchange))
|
||||||
|
{
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
CurrentStage = Stage.ConfirmReward;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginLog.Warning("Could not find selected reward item");
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
CurrentStage = Stage.CloseGcExchange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfirmReward()
|
||||||
|
{
|
||||||
|
if (SelectSelectYesno(0))
|
||||||
|
{
|
||||||
|
CurrentStage = Stage.CloseGcExchange;
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void CloseGcExchange()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
|
IsAddonReady(addonExchange))
|
||||||
|
{
|
||||||
|
addonExchange->FireCallbackInt(-1);
|
||||||
|
CurrentStage = Stage.TargetPersonnelOfficer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
197
Deliveroo/DeliverooPlugin.Supply.cs
Normal file
197
Deliveroo/DeliverooPlugin.Supply.cs
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
|
using Dalamud.Logging;
|
||||||
|
using Dalamud.Memory;
|
||||||
|
using Deliveroo.GameData;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||||
|
|
||||||
|
namespace Deliveroo;
|
||||||
|
|
||||||
|
partial class DeliverooPlugin
|
||||||
|
{
|
||||||
|
private void InteractWithPersonnelOfficer(GameObject personnelOfficer, GameObject quartermaster)
|
||||||
|
{
|
||||||
|
if (_targetManager.Target == quartermaster)
|
||||||
|
return;
|
||||||
|
|
||||||
|
InteractWithTarget(personnelOfficer);
|
||||||
|
CurrentStage = Stage.OpenGcSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenGcSupply()
|
||||||
|
{
|
||||||
|
if (SelectSelectString(0))
|
||||||
|
CurrentStage = Stage.SelectExpertDeliveryTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void SelectExpertDeliveryTab()
|
||||||
|
{
|
||||||
|
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
||||||
|
if (agentInterface != null && agentInterface->IsAgentActive())
|
||||||
|
{
|
||||||
|
var addonId = agentInterface->GetAddonID();
|
||||||
|
if (addonId == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
AtkUnitBase* addon = GetAddonById(addonId);
|
||||||
|
if (addon == null || !IsAddonReady(addon))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if using haseltweaks, this *can* be the default
|
||||||
|
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
||||||
|
if (addonGc->SelectedTab == 2)
|
||||||
|
{
|
||||||
|
PluginLog.Information("Tab already selected, probably due to haseltweaks");
|
||||||
|
CurrentStage = Stage.SelectItemToTurnIn;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginLog.Information("Switching to expert deliveries");
|
||||||
|
var selectExpertDeliveryTab = stackalloc AtkValue[]
|
||||||
|
{
|
||||||
|
new() { Type = ValueType.Int, Int = 0 },
|
||||||
|
new() { Type = ValueType.Int, Int = 2 },
|
||||||
|
new() { Type = 0, Int = 0 }
|
||||||
|
};
|
||||||
|
addon->FireCallback(3, selectExpertDeliveryTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void SelectItemToTurnIn()
|
||||||
|
{
|
||||||
|
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
||||||
|
if (agentInterface != null && agentInterface->IsAgentActive())
|
||||||
|
{
|
||||||
|
var addonId = agentInterface->GetAddonID();
|
||||||
|
if (addonId == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
AtkUnitBase* addon = GetAddonById(addonId);
|
||||||
|
if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20 ||
|
||||||
|
!addon->UldManager.NodeList[5]->IsVisible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
||||||
|
if (addonGc->SelectedTab != 2)
|
||||||
|
{
|
||||||
|
_turnInWindow.Error = "Wrong tab selected";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addonGc->SelectedFilter == 0 || addonGc->SelectedFilter != (int)_configuration.ItemFilter)
|
||||||
|
{
|
||||||
|
_turnInWindow.Error =
|
||||||
|
$"Wrong filter selected (expected {_configuration.ItemFilter}, but is {(Configuration.ItemFilterType)addonGc->SelectedFilter})";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var agent = (AgentGrandCompanySupply*)agentInterface;
|
||||||
|
List<TurnInItem> items = BuildTurnInList(agent);
|
||||||
|
if (items.Count == 0 || addon->UldManager.NodeList[20]->IsVisible)
|
||||||
|
{
|
||||||
|
CurrentStage = Stage.CloseGcSupplyThenStop;
|
||||||
|
addon->FireCallbackInt(-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetCurrentSealCount() + items[0].SealsWithBonus > GetSealCap())
|
||||||
|
{
|
||||||
|
CurrentStage = Stage.CloseGcSupply;
|
||||||
|
addon->FireCallbackInt(-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectFirstItem = stackalloc AtkValue[]
|
||||||
|
{
|
||||||
|
new() { Type = ValueType.Int, Int = 1 },
|
||||||
|
new() { Type = ValueType.Int, Int = 0 /* position within list */ },
|
||||||
|
new() { Type = 0, Int = 0 }
|
||||||
|
};
|
||||||
|
addon->FireCallback(3, selectFirstItem);
|
||||||
|
CurrentStage = Stage.TurnInSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void TurnInSelectedItem()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) &&
|
||||||
|
IsAddonReady(&addonSelectYesno->AtkUnitBase))
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
||||||
|
{
|
||||||
|
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.58);
|
||||||
|
CurrentStage = Stage.FinalizeTurnIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void FinalizeTurnInItem()
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
|
||||||
|
out var addonSupplyList) && IsAddonReady(&addonSupplyList->AtkUnitBase))
|
||||||
|
{
|
||||||
|
var updateFilter = stackalloc AtkValue[]
|
||||||
|
{
|
||||||
|
new() { Type = ValueType.Int, Int = 5 },
|
||||||
|
new() { Type = ValueType.Int, Int = (int)_configuration.ItemFilter },
|
||||||
|
new() { Type = 0, Int = 0 }
|
||||||
|
};
|
||||||
|
addonSupplyList->AtkUnitBase.FireCallback(3, updateFilter);
|
||||||
|
CurrentStage = Stage.SelectItemToTurnIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseGcSupply()
|
||||||
|
{
|
||||||
|
if (SelectSelectString(3))
|
||||||
|
{
|
||||||
|
if (!_selectedRewardItem.IsValid())
|
||||||
|
{
|
||||||
|
_turnInWindow.State = false;
|
||||||
|
CurrentStage = Stage.RequestStop;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// you can occasionally get a 'not enough seals' warning lol
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(1);
|
||||||
|
CurrentStage = Stage.TargetQuartermaster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseGcSupplyThenStop()
|
||||||
|
{
|
||||||
|
if (SelectSelectString(3))
|
||||||
|
{
|
||||||
|
if (!_selectedRewardItem.IsValid())
|
||||||
|
{
|
||||||
|
_turnInWindow.State = false;
|
||||||
|
CurrentStage = Stage.RequestStop;
|
||||||
|
}
|
||||||
|
else if (GetCurrentSealCount() <=
|
||||||
|
_configuration.ReservedSealCount + _selectedRewardItem.SealCost)
|
||||||
|
{
|
||||||
|
_turnInWindow.State = false;
|
||||||
|
CurrentStage = Stage.RequestStop;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(1);
|
||||||
|
CurrentStage = Stage.TargetQuartermaster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,7 +30,7 @@ using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
|||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
|
|
||||||
public sealed class DeliverooPlugin : IDalamudPlugin
|
public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
|
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
|||||||
_gcRewardsCache = new GcRewardsCache(dataManager);
|
_gcRewardsCache = new GcRewardsCache(dataManager);
|
||||||
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache);
|
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache);
|
||||||
_windowSystem.AddWindow(_configWindow);
|
_windowSystem.AddWindow(_configWindow);
|
||||||
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _gcRewardsCache);
|
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _gcRewardsCache, _configWindow);
|
||||||
_windowSystem.AddWindow(_turnInWindow);
|
_windowSystem.AddWindow(_turnInWindow);
|
||||||
_sealCaps = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
|
_sealCaps = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
|
||||||
.ToDictionary(x => x.RowId, x => x.MaxSeals);
|
.ToDictionary(x => x.RowId, x => x.MaxSeals);
|
||||||
@ -105,6 +105,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
private unsafe void FrameworkUpdate(Framework f)
|
private unsafe void FrameworkUpdate(Framework f)
|
||||||
{
|
{
|
||||||
|
_turnInWindow.Error = string.Empty;
|
||||||
if (!_clientState.IsLoggedIn || _clientState.TerritoryType is not 128 and not 130 and not 132 ||
|
if (!_clientState.IsLoggedIn || _clientState.TerritoryType is not 128 and not 130 and not 132 ||
|
||||||
GetDistanceToNpc(GetQuartermasterId(), out GameObject? quartermaster) >= 7f ||
|
GetDistanceToNpc(GetQuartermasterId(), out GameObject? quartermaster) >= 7f ||
|
||||||
GetDistanceToNpc(GetPersonnelOfficerId(), out GameObject? personnelOfficer) >= 7f ||
|
GetDistanceToNpc(GetPersonnelOfficerId(), out GameObject? personnelOfficer) >= 7f ||
|
||||||
@ -145,7 +146,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
|
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
|
||||||
IsAddonReady(&gcSupplyList->AtkUnitBase))
|
IsAddonReady(&gcSupplyList->AtkUnitBase))
|
||||||
CurrentStage = Stage.SelectItemToTurnIn;
|
CurrentStage = Stage.SelectExpertDeliveryTab;
|
||||||
|
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
|
||||||
IsAddonReady(gcExchange))
|
IsAddonReady(gcExchange))
|
||||||
@ -158,247 +159,60 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
|||||||
switch (CurrentStage)
|
switch (CurrentStage)
|
||||||
{
|
{
|
||||||
case Stage.TargetPersonnelOfficer:
|
case Stage.TargetPersonnelOfficer:
|
||||||
if (_targetManager.Target == quartermaster!)
|
InteractWithPersonnelOfficer(personnelOfficer!, quartermaster!);
|
||||||
break;
|
|
||||||
|
|
||||||
InteractWithTarget(personnelOfficer!);
|
|
||||||
CurrentStage = Stage.OpenGcSupply;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.OpenGcSupply:
|
case Stage.OpenGcSupply:
|
||||||
if (SelectSelectString(0))
|
OpenGcSupply();
|
||||||
CurrentStage = Stage.SelectItemToTurnIn;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Stage.SelectExpertDeliveryTab:
|
||||||
|
SelectExpertDeliveryTab();
|
||||||
|
break;
|
||||||
|
|
||||||
case Stage.SelectItemToTurnIn:
|
case Stage.SelectItemToTurnIn:
|
||||||
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
SelectItemToTurnIn();
|
||||||
if (agentInterface != null && agentInterface->IsAgentActive())
|
|
||||||
{
|
|
||||||
var addonId = agentInterface->GetAddonID();
|
|
||||||
if (addonId == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
AtkUnitBase* addon = GetAddonById(addonId);
|
|
||||||
if (addon == null || !IsAddonReady(addon) || addon->UldManager.NodeListCount <= 20 ||
|
|
||||||
!addon->UldManager.NodeList[5]->IsVisible)
|
|
||||||
break;
|
|
||||||
|
|
||||||
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
|
||||||
if (addonGc->SelectedTab != 2 || addonGc->SelectedFilter != 1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
var agent = (AgentGrandCompanySupply*)agentInterface;
|
|
||||||
List<TurnInItem> items = BuildTurnInList(agent);
|
|
||||||
if (items.Count == 0 || addon->UldManager.NodeList[20]->IsVisible)
|
|
||||||
{
|
|
||||||
CurrentStage = Stage.CloseGcSupplyThenStop;
|
|
||||||
addon->FireCallbackInt(-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetCurrentSealCount() + items[0].SealsWithBonus > GetSealCap())
|
|
||||||
{
|
|
||||||
CurrentStage = Stage.CloseGcSupply;
|
|
||||||
addon->FireCallbackInt(-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectFirstItem = stackalloc AtkValue[]
|
|
||||||
{
|
|
||||||
new() { Type = ValueType.Int, Int = 1 },
|
|
||||||
new() { Type = ValueType.Int, Int = 0 /* position within list */ },
|
|
||||||
new() { Type = 0, Int = 0 }
|
|
||||||
};
|
|
||||||
addon->FireCallback(3, selectFirstItem);
|
|
||||||
CurrentStage = Stage.TurnInSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.TurnInSelected:
|
case Stage.TurnInSelected:
|
||||||
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) &&
|
TurnInSelectedItem();
|
||||||
IsAddonReady(&addonSelectYesno->AtkUnitBase))
|
|
||||||
{
|
|
||||||
if (MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText).ToString()
|
|
||||||
.StartsWith("Do you really want to trade a high-quality item?"))
|
|
||||||
{
|
|
||||||
addonSelectYesno->AtkUnitBase.FireCallbackInt(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
|
||||||
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
|
||||||
{
|
|
||||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.58);
|
|
||||||
CurrentStage = Stage.FinalizeTurnIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.FinalizeTurnIn:
|
case Stage.FinalizeTurnIn:
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
|
FinalizeTurnInItem();
|
||||||
out var addonSupplyList) && IsAddonReady(&addonSupplyList->AtkUnitBase))
|
|
||||||
{
|
|
||||||
var updateFilter = stackalloc AtkValue[]
|
|
||||||
{
|
|
||||||
new() { Type = ValueType.Int, Int = 5 },
|
|
||||||
new() { Type = ValueType.Int, Int = addonSupplyList->SelectedFilter },
|
|
||||||
new() { Type = 0, Int = 0 }
|
|
||||||
};
|
|
||||||
addonSupplyList->AtkUnitBase.FireCallback(3, updateFilter);
|
|
||||||
CurrentStage = Stage.SelectItemToTurnIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.CloseGcSupply:
|
case Stage.CloseGcSupply:
|
||||||
if (SelectSelectString(3))
|
CloseGcSupply();
|
||||||
{
|
|
||||||
if (!_selectedRewardItem.IsValid())
|
|
||||||
{
|
|
||||||
_turnInWindow.State = false;
|
|
||||||
CurrentStage = Stage.RequestStop;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// you can occasionally get a 'not enough seals' warning lol
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(1);
|
|
||||||
CurrentStage = Stage.TargetQuartermaster;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.CloseGcSupplyThenStop:
|
case Stage.CloseGcSupplyThenStop:
|
||||||
if (SelectSelectString(3))
|
CloseGcSupplyThenStop();
|
||||||
{
|
|
||||||
if (!_selectedRewardItem.IsValid())
|
|
||||||
{
|
|
||||||
_turnInWindow.State = false;
|
|
||||||
CurrentStage = Stage.RequestStop;
|
|
||||||
}
|
|
||||||
else if (GetCurrentSealCount() <=
|
|
||||||
_configuration.ReservedSealCount + _selectedRewardItem.SealCost)
|
|
||||||
{
|
|
||||||
_turnInWindow.State = false;
|
|
||||||
CurrentStage = Stage.RequestStop;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(1);
|
|
||||||
CurrentStage = Stage.TargetQuartermaster;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.TargetQuartermaster:
|
case Stage.TargetQuartermaster:
|
||||||
if (GetCurrentSealCount() < _configuration.ReservedSealCount)
|
InteractWithQuartermaster(personnelOfficer!, quartermaster!);
|
||||||
{
|
|
||||||
CurrentStage = Stage.RequestStop;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_targetManager.Target == personnelOfficer!)
|
|
||||||
break;
|
|
||||||
|
|
||||||
InteractWithTarget(quartermaster!);
|
|
||||||
CurrentStage = Stage.SelectRewardTier;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.SelectRewardTier:
|
case Stage.SelectRewardTier:
|
||||||
{
|
SelectRewardTier();
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
|
||||||
IsAddonReady(addonExchange))
|
|
||||||
{
|
|
||||||
PluginLog.Information($"Selecting tier 1, {(int)_selectedRewardItem.Tier - 1}");
|
|
||||||
var selectRank = stackalloc AtkValue[]
|
|
||||||
{
|
|
||||||
new() { Type = ValueType.Int, Int = 1 },
|
|
||||||
new() { Type = ValueType.Int, Int = (int)_selectedRewardItem.Tier - 1 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 }
|
|
||||||
};
|
|
||||||
addonExchange->FireCallback(9, selectRank);
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
|
||||||
CurrentStage = Stage.SelectRewardSubCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case Stage.SelectRewardSubCategory:
|
case Stage.SelectRewardSubCategory:
|
||||||
{
|
SelectRewardSubCategory();
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
|
||||||
IsAddonReady(addonExchange))
|
|
||||||
{
|
|
||||||
PluginLog.Information($"Selecting subcategory 2, {(int)_selectedRewardItem.SubCategory}");
|
|
||||||
var selectType = stackalloc AtkValue[]
|
|
||||||
{
|
|
||||||
new() { Type = ValueType.Int, Int = 2 },
|
|
||||||
new() { Type = ValueType.Int, Int = (int)_selectedRewardItem.SubCategory },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 },
|
|
||||||
new() { Type = 0, Int = 0 }
|
|
||||||
};
|
|
||||||
addonExchange->FireCallback(9, selectType);
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
|
||||||
CurrentStage = Stage.SelectReward;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case Stage.SelectReward:
|
case Stage.SelectReward:
|
||||||
{
|
SelectReward();
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
|
||||||
IsAddonReady(addonExchange))
|
|
||||||
{
|
|
||||||
if (SelectRewardItem(addonExchange))
|
|
||||||
{
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
|
||||||
CurrentStage = Stage.ConfirmReward;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PluginLog.Warning("Could not find selected reward item");
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
|
||||||
CurrentStage = Stage.CloseGcExchange;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case Stage.ConfirmReward:
|
case Stage.ConfirmReward:
|
||||||
if (SelectSelectYesno(0))
|
ConfirmReward();
|
||||||
{
|
|
||||||
CurrentStage = Stage.CloseGcExchange;
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Stage.CloseGcExchange:
|
case Stage.CloseGcExchange:
|
||||||
{
|
CloseGcExchange();
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
|
||||||
IsAddonReady(addonExchange))
|
|
||||||
{
|
|
||||||
addonExchange->FireCallbackInt(-1);
|
|
||||||
CurrentStage = Stage.TargetPersonnelOfficer;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case Stage.RequestStop:
|
case Stage.RequestStop:
|
||||||
RestoreYesAlready();
|
RestoreYesAlready();
|
||||||
@ -699,6 +513,7 @@ public sealed class DeliverooPlugin : IDalamudPlugin
|
|||||||
{
|
{
|
||||||
TargetPersonnelOfficer,
|
TargetPersonnelOfficer,
|
||||||
OpenGcSupply,
|
OpenGcSupply,
|
||||||
|
SelectExpertDeliveryTab,
|
||||||
SelectItemToTurnIn,
|
SelectItemToTurnIn,
|
||||||
TurnInSelected,
|
TurnInSelected,
|
||||||
FinalizeTurnIn,
|
FinalizeTurnIn,
|
||||||
|
@ -13,6 +13,8 @@ namespace Deliveroo.Windows;
|
|||||||
|
|
||||||
internal sealed class ConfigWindow : Window
|
internal sealed class ConfigWindow : Window
|
||||||
{
|
{
|
||||||
|
private static string[] _itemFilterValues = { "Hide Gear Set Items", "Hide Armoury Chest Items" };
|
||||||
|
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
private readonly DeliverooPlugin _plugin;
|
private readonly DeliverooPlugin _plugin;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
@ -170,6 +172,16 @@ internal sealed class ConfigWindow : Window
|
|||||||
_configuration.ReservedSealCount = Math.Max(0, Math.Min(90_000, reservedSealCount));
|
_configuration.ReservedSealCount = Math.Max(0, Math.Min(90_000, reservedSealCount));
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
int selectedItemFilter = Math.Max(0, (int)_configuration.ItemFilter - 1);
|
||||||
|
if (ImGui.Combo("Item Filter", ref selectedItemFilter, _itemFilterValues, _itemFilterValues.Length))
|
||||||
|
{
|
||||||
|
_configuration.ItemFilter = (Configuration.ItemFilterType)(selectedItemFilter + 1);
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Deliveroo.GameData;
|
using Deliveroo.GameData;
|
||||||
@ -17,16 +19,18 @@ internal sealed class TurnInWindow : Window
|
|||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly GcRewardsCache _gcRewardsCache;
|
private readonly GcRewardsCache _gcRewardsCache;
|
||||||
|
private readonly ConfigWindow _configWindow;
|
||||||
private int _selectedAutoBuyItem = 0;
|
private int _selectedAutoBuyItem = 0;
|
||||||
|
|
||||||
public TurnInWindow(DeliverooPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration,
|
public TurnInWindow(DeliverooPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration,
|
||||||
GcRewardsCache gcRewardsCache)
|
GcRewardsCache gcRewardsCache, ConfigWindow configWindow)
|
||||||
: base("GC Delivery###DeliverooTurnIn")
|
: base("GC Delivery###DeliverooTurnIn")
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_gcRewardsCache = gcRewardsCache;
|
_gcRewardsCache = gcRewardsCache;
|
||||||
|
_configWindow = configWindow;
|
||||||
|
|
||||||
Position = new Vector2(100, 100);
|
Position = new Vector2(100, 100);
|
||||||
PositionCondition = ImGuiCond.FirstUseEver;
|
PositionCondition = ImGuiCond.FirstUseEver;
|
||||||
@ -37,6 +41,7 @@ internal sealed class TurnInWindow : Window
|
|||||||
|
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
public decimal Multiplier { private get; set; }
|
public decimal Multiplier { private get; set; }
|
||||||
|
public string Error { private get; set; }
|
||||||
|
|
||||||
public uint SelectedItemId
|
public uint SelectedItemId
|
||||||
{
|
{
|
||||||
@ -97,40 +102,50 @@ internal sealed class TurnInWindow : Window
|
|||||||
State = state;
|
State = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGuiComponents.IconButton("###OpenConfig", FontAwesomeIcon.Cog))
|
||||||
|
_configWindow.IsOpen = true;
|
||||||
|
|
||||||
ImGui.Indent(27);
|
ImGui.Indent(27);
|
||||||
if (Multiplier == 1m)
|
if (!string.IsNullOrEmpty(Error))
|
||||||
{
|
{
|
||||||
ImGui.TextColored(ImGuiColors.DalamudRed, "You do not have an active seal buff.");
|
ImGui.TextColored(ImGuiColors.DalamudRed, Error);
|
||||||
}
|
} else {
|
||||||
else
|
if (Multiplier == 1m)
|
||||||
{
|
{
|
||||||
ImGui.TextColored(ImGuiColors.HealerGreen, $"Current Buff: {(Multiplier - 1m) * 100:N0}%%");
|
ImGui.TextColored(ImGuiColors.DalamudYellow, "You do not have an active seal buff.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Spacing();
|
|
||||||
ImGui.BeginDisabled(state);
|
|
||||||
|
|
||||||
List<string> comboValues = new() { GcRewardItem.None.Name };
|
|
||||||
foreach (var itemId in _configuration.ItemsAvailableForPurchase)
|
|
||||||
{
|
|
||||||
var name = _gcRewardsCache.Rewards[grandCompany].First(x => x.ItemId == itemId).Name;
|
|
||||||
int itemCount = GetItemCount(itemId);
|
|
||||||
if (itemCount > 0)
|
|
||||||
comboValues.Add($"{name} ({itemCount:N0})");
|
|
||||||
else
|
else
|
||||||
comboValues.Add(name);
|
{
|
||||||
|
ImGui.TextColored(ImGuiColors.HealerGreen, $"Current Buff: {(Multiplier - 1m) * 100:N0}%%");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
ImGui.BeginDisabled(state);
|
||||||
|
|
||||||
|
List<string> comboValues = new() { GcRewardItem.None.Name };
|
||||||
|
foreach (var itemId in _configuration.ItemsAvailableForPurchase)
|
||||||
|
{
|
||||||
|
var name = _gcRewardsCache.Rewards[grandCompany].First(x => x.ItemId == itemId).Name;
|
||||||
|
int itemCount = GetItemCount(itemId);
|
||||||
|
if (itemCount > 0)
|
||||||
|
comboValues.Add($"{name} ({itemCount:N0})");
|
||||||
|
else
|
||||||
|
comboValues.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.Combo("", ref _selectedAutoBuyItem, comboValues.ToArray(), comboValues.Count))
|
||||||
|
{
|
||||||
|
_configuration.SelectedPurchaseItemId = SelectedItemId;
|
||||||
|
_pluginInterface.SavePluginConfig(_configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SelectedItem.IsValid() && SelectedItem.RequiredRank > _plugin.GetGrandCompanyRank())
|
||||||
|
ImGui.TextColored(ImGuiColors.DalamudRed, "Your rank isn't high enough to buy this item.");
|
||||||
|
|
||||||
|
ImGui.EndDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.Combo("", ref _selectedAutoBuyItem, comboValues.ToArray(), comboValues.Count))
|
|
||||||
{
|
|
||||||
_configuration.SelectedPurchaseItemId = SelectedItemId;
|
|
||||||
_pluginInterface.SavePluginConfig(_configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SelectedItem.IsValid() && SelectedItem.RequiredRank > _plugin.GetGrandCompanyRank())
|
|
||||||
ImGui.TextColored(ImGuiColors.DalamudRed, "Your rank isn't high enough to buy this item.");
|
|
||||||
|
|
||||||
ImGui.EndDisabled();
|
|
||||||
ImGui.Unindent(27);
|
ImGui.Unindent(27);
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
Loading…
Reference in New Issue
Block a user