1
0
forked from liza/ARDiscard

Add chat feedback for adding/removing items via context menu

This commit is contained in:
Liza 2023-10-11 10:06:07 +02:00
parent 0bfa666099
commit b0b430795d
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 23 additions and 5 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>3.0</Version> <Version>3.1</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -83,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(_pluginInterface, _configuration, _configWindow); _contextMenuIntegration = new(_pluginInterface, _chatGui, itemCache, _configuration, _configWindow);
_clientState.Login += _discardWindow.Login; _clientState.Login += _discardWindow.Login;
_clientState.Logout += _discardWindow.Logout; _clientState.Logout += _discardWindow.Logout;

View File

@ -7,20 +7,26 @@ 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 Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
namespace ARDiscard; namespace ARDiscard;
internal sealed class ContextMenuIntegration : IDisposable internal sealed class ContextMenuIntegration : IDisposable
{ {
private readonly IChatGui _chatGui;
private readonly ItemCache _itemCache;
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly ConfigWindow _configWindow; private readonly ConfigWindow _configWindow;
private readonly InventoryContextMenuItem _addItem; private readonly InventoryContextMenuItem _addItem;
private readonly InventoryContextMenuItem _removeItem; private readonly InventoryContextMenuItem _removeItem;
private readonly DalamudContextMenu _dalamudContextMenu; private readonly DalamudContextMenu _dalamudContextMenu;
public ContextMenuIntegration(DalamudPluginInterface pluginInterface, Configuration configuration, ConfigWindow configWindow) public ContextMenuIntegration(DalamudPluginInterface pluginInterface, IChatGui chatGui, ItemCache itemCache,
Configuration configuration, ConfigWindow configWindow)
{ {
_chatGui = chatGui;
_itemCache = itemCache;
_configuration = configuration; _configuration = configuration;
_configWindow = configWindow; _configWindow = configWindow;
_addItem = new InventoryContextMenuItem( _addItem = new InventoryContextMenuItem(
@ -71,12 +77,24 @@ internal sealed class ContextMenuIntegration : IDisposable
private void AddToDiscardList(InventoryContextMenuItemSelectedArgs args) private void AddToDiscardList(InventoryContextMenuItemSelectedArgs args)
{ {
_configWindow.AddToDiscardList(args.ItemId); if (_configWindow.AddToDiscardList(args.ItemId))
{
_chatGui.Print(new SeString(new UIForegroundPayload(52))
.Append($"\ue05f ")
.Append(new UIForegroundPayload(0))
.Append($"Added '{_itemCache.GetItemName(args.ItemId)}' to Auto Discard List."));
}
} }
private void RemoveFromDiscardList(InventoryContextMenuItemSelectedArgs args) private void RemoveFromDiscardList(InventoryContextMenuItemSelectedArgs args)
{ {
_configWindow.RemoveFromDiscardList(args.ItemId); if (_configWindow.RemoveFromDiscardList(args.ItemId))
{
_chatGui.Print(new SeString(new UIForegroundPayload(52))
.Append($"\ue05f ")
.Append(new UIForegroundPayload(0))
.Append($"Removed '{_itemCache.GetItemName(args.ItemId)}' from Auto Discard List."));
}
} }
public void Dispose() public void Dispose()