Compare commits
No commits in common. "master" and "v4.9" have entirely different histories.
@ -17,10 +17,10 @@ internal sealed class CharacterConfiguration
|
||||
public bool OverrideItemsToPurchase { get; set; }
|
||||
public List<Configuration.PurchasePriority> ItemsToPurchase { get; set; } = new();
|
||||
|
||||
public static string ResolveFilePath(IDalamudPluginInterface pluginInterface, ulong localContentId)
|
||||
public static string ResolveFilePath(DalamudPluginInterface pluginInterface, ulong localContentId)
|
||||
=> Path.Join(pluginInterface.GetPluginConfigDirectory(), $"char.{localContentId:X}.json");
|
||||
|
||||
public static CharacterConfiguration? Load(IDalamudPluginInterface pluginInterface, ulong localContentId)
|
||||
public static CharacterConfiguration? Load(DalamudPluginInterface pluginInterface, ulong localContentId)
|
||||
{
|
||||
string path = ResolveFilePath(pluginInterface, localContentId);
|
||||
if (!File.Exists(path))
|
||||
@ -29,11 +29,11 @@ internal sealed class CharacterConfiguration
|
||||
return JsonConvert.DeserializeObject<CharacterConfiguration>(File.ReadAllText(path));
|
||||
}
|
||||
|
||||
public void Save(IDalamudPluginInterface pluginInterface)
|
||||
public void Save(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
File.WriteAllText(ResolveFilePath(pluginInterface, LocalContentId), JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
|
||||
public void Delete(IDalamudPluginInterface pluginInterface) =>
|
||||
public void Delete(DalamudPluginInterface pluginInterface) =>
|
||||
File.Delete(ResolveFilePath(pluginInterface, LocalContentId));
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text;
|
||||
using Deliveroo.GameData;
|
||||
using LLib.ImGui;
|
||||
@ -11,13 +8,10 @@ namespace Deliveroo;
|
||||
|
||||
internal sealed class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 2;
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
[Obsolete]
|
||||
public List<uint> ItemsAvailableForPurchase { get; set; } = [];
|
||||
|
||||
public List<PurchaseOption> ItemsAvailableToPurchase { get; set; } = [];
|
||||
public List<PurchasePriority> ItemsToPurchase { get; set; } = [];
|
||||
public List<uint> ItemsAvailableForPurchase { get; set; } = new();
|
||||
public List<PurchasePriority> ItemsToPurchase { get; set; } = new();
|
||||
|
||||
public int ReservedSealCount { get; set; }
|
||||
public bool ReserveDifferentSealCountAtMaxRank { get; set; }
|
||||
@ -27,23 +21,12 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
public EBehaviorOnOtherWorld BehaviorOnOtherWorld { get; set; } = EBehaviorOnOtherWorld.Warning;
|
||||
public bool DisableFrameLimiter { get; set; } = true;
|
||||
public bool UncapFrameRate { get; set; }
|
||||
public VirtualKey QuickTurnInKey { get; set; } = VirtualKey.SHIFT;
|
||||
|
||||
public MinimizableWindowConfig TurnInWindowConfig { get; } = new();
|
||||
public WindowConfig TurnInWindowConfig { get; } = new();
|
||||
public WindowConfig ConfigWindowConfig { get; } = new();
|
||||
|
||||
internal sealed class PurchaseOption
|
||||
{
|
||||
public uint ItemId { get; set; }
|
||||
public bool SameQuantityForAllLists { get; set; }
|
||||
public int GlobalLimit { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class PurchasePriority
|
||||
{
|
||||
[JsonIgnore]
|
||||
public Guid InternalId { get; } = Guid.NewGuid();
|
||||
|
||||
public uint ItemId { get; set; }
|
||||
public int Limit { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
@ -69,9 +52,9 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
|
||||
public bool AddVentureIfNoItemToPurchaseSelected()
|
||||
{
|
||||
if (ItemsAvailableToPurchase.Count == 0)
|
||||
if (ItemsAvailableForPurchase.Count == 0)
|
||||
{
|
||||
ItemsAvailableToPurchase.Add(new PurchaseOption { ItemId = ItemIds.Venture });
|
||||
ItemsAvailableForPurchase.Add(ItemIds.Venture);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -84,9 +67,4 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
Warning,
|
||||
DisableTurnIn,
|
||||
}
|
||||
|
||||
internal sealed class MinimizableWindowConfig : WindowConfig
|
||||
{
|
||||
public bool IsMinimized { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<Target Name="PackagePluginDebug" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug'">
|
||||
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug'">
|
||||
<DalamudPackager
|
||||
ProjectDir="$(ProjectDir)"
|
||||
OutputPath="$(OutputPath)"
|
||||
|
@ -1,13 +1,63 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Version>6.3</Version>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Version>4.9</Version>
|
||||
<LangVersion>12</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<OutputPath>dist</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<DebugType>portable</DebugType>
|
||||
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\LLib\LLib.targets"/>
|
||||
<Import Project="..\LLib\RenameZip.targets"/>
|
||||
<PropertyGroup>
|
||||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LLib\LLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud">
|
||||
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImGui.NET">
|
||||
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina">
|
||||
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina.Excel">
|
||||
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="FFXIVClientStructs">
|
||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin">
|
||||
<Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/>
|
||||
</Target>
|
||||
</Project>
|
||||
|
@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Deliveroo.GameData;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using LLib.GameUI;
|
||||
|
||||
namespace Deliveroo;
|
||||
|
||||
partial class DeliverooPlugin
|
||||
{
|
||||
private unsafe void GrandCompanySupplyRewardPostSetup(AddonEvent type, AddonArgs args)
|
||||
{
|
||||
bool quickTurnIn = CurrentStage == Stage.Stopped && _configuration.QuickTurnInKey != VirtualKey.NO_KEY && _keyState[_configuration.QuickTurnInKey];
|
||||
if (CurrentStage == Stage.TurnInSelected || quickTurnIn)
|
||||
{
|
||||
AddonGrandCompanySupplyReward* addonSupplyReward = (AddonGrandCompanySupplyReward*)args.Addon;
|
||||
|
||||
string? itemName = addonSupplyReward->AtkUnitBase.AtkValues[4].ReadAtkString();
|
||||
if (itemName != null && _itemCache.GetItemIdFromItemName(itemName)
|
||||
.Any(itemId => InternalConfiguration.QuickVentureExclusiveItems.Contains(itemId)))
|
||||
{
|
||||
DeliveryResult = new MessageDeliveryResult
|
||||
{
|
||||
Message = new SeStringBuilder()
|
||||
.Append("Won't turn in ")
|
||||
.AddItemLink(_itemCache.GetItemIdFromItemName(itemName).First())
|
||||
.Append(", as it can only be obtained through Quick Ventures.")
|
||||
.Build(),
|
||||
};
|
||||
|
||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(1);
|
||||
if (quickTurnIn)
|
||||
CurrentStage = Stage.RequestStop;
|
||||
else
|
||||
CurrentStage = Stage.CloseGcSupplyWindowThenStop;
|
||||
return;
|
||||
}
|
||||
|
||||
_pluginLog.Information($"Turning in '{itemName}'");
|
||||
|
||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
||||
ContinueAt = DateTime.Now.AddSeconds(0.58);
|
||||
if (quickTurnIn)
|
||||
{
|
||||
DeliveryResult = new NoDeliveryResult();
|
||||
CurrentStage = Stage.SingleFinalizeTurnIn;
|
||||
}
|
||||
else
|
||||
CurrentStage = Stage.FinalizeTurnIn;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Memory;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
@ -41,7 +40,7 @@ partial class DeliverooPlugin
|
||||
CurrentStage = Stage.CloseGcExchange;
|
||||
ContinueAt = DateTime.Now.AddSeconds(0.5);
|
||||
}
|
||||
else if ((CurrentStage == Stage.TurnInSelected || (_configuration.QuickTurnInKey != VirtualKey.NO_KEY && _keyState[_configuration.QuickTurnInKey])) &&
|
||||
else if (CurrentStage == Stage.TurnInSelected &&
|
||||
_gameStrings.TradeHighQualityItem == text)
|
||||
{
|
||||
_pluginLog.Information($"Selecting 'yes' ({text})");
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
@ -26,7 +25,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
{
|
||||
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
|
||||
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly IChatGui _chatGui;
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly IFramework _framework;
|
||||
@ -35,7 +34,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
private readonly ICommandManager _commandManager;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly IAddonLifecycle _addonLifecycle;
|
||||
private readonly IKeyState _keyState;
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly Configuration _configuration;
|
||||
@ -48,7 +46,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
private readonly GcRewardsCache _gcRewardsCache;
|
||||
|
||||
private readonly IconCache _iconCache;
|
||||
private readonly ItemCache _itemCache;
|
||||
private readonly ExchangeHandler _exchangeHandler;
|
||||
private readonly SupplyHandler _supplyHandler;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
@ -56,10 +53,10 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
|
||||
private Stage _currentStageInternal = Stage.Stopped;
|
||||
|
||||
public DeliverooPlugin(IDalamudPluginInterface pluginInterface, IChatGui chatGui, IGameGui gameGui,
|
||||
public DeliverooPlugin(DalamudPluginInterface pluginInterface, IChatGui chatGui, IGameGui gameGui,
|
||||
IFramework framework, IClientState clientState, IObjectTable objectTable, ITargetManager targetManager,
|
||||
IDataManager dataManager, ICondition condition, ICommandManager commandManager, IPluginLog pluginLog,
|
||||
IAddonLifecycle addonLifecycle, ITextureProvider textureProvider, IGameConfig gameConfig, IKeyState keyState)
|
||||
IAddonLifecycle addonLifecycle, ITextureProvider textureProvider, IGameConfig gameConfig)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dataManager);
|
||||
|
||||
@ -72,27 +69,25 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
_commandManager = commandManager;
|
||||
_pluginLog = pluginLog;
|
||||
_addonLifecycle = addonLifecycle;
|
||||
_keyState = keyState;
|
||||
|
||||
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
||||
MigrateConfiguration();
|
||||
|
||||
_gameStrings = new GameStrings(dataManager, _pluginLog);
|
||||
_externalPluginHandler = new ExternalPluginHandler(_pluginInterface, gameConfig, _configuration, _pluginLog);
|
||||
_gameFunctions = new GameFunctions(objectTable, _clientState, targetManager, dataManager,
|
||||
_externalPluginHandler, _pluginLog);
|
||||
_gcRewardsCache = new GcRewardsCache(dataManager);
|
||||
_iconCache = new IconCache(textureProvider);
|
||||
_itemCache = new ItemCache(dataManager);
|
||||
var itemCache = new ItemCache(dataManager);
|
||||
|
||||
_exchangeHandler = new ExchangeHandler(this, _gameFunctions, targetManager, _gameGui, _chatGui, _pluginLog);
|
||||
_supplyHandler = new SupplyHandler(this, _gameFunctions, targetManager, _gameGui, _pluginLog);
|
||||
_supplyHandler = new SupplyHandler(this, _gameFunctions, targetManager, _gameGui, itemCache,
|
||||
_pluginLog);
|
||||
|
||||
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState,
|
||||
_pluginLog, _iconCache, _gameFunctions);
|
||||
_windowSystem.AddWindow(_configWindow);
|
||||
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState,
|
||||
_gcRewardsCache, _configWindow, _iconCache, _keyState, _gameFunctions);
|
||||
_gcRewardsCache, _configWindow, _iconCache, _gameFunctions);
|
||||
_windowSystem.AddWindow(_turnInWindow);
|
||||
|
||||
_framework.Update += FrameworkUpdate;
|
||||
@ -114,27 +109,9 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
|
||||
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup);
|
||||
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup);
|
||||
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "GrandCompanySupplyReward", GrandCompanySupplyRewardPostSetup);
|
||||
}
|
||||
|
||||
private void MigrateConfiguration()
|
||||
{
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
if (_configuration.Version == 1)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase = _configuration.ItemsAvailableForPurchase.Select(x =>
|
||||
new Configuration.PurchaseOption
|
||||
{
|
||||
ItemId = x,
|
||||
SameQuantityForAllLists = false,
|
||||
}).ToList();
|
||||
_configuration.Version = 2;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
|
||||
private void ChatMessage(XivChatType type, int timestamp, ref SeString sender, ref SeString message,
|
||||
private void ChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message,
|
||||
ref bool isHandled)
|
||||
{
|
||||
if (_configuration.PauseAtRank <= 0)
|
||||
@ -153,7 +130,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
{
|
||||
_turnInWindow.State = false;
|
||||
_pluginLog.Information($"Pausing GC delivery, FC reached rank {rank}");
|
||||
DeliveryResult = new MessageDeliveryResult
|
||||
DeliveryResult = new DeliveryResult
|
||||
{
|
||||
Message = new SeStringBuilder()
|
||||
.Append($"Pausing Deliveroo, your FC reached rank {rank}.")
|
||||
@ -183,7 +160,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
internal DateTime ContinueAt { private get; set; } = DateTime.MinValue;
|
||||
internal List<PurchaseItemRequest> ItemsToPurchaseNow { get; private set; } = new();
|
||||
internal int LastTurnInListSize { get; set; } = int.MaxValue;
|
||||
internal IDeliveryResult? DeliveryResult { get; set; }
|
||||
internal DeliveryResult? DeliveryResult { get; set; }
|
||||
|
||||
internal bool TurnInState
|
||||
{
|
||||
@ -218,11 +195,11 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
{
|
||||
if (CharacterConfiguration.CachedPlayerName != _clientState.LocalPlayer!.Name.ToString() ||
|
||||
CharacterConfiguration.CachedWorldName !=
|
||||
_clientState.LocalPlayer.HomeWorld.Value.Name.ToString())
|
||||
_clientState.LocalPlayer.HomeWorld.GameData!.Name.ToString())
|
||||
{
|
||||
CharacterConfiguration.CachedPlayerName = _clientState.LocalPlayer!.Name.ToString();
|
||||
CharacterConfiguration.CachedWorldName =
|
||||
_clientState.LocalPlayer.HomeWorld.Value.Name.ToString();
|
||||
_clientState.LocalPlayer.HomeWorld.GameData!.Name.ToString();
|
||||
|
||||
CharacterConfiguration.Save(_pluginInterface);
|
||||
}
|
||||
@ -242,7 +219,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void Logout(int type, int code)
|
||||
private void Logout()
|
||||
{
|
||||
CharacterConfiguration = null;
|
||||
}
|
||||
@ -253,8 +230,8 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
if (!_clientState.IsLoggedIn ||
|
||||
_clientState.TerritoryType is not 128 and not 130 and not 132 ||
|
||||
_condition[ConditionFlag.OccupiedInCutSceneEvent] ||
|
||||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetQuartermasterId(), out IGameObject? quartermaster) >= 7f ||
|
||||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetPersonnelOfficerId(), out IGameObject? personnelOfficer) >=
|
||||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetQuartermasterId(), out GameObject? quartermaster) >= 7f ||
|
||||
_gameFunctions.GetDistanceToNpc(_gameFunctions.GetPersonnelOfficerId(), out GameObject? personnelOfficer) >=
|
||||
7f ||
|
||||
CharacterConfiguration is { DisableForCharacter: true } ||
|
||||
_configWindow.IsOpen)
|
||||
@ -277,7 +254,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
{
|
||||
CurrentStage = Stage.TargetPersonnelOfficer;
|
||||
ItemsToPurchaseNow = _turnInWindow.SelectedItems;
|
||||
DeliveryResult = new MessageDeliveryResult();
|
||||
DeliveryResult = new();
|
||||
_supplyHandler.ResetTurnInErrorHandling();
|
||||
if (ItemsToPurchaseNow.Count > 0)
|
||||
{
|
||||
@ -333,11 +310,10 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
break;
|
||||
|
||||
case Stage.TurnInSelected:
|
||||
// see GrandCompanySupplyReward
|
||||
_supplyHandler.TurnInSelectedItem();
|
||||
break;
|
||||
|
||||
case Stage.FinalizeTurnIn:
|
||||
case Stage.SingleFinalizeTurnIn:
|
||||
_supplyHandler.FinalizeTurnInItem();
|
||||
break;
|
||||
|
||||
@ -398,9 +374,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
_externalPluginHandler.Restore();
|
||||
CurrentStage = Stage.Stopped;
|
||||
|
||||
if (DeliveryResult is null or MessageDeliveryResult)
|
||||
{
|
||||
var text = (DeliveryResult as MessageDeliveryResult)?.Message ?? "Delivery completed.";
|
||||
var text = DeliveryResult?.Message ?? "Delivery completed.";
|
||||
var message = _configuration.ChatType switch
|
||||
{
|
||||
XivChatType.Say
|
||||
@ -434,7 +408,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
}
|
||||
};
|
||||
_chatGui.Print(message);
|
||||
}
|
||||
|
||||
DeliveryResult = null;
|
||||
}
|
||||
@ -442,7 +415,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "GrandCompanySupplyReward", GrandCompanySupplyRewardPostSetup);
|
||||
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup);
|
||||
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup);
|
||||
|
||||
|
9
Deliveroo/DeliveryResult.cs
Normal file
9
Deliveroo/DeliveryResult.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
|
||||
namespace Deliveroo
|
||||
{
|
||||
internal sealed class DeliveryResult
|
||||
{
|
||||
public SeString? Message { get; init; }
|
||||
}
|
||||
}
|
2
Deliveroo/External/AllaganToolsIpc.cs
vendored
2
Deliveroo/External/AllaganToolsIpc.cs
vendored
@ -25,7 +25,7 @@ internal sealed class AllaganToolsIpc
|
||||
|
||||
private readonly ICallGateSubscriber<uint, bool, uint[], uint> _itemCountOwned;
|
||||
|
||||
public AllaganToolsIpc(IDalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
||||
public AllaganToolsIpc(DalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
||||
{
|
||||
_pluginLog = pluginLog;
|
||||
_itemCountOwned = pluginInterface.GetIpcSubscriber<uint, bool, uint[], uint>("AllaganTools.ItemCountOwned");
|
||||
|
2
Deliveroo/External/DeliverooIpc.cs
vendored
2
Deliveroo/External/DeliverooIpc.cs
vendored
@ -16,7 +16,7 @@ internal sealed class DeliverooIpc : IDisposable
|
||||
|
||||
private bool _running;
|
||||
|
||||
public DeliverooIpc(IDalamudPluginInterface pluginInterface)
|
||||
public DeliverooIpc(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
_isTurnInRunning = pluginInterface.GetIpcProvider<bool>(IsTurnInRunning);
|
||||
_turnInStarted = pluginInterface.GetIpcProvider<object>(TurnInStarted);
|
||||
|
4
Deliveroo/External/ExternalPluginHandler.cs
vendored
4
Deliveroo/External/ExternalPluginHandler.cs
vendored
@ -7,7 +7,7 @@ namespace Deliveroo.External;
|
||||
|
||||
internal sealed class ExternalPluginHandler : IDisposable
|
||||
{
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly IGameConfig _gameConfig;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
@ -19,7 +19,7 @@ internal sealed class ExternalPluginHandler : IDisposable
|
||||
private SystemConfigState? _limitFrameRateWhenClientInactive;
|
||||
private SystemConfigState? _uncapFrameRate;
|
||||
|
||||
public ExternalPluginHandler(IDalamudPluginInterface pluginInterface, IGameConfig gameConfig,
|
||||
public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IGameConfig gameConfig,
|
||||
Configuration configuration, IPluginLog pluginLog)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
|
2
Deliveroo/External/PandoraIpc.cs
vendored
2
Deliveroo/External/PandoraIpc.cs
vendored
@ -13,7 +13,7 @@ internal sealed class PandoraIpc
|
||||
private readonly ICallGateSubscriber<string, bool?> _getEnabled;
|
||||
private readonly ICallGateSubscriber<string, bool, object?> _setEnabled;
|
||||
|
||||
public PandoraIpc(IDalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
||||
public PandoraIpc(DalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
||||
{
|
||||
_pluginLog = pluginLog;
|
||||
_getEnabled = pluginInterface.GetIpcSubscriber<string, bool?>("PandorasBox.GetFeatureEnabled");
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System.Data;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Plugin.Services;
|
||||
using LLib;
|
||||
using Lumina.Excel;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Text.ReadOnly;
|
||||
using Lumina.Excel.CustomSheets;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Deliveroo.GameData;
|
||||
|
||||
@ -23,10 +24,10 @@ internal sealed class GameStrings
|
||||
ExchangeItems = dataManager.GetRegex<Addon>(3290, addon => addon.Text, pluginLog)
|
||||
?? throw new ConstraintException($"Unable to resolve {nameof(ExchangeItems)}");
|
||||
TradeHighQualityItem =
|
||||
dataManager.GetString<Addon>(102434, addon => addon.Text, pluginLog)
|
||||
dataManager.GetString<Addon>(102434, addon => addon.Text, pluginLog)?.ReplaceLineEndings("")
|
||||
?? throw new ConstraintException($"Unable to resolve {nameof(TradeHighQualityItem)}");
|
||||
|
||||
var rankUpFc = dataManager.GetExcelSheet<LogMessage>().GetRow(3123);
|
||||
var rankUpFc = dataManager.GetExcelSheet<LogMessage>()!.GetRow(3123)!;
|
||||
RankUpFc = rankUpFc.GetRegex(logMessage => logMessage.Text, pluginLog)
|
||||
?? throw new ConstraintException($"Unable to resolve {nameof(RankUpFc)}");
|
||||
RankUpFcType = (XivChatType)rankUpFc.LogKind;
|
||||
@ -42,16 +43,7 @@ internal sealed class GameStrings
|
||||
|
||||
[Sheet("custom/000/ComDefGrandCompanyOfficer_00073")]
|
||||
[SuppressMessage("Performance", "CA1812")]
|
||||
private readonly struct ComDefGrandCompanyOfficer(ExcelPage page, uint offset, uint row)
|
||||
: IQuestDialogueText, IExcelRow<ComDefGrandCompanyOfficer>
|
||||
private sealed class ComDefGrandCompanyOfficer : QuestDialogueText
|
||||
{
|
||||
public uint RowId => row;
|
||||
|
||||
public ReadOnlySeString Key => page.ReadString(offset, offset);
|
||||
public ReadOnlySeString Value => page.ReadString(offset + 4, offset);
|
||||
|
||||
static ComDefGrandCompanyOfficer IExcelRow<ComDefGrandCompanyOfficer>.Create(ExcelPage page, uint offset,
|
||||
uint row) =>
|
||||
new(page, offset, row);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
|
||||
namespace Deliveroo.GameData;
|
||||
@ -10,32 +10,31 @@ internal sealed class GcRewardsCache
|
||||
{
|
||||
public GcRewardsCache(IDataManager dataManager)
|
||||
{
|
||||
var categories = dataManager.GetExcelSheet<GCScripShopCategory>()
|
||||
var categories = dataManager.GetExcelSheet<GCScripShopCategory>()!
|
||||
.Where(x => x.RowId > 0)
|
||||
.ToDictionary(x => x.RowId,
|
||||
x =>
|
||||
(GrandCompany: (GrandCompany)x.GrandCompany.RowId,
|
||||
(GrandCompany: (GrandCompany)x.GrandCompany.Row,
|
||||
Tier: (RewardTier)x.Tier,
|
||||
SubCategory: (RewardSubCategory)x.SubCategory));
|
||||
|
||||
Rewards = dataManager.GetSubrowExcelSheet<GCScripShopItem>()
|
||||
.SelectMany(x => x)
|
||||
.Where(x => x.RowId > 0 && x.Item.RowId > 0)
|
||||
Rewards = dataManager.GetExcelSheet<GCScripShopItem>()!
|
||||
.Where(x => x.RowId > 0 && x.Item.Row > 0)
|
||||
.GroupBy(item =>
|
||||
{
|
||||
var category = categories[item.RowId];
|
||||
return new
|
||||
{
|
||||
ItemId = item.Item.RowId,
|
||||
Name = item.Item.Value.Name.ToString(),
|
||||
IconId = item.Item.RowId == ItemIds.Venture ? 25917 : item.Item.Value.Icon,
|
||||
ItemId = item.Item.Row,
|
||||
Name = item.Item.Value!.Name.ToString(),
|
||||
IconId = item.Item.Row == ItemIds.Venture ? 25917 : item.Item.Value!.Icon,
|
||||
category.Tier,
|
||||
category.SubCategory,
|
||||
RequiredRank = item.RequiredGrandCompanyRank.RowId,
|
||||
item.Item.Value.StackSize,
|
||||
RequiredRank = item.RequiredGrandCompanyRank.Row,
|
||||
item.Item!.Value.StackSize,
|
||||
SealCost = item.CostGCSeals,
|
||||
InventoryLimit = item.Item.Value.IsUnique ? 1
|
||||
: item.Item.RowId == ItemIds.Venture ? item.Item.Value.StackSize
|
||||
InventoryLimit = item.Item.Value!.IsUnique ? 1
|
||||
: item.Item.Row == ItemIds.Venture ? item.Item.Value!.StackSize
|
||||
: int.MaxValue,
|
||||
};
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Deliveroo.GameData;
|
||||
|
||||
@ -10,7 +10,7 @@ internal sealed class ItemCache
|
||||
|
||||
public ItemCache(IDataManager dataManager)
|
||||
{
|
||||
foreach (var item in dataManager.GetExcelSheet<Item>())
|
||||
foreach (var item in dataManager.GetExcelSheet<Item>()!)
|
||||
{
|
||||
string name = item.Name.ToString();
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
@ -19,10 +19,9 @@ internal sealed class ItemCache
|
||||
if (_itemNamesToIds.TryGetValue(name, out HashSet<uint>? itemIds))
|
||||
itemIds.Add(item.RowId);
|
||||
else
|
||||
_itemNamesToIds.Add(name, [item.RowId]);
|
||||
_itemNamesToIds.Add(name, new HashSet<uint>{item.RowId});
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<uint> GetItemIdFromItemName(string name) =>
|
||||
_itemNamesToIds.TryGetValue(name, out var itemIds) ? itemIds : [];
|
||||
public HashSet<uint> GetItemIdFromItemName(string name) => _itemNamesToIds[name];
|
||||
}
|
||||
|
@ -15,10 +15,8 @@ using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Common.Math;
|
||||
using FFXIVClientStructs.FFXIV.Component.Excel;
|
||||
using Lumina.Excel;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Text.ReadOnly;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
|
||||
|
||||
namespace Deliveroo;
|
||||
@ -43,7 +41,7 @@ internal sealed class GameFunctions : IDisposable
|
||||
_pluginLog = pluginLog;
|
||||
|
||||
|
||||
_gcRankInfo = dataManager.GetExcelSheet<GrandCompanyRank>().Where(x => x.RowId > 0)
|
||||
_gcRankInfo = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
|
||||
.ToDictionary(x => x.RowId, x => new GcRankInfo
|
||||
{
|
||||
NameTwinAddersMale = ExtractRankName<GCRankGridaniaMaleText>(dataManager, x.RowId, r => r.Singular),
|
||||
@ -55,7 +53,7 @@ internal sealed class GameFunctions : IDisposable
|
||||
ExtractRankName<GCRankUldahFemaleText>(dataManager, x.RowId, r => r.Singular),
|
||||
MaxSeals = x.MaxSeals,
|
||||
RequiredSeals = x.RequiredSeals,
|
||||
RequiredHuntingLog = x.Unknown0,
|
||||
RequiredHuntingLog = x.Unknown10,
|
||||
})
|
||||
.AsReadOnly();
|
||||
|
||||
@ -63,14 +61,14 @@ internal sealed class GameFunctions : IDisposable
|
||||
_clientState.TerritoryChanged += TerritoryChanged;
|
||||
}
|
||||
|
||||
private static string ExtractRankName<T>(IDataManager dataManager, uint rankId, Func<T, ReadOnlySeString> func)
|
||||
where T : struct, IExcelRow<T>
|
||||
private static string ExtractRankName<T>(IDataManager dataManager, uint rankId, Func<T, Lumina.Text.SeString> func)
|
||||
where T : ExcelRow
|
||||
{
|
||||
return func(dataManager.GetExcelSheet<T>().GetRow(rankId)).ToString();
|
||||
return func(dataManager.GetExcelSheet<T>()!.GetRow(rankId)!).ToString();
|
||||
}
|
||||
|
||||
|
||||
private void Logout(int type, int code)
|
||||
private void Logout()
|
||||
{
|
||||
_retainerItemCache.Clear();
|
||||
}
|
||||
@ -81,10 +79,10 @@ internal sealed class GameFunctions : IDisposable
|
||||
_retainerItemCache.Clear();
|
||||
}
|
||||
|
||||
public unsafe void InteractWithTarget(IGameObject obj)
|
||||
public unsafe void InteractWithTarget(GameObject obj)
|
||||
{
|
||||
_pluginLog.Information($"Setting target to {obj}");
|
||||
if (_targetManager.Target == null || _targetManager.Target.EntityId != obj.EntityId)
|
||||
if (_targetManager.Target == null || _targetManager.Target != obj)
|
||||
{
|
||||
_targetManager.Target = obj;
|
||||
}
|
||||
@ -113,13 +111,13 @@ internal sealed class GameFunctions : IDisposable
|
||||
|
||||
public unsafe byte GetGrandCompanyRank() => PlayerState.Instance()->GetGrandCompanyRank();
|
||||
|
||||
public float GetDistanceToNpc(int npcId, out IGameObject? o)
|
||||
public float GetDistanceToNpc(int npcId, out GameObject? o)
|
||||
{
|
||||
foreach (var obj in _objectTable)
|
||||
{
|
||||
if (obj.ObjectKind == ObjectKind.EventNpc && obj is ICharacter c)
|
||||
if (obj.ObjectKind == ObjectKind.EventNpc && obj is Character c)
|
||||
{
|
||||
if (c.DataId == npcId)
|
||||
if (GetNpcId(obj) == npcId)
|
||||
{
|
||||
o = obj;
|
||||
return Vector3.Distance(_clientState.LocalPlayer?.Position ?? Vector3.Zero, c.Position);
|
||||
@ -131,7 +129,7 @@ internal sealed class GameFunctions : IDisposable
|
||||
return float.MaxValue;
|
||||
}
|
||||
|
||||
public static int GetNpcId(IGameObject obj)
|
||||
public static int GetNpcId(GameObject obj)
|
||||
{
|
||||
return Marshal.ReadInt32(obj.Address + 128);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ internal sealed class ExchangeHandler
|
||||
_pluginLog = pluginLog;
|
||||
}
|
||||
|
||||
public void InteractWithQuartermaster(IGameObject personnelOfficer, IGameObject quartermaster)
|
||||
public void InteractWithQuartermaster(GameObject personnelOfficer, GameObject quartermaster)
|
||||
{
|
||||
if (_gameFunctions.GetCurrentSealCount() < _plugin.EffectiveReservedSealCount)
|
||||
{
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Deliveroo.GameData;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
@ -18,23 +20,25 @@ internal sealed class SupplyHandler
|
||||
private readonly GameFunctions _gameFunctions;
|
||||
private readonly ITargetManager _targetManager;
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly ItemCache _itemCache;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
|
||||
private uint _turnInErrors;
|
||||
|
||||
public SupplyHandler(DeliverooPlugin plugin, GameFunctions gameFunctions, ITargetManager targetManager,
|
||||
IGameGui gameGui, IPluginLog pluginLog)
|
||||
IGameGui gameGui, ItemCache itemCache, IPluginLog pluginLog)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_gameFunctions = gameFunctions;
|
||||
_targetManager = targetManager;
|
||||
_gameGui = gameGui;
|
||||
_itemCache = itemCache;
|
||||
_pluginLog = pluginLog;
|
||||
}
|
||||
|
||||
public void InteractWithPersonnelOfficer(IGameObject personnelOfficer, IGameObject quartermaster)
|
||||
public void InteractWithPersonnelOfficer(GameObject personnelOfficer, GameObject quartermaster)
|
||||
{
|
||||
if (_targetManager.Target?.EntityId == quartermaster.EntityId)
|
||||
if (_targetManager.Target == quartermaster)
|
||||
return;
|
||||
|
||||
_gameFunctions.InteractWithTarget(personnelOfficer);
|
||||
@ -46,7 +50,7 @@ internal sealed class SupplyHandler
|
||||
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
||||
if (agentInterface != null && agentInterface->IsAgentActive())
|
||||
{
|
||||
var addonId = agentInterface->GetAddonId();
|
||||
var addonId = agentInterface->GetAddonID();
|
||||
if (addonId == 0)
|
||||
return;
|
||||
|
||||
@ -89,7 +93,7 @@ internal sealed class SupplyHandler
|
||||
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
||||
if (agentInterface != null && agentInterface->IsAgentActive())
|
||||
{
|
||||
var addonId = agentInterface->GetAddonId();
|
||||
var addonId = agentInterface->GetAddonID();
|
||||
if (addonId == 0)
|
||||
return;
|
||||
|
||||
@ -99,7 +103,7 @@ internal sealed class SupplyHandler
|
||||
|
||||
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
||||
if (addonGc->ExpertDeliveryList == null ||
|
||||
!addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible())
|
||||
!addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible)
|
||||
return;
|
||||
|
||||
if (addonGc->SelectedTab != 2)
|
||||
@ -117,7 +121,7 @@ internal sealed class SupplyHandler
|
||||
}
|
||||
|
||||
int currentListSize = addonGc->ExpertDeliveryList->ListLength;
|
||||
if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible() || currentListSize == 0)
|
||||
if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible || currentListSize == 0)
|
||||
{
|
||||
_pluginLog.Information(
|
||||
$"No items to turn in ({addonGc->ListEmptyTextNode->AtkResNode.IsVisible}, {currentListSize})");
|
||||
@ -194,6 +198,37 @@ internal sealed class SupplyHandler
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void TurnInSelectedItem()
|
||||
{
|
||||
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
||||
out var addonSupplyReward) && LAddon.IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
||||
{
|
||||
string? itemName = addonSupplyReward->AtkUnitBase.AtkValues[4].ReadAtkString();
|
||||
if (itemName != null && _itemCache.GetItemIdFromItemName(itemName)
|
||||
.Any(itemId => InternalConfiguration.QuickVentureExclusiveItems.Contains(itemId)))
|
||||
{
|
||||
_plugin.DeliveryResult = new DeliveryResult
|
||||
{
|
||||
Message = new SeStringBuilder()
|
||||
.Append("Won't turn in ")
|
||||
.AddItemLink(_itemCache.GetItemIdFromItemName(itemName).First())
|
||||
.Append(", as it can only be obtained through Quick Ventures.")
|
||||
.Build(),
|
||||
};
|
||||
|
||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(1);
|
||||
_plugin.CurrentStage = Stage.CloseGcSupplyWindowThenStop;
|
||||
return;
|
||||
}
|
||||
|
||||
_pluginLog.Information($"Turning in '{itemName}'");
|
||||
|
||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
||||
_plugin.ContinueAt = DateTime.Now.AddSeconds(0.58);
|
||||
_plugin.CurrentStage = Stage.FinalizeTurnIn;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void FinalizeTurnInItem()
|
||||
{
|
||||
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList",
|
||||
@ -206,10 +241,7 @@ internal sealed class SupplyHandler
|
||||
new() { Type = 0, Int = 0 }
|
||||
};
|
||||
addonSupplyList->AtkUnitBase.FireCallback(3, updateFilter);
|
||||
if (_plugin.CurrentStage == Stage.FinalizeTurnIn)
|
||||
_plugin.CurrentStage = Stage.SelectItemToTurnIn;
|
||||
else
|
||||
_plugin.CurrentStage = Stage.RequestStop;
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +258,7 @@ internal sealed class SupplyHandler
|
||||
var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply);
|
||||
if (agentInterface != null && agentInterface->IsAgentActive())
|
||||
{
|
||||
var addonId = agentInterface->GetAddonId();
|
||||
var addonId = agentInterface->GetAddonID();
|
||||
if (addonId == 0)
|
||||
return;
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
|
||||
namespace Deliveroo;
|
||||
|
||||
internal interface IDeliveryResult;
|
||||
|
||||
internal sealed class MessageDeliveryResult : IDeliveryResult
|
||||
{
|
||||
public SeString? Message { get; init; }
|
||||
}
|
||||
|
||||
internal sealed class NoDeliveryResult : IDeliveryResult;
|
@ -21,6 +21,4 @@ internal enum Stage
|
||||
|
||||
RequestStop,
|
||||
Stopped,
|
||||
|
||||
SingleFinalizeTurnIn,
|
||||
}
|
||||
|
@ -2,11 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
@ -20,7 +19,7 @@ namespace Deliveroo.Windows;
|
||||
|
||||
internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly DeliverooPlugin _plugin;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly GcRewardsCache _gcRewardsCache;
|
||||
@ -30,19 +29,10 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
private readonly GameFunctions _gameFunctions;
|
||||
|
||||
private readonly IReadOnlyDictionary<uint, GcRewardItem> _itemLookup;
|
||||
|
||||
private readonly List<(VirtualKey Key, string Label)> _keyCodes =
|
||||
[
|
||||
(VirtualKey.NO_KEY, "Disabled"),
|
||||
(VirtualKey.CONTROL, "CTRL"),
|
||||
(VirtualKey.SHIFT, "SHIFT"),
|
||||
(VirtualKey.MENU, "ALT"),
|
||||
];
|
||||
|
||||
private string _searchString = string.Empty;
|
||||
private Configuration.PurchaseOption? _dragDropSource;
|
||||
private uint _dragDropSource;
|
||||
|
||||
public ConfigWindow(IDalamudPluginInterface pluginInterface, DeliverooPlugin plugin, Configuration configuration,
|
||||
public ConfigWindow(DalamudPluginInterface pluginInterface, DeliverooPlugin plugin, Configuration configuration,
|
||||
GcRewardsCache gcRewardsCache, IClientState clientState, IPluginLog pluginLog, IconCache iconCache,
|
||||
GameFunctions gameFunctions)
|
||||
: base("Deliveroo - Configuration###DeliverooConfig")
|
||||
@ -89,52 +79,56 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
if (ImGui.BeginTabItem("Items for Auto-Buy"))
|
||||
{
|
||||
Configuration.PurchaseOption? itemToRemove = null;
|
||||
Configuration.PurchaseOption? itemToAdd = null;
|
||||
uint? itemToRemove = null;
|
||||
uint? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
if (ImGui.BeginChild("Items", new Vector2(-1, -ImGui.GetFrameHeightWithSpacing()), true,
|
||||
ImGuiWindowFlags.NoSavedSettings))
|
||||
{
|
||||
for (int i = 0; i < _configuration.ItemsAvailableToPurchase.Count; ++i)
|
||||
for (int i = 0; i < _configuration.ItemsAvailableForPurchase.Count; ++i)
|
||||
{
|
||||
var purchaseOption = _configuration.ItemsAvailableToPurchase[i];
|
||||
uint itemId = _configuration.ItemsAvailableForPurchase[i];
|
||||
ImGui.PushID($"###Item{i}");
|
||||
ImGui.BeginDisabled(
|
||||
_configuration.ItemsAvailableToPurchase.Count == 1 && purchaseOption.ItemId == ItemIds.Venture);
|
||||
_configuration.ItemsAvailableForPurchase.Count == 1 && itemId == ItemIds.Venture);
|
||||
|
||||
var item = _itemLookup[purchaseOption.ItemId];
|
||||
using (var icon = _iconCache.GetIcon(item.IconId))
|
||||
{
|
||||
var item = _itemLookup[itemId];
|
||||
IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId);
|
||||
Vector2 pos = ImGui.GetCursorPos();
|
||||
Vector2 iconSize = new Vector2(ImGui.GetTextLineHeight() + ImGui.GetStyle().ItemSpacing.Y);
|
||||
|
||||
if (icon != null)
|
||||
{
|
||||
ImGui.SetCursorPos(pos + new Vector2(iconSize.X + ImGui.GetStyle().FramePadding.X,
|
||||
ImGui.GetStyle().ItemSpacing.Y / 2));
|
||||
}
|
||||
|
||||
ImGui.Selectable(
|
||||
$"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}{(purchaseOption.SameQuantityForAllLists ? $" {((SeIconChar)57412).ToIconString()} (Limit: {purchaseOption.GlobalLimit:N0})" : "")}",
|
||||
ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}",
|
||||
false, ImGuiSelectableFlags.SpanAllColumns);
|
||||
|
||||
if (icon != null)
|
||||
{
|
||||
ImGui.SameLine(0, 0);
|
||||
ImGui.SetCursorPos(pos);
|
||||
ImGui.Image(icon.ImGuiHandle, iconSize);
|
||||
}
|
||||
|
||||
if (ImGui.BeginDragDropSource())
|
||||
{
|
||||
ImGui.SetDragDropPayload("DeliverooDragDrop", nint.Zero, 0);
|
||||
_dragDropSource = purchaseOption;
|
||||
_dragDropSource = itemId;
|
||||
|
||||
ImGui.EndDragDropSource();
|
||||
}
|
||||
|
||||
if (ImGui.BeginDragDropTarget())
|
||||
{
|
||||
if (_dragDropSource != null &&
|
||||
if (_dragDropSource > 0 &&
|
||||
ImGui.AcceptDragDropPayload("DeliverooDragDrop").NativePtr != null)
|
||||
{
|
||||
itemToAdd = _dragDropSource;
|
||||
indexToAdd = i;
|
||||
|
||||
_dragDropSource = null;
|
||||
_dragDropSource = 0;
|
||||
}
|
||||
|
||||
ImGui.EndDragDropTarget();
|
||||
@ -143,28 +137,12 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
ImGui.OpenPopupOnItemClick($"###ctx{i}", ImGuiPopupFlags.MouseButtonRight);
|
||||
if (ImGui.BeginPopup($"###ctx{i}"))
|
||||
{
|
||||
bool sameQuantityForAllLists = purchaseOption.SameQuantityForAllLists;
|
||||
if (ImGui.MenuItem("Use same quantity for global and character-specific lists", null,
|
||||
ref sameQuantityForAllLists))
|
||||
{
|
||||
purchaseOption.SameQuantityForAllLists = sameQuantityForAllLists;
|
||||
Save();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem($"Remove {_itemLookup[purchaseOption.ItemId].Name}"))
|
||||
itemToRemove = purchaseOption;
|
||||
if (ImGui.Selectable($"Remove {_itemLookup[itemId].Name}"))
|
||||
itemToRemove = itemId;
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
if (icon != null)
|
||||
{
|
||||
ImGui.SameLine(0, 0);
|
||||
ImGui.SetCursorPos(pos);
|
||||
ImGui.Image(icon.ImGuiHandle, iconSize);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndDisabled();
|
||||
ImGui.PopID();
|
||||
}
|
||||
@ -174,20 +152,20 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Remove(itemToRemove);
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToRemove.Value);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Remove(itemToAdd);
|
||||
_configuration.ItemsAvailableToPurchase.Insert(indexToAdd, itemToAdd);
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToAdd.Value);
|
||||
_configuration.ItemsAvailableForPurchase.Insert(indexToAdd, itemToAdd.Value);
|
||||
Save();
|
||||
}
|
||||
|
||||
List<(uint ItemId, string Name, ushort IconId, bool Limited)> comboValues = _gcRewardsCache.Rewards
|
||||
.Where(x => x.SubCategory is RewardSubCategory.Materials or RewardSubCategory.Materiel)
|
||||
.Where(x => _configuration.ItemsAvailableToPurchase.All(y => y.ItemId != x.ItemId))
|
||||
.Where(x => !_configuration.ItemsAvailableForPurchase.Contains(x.ItemId))
|
||||
.Select(x => (x.ItemId, x.Name, x.IconId, x.Limited))
|
||||
.OrderBy(x => x.Name)
|
||||
.ThenBy(x => x.GetHashCode())
|
||||
@ -202,23 +180,20 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
foreach (var item in comboValues.Where(x =>
|
||||
x.Name.Contains(_searchString, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
using (var icon = _iconCache.GetIcon(item.IconId))
|
||||
{
|
||||
IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId);
|
||||
if (icon != null)
|
||||
{
|
||||
ImGui.Image(icon.ImGuiHandle, new Vector2(ImGui.GetFrameHeight()));
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + ImGui.GetStyle().FramePadding.X);
|
||||
}
|
||||
}
|
||||
|
||||
bool addThis =
|
||||
ImGui.Selectable(
|
||||
$"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}##SelectVenture{item.IconId}");
|
||||
if (addThis || addFirst)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Add(new Configuration.PurchaseOption
|
||||
{ ItemId = item.ItemId });
|
||||
_configuration.ItemsAvailableForPurchase.Add(item.ItemId);
|
||||
|
||||
if (addFirst)
|
||||
{
|
||||
@ -244,7 +219,7 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
if (_clientState is { IsLoggedIn: true, LocalContentId: > 0 })
|
||||
{
|
||||
string currentCharacterName = _clientState.LocalPlayer!.Name.ToString();
|
||||
string currentWorldName = _clientState.LocalPlayer.HomeWorld.Value.Name.ToString();
|
||||
string currentWorldName = _clientState.LocalPlayer.HomeWorld.GameData!.Name.ToString();
|
||||
ImGui.Text($"Current Character: {currentCharacterName} @ {currentWorldName}");
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
@ -387,15 +362,6 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
ImGui.EndDisabled();
|
||||
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120);
|
||||
int selectedKey = Math.Max(0, _keyCodes.FindIndex(x => x.Key == _configuration.QuickTurnInKey));
|
||||
if (ImGui.Combo("Quick Turn-In Key", ref selectedKey, _keyCodes.Select(x => x.Label).ToArray(),
|
||||
_keyCodes.Count))
|
||||
{
|
||||
_configuration.QuickTurnInKey = _keyCodes[selectedKey].Key;
|
||||
Save();
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120);
|
||||
var xivChatTypes = Enum.GetValues<XivChatType>()
|
||||
.Where(x => x != XivChatType.StandardEmote)
|
||||
|
@ -3,14 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Deliveroo.GameData;
|
||||
@ -22,7 +19,7 @@ using LLib.ImGui;
|
||||
|
||||
namespace Deliveroo.Windows;
|
||||
|
||||
internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configuration.MinimizableWindowConfig>
|
||||
internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
private static readonly IReadOnlyList<InventoryType> InventoryTypes = new[]
|
||||
{
|
||||
@ -47,23 +44,20 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
private static readonly string[] StockingTypeLabels = { "Purchase Once", "Keep in Stock" };
|
||||
|
||||
private readonly DeliverooPlugin _plugin;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly ICondition _condition;
|
||||
private readonly IClientState _clientState;
|
||||
private readonly GcRewardsCache _gcRewardsCache;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
private readonly IconCache _iconCache;
|
||||
private readonly IKeyState _keyState;
|
||||
private readonly GameFunctions _gameFunctions;
|
||||
private readonly TitleBarButton _minimizeButton;
|
||||
|
||||
private bool _state;
|
||||
private Guid? _draggedItem;
|
||||
|
||||
public TurnInWindow(DeliverooPlugin plugin, IDalamudPluginInterface pluginInterface, Configuration configuration,
|
||||
public TurnInWindow(DeliverooPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration,
|
||||
ICondition condition, IClientState clientState, GcRewardsCache gcRewardsCache, ConfigWindow configWindow,
|
||||
IconCache iconCache, IKeyState keyState, GameFunctions gameFunctions)
|
||||
IconCache iconCache, GameFunctions gameFunctions)
|
||||
: base("GC Delivery###DeliverooTurnIn")
|
||||
{
|
||||
_plugin = plugin;
|
||||
@ -74,7 +68,6 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
_gcRewardsCache = gcRewardsCache;
|
||||
_configWindow = configWindow;
|
||||
_iconCache = iconCache;
|
||||
_keyState = keyState;
|
||||
_gameFunctions = gameFunctions;
|
||||
|
||||
Position = new Vector2(100, 100);
|
||||
@ -90,20 +83,6 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
ShowCloseButton = false;
|
||||
AllowClickthrough = false;
|
||||
|
||||
_minimizeButton = new TitleBarButton
|
||||
{
|
||||
Icon = FontAwesomeIcon.Minus,
|
||||
Priority = int.MinValue,
|
||||
IconOffset = new Vector2(1.5f, 1),
|
||||
Click = _ =>
|
||||
{
|
||||
IsMinimized = !IsMinimized;
|
||||
_minimizeButton!.Icon = IsMinimized ? FontAwesomeIcon.WindowMaximize : FontAwesomeIcon.Minus;
|
||||
},
|
||||
AvailableClickthrough = true,
|
||||
};
|
||||
TitleBarButtons.Insert(0, _minimizeButton);
|
||||
|
||||
TitleBarButtons.Add(new TitleBarButton
|
||||
{
|
||||
Icon = FontAwesomeIcon.Cog,
|
||||
@ -119,17 +98,7 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
});
|
||||
}
|
||||
|
||||
public Configuration.MinimizableWindowConfig WindowConfig => _configuration.TurnInWindowConfig;
|
||||
|
||||
private bool IsMinimized
|
||||
{
|
||||
get => WindowConfig.IsMinimized;
|
||||
set
|
||||
{
|
||||
WindowConfig.IsMinimized = value;
|
||||
SaveWindowConfig();
|
||||
}
|
||||
}
|
||||
public WindowConfig WindowConfig => _configuration.TurnInWindowConfig;
|
||||
|
||||
public bool State
|
||||
{
|
||||
@ -152,7 +121,7 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
|
||||
private bool IsOnHomeWorld =>
|
||||
_clientState.LocalPlayer == null ||
|
||||
_clientState.LocalPlayer.HomeWorld.RowId == _clientState.LocalPlayer.CurrentWorld.RowId;
|
||||
_clientState.LocalPlayer.HomeWorld.Id == _clientState.LocalPlayer.CurrentWorld.Id;
|
||||
|
||||
private IItemsToPurchase ItemsWrapper => UseCharacterSpecificItemsToPurchase
|
||||
? new CharacterSpecificItemsToPurchase(_plugin.CharacterConfiguration!, _pluginInterface)
|
||||
@ -176,16 +145,13 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
.Where(x => x.Reward.RequiredRank <= rank)
|
||||
.Select(x =>
|
||||
{
|
||||
var purchaseOption = _configuration.ItemsAvailableToPurchase.Where(y => y.SameQuantityForAllLists)
|
||||
.FirstOrDefault(y => y.ItemId == x.Item.ItemId);
|
||||
int limit = purchaseOption?.GlobalLimit ?? x.Item.Limit;
|
||||
var request = new PurchaseItemRequest
|
||||
{
|
||||
ItemId = x.Item.ItemId,
|
||||
Name = x.Reward.Name,
|
||||
EffectiveLimit = CalculateEffectiveLimit(
|
||||
x.Item.ItemId,
|
||||
limit <= 0 ? uint.MaxValue : (uint)limit,
|
||||
x.Item.Limit <= 0 ? uint.MaxValue : (uint)x.Item.Limit,
|
||||
x.Reward.StackSize,
|
||||
x.Reward.InventoryLimit),
|
||||
SealCost = x.Reward.SealCost,
|
||||
@ -244,17 +210,14 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
}
|
||||
|
||||
float indentSize = ImGui.GetFrameHeight() + ImGui.GetStyle().ItemInnerSpacing.X;
|
||||
ImGui.Indent(indentSize);
|
||||
if (!string.IsNullOrEmpty(Error))
|
||||
{
|
||||
using (ImRaii.PushIndent(indentSize))
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (ImRaii.PushIndent(indentSize))
|
||||
{
|
||||
if (_configuration.BehaviorOnOtherWorld == Configuration.EBehaviorOnOtherWorld.Warning &&
|
||||
!IsOnHomeWorld)
|
||||
if (_configuration.BehaviorOnOtherWorld == Configuration.EBehaviorOnOtherWorld.Warning && !IsOnHomeWorld)
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed,
|
||||
"You are not on your home world and will not earn FC points.");
|
||||
@ -278,8 +241,7 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
ImGui.BeginDisabled(_condition[ConditionFlag.OccupiedInQuestEvent] ||
|
||||
_condition[ConditionFlag.Casting] ||
|
||||
agentInventoryContext == null);
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Bolt,
|
||||
"Use Priority Seal Allowance (15%)"))
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Bolt, "Use Priority Seal Allowance (15%)"))
|
||||
{
|
||||
agentInventoryContext->UseItem(ItemIds.PrioritySealAllowance);
|
||||
}
|
||||
@ -287,43 +249,19 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsMinimized)
|
||||
{
|
||||
ImGui.Unindent(indentSize);
|
||||
ImGui.Separator();
|
||||
using (ImRaii.Disabled(state))
|
||||
ImGui.BeginDisabled(state);
|
||||
|
||||
DrawItemsToBuy(grandCompany);
|
||||
}
|
||||
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
if (_configuration.QuickTurnInKey != VirtualKey.NO_KEY)
|
||||
{
|
||||
var key = _configuration.QuickTurnInKey switch
|
||||
{
|
||||
VirtualKey.MENU => "ALT",
|
||||
VirtualKey.SHIFT => "SHIFT",
|
||||
VirtualKey.CONTROL => "CTRL",
|
||||
_ => _configuration.QuickTurnInKey.ToString()
|
||||
};
|
||||
if (!State && _keyState[_configuration.QuickTurnInKey])
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.TextColored(ImGuiColors.HealerGreen, "Click an item to turn it in without confirmation");
|
||||
}
|
||||
else if (!IsMinimized)
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Hold '{key}' when clicking an item to turn it in without confirmation.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsMinimized)
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Debug (State): {_plugin.CurrentStage}");
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawNextRankPrequesites()
|
||||
{
|
||||
@ -334,7 +272,7 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
uint requiredSeals = _gameFunctions.GetSealsRequiredForNextRank();
|
||||
|
||||
int currentHuntingLog =
|
||||
MonsterNoteManager.Instance()->RankData[(int)_gameFunctions.GetGrandCompany() + 7]
|
||||
MonsterNoteManager.Instance()->RankDataArraySpan[(int)_gameFunctions.GetGrandCompany() + 7]
|
||||
.Rank;
|
||||
byte requiredHuntingLog = _gameFunctions.GetRequiredHuntingLogForNextRank();
|
||||
|
||||
@ -381,20 +319,13 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
{
|
||||
(GcRewardItem.None, GcRewardItem.None.Name, GcRewardItem.None.Name),
|
||||
};
|
||||
foreach (Configuration.PurchaseOption purchaseOption in _configuration.ItemsAvailableToPurchase)
|
||||
foreach (uint itemId in _configuration.ItemsAvailableForPurchase)
|
||||
{
|
||||
var gcReward = _gcRewardsCache.GetReward(purchaseOption.ItemId);
|
||||
int itemCountWithoutRetainers = _gameFunctions.GetItemCount(purchaseOption.ItemId, false);
|
||||
int itemCountWithRetainers = _gameFunctions.GetItemCount(purchaseOption.ItemId, true);
|
||||
var gcReward = _gcRewardsCache.GetReward(itemId);
|
||||
int itemCountWithoutRetainers = _gameFunctions.GetItemCount(itemId, false);
|
||||
int itemCountWithRetainers = _gameFunctions.GetItemCount(itemId, true);
|
||||
string itemNameWithoutRetainers = gcReward.Name;
|
||||
string itemNameWithRetainers = gcReward.Name;
|
||||
|
||||
if (purchaseOption.SameQuantityForAllLists)
|
||||
{
|
||||
itemNameWithoutRetainers += $" {((SeIconChar)57412).ToIconString()}";
|
||||
itemNameWithRetainers += $" {((SeIconChar)57412).ToIconString()}";
|
||||
}
|
||||
|
||||
if (itemCountWithoutRetainers > 0)
|
||||
itemNameWithoutRetainers += $" ({itemCountWithoutRetainers:N0})";
|
||||
if (itemCountWithRetainers > 0)
|
||||
@ -408,89 +339,11 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
Configuration.PurchasePriority? itemToRemove = null;
|
||||
int? itemToRemove = null;
|
||||
Configuration.PurchasePriority? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
|
||||
float width = ImGui.GetContentRegionAvail().X;
|
||||
List<(Vector2 TopLeft, Vector2 BottomRight)> itemPositions = [];
|
||||
|
||||
for (int i = 0; i < itemsWrapper.GetItemsToPurchase().Count; ++i)
|
||||
{
|
||||
DrawItemToBuy(grandCompany, i, itemsWrapper, comboValues, width, ref itemToRemove, itemPositions);
|
||||
}
|
||||
|
||||
if (!ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
_draggedItem = null;
|
||||
else if (_draggedItem != null)
|
||||
{
|
||||
var items = itemsWrapper.GetItemsToPurchase().ToList();
|
||||
var draggedItem = items.Single(x => x.InternalId == _draggedItem);
|
||||
int oldIndex = items.IndexOf(draggedItem);
|
||||
|
||||
var (topLeft, bottomRight) = itemPositions[oldIndex];
|
||||
ImGui.GetWindowDrawList().AddRect(topLeft, bottomRight, ImGui.GetColorU32(ImGuiColors.DalamudGrey), 3f,
|
||||
ImDrawFlags.RoundCornersAll);
|
||||
|
||||
int newIndex = itemPositions.FindIndex(x => ImGui.IsMouseHoveringRect(x.TopLeft, x.BottomRight, true));
|
||||
if (newIndex >= 0 && oldIndex != newIndex)
|
||||
{
|
||||
itemToAdd = items.Single(x => x.InternalId == _draggedItem);
|
||||
indexToAdd = newIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToRemove);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToAdd);
|
||||
itemsWrapper.Insert(indexToAdd, itemToAdd);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ItemsAvailableToPurchase.Any(x =>
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x.ItemId != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
ImGui.OpenPopup("##AddItem");
|
||||
|
||||
if (ImGui.BeginPopupContextItem("##AddItem", ImGuiPopupFlags.NoOpenOverItems))
|
||||
{
|
||||
foreach (var purchaseOption in _configuration.ItemsAvailableToPurchase.Distinct())
|
||||
{
|
||||
if (_gcRewardsCache.RewardLookup.TryGetValue(purchaseOption.ItemId, out var reward))
|
||||
{
|
||||
if (ImGui.MenuItem($"{reward.Name}##{purchaseOption.ItemId}"))
|
||||
{
|
||||
itemsWrapper.Add(new Configuration.PurchasePriority
|
||||
{ ItemId = purchaseOption.ItemId, Limit = 0 });
|
||||
itemsWrapper.Save();
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, "Configure available Items"))
|
||||
_configWindow.IsOpen = true;
|
||||
}
|
||||
|
||||
private void DrawItemToBuy(GrandCompany grandCompany, int i, IItemsToPurchase itemsWrapper,
|
||||
List<(GcRewardItem Item, string NameWithoutRetainers, string NameWithRetainers)> comboValues, float width,
|
||||
ref Configuration.PurchasePriority? itemToRemove, List<(Vector2 TopLeft, Vector2 BottomRight)> itemPositions)
|
||||
{
|
||||
Vector2 topLeft = ImGui.GetCursorScreenPos() + new Vector2(0, -ImGui.GetStyle().ItemSpacing.Y / 2);
|
||||
|
||||
ImGui.PushID($"ItemToBuy{i}");
|
||||
Configuration.PurchasePriority item = itemsWrapper.GetItemsToPurchase()[i];
|
||||
|
||||
@ -553,27 +406,15 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
}
|
||||
|
||||
var comboItem = comboValues[comboValueIndex];
|
||||
using (var icon = _iconCache.GetIcon(comboItem.Item.IconId))
|
||||
{
|
||||
IDalamudTextureWrap? icon = _iconCache.GetIcon(comboItem.Item.IconId);
|
||||
if (icon != null)
|
||||
{
|
||||
ImGui.Image(icon.ImGuiHandle, new Vector2(ImGui.GetFrameHeight()));
|
||||
ImGui.SameLine(0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
indentX = ImGui.GetCursorPosX() - indentX;
|
||||
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SetNextItemWidth(width -
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Circle.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.ArrowsUpDown.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 8 -
|
||||
ImGui.GetStyle().ItemSpacing.X * 2 - 3 * 3);
|
||||
ImGui.PopFont();
|
||||
|
||||
if (ImGui.Combo("", ref comboValueIndex,
|
||||
comboValues.Select(x => item.CheckRetainerInventory ? x.NameWithRetainers : x.NameWithoutRetainers)
|
||||
.ToArray(), comboValues.Count))
|
||||
@ -587,72 +428,48 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
|
||||
if (itemsWrapper.GetItemsToPurchase().Count >= 2)
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X +
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.ArrowsUpDown.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 4 -
|
||||
ImGui.GetStyle().ItemSpacing.X);
|
||||
ImGui.PopFont();
|
||||
|
||||
if (_draggedItem == item.InternalId)
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton($"##Up{i}", FontAwesomeIcon.ArrowUp))
|
||||
{
|
||||
ImGuiComponents.IconButton("##Move", FontAwesomeIcon.ArrowsUpDown,
|
||||
ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.ButtonActive)));
|
||||
}
|
||||
itemToAdd = item;
|
||||
if (i > 0)
|
||||
indexToAdd = i - 1;
|
||||
else
|
||||
ImGuiComponents.IconButton("##Move", FontAwesomeIcon.ArrowsUpDown);
|
||||
indexToAdd = itemsWrapper.GetItemsToPurchase().Count - 1;
|
||||
}
|
||||
|
||||
if (_draggedItem == null && ImGui.IsItemActive() && ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
_draggedItem = item.InternalId;
|
||||
ImGui.SameLine(0, 0);
|
||||
if (ImGuiComponents.IconButton($"##Down{i}", FontAwesomeIcon.ArrowDown))
|
||||
{
|
||||
itemToAdd = item;
|
||||
if (i < itemsWrapper.GetItemsToPurchase().Count - 1)
|
||||
indexToAdd = i + 1;
|
||||
else
|
||||
indexToAdd = 0;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X +
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 2);
|
||||
ImGui.PopFont();
|
||||
}
|
||||
|
||||
if (ImGuiComponents.IconButton($"###Remove{i}", FontAwesomeIcon.Times))
|
||||
itemToRemove = item;
|
||||
itemToRemove = i;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
ImGui.Indent(indentX);
|
||||
if (comboValueIndex > 0)
|
||||
{
|
||||
var purchaseOption =
|
||||
_configuration.ItemsAvailableToPurchase
|
||||
.Where(x => x.SameQuantityForAllLists)
|
||||
.FirstOrDefault(x => x.ItemId == item.ItemId);
|
||||
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 130);
|
||||
int limit = Math.Min(purchaseOption?.GlobalLimit ?? item.Limit, (int)comboItem.Item.InventoryLimit);
|
||||
int limit = Math.Min(item.Limit, (int)comboItem.Item.InventoryLimit);
|
||||
int stepSize = comboItem.Item.StackSize < 99 ? 1 : 50;
|
||||
string label = item.Type == Configuration.PurchaseType.KeepStocked
|
||||
? "Maximum items to buy"
|
||||
: "Remaining items to buy";
|
||||
if (ImGui.InputInt(label, ref limit, stepSize, stepSize * 10))
|
||||
{
|
||||
int newLimit = Math.Min(Math.Max(0, limit), (int)comboItem.Item.InventoryLimit);
|
||||
if (purchaseOption != null)
|
||||
{
|
||||
purchaseOption.GlobalLimit = newLimit;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Limit = newLimit;
|
||||
item.Limit = Math.Min(Math.Max(0, limit), (int)comboItem.Item.InventoryLimit);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.Limit != 0)
|
||||
{
|
||||
item.Limit = 0;
|
||||
@ -677,10 +494,49 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
Vector2 bottomRight = new Vector2(topLeft.X + width,
|
||||
ImGui.GetCursorScreenPos().Y - ImGui.GetStyle().ItemSpacing.Y + 2);
|
||||
itemPositions.Add((topLeft, bottomRight));
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToAdd);
|
||||
itemsWrapper.Insert(indexToAdd, itemToAdd);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
itemsWrapper.RemoveAt(itemToRemove.Value);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ItemsAvailableForPurchase.Any(x =>
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
ImGui.OpenPopup("##AddItem");
|
||||
|
||||
if (ImGui.BeginPopupContextItem("##AddItem", ImGuiPopupFlags.NoOpenOverItems))
|
||||
{
|
||||
foreach (var itemId in _configuration.ItemsAvailableForPurchase.Distinct())
|
||||
{
|
||||
if (_gcRewardsCache.RewardLookup.TryGetValue(itemId, out var reward))
|
||||
{
|
||||
if (ImGui.MenuItem($"{reward.Name}##{itemId}"))
|
||||
{
|
||||
itemsWrapper.Add(new Configuration.PurchasePriority { ItemId = itemId, Limit = 0 });
|
||||
itemsWrapper.Save();
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, "Configure available Items"))
|
||||
_configWindow.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe uint CalculateEffectiveLimit(uint itemId, uint limit, uint stackSize, uint inventoryLimit)
|
||||
@ -697,7 +553,7 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
for (int i = 0; i < container->Size; ++i)
|
||||
{
|
||||
var item = container->GetInventorySlot(i);
|
||||
if (item == null || item->ItemId == 0 || item->ItemId == itemId)
|
||||
if (item == null || item->ItemID == 0 || item->ItemID == itemId)
|
||||
{
|
||||
slotsThatCanBeUsed++;
|
||||
}
|
||||
@ -725,10 +581,10 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
private sealed class CharacterSpecificItemsToPurchase : IItemsToPurchase
|
||||
{
|
||||
private readonly CharacterConfiguration _characterConfiguration;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
|
||||
public CharacterSpecificItemsToPurchase(CharacterConfiguration characterConfiguration,
|
||||
IDalamudPluginInterface pluginInterface)
|
||||
DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
_characterConfiguration = characterConfiguration;
|
||||
_pluginInterface = pluginInterface;
|
||||
@ -758,9 +614,9 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig<Configura
|
||||
private sealed class GlobalItemsToPurchase : IItemsToPurchase
|
||||
{
|
||||
private readonly Configuration _configuration;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
|
||||
public GlobalItemsToPurchase(Configuration configuration, IDalamudPluginInterface pluginInterface)
|
||||
public GlobalItemsToPurchase(Configuration configuration, DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_pluginInterface = pluginInterface;
|
||||
|
@ -4,83 +4,12 @@
|
||||
"net8.0-windows7.0": {
|
||||
"DalamudPackager": {
|
||||
"type": "Direct",
|
||||
"requested": "[11.0.0, )",
|
||||
"resolved": "11.0.0",
|
||||
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
|
||||
},
|
||||
"DotNet.ReproducibleBuilds": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.1.1, )",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "+H2t/t34h6mhEoUvHi8yGXyuZ2GjSovcGYehJrS2MDm2XgmPfZL2Sdxg+uL2lKgZ4M6tTwKHIlxOob2bgh0NRQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.SourceLink.AzureRepos.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Bitbucket.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.GitHub": "1.1.1",
|
||||
"Microsoft.SourceLink.GitLab": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Gitea": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.0, )",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "KOBodmDnlWGIqZt2hT47Q69TIoGhIApDVLCyyj9TT5ct8ju16AbHYcB4XeknoHX562wO1pMS/1DfBIZK+V+sxg==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "8.0.0",
|
||||
"Microsoft.SourceLink.Common": "8.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.Build.Tasks.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
|
||||
},
|
||||
"Microsoft.SourceLink.AzureRepos.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "qB5urvw9LO2bG3eVAkuL+2ughxz2rR7aYgm2iyrB8Rlk9cp2ndvGRCvehk3rNIhRuNtQaeKwctOl1KvWiklv5w==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Bitbucket.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "cDzxXwlyWpLWaH0em4Idj0H3AmVo3L/6xRXKssYemx+7W52iNskj/SQ4FOmfCb8YQt39otTDNMveCZzYtMoucQ==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
|
||||
},
|
||||
"Microsoft.SourceLink.GitHub": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.SourceLink.GitLab": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.1",
|
||||
"contentHash": "tvsg47DDLqqedlPeYVE2lmiTpND8F0hkrealQ5hYltSmvruy/Gr5nHAKSsjyw5L3NeM/HLMI5ORv7on/M4qyZw==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.1.1",
|
||||
"Microsoft.SourceLink.Common": "1.1.1"
|
||||
}
|
||||
"requested": "[2.1.12, )",
|
||||
"resolved": "2.1.12",
|
||||
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
||||
},
|
||||
"llib": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"DalamudPackager": "[11.0.0, )"
|
||||
}
|
||||
"type": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
LLib
2
LLib
@ -1 +1 @@
|
||||
Subproject commit b581e2ea2a61f44ed3f0cb4f6ea8cc1595525544
|
||||
Subproject commit b5125d4b3f7cdc0c7514a01764e5b5d4d85f80a7
|
Loading…
Reference in New Issue
Block a user