(2.x) Improve chat feedback

pull/3/head
Liza 2023-10-11 10:38:26 +02:00
parent fe29867929
commit fbba9244a6
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 88 additions and 20 deletions

View File

@ -65,7 +65,6 @@
</ItemGroup> </ItemGroup>
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin"> <Target Name="RenameLatestZip" AfterTargets="PackagePlugin">
<Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/> <Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/>
</Target> </Target>

View File

@ -6,6 +6,9 @@ using ARControl.GameData;
using ARControl.Windows; using ARControl.Windows;
using AutoRetainerAPI; using AutoRetainerAPI;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin; using Dalamud.Plugin;
@ -51,7 +54,8 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
_iconCache = new IconCache(textureProvider); _iconCache = new IconCache(textureProvider);
_ventureResolver = new VentureResolver(_gameCache, _pluginLog); _ventureResolver = new VentureResolver(_gameCache, _pluginLog);
_configWindow = _configWindow =
new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _iconCache, _pluginLog) new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _iconCache,
_pluginLog)
{ IsOpen = true }; { IsOpen = true };
_windowSystem.AddWindow(_configWindow); _windowSystem.AddWindow(_configWindow);
@ -161,7 +165,9 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
{ {
QueuedItem = x, QueuedItem = x,
InventoryCount = inventoryManager->GetInventoryItemCount(x.ItemId) + InventoryCount = inventoryManager->GetInventoryItemCount(x.ItemId) +
(venturesInProgress.TryGetValue(x.ItemId, out int inProgress) ? inProgress : 0), (venturesInProgress.TryGetValue(x.ItemId, out int inProgress)
? inProgress
: 0),
}) })
.Where(x => x.InventoryCount <= x.RequestedCount) .Where(x => x.InventoryCount <= x.RequestedCount)
.ToList() .ToList()
@ -188,7 +194,25 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
else else
{ {
_chatGui.Print( _chatGui.Print(
$"[ARC] Sending retainer {retainerName} to collect {reward.Quantity}x {venture.Name}."); new SeString(new UIForegroundPayload(579))
.Append(SeIconChar.Collectible.ToIconString())
.Append(new UIForegroundPayload(0))
.Append($" Sending retainer ")
.Append(new UIForegroundPayload(1))
.Append(retainerName)
.Append(new UIForegroundPayload(0))
.Append(" to collect ")
.Append(new UIForegroundPayload(1))
.Append($"{reward.Quantity}x ")
.Append(new ItemPayload(venture.ItemId))
.Append(venture.Name)
.Append(RawPayload.LinkTerminator)
.Append(new UIForegroundPayload(0))
.Append(" for ")
.Append(new UIForegroundPayload(1))
.Append($"{list.Name} {list.GetIcon()}")
.Append(new UIForegroundPayload(0))
.Append("."));
_pluginLog.Information( _pluginLog.Information(
$"Setting AR to use venture {venture.RowId}, which should retrieve {reward.Quantity}x {venture.Name}"); $"Setting AR to use venture {venture.RowId}, which should retrieve {reward.Quantity}x {venture.Name}");
@ -209,13 +233,24 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
return venture.RowId; return venture.RowId;
} }
} }
} }
// fallback: managed but no venture found // fallback: managed but no venture found
if (retainer.LastVenture != QuickVentureId) if (retainer.LastVenture != QuickVentureId)
{ {
_chatGui.Print($"[ARC] No tasks left for retainer {retainerName}, sending to Quick Venture."); _chatGui.Print(
new SeString(new UIForegroundPayload(579))
.Append(SeIconChar.Collectible.ToIconString())
.Append(new UIForegroundPayload(0))
.Append($" No tasks left for retainer ")
.Append(new UIForegroundPayload(1))
.Append(retainerName)
.Append(new UIForegroundPayload(0))
.Append(", sending to ")
.Append(new UIForegroundPayload(1))
.Append("Quick Venture")
.Append(new UIForegroundPayload(0))
.Append("."));
_pluginLog.Information($"No tasks left (previous venture = {retainer.LastVenture}), using QC"); _pluginLog.Information($"No tasks left (previous venture = {retainer.LastVenture}), using QC");
if (!dryRun) if (!dryRun)
@ -318,7 +353,8 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
if (venture == QuickVentureId) if (venture == QuickVentureId)
_chatGui.Print($"Next venture for {retainerName} is Quick Venture."); _chatGui.Print($"Next venture for {retainerName} is Quick Venture.");
else if (venture.HasValue) else if (venture.HasValue)
_chatGui.Print($"Next venture for {retainerName} is {_gameCache.Ventures.First(x => x.RowId == venture.Value).Name}."); _chatGui.Print(
$"Next venture for {retainerName} is {_gameCache.Ventures.First(x => x.RowId == venture.Value).Name}.");
else else
_chatGui.Print($"Next venture for {retainerName} is (none)."); _chatGui.Print($"Next venture for {retainerName} is (none).");
} }
@ -345,6 +381,7 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
public required Configuration.QueuedItem QueuedItem { get; set; } public required Configuration.QueuedItem QueuedItem { get; set; }
public required int InventoryCount { get; set; } public required int InventoryCount { get; set; }
public uint ItemId => QueuedItem.ItemId; public uint ItemId => QueuedItem.ItemId;
public int RequestedCount public int RequestedCount
{ {
get => QueuedItem.RemainingQuantity; get => QueuedItem.RemainingQuantity;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using ARControl.GameData; using ARControl.GameData;
using Dalamud.Game.Text;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
@ -26,7 +27,9 @@ internal sealed class ConfigWindow : Window
private static readonly Vector4 ColorRed = ImGuiColors.DalamudRed; private static readonly Vector4 ColorRed = ImGuiColors.DalamudRed;
private static readonly Vector4 ColorGrey = ImGuiColors.DalamudGrey; private static readonly Vector4 ColorGrey = ImGuiColors.DalamudGrey;
private static readonly string[] StockingTypeLabels = { "Collect Once", "Keep in Stock" }; private static readonly string[] StockingTypeLabels = { "Collect Once", "Keep in Stock" };
private static readonly string[] PriorityLabels = { "Collect in order of the list", "Collect item with lowest inventory first" };
private static readonly string[] PriorityLabels =
{ "Collect in order of the list", "Collect item with lowest inventory first" };
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _configuration; private readonly Configuration _configuration;
@ -39,12 +42,14 @@ internal sealed class ConfigWindow : Window
private readonly Dictionary<Guid, TemporaryConfig> _currentEditPopups = new(); private readonly Dictionary<Guid, TemporaryConfig> _currentEditPopups = new();
private string _searchString = string.Empty; private string _searchString = string.Empty;
private TemporaryConfig _newGroup = new() { Name = string.Empty }; private TemporaryConfig _newGroup = new() { Name = string.Empty };
private TemporaryConfig _newList = new() private TemporaryConfig _newList = new()
{ {
Name = string.Empty, Name = string.Empty,
ListType = Configuration.ListType.CollectOneTime, ListType = Configuration.ListType.CollectOneTime,
ListPriority = Configuration.ListPriority.InOrder ListPriority = Configuration.ListPriority.InOrder
}; };
private bool _checkPerCharacter = true; private bool _checkPerCharacter = true;
private bool _onlyShowMissing = true; private bool _onlyShowMissing = true;
@ -56,7 +61,7 @@ internal sealed class ConfigWindow : Window
ICommandManager commandManager, ICommandManager commandManager,
IconCache iconCache, IconCache iconCache,
IPluginLog pluginLog) IPluginLog pluginLog)
: base("ARC###ARControlConfig") : base($"ARC {SeIconChar.Collectible.ToIconString()}###ARControlConfig")
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_configuration = configuration; _configuration = configuration;
@ -106,6 +111,7 @@ internal sealed class ConfigWindow : Window
}; };
ImGui.OpenPopup($"##EditList{list.Id}"); ImGui.OpenPopup($"##EditList{list.Id}");
} }
DrawVentureListEditorPopup(list, ref listToDelete); DrawVentureListEditorPopup(list, ref listToDelete);
ImGui.SameLine(); ImGui.SameLine();
@ -118,6 +124,7 @@ internal sealed class ConfigWindow : Window
DrawVentureListItemSelection(list); DrawVentureListItemSelection(list);
ImGui.Unindent(30); ImGui.Unindent(30);
} }
ImGui.PopID(); ImGui.PopID();
} }
@ -233,7 +240,8 @@ internal sealed class ConfigWindow : Window
} }
} }
private (bool Save, bool CanSave) DrawVentureListEditor(TemporaryConfig temporaryConfig, Configuration.ItemList? list) private (bool Save, bool CanSave) DrawVentureListEditor(TemporaryConfig temporaryConfig,
Configuration.ItemList? list)
{ {
string listName = temporaryConfig.Name; string listName = temporaryConfig.Name;
bool save = ImGui.InputTextWithHint("", "List Name...", ref listName, 64, bool save = ImGui.InputTextWithHint("", "List Name...", ref listName, 64,
@ -339,6 +347,7 @@ internal sealed class ConfigWindow : Window
itemToAdd = item; itemToAdd = item;
indexToAdd = i - 1; indexToAdd = i - 1;
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.SameLine(0, 0); ImGui.SameLine(0, 0);
@ -348,6 +357,7 @@ internal sealed class ConfigWindow : Window
itemToAdd = item; itemToAdd = item;
indexToAdd = i + 1; indexToAdd = i + 1;
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.SameLine(); ImGui.SameLine();
@ -380,8 +390,10 @@ internal sealed class ConfigWindow : Window
list.Items.RemoveAll(q => q.RemainingQuantity <= 0); list.Items.RemoveAll(q => q.RemainingQuantity <= 0);
Save(); Save();
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
} }
ImGui.Spacing(); ImGui.Spacing();
} }
@ -443,7 +455,8 @@ internal sealed class ConfigWindow : Window
if (ImGui.BeginTabBar("CharOptions")) if (ImGui.BeginTabBar("CharOptions"))
{ {
if (character.Type != Configuration.CharacterType.NotManaged && ImGui.BeginTabItem("Venture Lists")) if (character.Type != Configuration.CharacterType.NotManaged &&
ImGui.BeginTabItem("Venture Lists"))
{ {
int groupIndex = 0; int groupIndex = 0;
if (character.Type == Configuration.CharacterType.PartOfCharacterGroup) if (character.Type == Configuration.CharacterType.PartOfCharacterGroup)
@ -461,6 +474,7 @@ internal sealed class ConfigWindow : Window
character.Type = Configuration.CharacterType.PartOfCharacterGroup; character.Type = Configuration.CharacterType.PartOfCharacterGroup;
character.CharacterGroupId = groups[groupIndex].Id; character.CharacterGroupId = groups[groupIndex].Id;
} }
Save(); Save();
} }
@ -470,14 +484,16 @@ internal sealed class ConfigWindow : Window
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (character.ItemListIds == null) if (character.ItemListIds == null)
character.ItemListIds = new(); character.ItemListIds = new();
DrawVentureListSelection(character.LocalContentId.ToString(), character.ItemListIds); DrawVentureListSelection(character.LocalContentId.ToString(),
character.ItemListIds);
} }
else else
{ {
ImGui.TextWrapped($"Retainers will participate in the following lists:"); ImGui.TextWrapped($"Retainers will participate in the following lists:");
ImGui.Indent(30); ImGui.Indent(30);
var group = _configuration.CharacterGroups.Single(x => x.Id == groups[groupIndex].Id); var group = _configuration.CharacterGroups.Single(
x => x.Id == groups[groupIndex].Id);
var lists = group.ItemListIds var lists = group.ItemListIds
.Where(listId => listId != Guid.Empty) .Where(listId => listId != Guid.Empty)
.Select(listId => _configuration.ItemLists.SingleOrDefault(x => x.Id == listId)) .Select(listId => _configuration.ItemLists.SingleOrDefault(x => x.Id == listId))
@ -495,11 +511,14 @@ internal sealed class ConfigWindow : Window
ImGui.Unindent(30); ImGui.Unindent(30);
ImGui.Spacing(); ImGui.Spacing();
} }
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if (ImGui.BeginTabItem("Retainers")) if (ImGui.BeginTabItem("Retainers"))
{ {
foreach (var retainer in character.Retainers.Where(x => x.Job > 0).OrderBy(x => x.DisplayOrder)) foreach (var retainer in character.Retainers.Where(x => x.Job > 0)
.OrderBy(x => x.DisplayOrder))
{ {
ImGui.BeginDisabled(retainer.Level < MinLevel); ImGui.BeginDisabled(retainer.Level < MinLevel);
@ -512,7 +531,8 @@ internal sealed class ConfigWindow : Window
ImGui.SameLine(); ImGui.SameLine();
} }
if (ImGui.Checkbox($"{retainer.Name}###Retainer{retainer.Name}{retainer.DisplayOrder}", if (ImGui.Checkbox(
$"{retainer.Name}###Retainer{retainer.Name}{retainer.DisplayOrder}",
ref managed)) ref managed))
{ {
retainer.Managed = managed; retainer.Managed = managed;
@ -521,8 +541,10 @@ internal sealed class ConfigWindow : Window
ImGui.EndDisabled(); ImGui.EndDisabled();
} }
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
ImGui.EndTabBar(); ImGui.EndTabBar();
} }
@ -575,7 +597,9 @@ internal sealed class ConfigWindow : Window
} }
} }
private void DrawCharacterGroupEditorPopup(Configuration.CharacterGroup group, out List<Configuration.CharacterConfiguration> assignedCharacters, ref Configuration.CharacterGroup? groupToDelete) private void DrawCharacterGroupEditorPopup(Configuration.CharacterGroup group,
out List<Configuration.CharacterConfiguration> assignedCharacters,
ref Configuration.CharacterGroup? groupToDelete)
{ {
assignedCharacters = _configuration.Characters assignedCharacters = _configuration.Characters
.Where(x => x.Type == Configuration.CharacterType.PartOfCharacterGroup && .Where(x => x.Type == Configuration.CharacterType.PartOfCharacterGroup &&
@ -583,7 +607,8 @@ internal sealed class ConfigWindow : Window
.OrderBy(x => x.WorldName) .OrderBy(x => x.WorldName)
.ThenBy(x => x.LocalContentId) .ThenBy(x => x.LocalContentId)
.ToList(); .ToList();
if (_currentEditPopups.TryGetValue(group.Id, out TemporaryConfig? temporaryConfig) && ImGui.BeginPopup($"##EditGroup{group.Id}")) if (_currentEditPopups.TryGetValue(group.Id, out TemporaryConfig? temporaryConfig) &&
ImGui.BeginPopup($"##EditGroup{group.Id}"))
{ {
(bool save, bool canSave) = DrawGroupEditor(temporaryConfig, group); (bool save, bool canSave) = DrawGroupEditor(temporaryConfig, group);
@ -607,6 +632,7 @@ internal sealed class ConfigWindow : Window
groupToDelete = group; groupToDelete = group;
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
if (assignedCharacters.Count > 0 && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) if (assignedCharacters.Count > 0 && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
{ {
@ -618,11 +644,13 @@ internal sealed class ConfigWindow : Window
ImGui.EndTooltip(); ImGui.EndTooltip();
} }
} }
ImGui.EndPopup(); ImGui.EndPopup();
} }
} }
private void DrawCharacterGroup(Configuration.CharacterGroup group, List<Configuration.CharacterConfiguration> assignedCharacters) private void DrawCharacterGroup(Configuration.CharacterGroup group,
List<Configuration.CharacterConfiguration> assignedCharacters)
{ {
string countLabel = assignedCharacters.Count == 0 ? "no characters" string countLabel = assignedCharacters.Count == 0 ? "no characters"
: assignedCharacters.Count == 1 ? "1 character" : assignedCharacters.Count == 1 ? "1 character"
@ -687,7 +715,8 @@ internal sealed class ConfigWindow : Window
} }
} }
private (bool Save, bool CanSave) DrawGroupEditor(TemporaryConfig group, Configuration.CharacterGroup? existingGroup) private (bool Save, bool CanSave) DrawGroupEditor(TemporaryConfig group,
Configuration.CharacterGroup? existingGroup)
{ {
string name = group.Name; string name = group.Name;
bool save = ImGui.InputTextWithHint("", "Group Name...", ref name, 64, ImGuiInputTextFlags.EnterReturnsTrue); bool save = ImGui.InputTextWithHint("", "Group Name...", ref name, 64, ImGuiInputTextFlags.EnterReturnsTrue);
@ -870,6 +899,7 @@ internal sealed class ConfigWindow : Window
itemToAdd = i; itemToAdd = i;
indexToAdd = i - 1; indexToAdd = i - 1;
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.SameLine(0, 0); ImGui.SameLine(0, 0);
@ -879,6 +909,7 @@ internal sealed class ConfigWindow : Window
itemToAdd = i; itemToAdd = i;
indexToAdd = i + 1; indexToAdd = i + 1;
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.SameLine(); ImGui.SameLine();
@ -946,6 +977,7 @@ internal sealed class ConfigWindow : Window
ImGui.EndPopup(); ImGui.EndPopup();
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.PopID(); ImGui.PopID();