diff --git a/ARControl/ARControl.csproj b/ARControl/ARControl.csproj index aae7b14..030bb84 100644 --- a/ARControl/ARControl.csproj +++ b/ARControl/ARControl.csproj @@ -1,7 +1,7 @@ net7.0-windows - 3.0 + 3.1 11.0 enable true diff --git a/ARControl/AutoRetainerControlPlugin.cs b/ARControl/AutoRetainerControlPlugin.cs index d227acf..413be3d 100644 --- a/ARControl/AutoRetainerControlPlugin.cs +++ b/ARControl/AutoRetainerControlPlugin.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using ARControl.External; using ARControl.GameData; using ARControl.Windows; using AutoRetainerAPI; @@ -53,9 +54,10 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin _gameCache = new GameCache(dataManager); _iconCache = new IconCache(textureProvider); _ventureResolver = new VentureResolver(_gameCache, _pluginLog); + DiscardHelperIpc discardHelperIpc = new(_pluginInterface); _configWindow = new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _iconCache, - _pluginLog); + discardHelperIpc, _pluginLog); _windowSystem.AddWindow(_configWindow); ECommonsMain.Init(_pluginInterface, this); @@ -115,11 +117,13 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin if (ch.Ventures == 0) { - _pluginLog.Warning("Could not assign a next venture from venture list, as the character has no ventures left."); + _pluginLog.Warning( + "Could not assign a next venture from venture list, as the character has no ventures left."); } else if (ch.Ventures <= _configuration.Misc.VenturesToKeep) { - _pluginLog.Warning($"Could not assign a next venture from venture list, character only has {ch.Ventures} left, configuration says to only send out above {_configuration.Misc.VenturesToKeep} ventures."); + _pluginLog.Warning( + $"Could not assign a next venture from venture list, character only has {ch.Ventures} left, configuration says to only send out above {_configuration.Misc.VenturesToKeep} ventures."); } else { diff --git a/ARControl/External/DiscardHelperIpc.cs b/ARControl/External/DiscardHelperIpc.cs new file mode 100644 index 0000000..7b67856 --- /dev/null +++ b/ARControl/External/DiscardHelperIpc.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using Dalamud.Plugin; +using Dalamud.Plugin.Ipc; +using Dalamud.Plugin.Ipc.Exceptions; + +namespace ARControl.External; + +internal sealed class DiscardHelperIpc +{ + private readonly ICallGateSubscriber> _itemsToDiscard; + + public DiscardHelperIpc(DalamudPluginInterface pluginInterface) + { + _itemsToDiscard = pluginInterface.GetIpcSubscriber>("ARDiscard.GetItemsToDiscard"); + } + + public IReadOnlySet GetItemsToDiscard() + { + try + { + return _itemsToDiscard.InvokeFunc(); + } + catch (IpcError) + { + // ignore + return ImmutableHashSet.Empty; + } + } +} diff --git a/ARControl/Windows/ConfigWindow.cs b/ARControl/Windows/ConfigWindow.cs index 60dc13e..0cd5b84 100644 --- a/ARControl/Windows/ConfigWindow.cs +++ b/ARControl/Windows/ConfigWindow.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; +using ARControl.External; using ARControl.GameData; using Dalamud.Game.Text; using Dalamud.Interface; @@ -34,6 +36,7 @@ internal sealed class ConfigWindow : LImGui.LWindow private static readonly Regex CountAndName = new(@"^(\d{1,5})x?\s+(.*)$", RegexOptions.Compiled); private static readonly string CurrentCharPrefix = FontAwesomeIcon.Male.ToIconString(); + private static readonly string DiscardWarningPrefix = FontAwesomeIcon.ExclamationCircle.ToIconString(); private readonly DalamudPluginInterface _pluginInterface; private readonly Configuration _configuration; @@ -41,6 +44,7 @@ internal sealed class ConfigWindow : LImGui.LWindow private readonly IClientState _clientState; private readonly ICommandManager _commandManager; private readonly IconCache _iconCache; + private readonly DiscardHelperIpc _discardHelperIpc; private readonly IPluginLog _pluginLog; private readonly Dictionary _currentEditPopups = new(); @@ -61,6 +65,7 @@ internal sealed class ConfigWindow : LImGui.LWindow IClientState clientState, ICommandManager commandManager, IconCache iconCache, + DiscardHelperIpc discardHelperIpc, IPluginLog pluginLog) : base($"ARC {SeIconChar.Collectible.ToIconString()}###ARControlConfig") { @@ -70,6 +75,7 @@ internal sealed class ConfigWindow : LImGui.LWindow _clientState = clientState; _commandManager = commandManager; _iconCache = iconCache; + _discardHelperIpc = discardHelperIpc; _pluginLog = pluginLog; SizeConstraints = new() @@ -97,6 +103,7 @@ internal sealed class ConfigWindow : LImGui.LWindow if (ImGui.BeginTabItem("Venture Lists")) { Configuration.ItemList? listToDelete = null; + IReadOnlySet itemsToDiscard = _discardHelperIpc.GetItemsToDiscard(); foreach (var list in _configuration.ItemLists) { ImGui.PushID($"List{list.Id}"); @@ -121,7 +128,7 @@ internal sealed class ConfigWindow : LImGui.LWindow if (ImGui.CollapsingHeader(label)) { ImGui.Indent(30); - DrawVentureListItemSelection(list); + DrawVentureListItemSelection(list, itemsToDiscard); ImGui.Unindent(30); } @@ -272,7 +279,7 @@ internal sealed class ConfigWindow : LImGui.LWindow return (save, canSave); } - private void DrawVentureListItemSelection(Configuration.ItemList list) + private void DrawVentureListItemSelection(Configuration.ItemList list, IReadOnlySet itemsToDiscard) { ImGuiEx.SetNextItemFullWidth(); if (ImGui.BeginCombo($"##VentureSelection{list.Id}", "Add Venture...", ImGuiComboFlags.HeightLarge)) @@ -353,6 +360,19 @@ internal sealed class ConfigWindow : LImGui.LWindow var ventures = _gameCache.Ventures.Where(x => x.ItemId == item.ItemId).ToList(); var venture = ventures.First(); + if (itemsToDiscard.Contains(venture.ItemId)) + { + ImGui.PushFont(UiBuilder.IconFont); + var pos = ImGui.GetCursorPos(); + ImGui.SetCursorPos(new Vector2(pos.X - ImGui.CalcTextSize(DiscardWarningPrefix).X - 5, pos.Y + 2)); + ImGui.TextColored(ImGuiColors.DalamudYellow, DiscardWarningPrefix); + ImGui.SetCursorPos(pos); + ImGui.PopFont(); + + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("This item will be automatically discarded by 'Discard Helper'."); + } + IDalamudTextureWrap? icon = _iconCache.GetIcon(venture.IconId); if (icon != null) { @@ -984,11 +1004,10 @@ internal sealed class ConfigWindow : LImGui.LWindow if (currentCharacter) { ImGui.PushFont(UiBuilder.IconFont); - float x = ImGui.GetCursorPosX(); - ImGui.SetCursorPosX(x - ImGui.CalcTextSize(CurrentCharPrefix).X - 5); + var pos = ImGui.GetCursorPos(); + ImGui.SetCursorPos(pos with { X = pos.X - ImGui.CalcTextSize(CurrentCharPrefix).X - 5 }); ImGui.TextUnformatted(CurrentCharPrefix); - ImGui.SetCursorPosX(x); - ImGui.SameLine(0, 5); + ImGui.SetCursorPos(pos); ImGui.PopFont(); }