This commit is contained in:
Liza 2023-10-04 12:27:31 +02:00
parent 849f677a1b
commit 188f0033fa
Signed by: liza
GPG Key ID: 7199F8D727D55F67
11 changed files with 75 additions and 76 deletions

View File

@ -16,7 +16,7 @@
<PropertyGroup> <PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath> <DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.1.2.5\</AutoRetainerLibPath> <AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.2.0.2\</AutoRetainerLibPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'"> <PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
@ -24,8 +24,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dalamud.ContextMenu" Version="1.2.3"/> <PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="DalamudPackager" Version="2.1.11"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -37,10 +36,6 @@
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath> <HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina"> <Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath> <HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>false</Private> <Private>false</Private>
@ -57,10 +52,6 @@
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath> <HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="AutoRetainerAPI"> <Reference Include="AutoRetainerAPI">
<HintPath>$(AutoRetainerLibPath)AutoRetainerAPI.dll</HintPath> <HintPath>$(AutoRetainerLibPath)AutoRetainerAPI.dll</HintPath>
</Reference> </Reference>

View File

@ -1,7 +1,7 @@
{ {
"Name": "ARC", "Name": "ARC",
"Author": "Liza Carvelli", "Author": "Liza Carvelli",
"Punchline": "Better AutoRetainer Venture Distribution", "Punchline": "Better AutoRetainer Venture Planner",
"Description": "", "Description": "",
"RepoUrl": "https://git.carvel.li/liza/ARControl" "RepoUrl": "https://git.carvel.li/liza/ARControl"
} }

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Linq;
using Dalamud.Logging;
namespace ARControl; namespace ARControl;
@ -12,7 +11,7 @@ partial class AutoRetainerControlPlugin
// FIXME This should have a way to get blacklisted character ids // FIXME This should have a way to get blacklisted character ids
foreach (ulong registeredCharacterId in _autoRetainerApi.GetRegisteredCharacters()) foreach (ulong registeredCharacterId in _autoRetainerApi.GetRegisteredCharacters())
{ {
PluginLog.Information($"ch → {registeredCharacterId:X}"); _pluginLog.Verbose($"Sync for character {registeredCharacterId:X}");
var offlineCharacterData = _autoRetainerApi.GetOfflineCharacterData(registeredCharacterId); var offlineCharacterData = _autoRetainerApi.GetOfflineCharacterData(registeredCharacterId);
if (offlineCharacterData.ExcludeRetainer) if (offlineCharacterData.ExcludeRetainer)
continue; continue;

View File

@ -4,15 +4,12 @@ using System.Linq;
using ARControl.GameData; using ARControl.GameData;
using ARControl.Windows; using ARControl.Windows;
using AutoRetainerAPI; using AutoRetainerAPI;
using Dalamud.Data;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ECommons; using ECommons;
using ImGuiNET; using ImGuiNET;
@ -24,9 +21,10 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
private readonly WindowSystem _windowSystem = new(nameof(AutoRetainerControlPlugin)); private readonly WindowSystem _windowSystem = new(nameof(AutoRetainerControlPlugin));
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly ClientState _clientState; private readonly IClientState _clientState;
private readonly ChatGui _chatGui; private readonly IChatGui _chatGui;
private readonly CommandManager _commandManager; private readonly ICommandManager _commandManager;
private readonly IPluginLog _pluginLog;
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly GameCache _gameCache; private readonly GameCache _gameCache;
@ -34,19 +32,20 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
private readonly ConfigWindow _configWindow; private readonly ConfigWindow _configWindow;
private readonly AutoRetainerApi _autoRetainerApi; private readonly AutoRetainerApi _autoRetainerApi;
public AutoRetainerControlPlugin(DalamudPluginInterface pluginInterface, DataManager dataManager, public AutoRetainerControlPlugin(DalamudPluginInterface pluginInterface, IDataManager dataManager,
ClientState clientState, ChatGui chatGui, CommandManager commandManager) IClientState clientState, IChatGui chatGui, ICommandManager commandManager, IPluginLog pluginLog)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_clientState = clientState; _clientState = clientState;
_chatGui = chatGui; _chatGui = chatGui;
_commandManager = commandManager; _commandManager = commandManager;
_pluginLog = pluginLog;
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration(); _configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
_gameCache = new GameCache(dataManager); _gameCache = new GameCache(dataManager);
_ventureResolver = new VentureResolver(_gameCache); _ventureResolver = new VentureResolver(_gameCache, _pluginLog);
_configWindow = new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager); _configWindow = new ConfigWindow(_pluginInterface, _configuration, _gameCache, _clientState, _commandManager, _pluginLog);
_windowSystem.AddWindow(_configWindow); _windowSystem.AddWindow(_configWindow);
ECommonsMain.Init(_pluginInterface, this); ECommonsMain.Init(_pluginInterface, this);
@ -57,54 +56,55 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
_autoRetainerApi.OnSendRetainerToVenture += SendRetainerToVenture; _autoRetainerApi.OnSendRetainerToVenture += SendRetainerToVenture;
_autoRetainerApi.OnRetainerPostVentureTaskDraw += RetainerTaskButtonDraw; _autoRetainerApi.OnRetainerPostVentureTaskDraw += RetainerTaskButtonDraw;
_clientState.TerritoryChanged += TerritoryChanged; _clientState.TerritoryChanged += TerritoryChanged;
_commandManager.AddHandler("/arc", new CommandInfo(ProcessCommand)); _commandManager.AddHandler("/arc", new CommandInfo(ProcessCommand)
{
HelpMessage = "Manage retainers"
});
if (_autoRetainerApi.Ready) if (_autoRetainerApi.Ready)
Sync(); Sync();
} }
public string Name => "ARC";
private void SendRetainerToVenture(string retainerName) private void SendRetainerToVenture(string retainerName)
{ {
var ch = _configuration.Characters.SingleOrDefault(x => x.LocalContentId == _clientState.LocalContentId); var ch = _configuration.Characters.SingleOrDefault(x => x.LocalContentId == _clientState.LocalContentId);
if (ch == null) if (ch == null)
{ {
PluginLog.Information("No character information found"); _pluginLog.Information("No character information found");
} }
else if (!ch.Managed) else if (!ch.Managed)
{ {
PluginLog.Information("Character is not managed"); _pluginLog.Information("Character is not managed");
} }
else else
{ {
var retainer = ch.Retainers.SingleOrDefault(x => x.Name == retainerName); var retainer = ch.Retainers.SingleOrDefault(x => x.Name == retainerName);
if (retainer == null) if (retainer == null)
{ {
PluginLog.Information("No retainer information found"); _pluginLog.Information("No retainer information found");
} }
else if (!retainer.Managed) else if (!retainer.Managed)
{ {
PluginLog.Information("Retainer is not managed"); _pluginLog.Information("Retainer is not managed");
} }
else else
{ {
PluginLog.Information("Checking tasks..."); _pluginLog.Information("Checking tasks...");
Sync(); Sync();
foreach (var queuedItem in _configuration.QueuedItems.Where(x => x.RemainingQuantity > 0)) foreach (var queuedItem in _configuration.QueuedItems.Where(x => x.RemainingQuantity > 0))
{ {
PluginLog.Information($"Checking venture info for itemId {queuedItem.ItemId}"); _pluginLog.Information($"Checking venture info for itemId {queuedItem.ItemId}");
var (venture, reward) = _ventureResolver.ResolveVenture(ch, retainer, queuedItem); var (venture, reward) = _ventureResolver.ResolveVenture(ch, retainer, queuedItem);
if (reward == null) if (reward == null)
{ {
PluginLog.Information("Retainer can't complete venture"); _pluginLog.Information("Retainer can't complete venture");
} }
else else
{ {
_chatGui.Print( _chatGui.Print(
$"ARC → Overriding venture to collect {reward.Quantity}x {venture!.Name}."); $"[ARC] Sending retainer {retainerName} to collect {reward.Quantity}x {venture!.Name}.");
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}");
_autoRetainerApi.SetVenture(venture.RowId); _autoRetainerApi.SetVenture(venture.RowId);
@ -119,15 +119,15 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
// fallback: managed but no venture found // fallback: managed but no venture found
if (retainer.LastVenture != 395) if (retainer.LastVenture != 395)
{ {
_chatGui.Print("ARC → No tasks left, using QC"); _chatGui.Print($"[ARC] No tasks left for retainer {retainerName}, sending to Quick Venture.");
PluginLog.Information($"No tasks left (previous venture = {retainer.LastVenture}), using QC"); _pluginLog.Information($"No tasks left (previous venture = {retainer.LastVenture}), using QC");
_autoRetainerApi.SetVenture(395); _autoRetainerApi.SetVenture(395);
retainer.LastVenture = 395; retainer.LastVenture = 395;
_pluginInterface.SavePluginConfig(_configuration); _pluginInterface.SavePluginConfig(_configuration);
} }
else else
PluginLog.Information("Not changing venture plan, already 395"); _pluginLog.Information("Not changing venture plan, already 395");
} }
} }
} }
@ -148,7 +148,7 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
ImGuiComponents.IconButton(FontAwesomeIcon.Book); ImGuiComponents.IconButton(FontAwesomeIcon.Book);
} }
private void TerritoryChanged(object? sender, ushort e) => Sync(); private void TerritoryChanged(ushort e) => Sync();
private void ProcessCommand(string command, string arguments) private void ProcessCommand(string command, string arguments)
{ {

View File

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Configuration; using Dalamud.Configuration;
namespace ARControl; namespace ARControl;

View File

@ -1,13 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Data; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ARControl.GameData; namespace ARControl.GameData;
internal sealed class GameCache internal sealed class GameCache
{ {
public GameCache(DataManager dataManager) public GameCache(IDataManager dataManager)
{ {
Jobs = dataManager.GetExcelSheet<ClassJob>()!.ToDictionary(x => x.RowId, x => x.Abbreviation.ToString()); Jobs = dataManager.GetExcelSheet<ClassJob>()!.ToDictionary(x => x.RowId, x => x.Abbreviation.ToString());
Ventures = dataManager.GetExcelSheet<RetainerTask>()! Ventures = dataManager.GetExcelSheet<RetainerTask>()!

View File

@ -1,11 +1,11 @@
using Dalamud.Data; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ARControl.GameData; namespace ARControl.GameData;
internal sealed class ItemToGather internal sealed class ItemToGather
{ {
public ItemToGather(DataManager dataManager, GatheringItem item) public ItemToGather(IDataManager dataManager, GatheringItem item)
{ {
GatheredItemId = item.RowId; GatheredItemId = item.RowId;
ItemId = item.Item; ItemId = item.Item;

View File

@ -1,12 +1,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Data; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ARControl.GameData; namespace ARControl.GameData;
internal sealed class Venture internal sealed class Venture
{ {
public Venture(DataManager dataManager, RetainerTask retainerTask) public Venture(IDataManager dataManager, RetainerTask retainerTask)
{ {
RowId = retainerTask.RowId; RowId = retainerTask.RowId;
Category = retainerTask.ClassJobCategory.Value!; Category = retainerTask.ClassJobCategory.Value!;

View File

@ -1,16 +1,17 @@
using System; using System.Linq;
using System.Linq; using Dalamud.Plugin.Services;
using Dalamud.Logging;
namespace ARControl.GameData; namespace ARControl.GameData;
internal sealed class VentureResolver internal sealed class VentureResolver
{ {
private readonly GameCache _gameCache; private readonly GameCache _gameCache;
private readonly IPluginLog _pluginLog;
public VentureResolver(GameCache gameCache) public VentureResolver(GameCache gameCache, IPluginLog pluginLog)
{ {
_gameCache = gameCache; _gameCache = gameCache;
_pluginLog = pluginLog;
} }
public (Venture?, VentureReward?) ResolveVenture(Configuration.CharacterConfiguration character, public (Venture?, VentureReward?) ResolveVenture(Configuration.CharacterConfiguration character,
@ -21,18 +22,18 @@ internal sealed class VentureResolver
.FirstOrDefault(x => x.ItemId == queuedItem.ItemId && x.MatchesJob(retainer.Job)); .FirstOrDefault(x => x.ItemId == queuedItem.ItemId && x.MatchesJob(retainer.Job));
if (venture == null) if (venture == null)
{ {
PluginLog.Information($"No applicable venture found for itemId {queuedItem.ItemId}"); _pluginLog.Information($"No applicable venture found for itemId {queuedItem.ItemId}");
return (null, null); return (null, null);
} }
var itemToGather = _gameCache.ItemsToGather.FirstOrDefault(x => x.ItemId == queuedItem.ItemId); var itemToGather = _gameCache.ItemsToGather.FirstOrDefault(x => x.ItemId == queuedItem.ItemId);
if (itemToGather != null && !character.GatheredItems.Contains(itemToGather.GatheredItemId)) if (itemToGather != null && !character.GatheredItems.Contains(itemToGather.GatheredItemId))
{ {
PluginLog.Information($"Character hasn't gathered {venture.Name} yet"); _pluginLog.Information($"Character hasn't gathered {venture.Name} yet");
return (null, null); return (null, null);
} }
PluginLog.Information( _pluginLog.Information(
$"Found venture {venture.Name}, row = {venture.RowId}, checking if it is suitable"); $"Found venture {venture.Name}, row = {venture.RowId}, checking if it is suitable");
VentureReward? reward = null; VentureReward? reward = null;
if (venture.CategoryName is "MIN" or "BTN") if (venture.CategoryName is "MIN" or "BTN")

View File

@ -2,15 +2,12 @@
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using ARControl.GameData; using ARControl.GameData;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Style;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ECommons.ImGuiMethods; using ECommons.ImGuiMethods;
using ImGuiNET; using ImGuiNET;
@ -27,8 +24,9 @@ internal sealed class ConfigWindow : Window
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly GameCache _gameCache; private readonly GameCache _gameCache;
private readonly ClientState _clientState; private readonly IClientState _clientState;
private readonly CommandManager _commandManager; private readonly ICommandManager _commandManager;
private readonly IPluginLog _pluginLog;
private string _searchString = string.Empty; private string _searchString = string.Empty;
private Configuration.QueuedItem? _dragDropSource; private Configuration.QueuedItem? _dragDropSource;
@ -40,8 +38,9 @@ internal sealed class ConfigWindow : Window
DalamudPluginInterface pluginInterface, DalamudPluginInterface pluginInterface,
Configuration configuration, Configuration configuration,
GameCache gameCache, GameCache gameCache,
ClientState clientState, IClientState clientState,
CommandManager commandManager) ICommandManager commandManager,
IPluginLog pluginLog)
: base("ARC###ARControlConfig") : base("ARC###ARControlConfig")
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
@ -49,6 +48,7 @@ internal sealed class ConfigWindow : Window
_gameCache = gameCache; _gameCache = gameCache;
_clientState = clientState; _clientState = clientState;
_commandManager = commandManager; _commandManager = commandManager;
_pluginLog = pluginLog;
} }
public override void Draw() public override void Draw()
@ -66,7 +66,7 @@ internal sealed class ConfigWindow : Window
{ {
if (ImGui.BeginTabItem("Venture Queue")) if (ImGui.BeginTabItem("Venture Queue"))
{ {
if (ImGui.BeginCombo("Venture...##VentureSelection", "")) if (ImGui.BeginCombo("Add Item...##VentureSelection", ""))
{ {
ImGuiEx.SetNextItemFullWidth(); ImGuiEx.SetNextItemFullWidth();
ImGui.InputTextWithHint("", "Filter...", ref _searchString, 256); ImGui.InputTextWithHint("", "Filter...", ref _searchString, 256);
@ -95,7 +95,6 @@ internal sealed class ConfigWindow : Window
ImGui.EndCombo(); ImGui.EndCombo();
} }
ImGui.Checkbox("Enable Drag&Drop", ref _enableDragDrop);
ImGui.Separator(); ImGui.Separator();
ImGui.Indent(30); ImGui.Indent(30);
@ -167,13 +166,29 @@ internal sealed class ConfigWindow : Window
if (itemToAdd != null) if (itemToAdd != null)
{ {
PluginLog.Information($"Updating {itemToAdd.ItemId} → {indexToAdd}"); _pluginLog.Information($"Updating {itemToAdd.ItemId} → {indexToAdd}");
_configuration.QueuedItems.Remove(itemToAdd); _configuration.QueuedItems.Remove(itemToAdd);
_configuration.QueuedItems.Insert(indexToAdd, itemToAdd); _configuration.QueuedItems.Insert(indexToAdd, itemToAdd);
Save(); Save();
} }
ImGui.Unindent(30); ImGui.Unindent(30);
if (_configuration.QueuedItems.Count > 0)
ImGui.Separator();
if (ImGuiComponents.IconButtonWithText(_enableDragDrop ? FontAwesomeIcon.Times : FontAwesomeIcon.Sort, _enableDragDrop ? "Disable Drag&Drop" : "Enable Drag&Drop"))
{
_enableDragDrop = !_enableDragDrop;
}
ImGui.SameLine();
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Check, "Remove all finished items"))
{
if (_configuration.QueuedItems.RemoveAll(q => q.RemainingQuantity == 0) > 0)
Save();
}
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
} }

View File

@ -2,17 +2,11 @@
"version": 1, "version": 1,
"dependencies": { "dependencies": {
"net7.0-windows7.0": { "net7.0-windows7.0": {
"Dalamud.ContextMenu": {
"type": "Direct",
"requested": "[1.2.3, )",
"resolved": "1.2.3",
"contentHash": "ydemplF7DNcA/LLeongDVzWUD/JV0Fw3EwA2+P0jYq3Le2ZYSt4U8qyJq4FyoChqt0lFG8BxYCAzfeWp4Jmnqw=="
},
"DalamudPackager": { "DalamudPackager": {
"type": "Direct", "type": "Direct",
"requested": "[2.1.11, )", "requested": "[2.1.12, )",
"resolved": "2.1.11", "resolved": "2.1.12",
"contentHash": "9qlAWoRRTiL/geAvuwR/g6Bcbrd/bJJgVnB/RurBiyKs6srsP0bvpoo8IK+Eg8EA6jWeM6/YJWs66w4FIAzqPw==" "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
} }
} }
} }