This commit is contained in:
Liza 2024-03-22 21:43:11 +01:00
parent 5836c6312e
commit 1f119d859f
Signed by: liza
GPG Key ID: 7199F8D727D55F67
16 changed files with 1058 additions and 40 deletions

1017
Deliveroo/.editorconfig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,13 +18,6 @@ internal sealed class Configuration : IPluginConfiguration
public int PauseAtRank { get; set; }
public EBehaviorOnOtherWorld BehaviorOnOtherWorld { get; set; } = EBehaviorOnOtherWorld.Warning;
/// <summary>
/// A config-only setting, not exposed in the UI.
///
/// If set, buys all GC items in their max quantity (otherwise, everything except ventures is capped to 99).
/// </summary>
public bool IgnoreCertainLimitations { get; set; } = false;
internal sealed class PurchasePriority
{
public uint ItemId { get; set; }

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Version>3.3</Version>
<LangVersion>11.0</LangVersion>
<TargetFramework>net8.0-windows</TargetFramework>
<Version>4.0</Version>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

View File

@ -34,7 +34,7 @@ partial class DeliverooPlugin
if (request == previousRequest)
{
toBuy = (int)request.StackSize;
if (request.ItemId != ItemIds.Venture && !_configuration.IgnoreCertainLimitations)
if (request.ItemId != ItemIds.Venture)
toBuy = Math.Min(toBuy, 99);
}
@ -152,7 +152,7 @@ partial class DeliverooPlugin
else
toBuy = Math.Min(toBuy, item.EffectiveLimit);
if (item.ItemId != ItemIds.Venture && !_configuration.IgnoreCertainLimitations)
if (item.ItemId != ItemIds.Venture)
toBuy = Math.Min(toBuy, 99);
if (toBuy <= 0)

View File

@ -66,7 +66,7 @@ partial class DeliverooPlugin
return float.MaxValue;
}
private int GetNpcId(GameObject obj)
private static int GetNpcId(GameObject obj)
{
return Marshal.ReadInt32(obj.Address + 128);
}
@ -95,7 +95,7 @@ partial class DeliverooPlugin
private uint GetSealCap() => _sealCaps.TryGetValue(GetGrandCompanyRank(), out var cap) ? cap : 0;
public uint GetMaxSealCap() => _sealCaps[11];
public uint MaxSealCap => _sealCaps[11];
public unsafe int GetItemCount(uint itemId, bool checkRetainerInventory)
{

View File

@ -8,7 +8,6 @@ using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using LLib.GameUI;
using Lumina.Text.Payloads;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace Deliveroo;

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.ClientState.Conditions;
@ -25,7 +26,6 @@ namespace Deliveroo;
public sealed partial class DeliverooPlugin : IDalamudPlugin
{
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
private readonly IReadOnlyList<uint> DisabledTurnInItems = new List<uint> { 2820 }.AsReadOnly();
private readonly DalamudPluginInterface _pluginInterface;
private readonly IChatGui _chatGui;
@ -52,13 +52,13 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
private readonly ItemCache _itemCache;
private readonly ConfigWindow _configWindow;
private readonly TurnInWindow _turnInWindow;
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
private readonly ReadOnlyDictionary<uint, uint> _sealCaps;
private readonly Dictionary<uint, int> _retainerItemCache = new();
private Stage _currentStageInternal = Stage.Stopped;
private DateTime _continueAt = DateTime.MinValue;
private int _lastTurnInListSize = int.MaxValue;
private uint _turnInErrors = 0;
private uint _turnInErrors;
private List<PurchaseItemRequest> _itemsToPurchaseNow = new();
public DeliverooPlugin(DalamudPluginInterface pluginInterface, IChatGui chatGui, IGameGui gameGui,
@ -66,6 +66,8 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
IDataManager dataManager, ICondition condition, ICommandManager commandManager, IPluginLog pluginLog,
IAddonLifecycle addonLifecycle, ITextureProvider textureProvider)
{
ArgumentNullException.ThrowIfNull(dataManager);
_pluginInterface = pluginInterface;
_chatGui = chatGui;
_gameGui = gameGui;
@ -89,7 +91,8 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState, _gcRewardsCache, _configWindow, _iconCache);
_windowSystem.AddWindow(_turnInWindow);
_sealCaps = dataManager.GetExcelSheet<GrandCompanyRank>()!.Where(x => x.RowId > 0)
.ToDictionary(x => x.RowId, x => x.MaxSeals);
.ToDictionary(x => x.RowId, x => x.MaxSeals)
.AsReadOnly();
_framework.Update += FrameworkUpdate;
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
@ -160,7 +163,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
if (CharacterConfiguration is { IgnoreMinimumSealsToKeep: true })
return 0;
return _configuration.ReserveDifferentSealCountAtMaxRank && GetSealCap() == GetMaxSealCap()
return _configuration.ReserveDifferentSealCountAtMaxRank && GetSealCap() == MaxSealCap
? _configuration.ReservedSealCountAtMaxRank
: _configuration.ReservedSealCount;
}

View File

@ -5,9 +5,9 @@ using Dalamud.Plugin.Ipc.Exceptions;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
namespace ARControl.External;
namespace Deliveroo.External;
public class AllaganToolsIpc
internal sealed class AllaganToolsIpc
{
private readonly IPluginLog _pluginLog;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using ARControl.External;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

View File

@ -1,4 +1,6 @@
using System;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
using Dalamud.Game.Text;
using Dalamud.Plugin.Services;
@ -15,19 +17,19 @@ internal sealed class GameStrings
{
UndertakeSupplyAndProvisioningMission =
dataManager.GetString<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog)
?? throw new Exception($"Unable to resolve {nameof(UndertakeSupplyAndProvisioningMission)}");
?? throw new ConstraintException($"Unable to resolve {nameof(UndertakeSupplyAndProvisioningMission)}");
ClosePersonnelOfficerTalk =
dataManager.GetString<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog)
?? throw new Exception($"Unable to resolve {nameof(ClosePersonnelOfficerTalk)}");
?? throw new ConstraintException($"Unable to resolve {nameof(ClosePersonnelOfficerTalk)}");
ExchangeItems = dataManager.GetRegex<Addon>(3290, addon => addon.Text, pluginLog)
?? throw new Exception($"Unable to resolve {nameof(ExchangeItems)}");
?? throw new ConstraintException($"Unable to resolve {nameof(ExchangeItems)}");
TradeHighQualityItem =
dataManager.GetString<Addon>(102434, addon => addon.Text, pluginLog)?.ReplaceLineEndings("")
?? throw new Exception($"Unable to resolve {nameof(TradeHighQualityItem)}");
?? throw new ConstraintException($"Unable to resolve {nameof(TradeHighQualityItem)}");
var rankUpFc = dataManager.GetExcelSheet<LogMessage>()!.GetRow(3123)!;
RankUpFc = rankUpFc.GetRegex(logMessage => logMessage.Text, pluginLog)
?? throw new Exception($"Unable to resolve {nameof(RankUpFc)}");
?? throw new ConstraintException($"Unable to resolve {nameof(RankUpFc)}");
RankUpFcType = (XivChatType)rankUpFc.LogKind;
}
@ -40,7 +42,8 @@ internal sealed class GameStrings
public XivChatType RankUpFcType { get; }
[Sheet("custom/000/ComDefGrandCompanyOfficer_00073")]
private class ComDefGrandCompanyOfficer : QuestDialogueText
[SuppressMessage("Performance", "CA1812")]
private sealed class ComDefGrandCompanyOfficer : QuestDialogueText
{
}
}

View File

@ -4,7 +4,7 @@ using Lumina.Excel.GeneratedSheets;
namespace Deliveroo.GameData;
internal class ItemCache
internal sealed class ItemCache
{
private readonly Dictionary<string, HashSet<uint>> _itemNamesToIds = new();

View File

@ -12,10 +12,11 @@ using Dalamud.Plugin.Services;
using Deliveroo.GameData;
using ImGuiNET;
using LLib;
using LLib.ImGui;
namespace Deliveroo.Windows;
internal sealed class ConfigWindow : LImGui.LWindow
internal sealed class ConfigWindow : LWindow
{
private readonly DalamudPluginInterface _pluginInterface;
private readonly DeliverooPlugin _plugin;
@ -160,7 +161,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
bool addFirst = ImGui.InputTextWithHint("", "Filter...", ref _searchString, 256,
ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.EnterReturnsTrue);
foreach (var item in comboValues.Where(x => x.Name.ToLower().Contains(_searchString.ToLower())))
foreach (var item in comboValues.Where(x => x.Name.Contains(_searchString, StringComparison.OrdinalIgnoreCase)))
{
IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId);
if (icon != null)
@ -314,7 +315,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
if (ImGui.InputInt("Minimum Seals to keep (e.g. for Squadron Missions)", ref reservedSealCount, 1000))
{
_configuration.ReservedSealCount =
Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCount));
Math.Max(0, Math.Min((int)_plugin.MaxSealCap, reservedSealCount));
Save();
}
@ -334,7 +335,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
if (ImGui.InputInt("Minimum seals to keep at max rank", ref reservedSealCountAtMaxRank))
{
_configuration.ReservedSealCountAtMaxRank = Math.Max(0,
Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCountAtMaxRank));
Math.Min((int)_plugin.MaxSealCap, reservedSealCountAtMaxRank));
Save();
}

View File

@ -15,10 +15,11 @@ using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET;
using LLib;
using LLib.ImGui;
namespace Deliveroo.Windows;
internal sealed class TurnInWindow : LImGui.LWindow
internal sealed class TurnInWindow : LWindow
{
private static readonly IReadOnlyList<InventoryType> InventoryTypes = new[]
{
@ -224,13 +225,15 @@ internal sealed class TurnInWindow : LImGui.LWindow
if (Multiplier <= 1.10m)
{
InventoryManager* inventoryManager = InventoryManager.Instance();
AgentInventoryContext* agentInventoryContext = AgentInventoryContext.Instance();
if (inventoryManager->GetInventoryItemCount(ItemIds.PrioritySealAllowance) > 0)
{
ImGui.BeginDisabled(_condition[ConditionFlag.OccupiedInQuestEvent] ||
_condition[ConditionFlag.Casting]);
_condition[ConditionFlag.Casting] ||
agentInventoryContext == null);
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Bolt, "Use Priority Seal Allowance (15%)"))
{
AgentInventoryContext.Instance()->UseItem(ItemIds.PrioritySealAllowance);
agentInventoryContext->UseItem(ItemIds.PrioritySealAllowance);
}
ImGui.EndDisabled();

View File

@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",

2
LLib

@ -1 +1 @@
Subproject commit 865a6080319f8ccbcd5fd5b0004404822b6e60d4
Subproject commit 3792244261a9f5426a7916f5a6dd1966238ba84a

View File

@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.0",
"version": "8.0.0",
"rollForward": "latestMinor",
"allowPrerelease": false
}