diff --git a/.gitmodules b/.gitmodules
index 4ac68e0..be5dc56 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,9 @@
[submodule "LLib"]
path = LLib
url = https://git.carvel.li/liza/LLib.git
+[submodule "ECommons"]
+ path = ECommons
+ url = https://github.com/NightmareXIV/ECommons.git
+[submodule "AutoRetainerAPI"]
+ path = AutoRetainerAPI
+ url = https://github.com/PunishXIV/AutoRetainerAPI.git
diff --git a/AutoRetainerAPI b/AutoRetainerAPI
new file mode 160000
index 0000000..2715088
--- /dev/null
+++ b/AutoRetainerAPI
@@ -0,0 +1 @@
+Subproject commit 2715088db81d2be34447b27b0e5e5a3e766e47c7
diff --git a/ECommons b/ECommons
new file mode 160000
index 0000000..f1c688a
--- /dev/null
+++ b/ECommons
@@ -0,0 +1 @@
+Subproject commit f1c688a0599b41d70230021328a575da7351cf91
diff --git a/Influx.sln b/Influx.sln
index 33ff0ff..5ddcc61 100644
--- a/Influx.sln
+++ b/Influx.sln
@@ -4,6 +4,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Influx", "Influx\Influx.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LLib", "LLib\LLib.csproj", "{C11552A8-9C8C-4084-A669-AAFE55E24DCC}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{FC6E184C-5B01-4298-87DF-CC10C4955936}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRetainerAPI", "AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj", "{7352C470-D652-4909-AD90-8A5171A86698}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +22,13 @@ Global
{C11552A8-9C8C-4084-A669-AAFE55E24DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C11552A8-9C8C-4084-A669-AAFE55E24DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C11552A8-9C8C-4084-A669-AAFE55E24DCC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FC6E184C-5B01-4298-87DF-CC10C4955936}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {FC6E184C-5B01-4298-87DF-CC10C4955936}.Debug|Any CPU.Build.0 = Debug|x64
+ {FC6E184C-5B01-4298-87DF-CC10C4955936}.Release|Any CPU.ActiveCfg = Release|x64
+ {FC6E184C-5B01-4298-87DF-CC10C4955936}.Release|Any CPU.Build.0 = Release|x64
+ {7352C470-D652-4909-AD90-8A5171A86698}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {7352C470-D652-4909-AD90-8A5171A86698}.Debug|Any CPU.Build.0 = Debug|x64
+ {7352C470-D652-4909-AD90-8A5171A86698}.Release|Any CPU.ActiveCfg = Release|x64
+ {7352C470-D652-4909-AD90-8A5171A86698}.Release|Any CPU.Build.0 = Release|x64
EndGlobalSection
EndGlobal
diff --git a/Influx/Influx.csproj b/Influx/Influx.csproj
index 87400ba..7f2d449 100644
--- a/Influx/Influx.csproj
+++ b/Influx/Influx.csproj
@@ -54,6 +54,8 @@
+
+
diff --git a/Influx/InfluxPlugin.cs b/Influx/InfluxPlugin.cs
index f1a3229..229d2a3 100644
--- a/Influx/InfluxPlugin.cs
+++ b/Influx/InfluxPlugin.cs
@@ -2,16 +2,25 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
+using AutoRetainerAPI;
+using Dalamud.Game.Addon.Lifecycle;
+using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using Dalamud.Game.Command;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
+using ECommons;
+using ECommons.Automation;
+using FFXIVClientStructs.FFXIV.Client.System.Framework;
+using FFXIVClientStructs.FFXIV.Client.UI.Info;
+using FFXIVClientStructs.FFXIV.Component.GUI;
using Influx.AllaganTools;
using Influx.Influx;
using Influx.LocalStatistics;
using Influx.SubmarineTracker;
using Influx.Windows;
using LLib;
+using Task = System.Threading.Tasks.Task;
namespace Influx;
@@ -23,6 +32,8 @@ public class InfluxPlugin : IDalamudPlugin
private readonly IClientState _clientState;
private readonly ICommandManager _commandManager;
private readonly IPluginLog _pluginLog;
+ private readonly IAddonLifecycle _addonLifecycle;
+ private readonly IGameGui _gameGui;
private readonly AllaganToolsIpc _allaganToolsIpc;
private readonly SubmarineTrackerIpc _submarineTrackerIpc;
private readonly LocalStatsCalculator _localStatsCalculator;
@@ -31,16 +42,21 @@ public class InfluxPlugin : IDalamudPlugin
private readonly StatisticsWindow _statisticsWindow;
private readonly ConfigurationWindow _configurationWindow;
private readonly Timer _timer;
+ private readonly AutoRetainerApi _autoRetainerApi;
+
+ private bool closeFcWindow = false;
public InfluxPlugin(DalamudPluginInterface pluginInterface, IClientState clientState, IPluginLog pluginLog,
ICommandManager commandManager, IChatGui chatGui, IDataManager dataManager, IFramework framework,
- IAddonLifecycle addonLifecycle)
+ IAddonLifecycle addonLifecycle, IGameGui gameGui)
{
_pluginInterface = pluginInterface;
_configuration = LoadConfig();
_clientState = clientState;
_commandManager = commandManager;
_pluginLog = pluginLog;
+ _addonLifecycle = addonLifecycle;
+ _gameGui = gameGui;
DalamudReflector dalamudReflector = new DalamudReflector(pluginInterface, framework, pluginLog);
_allaganToolsIpc = new AllaganToolsIpc(pluginInterface, chatGui, dalamudReflector, framework, _pluginLog);
_submarineTrackerIpc = new SubmarineTrackerIpc(dalamudReflector);
@@ -57,6 +73,12 @@ public class InfluxPlugin : IDalamudPlugin
_timer = new Timer(_ => UpdateStatistics(), null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
_pluginInterface.UiBuilder.OpenConfigUi += _configurationWindow.Toggle;
+
+ ECommonsMain.Init(_pluginInterface, this);
+ _autoRetainerApi = new();
+ _autoRetainerApi.OnCharacterPostprocessStep += CheckCharacterPostProcess;
+ _autoRetainerApi.OnCharacterReadyToPostProcess += DoCharacterPostProcess;
+ _addonLifecycle.RegisterListener(AddonEvent.PostSetup ,"FreeCompany", CloseFcWindow);
}
private Configuration LoadConfig()
@@ -120,8 +142,63 @@ public class InfluxPlugin : IDalamudPlugin
}
}
+ private unsafe void CheckCharacterPostProcess()
+ {
+
+ var infoProxy = Framework.Instance()->UIModule->GetInfoModule()->GetInfoProxyById(InfoProxyId.FreeCompany);
+ if (infoProxy != null)
+ {
+ var fcProxy = (InfoProxyFreeCompany*)infoProxy;
+ if (fcProxy->ID != 0)
+ {
+ _pluginLog.Information($"Requesting post-process, FC is {fcProxy->ID}");
+ _autoRetainerApi.RequestCharacterPostprocess();
+ }
+ else
+ _pluginLog.Information("No FC id");
+ }
+ else
+ _pluginLog.Information("No FreeCompany info proxy");
+ }
+
+ private void DoCharacterPostProcess()
+ {
+ closeFcWindow = true;
+ Chat.Instance.SendMessage("/freecompanycmd");
+ }
+
+ private void CloseFcWindow(AddonEvent type, AddonArgs args)
+ {
+ if (closeFcWindow)
+ {
+ Task.Run(async () =>
+ {
+ // this runs every 500ms
+ // https://github.com/Critical-Impact/CriticalCommonLib/blob/7b3814e703dd5b2981cd4334524b4b301c23e639/Services/InventoryScanner.cs#L436
+ await Task.Delay(550);
+
+ _pluginLog.Information("Closing FC window...");
+ unsafe
+ {
+ AtkUnitBase* addon = (AtkUnitBase*)_gameGui.GetAddonByName("FreeCompany");
+ if (addon->IsVisible)
+ addon->FireCallbackInt(-1);
+ }
+
+ closeFcWindow = false;
+ _autoRetainerApi.FinishCharacterPostProcess();
+ });
+ }
+ }
+
public void Dispose()
{
+ _addonLifecycle.UnregisterListener(AddonEvent.PostSetup ,"FreeCompany", CloseFcWindow);
+ _autoRetainerApi.OnCharacterPostprocessStep -= CheckCharacterPostProcess;
+ _autoRetainerApi.OnCharacterReadyToPostProcess -= DoCharacterPostProcess;
+ _autoRetainerApi.Dispose();
+ ECommonsMain.Dispose();
+
_pluginInterface.UiBuilder.OpenConfigUi -= _configurationWindow.Toggle;
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
_timer.Dispose();
diff --git a/Influx/LocalStatistics/LocalStatsCalculator.cs b/Influx/LocalStatistics/LocalStatsCalculator.cs
index f5b1644..a8ce130 100644
--- a/Influx/LocalStatistics/LocalStatsCalculator.cs
+++ b/Influx/LocalStatistics/LocalStatsCalculator.cs
@@ -209,7 +209,7 @@ internal sealed class LocalStatsCalculator : IDisposable
}
else
{
- _pluginLog.Information($"XX → {playerState->StartTown}");
+ //_pluginLog.Information($"XX → {playerState->StartTown}");
IReadOnlyList cityQuests = playerState->StartTown switch
{
1 => _limsaStart!,
@@ -230,7 +230,7 @@ internal sealed class LocalStatsCalculator : IDisposable
localStats.MsqGenre = 0;
}
- _pluginLog.Information($"Current MSQ Progress: {localStats.MsqCount}, {localStats.MsqName}");
+ _pluginLog.Verbose($"Current MSQ Progress: {localStats.MsqCount}, {localStats.MsqName}");
if (_cache.TryGetValue(localContentId, out var existingStats))
{
diff --git a/Influx/packages.lock.json b/Influx/packages.lock.json
index 58ad93d..9d4aaf9 100644
--- a/Influx/packages.lock.json
+++ b/Influx/packages.lock.json
@@ -191,6 +191,15 @@
"System.Drawing.Common": "6.0.0"
}
},
+ "autoretainerapi": {
+ "type": "Project",
+ "dependencies": {
+ "ECommons": "[2.1.0, )"
+ }
+ },
+ "ecommons": {
+ "type": "Project"
+ },
"llib": {
"type": "Project"
}