forked from liza/ARControl
Show warning icon for icons that are on auto-discard list
This commit is contained in:
parent
a722f6a303
commit
37e9f29d41
@ -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>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using ARControl.External;
|
||||||
using ARControl.GameData;
|
using ARControl.GameData;
|
||||||
using ARControl.Windows;
|
using ARControl.Windows;
|
||||||
using AutoRetainerAPI;
|
using AutoRetainerAPI;
|
||||||
@ -53,9 +54,10 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
|
|||||||
_gameCache = new GameCache(dataManager);
|
_gameCache = new GameCache(dataManager);
|
||||||
_iconCache = new IconCache(textureProvider);
|
_iconCache = new IconCache(textureProvider);
|
||||||
_ventureResolver = new VentureResolver(_gameCache, _pluginLog);
|
_ventureResolver = new VentureResolver(_gameCache, _pluginLog);
|
||||||
|
DiscardHelperIpc discardHelperIpc = new(_pluginInterface);
|
||||||
_configWindow =
|
_configWindow =
|
||||||
new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _iconCache,
|
new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _iconCache,
|
||||||
_pluginLog);
|
discardHelperIpc, _pluginLog);
|
||||||
_windowSystem.AddWindow(_configWindow);
|
_windowSystem.AddWindow(_configWindow);
|
||||||
|
|
||||||
ECommonsMain.Init(_pluginInterface, this);
|
ECommonsMain.Init(_pluginInterface, this);
|
||||||
@ -115,11 +117,13 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
if (ch.Ventures == 0)
|
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)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
30
ARControl/External/DiscardHelperIpc.cs
vendored
Normal file
30
ARControl/External/DiscardHelperIpc.cs
vendored
Normal file
@ -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<IReadOnlySet<uint>> _itemsToDiscard;
|
||||||
|
|
||||||
|
public DiscardHelperIpc(DalamudPluginInterface pluginInterface)
|
||||||
|
{
|
||||||
|
_itemsToDiscard = pluginInterface.GetIpcSubscriber<IReadOnlySet<uint>>("ARDiscard.GetItemsToDiscard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IReadOnlySet<uint> GetItemsToDiscard()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _itemsToDiscard.InvokeFunc();
|
||||||
|
}
|
||||||
|
catch (IpcError)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
return ImmutableHashSet<uint>.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using ARControl.External;
|
||||||
using ARControl.GameData;
|
using ARControl.GameData;
|
||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
using Dalamud.Interface;
|
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 Regex CountAndName = new(@"^(\d{1,5})x?\s+(.*)$", RegexOptions.Compiled);
|
||||||
private static readonly string CurrentCharPrefix = FontAwesomeIcon.Male.ToIconString();
|
private static readonly string CurrentCharPrefix = FontAwesomeIcon.Male.ToIconString();
|
||||||
|
private static readonly string DiscardWarningPrefix = FontAwesomeIcon.ExclamationCircle.ToIconString();
|
||||||
|
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
@ -41,6 +44,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
private readonly IClientState _clientState;
|
private readonly IClientState _clientState;
|
||||||
private readonly ICommandManager _commandManager;
|
private readonly ICommandManager _commandManager;
|
||||||
private readonly IconCache _iconCache;
|
private readonly IconCache _iconCache;
|
||||||
|
private readonly DiscardHelperIpc _discardHelperIpc;
|
||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
|
|
||||||
private readonly Dictionary<Guid, TemporaryConfig> _currentEditPopups = new();
|
private readonly Dictionary<Guid, TemporaryConfig> _currentEditPopups = new();
|
||||||
@ -61,6 +65,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
IClientState clientState,
|
IClientState clientState,
|
||||||
ICommandManager commandManager,
|
ICommandManager commandManager,
|
||||||
IconCache iconCache,
|
IconCache iconCache,
|
||||||
|
DiscardHelperIpc discardHelperIpc,
|
||||||
IPluginLog pluginLog)
|
IPluginLog pluginLog)
|
||||||
: base($"ARC {SeIconChar.Collectible.ToIconString()}###ARControlConfig")
|
: base($"ARC {SeIconChar.Collectible.ToIconString()}###ARControlConfig")
|
||||||
{
|
{
|
||||||
@ -70,6 +75,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
_commandManager = commandManager;
|
_commandManager = commandManager;
|
||||||
_iconCache = iconCache;
|
_iconCache = iconCache;
|
||||||
|
_discardHelperIpc = discardHelperIpc;
|
||||||
_pluginLog = pluginLog;
|
_pluginLog = pluginLog;
|
||||||
|
|
||||||
SizeConstraints = new()
|
SizeConstraints = new()
|
||||||
@ -97,6 +103,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
if (ImGui.BeginTabItem("Venture Lists"))
|
if (ImGui.BeginTabItem("Venture Lists"))
|
||||||
{
|
{
|
||||||
Configuration.ItemList? listToDelete = null;
|
Configuration.ItemList? listToDelete = null;
|
||||||
|
IReadOnlySet<uint> itemsToDiscard = _discardHelperIpc.GetItemsToDiscard();
|
||||||
foreach (var list in _configuration.ItemLists)
|
foreach (var list in _configuration.ItemLists)
|
||||||
{
|
{
|
||||||
ImGui.PushID($"List{list.Id}");
|
ImGui.PushID($"List{list.Id}");
|
||||||
@ -121,7 +128,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
if (ImGui.CollapsingHeader(label))
|
if (ImGui.CollapsingHeader(label))
|
||||||
{
|
{
|
||||||
ImGui.Indent(30);
|
ImGui.Indent(30);
|
||||||
DrawVentureListItemSelection(list);
|
DrawVentureListItemSelection(list, itemsToDiscard);
|
||||||
ImGui.Unindent(30);
|
ImGui.Unindent(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +279,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
return (save, canSave);
|
return (save, canSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawVentureListItemSelection(Configuration.ItemList list)
|
private void DrawVentureListItemSelection(Configuration.ItemList list, IReadOnlySet<uint> itemsToDiscard)
|
||||||
{
|
{
|
||||||
ImGuiEx.SetNextItemFullWidth();
|
ImGuiEx.SetNextItemFullWidth();
|
||||||
if (ImGui.BeginCombo($"##VentureSelection{list.Id}", "Add Venture...", ImGuiComboFlags.HeightLarge))
|
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 ventures = _gameCache.Ventures.Where(x => x.ItemId == item.ItemId).ToList();
|
||||||
var venture = ventures.First();
|
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);
|
IDalamudTextureWrap? icon = _iconCache.GetIcon(venture.IconId);
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
{
|
{
|
||||||
@ -984,11 +1004,10 @@ internal sealed class ConfigWindow : LImGui.LWindow
|
|||||||
if (currentCharacter)
|
if (currentCharacter)
|
||||||
{
|
{
|
||||||
ImGui.PushFont(UiBuilder.IconFont);
|
ImGui.PushFont(UiBuilder.IconFont);
|
||||||
float x = ImGui.GetCursorPosX();
|
var pos = ImGui.GetCursorPos();
|
||||||
ImGui.SetCursorPosX(x - ImGui.CalcTextSize(CurrentCharPrefix).X - 5);
|
ImGui.SetCursorPos(pos with { X = pos.X - ImGui.CalcTextSize(CurrentCharPrefix).X - 5 });
|
||||||
ImGui.TextUnformatted(CurrentCharPrefix);
|
ImGui.TextUnformatted(CurrentCharPrefix);
|
||||||
ImGui.SetCursorPosX(x);
|
ImGui.SetCursorPos(pos);
|
||||||
ImGui.SameLine(0, 5);
|
|
||||||
ImGui.PopFont();
|
ImGui.PopFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user