Add chat feedback for adding/removing items via context menu

master
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">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Version>3.0</Version>
<Version>3.1</Version>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -83,7 +83,7 @@ public class AutoDiscardPlogon : IDalamudPlugin
ECommonsMain.Init(_pluginInterface, this);
_autoRetainerApi = new();
_taskManager = new();
_contextMenuIntegration = new(_pluginInterface, _configuration, _configWindow);
_contextMenuIntegration = new(_pluginInterface, _chatGui, itemCache, _configuration, _configWindow);
_clientState.Login += _discardWindow.Login;
_clientState.Logout += _discardWindow.Logout;

View File

@ -7,20 +7,26 @@ using Dalamud.ContextMenu;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
namespace ARDiscard;
internal sealed class ContextMenuIntegration : IDisposable
{
private readonly IChatGui _chatGui;
private readonly ItemCache _itemCache;
private readonly Configuration _configuration;
private readonly ConfigWindow _configWindow;
private readonly InventoryContextMenuItem _addItem;
private readonly InventoryContextMenuItem _removeItem;
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;
_configWindow = configWindow;
_addItem = new InventoryContextMenuItem(
@ -71,12 +77,24 @@ internal sealed class ContextMenuIntegration : IDisposable
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)
{
_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()