master v3.0
Liza 2023-10-04 10:37:09 +02:00
parent 1ffeb4ae14
commit 33f3639ea9
Signed by: liza
GPG Key ID: 7199F8D727D55F67
8 changed files with 65 additions and 82 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Version>2.5</Version> <Version>3.0</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
@ -17,7 +17,7 @@
<PropertyGroup> <PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath> <DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.1.2.3\</AutoRetainerLibPath> <AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.2.0.2\</AutoRetainerLibPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'"> <PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
@ -25,8 +25,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dalamud.ContextMenu" Version="1.2.3"/> <PackageReference Include="Dalamud.ContextMenu" Version="1.3.1" />
<PackageReference Include="DalamudPackager" Version="2.1.11"/> <PackageReference Include="DalamudPackager" Version="2.1.12"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -38,10 +38,6 @@
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath> <HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina"> <Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath> <HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>false</Private> <Private>false</Private>
@ -58,10 +54,6 @@
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath> <HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="AutoRetainerAPI"> <Reference Include="AutoRetainerAPI">
<HintPath>$(AutoRetainerLibPath)AutoRetainerAPI.dll</HintPath> <HintPath>$(AutoRetainerLibPath)AutoRetainerAPI.dll</HintPath>
</Reference> </Reference>

View File

@ -5,18 +5,13 @@ using ARDiscard.GameData;
using ARDiscard.Windows; using ARDiscard.Windows;
using AutoRetainerAPI; using AutoRetainerAPI;
using ClickLib.Clicks; using ClickLib.Clicks;
using Dalamud.Data;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Memory; using Dalamud.Memory;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ECommons; using ECommons;
using ECommons.Automation; using ECommons.Automation;
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
@ -32,9 +27,11 @@ public class AutoDiscardPlogon : IDalamudPlugin
private readonly DiscardWindow _discardWindow; private readonly DiscardWindow _discardWindow;
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly ChatGui _chatGui; private readonly IChatGui _chatGui;
private readonly ClientState _clientState; private readonly IClientState _clientState;
private readonly CommandManager _commandManager; private readonly IPluginLog _pluginLog;
private readonly IGameGui _gameGui;
private readonly ICommandManager _commandManager;
private readonly InventoryUtils _inventoryUtils; private readonly InventoryUtils _inventoryUtils;
private readonly AutoRetainerApi _autoRetainerApi; private readonly AutoRetainerApi _autoRetainerApi;
private readonly TaskManager _taskManager; private readonly TaskManager _taskManager;
@ -42,8 +39,8 @@ public class AutoDiscardPlogon : IDalamudPlugin
private DateTime _cancelDiscardAfter = DateTime.MaxValue; private DateTime _cancelDiscardAfter = DateTime.MaxValue;
public AutoDiscardPlogon(DalamudPluginInterface pluginInterface, CommandManager commandManager, ChatGui chatGui, public AutoDiscardPlogon(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IChatGui chatGui,
DataManager dataManager, ClientState clientState, Condition condition) IDataManager dataManager, IClientState clientState, ICondition condition, IPluginLog pluginLog, IGameGui gameGui)
{ {
ItemCache itemCache = new ItemCache(dataManager); ItemCache itemCache = new ItemCache(dataManager);
@ -51,6 +48,8 @@ public class AutoDiscardPlogon : IDalamudPlugin
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration(); _configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
_chatGui = chatGui; _chatGui = chatGui;
_clientState = clientState; _clientState = clientState;
_pluginLog = pluginLog;
_gameGui = gameGui;
_commandManager = commandManager; _commandManager = commandManager;
_commandManager.AddHandler("/discardconfig", new CommandInfo(OpenConfig) _commandManager.AddHandler("/discardconfig", new CommandInfo(OpenConfig)
{ {
@ -64,7 +63,7 @@ public class AutoDiscardPlogon : IDalamudPlugin
{ {
HelpMessage = "Show what will be discarded with your current configuration", HelpMessage = "Show what will be discarded with your current configuration",
}); });
_inventoryUtils = new InventoryUtils(_configuration, itemCache); _inventoryUtils = new InventoryUtils(_configuration, itemCache, _pluginLog);
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw; _pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
_pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi; _pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
@ -84,7 +83,7 @@ public class AutoDiscardPlogon : IDalamudPlugin
ECommonsMain.Init(_pluginInterface, this); ECommonsMain.Init(_pluginInterface, this);
_autoRetainerApi = new(); _autoRetainerApi = new();
_taskManager = new(); _taskManager = new();
_contextMenuIntegration = new(_configuration, _configWindow); _contextMenuIntegration = new(_pluginInterface, _configuration, _configWindow);
_clientState.Login += _discardWindow.Login; _clientState.Login += _discardWindow.Login;
_clientState.Logout += _discardWindow.Logout; _clientState.Logout += _discardWindow.Logout;
@ -94,8 +93,6 @@ public class AutoDiscardPlogon : IDalamudPlugin
_autoRetainerApi.OnCharacterReadyToPostProcess += DoCharacterPostProcess; _autoRetainerApi.OnCharacterReadyToPostProcess += DoCharacterPostProcess;
} }
public string Name => "Discard after AutoRetainer";
private void CheckRetainerPostProcess(string retainerName) => private void CheckRetainerPostProcess(string retainerName) =>
CheckPostProcessInternal(PostProcessType.Retainer, retainerName, _configuration.RunAfterVenture); CheckPostProcessInternal(PostProcessType.Retainer, retainerName, _configuration.RunAfterVenture);
@ -106,19 +103,19 @@ public class AutoDiscardPlogon : IDalamudPlugin
{ {
if (!enabled) if (!enabled)
{ {
PluginLog.Information($"Not running post-venture tasks for {name}, disabled globally"); _pluginLog.Information($"Not running post-venture tasks for {name}, disabled globally");
} }
else if (_configuration.ExcludedCharacters.Any(x => x.LocalContentId == _clientState.LocalContentId)) else if (_configuration.ExcludedCharacters.Any(x => x.LocalContentId == _clientState.LocalContentId))
{ {
PluginLog.Information($"Not running post-venture tasks for {name}, disabled for current character"); _pluginLog.Information($"Not running post-venture tasks for {name}, disabled for current character");
} }
else if (_inventoryUtils.GetNextItemToDiscard(ItemFilter.None) == null) else if (_inventoryUtils.GetNextItemToDiscard(ItemFilter.None) == null)
{ {
PluginLog.Information($"Not running post-venture tasks for {name}, no items to discard"); _pluginLog.Information($"Not running post-venture tasks for {name}, no items to discard");
} }
else else
{ {
PluginLog.Information($"Requesting post-processing for {name}"); _pluginLog.Information($"Requesting post-processing for {name}");
if (type == PostProcessType.Retainer) if (type == PostProcessType.Retainer)
_autoRetainerApi.RequestRetainerPostprocess(); _autoRetainerApi.RequestRetainerPostprocess();
else if (type == PostProcessType.Character) else if (type == PostProcessType.Character)
@ -155,20 +152,20 @@ public class AutoDiscardPlogon : IDalamudPlugin
private unsafe void DiscardNextItem(PostProcessType type, ItemFilter? itemFilter) private unsafe void DiscardNextItem(PostProcessType type, ItemFilter? itemFilter)
{ {
PluginLog.Information($"DiscardNextItem (type = {type})"); _pluginLog.Information($"DiscardNextItem (type = {type})");
_discardWindow.Locked = true; _discardWindow.Locked = true;
InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter); InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter);
if (nextItem == null) if (nextItem == null)
{ {
PluginLog.Information($"No item to discard found"); _pluginLog.Information($"No item to discard found");
FinishDiscarding(type); FinishDiscarding(type);
} }
else else
{ {
var (inventoryType, slot) = (nextItem->Container, nextItem->Slot); var (inventoryType, slot) = (nextItem->Container, nextItem->Slot);
PluginLog.Information( _pluginLog.Information(
$"Discarding itemId {nextItem->ItemID} in slot {nextItem->Slot} of container {nextItem->Container}."); $"Discarding itemId {nextItem->ItemID} in slot {nextItem->Slot} of container {nextItem->Container}.");
_inventoryUtils.Discard(nextItem); _inventoryUtils.Discard(nextItem);
_cancelDiscardAfter = DateTime.Now.AddSeconds(15); _cancelDiscardAfter = DateTime.Now.AddSeconds(15);
@ -184,7 +181,7 @@ public class AutoDiscardPlogon : IDalamudPlugin
var addon = GetDiscardAddon(); var addon = GetDiscardAddon();
if (addon != null) if (addon != null)
{ {
PluginLog.Information("Addon is visible, clicking 'yes'"); _pluginLog.Information("Addon is visible, clicking 'yes'");
((AddonSelectYesno*)addon)->YesButton->AtkComponentBase.SetEnabledState(true); ((AddonSelectYesno*)addon)->YesButton->AtkComponentBase.SetEnabledState(true);
ClickSelectYesNo.Using((nint)addon).Yes(); ClickSelectYesNo.Using((nint)addon).Yes();
@ -196,19 +193,19 @@ public class AutoDiscardPlogon : IDalamudPlugin
InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter); InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter);
if (nextItem == null) if (nextItem == null)
{ {
PluginLog.Information("Addon is not visible, but next item is also no longer set"); _pluginLog.Information("Addon is not visible, but next item is also no longer set");
FinishDiscarding(type); FinishDiscarding(type);
} }
else if (nextItem->Container == inventoryType && nextItem->Slot == slot) else if (nextItem->Container == inventoryType && nextItem->Slot == slot)
{ {
PluginLog.Information( _pluginLog.Information(
$"Addon is not (yet) visible, still trying to discard item in slot {slot} in inventory {inventoryType}"); $"Addon is not (yet) visible, still trying to discard item in slot {slot} in inventory {inventoryType}");
_taskManager.DelayNext(100); _taskManager.DelayNext(100);
_taskManager.Enqueue(() => ConfirmDiscardItem(type, itemFilter, inventoryType, slot)); _taskManager.Enqueue(() => ConfirmDiscardItem(type, itemFilter, inventoryType, slot));
} }
else else
{ {
PluginLog.Information( _pluginLog.Information(
$"Addon is not (yet) visible, but slot or inventory type changed, retrying from start"); $"Addon is not (yet) visible, but slot or inventory type changed, retrying from start");
_taskManager.DelayNext(100); _taskManager.DelayNext(100);
_taskManager.Enqueue(() => DiscardNextItem(type, itemFilter)); _taskManager.Enqueue(() => DiscardNextItem(type, itemFilter));
@ -222,26 +219,26 @@ public class AutoDiscardPlogon : IDalamudPlugin
InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter); InventoryItem* nextItem = _inventoryUtils.GetNextItemToDiscard(itemFilter);
if (nextItem == null) if (nextItem == null)
{ {
PluginLog.Information($"Continuing after discard: no next item (type = {type})"); _pluginLog.Information($"Continuing after discard: no next item (type = {type})");
FinishDiscarding(type); FinishDiscarding(type);
} }
else if (nextItem->Container == inventoryType && nextItem->Slot == slot) else if (nextItem->Container == inventoryType && nextItem->Slot == slot)
{ {
if (_cancelDiscardAfter < DateTime.Now) if (_cancelDiscardAfter < DateTime.Now)
{ {
PluginLog.Information("No longer waiting for plugin to pop up, assume discard failed"); _pluginLog.Information("No longer waiting for plugin to pop up, assume discard failed");
FinishDiscarding(type, "Discarding probably failed due to an error."); FinishDiscarding(type, "Discarding probably failed due to an error.");
} }
else else
{ {
PluginLog.Information($"ContinueAfterDiscard: Waiting for server response until {_cancelDiscardAfter}"); _pluginLog.Information($"ContinueAfterDiscard: Waiting for server response until {_cancelDiscardAfter}");
_taskManager.DelayNext(20); _taskManager.DelayNext(20);
_taskManager.Enqueue(() => ContinueAfterDiscard(type, itemFilter, inventoryType, slot)); _taskManager.Enqueue(() => ContinueAfterDiscard(type, itemFilter, inventoryType, slot));
} }
} }
else else
{ {
PluginLog.Information($"ContinueAfterDiscard: Discovered different item to discard"); _pluginLog.Information($"ContinueAfterDiscard: Discovered different item to discard");
_taskManager.EnqueueImmediate(() => DiscardNextItem(type, itemFilter)); _taskManager.EnqueueImmediate(() => DiscardNextItem(type, itemFilter));
} }
} }
@ -284,19 +281,19 @@ public class AutoDiscardPlogon : IDalamudPlugin
_commandManager.RemoveHandler("/discardconfig"); _commandManager.RemoveHandler("/discardconfig");
} }
private static unsafe AtkUnitBase* GetDiscardAddon() private unsafe AtkUnitBase* GetDiscardAddon()
{ {
for (int i = 1; i < 100; i++) for (int i = 1; i < 100; i++)
{ {
try try
{ {
var addon = (AtkUnitBase*)Svc.GameGui.GetAddonByName("SelectYesno", i); var addon = (AtkUnitBase*)_gameGui.GetAddonByName("SelectYesno", i);
if (addon == null) return null; if (addon == null) return null;
if (addon->IsVisible && addon->UldManager.LoadedState == AtkLoadState.Loaded) if (addon->IsVisible && addon->UldManager.LoadedState == AtkLoadState.Loaded)
{ {
var textNode = addon->UldManager.NodeList[15]->GetAsAtkTextNode(); var textNode = addon->UldManager.NodeList[15]->GetAsAtkTextNode();
var text = MemoryHelper.ReadSeString(&textNode->NodeText).ExtractText(); var text = MemoryHelper.ReadSeString(&textNode->NodeText).ExtractText();
PluginLog.Information($"YesNo prompt: {text}"); _pluginLog.Information($"YesNo prompt: {text}");
if (text.StartsWith("Discard")) if (text.StartsWith("Discard"))
{ {
return addon; return addon;

View File

@ -6,6 +6,7 @@ using ARDiscard.Windows;
using Dalamud.ContextMenu; using Dalamud.ContextMenu;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
namespace ARDiscard; namespace ARDiscard;
@ -18,7 +19,7 @@ internal sealed class ContextMenuIntegration : IDisposable
private readonly InventoryContextMenuItem _removeItem; private readonly InventoryContextMenuItem _removeItem;
private readonly DalamudContextMenu _dalamudContextMenu; private readonly DalamudContextMenu _dalamudContextMenu;
public ContextMenuIntegration(Configuration configuration, ConfigWindow configWindow) public ContextMenuIntegration(DalamudPluginInterface pluginInterface, Configuration configuration, ConfigWindow configWindow)
{ {
_configuration = configuration; _configuration = configuration;
_configWindow = configWindow; _configWindow = configWindow;
@ -33,7 +34,7 @@ internal sealed class ContextMenuIntegration : IDisposable
.Append(new UIForegroundPayload(0)).Append("Remove from Auto Discard List"), .Append(new UIForegroundPayload(0)).Append("Remove from Auto Discard List"),
RemoveFromDiscardList); RemoveFromDiscardList);
_dalamudContextMenu = new(); _dalamudContextMenu = new(pluginInterface);
_dalamudContextMenu.OnOpenInventoryContextMenu += OpenInventoryContextMenu; _dalamudContextMenu.OnOpenInventoryContextMenu += OpenInventoryContextMenu;
} }

View File

@ -1,8 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Logging; using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Client.UI.Misc;
@ -38,18 +37,13 @@ internal sealed class InventoryUtils
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly ItemCache _itemCache; private readonly ItemCache _itemCache;
private readonly IPluginLog _pluginLog;
private unsafe delegate void DiscardItemDelegate(AgentInventoryContext* inventoryManager, InventoryItem* itemSlot, public InventoryUtils(Configuration configuration, ItemCache itemCache, IPluginLog pluginLog)
InventoryType inventory, int slot, uint addonId, int position = -1);
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 85 C0 74 ?? 0F B7 48")]
private DiscardItemDelegate _discardItem = null!;
public InventoryUtils(Configuration configuration, ItemCache itemCache)
{ {
_configuration = configuration; _configuration = configuration;
_itemCache = itemCache; _itemCache = itemCache;
SignatureHelper.Initialise(this); _pluginLog = pluginLog;
} }
public unsafe List<ItemWrapper> GetAllItemsToDiscard() public unsafe List<ItemWrapper> GetAllItemsToDiscard()
@ -129,7 +123,7 @@ internal sealed class InventoryUtils
//PluginLog.Verbose($"{i} → {item->ItemID}"); //PluginLog.Verbose($"{i} → {item->ItemID}");
if (_configuration.DiscardingItems.Contains(item->ItemID)) if (_configuration.DiscardingItems.Contains(item->ItemID))
{ {
PluginLog.Information( _pluginLog.Information(
$"Found item {item->ItemID} to discard in inventory {inventoryType} in slot {i}"); $"Found item {item->ItemID} to discard in inventory {inventoryType} in slot {i}");
toDiscard.Add(new ItemWrapper { InventoryItem = item }); toDiscard.Add(new ItemWrapper { InventoryItem = item });
} }
@ -168,7 +162,7 @@ internal sealed class InventoryUtils
gearset->Neck, gearset->Neck,
gearset->Wrists, gearset->Wrists,
gearset->RingRight, gearset->RingRight,
gearset->RightLeft, // why is this called RightLeft gearset->RingLeft,
}; };
foreach (var gearsetItem in gearsetItems) foreach (var gearsetItem in gearsetItems)
{ {
@ -186,7 +180,7 @@ internal sealed class InventoryUtils
if (InternalConfiguration.BlacklistedItems.Contains(item->ItemID)) if (InternalConfiguration.BlacklistedItems.Contains(item->ItemID))
throw new Exception($"Can't discard {item->ItemID}"); throw new Exception($"Can't discard {item->ItemID}");
_discardItem(AgentInventoryContext.Instance(), item, item->Container, item->Slot, 0); AgentInventoryContext.Instance()->DiscardItem(item, item->Container, item->Slot, 0);
} }
public sealed unsafe class ItemWrapper public sealed unsafe class ItemWrapper

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Data; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ARDiscard.GameData; namespace ARDiscard.GameData;
@ -8,7 +8,7 @@ internal sealed class ItemCache
{ {
private readonly Dictionary<uint, CachedItemInfo> _items = new(); private readonly Dictionary<uint, CachedItemInfo> _items = new();
public ItemCache(DataManager dataManager) public ItemCache(IDataManager dataManager)
{ {
foreach (var item in dataManager.GetExcelSheet<Item>()!) foreach (var item in dataManager.GetExcelSheet<Item>()!)
{ {

View File

@ -3,15 +3,14 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using ARDiscard.GameData; using ARDiscard.GameData;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ECommons; using ECommons;
using ImGuiNET; using ImGuiNET;
using Condition = Dalamud.Game.ClientState.Conditions.Condition;
namespace ARDiscard.Windows; namespace ARDiscard.Windows;
@ -20,8 +19,8 @@ internal sealed class ConfigWindow : Window
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly ItemCache _itemCache; private readonly ItemCache _itemCache;
private readonly ClientState _clientState; private readonly IClientState _clientState;
private readonly Condition _condition; private readonly ICondition _condition;
private string _itemName = string.Empty; private string _itemName = string.Empty;
private List<(uint ItemId, string Name)> _searchResults = new(); private List<(uint ItemId, string Name)> _searchResults = new();
@ -33,7 +32,7 @@ internal sealed class ConfigWindow : Window
public event EventHandler? ConfigSaved; public event EventHandler? ConfigSaved;
public ConfigWindow(DalamudPluginInterface pluginInterface, Configuration configuration, ItemCache itemCache, public ConfigWindow(DalamudPluginInterface pluginInterface, Configuration configuration, ItemCache itemCache,
ClientState clientState, Condition condition) IClientState clientState, ICondition condition)
: base("Auto Discard###AutoDiscardConfig") : base("Auto Discard###AutoDiscardConfig")
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;

View File

@ -2,10 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ARDiscard.GameData; using ARDiscard.GameData;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface; using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Common.Math; using FFXIVClientStructs.FFXIV.Common.Math;
using ImGuiNET; using ImGuiNET;
@ -15,16 +15,16 @@ internal sealed class DiscardWindow : Window
{ {
private readonly InventoryUtils _inventoryUtils; private readonly InventoryUtils _inventoryUtils;
private readonly ItemCache _itemCache; private readonly ItemCache _itemCache;
private readonly ClientState _clientState; private readonly IClientState _clientState;
private readonly Condition _condition; private readonly ICondition _condition;
private List<SelectableItem> _displayedItems = new(); private List<SelectableItem> _displayedItems = new();
public event EventHandler? OpenConfigurationClicked; public event EventHandler? OpenConfigurationClicked;
public event EventHandler<ItemFilter>? DiscardAllClicked; public event EventHandler<ItemFilter>? DiscardAllClicked;
public DiscardWindow(InventoryUtils inventoryUtils, ItemCache itemCache, ClientState clientState, public DiscardWindow(InventoryUtils inventoryUtils, ItemCache itemCache, IClientState clientState,
Condition condition) ICondition condition)
: base("Discard Items") : base("Discard Items")
{ {
_inventoryUtils = inventoryUtils; _inventoryUtils = inventoryUtils;
@ -140,7 +140,7 @@ internal sealed class DiscardWindow : Window
} }
} }
public void Login(object? sender, EventArgs e) => RefreshInventory(false); public void Login() => RefreshInventory(false);
public void Logout(object? sender, EventArgs e) => _displayedItems.Clear(); public void Logout() => _displayedItems.Clear();
} }

View File

@ -4,15 +4,15 @@
"net7.0-windows7.0": { "net7.0-windows7.0": {
"Dalamud.ContextMenu": { "Dalamud.ContextMenu": {
"type": "Direct", "type": "Direct",
"requested": "[1.2.3, )", "requested": "[1.3.1, )",
"resolved": "1.2.3", "resolved": "1.3.1",
"contentHash": "ydemplF7DNcA/LLeongDVzWUD/JV0Fw3EwA2+P0jYq3Le2ZYSt4U8qyJq4FyoChqt0lFG8BxYCAzfeWp4Jmnqw==" "contentHash": "ptAxut5PiLnzZ4G/KQdHJVcyklC/BF3otHJ7zYVUPiKBjsOCoF0n/6h2jK7e+8ev2Y1yAY3Wtx2GuXLFQgt9Uw=="
}, },
"DalamudPackager": { "DalamudPackager": {
"type": "Direct", "type": "Direct",
"requested": "[2.1.11, )", "requested": "[2.1.12, )",
"resolved": "2.1.11", "resolved": "2.1.12",
"contentHash": "9qlAWoRRTiL/geAvuwR/g6Bcbrd/bJJgVnB/RurBiyKs6srsP0bvpoo8IK+Eg8EA6jWeM6/YJWs66w4FIAzqPw==" "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
} }
} }
} }