Adjustments around FC exclusions

master v0.7
Liza 2024-03-02 14:52:43 +01:00
parent 533b87118e
commit 80577a7636
Signed by: liza
GPG Key ID: 7199F8D727D55F67
5 changed files with 32 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Version>0.6</Version>
<Version>0.7</Version>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -69,7 +69,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
var validFcIds = currencyStats.Keys
.Where(x => x.CharacterType == CharacterType.Character)
.Where(x => _configuration.IncludedCharacters
.SingleOrDefault(config => config.LocalContentId == x.CharacterId)?.IncludeFreeCompany == true)
.Any(config => config.LocalContentId == x.CharacterId && config.IncludeFreeCompany))
.Select(x => x.FreeCompanyId)
.ToList();
var client = _influxClient;

View File

@ -56,9 +56,12 @@ public class InfluxPlugin : IDalamudPlugin
DalamudReflector dalamudReflector = new DalamudReflector(pluginInterface, framework, pluginLog);
_allaganToolsIpc = new AllaganToolsIpc(pluginInterface, chatGui, dalamudReflector, framework, _pluginLog);
_submarineTrackerIpc = new SubmarineTrackerIpc(dalamudReflector);
_localStatsCalculator = new LocalStatsCalculator(pluginInterface, clientState, addonLifecycle, pluginLog, dataManager);
_fcStatsCalculator = new FcStatsCalculator(this, pluginInterface, clientState, addonLifecycle, gameGui, framework, pluginLog);
_influxStatisticsClient = new InfluxStatisticsClient(chatGui, _configuration, dataManager, clientState, _pluginLog);
_localStatsCalculator =
new LocalStatsCalculator(pluginInterface, clientState, addonLifecycle, pluginLog, dataManager);
_fcStatsCalculator = new FcStatsCalculator(this, pluginInterface, clientState, addonLifecycle, gameGui,
framework, _configuration, pluginLog);
_influxStatisticsClient =
new InfluxStatisticsClient(chatGui, _configuration, dataManager, clientState, _pluginLog);
_windowSystem = new WindowSystem(typeof(InfluxPlugin).FullName);
_statisticsWindow = new StatisticsWindow();

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AutoRetainerAPI;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
@ -13,6 +14,7 @@ using FFXIVClientStructs.FFXIV.Client.UI.Info;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Newtonsoft.Json;
using Task = System.Threading.Tasks.Task;
namespace Influx.LocalStatistics;
public class FcStatsCalculator : IDisposable
@ -22,6 +24,7 @@ public class FcStatsCalculator : IDisposable
private readonly IAddonLifecycle _addonLifecycle;
private readonly IGameGui _gameGui;
private readonly IFramework _framework;
private readonly Configuration _configuration;
private readonly IPluginLog _pluginLog;
private readonly AutoRetainerApi _autoRetainerApi;
@ -36,6 +39,7 @@ public class FcStatsCalculator : IDisposable
IAddonLifecycle addonLifecycle,
IGameGui gameGui,
IFramework framework,
Configuration configuration,
IPluginLog pluginLog)
{
_pluginInterface = pluginInterface;
@ -43,13 +47,14 @@ public class FcStatsCalculator : IDisposable
_addonLifecycle = addonLifecycle;
_gameGui = gameGui;
_framework = framework;
_configuration = configuration;
_pluginLog = pluginLog;
ECommonsMain.Init(_pluginInterface, plugin);
_autoRetainerApi = new();
_autoRetainerApi.OnCharacterPostprocessStep += CheckCharacterPostProcess;
_autoRetainerApi.OnCharacterReadyToPostProcess += DoCharacterPostProcess;
_addonLifecycle.RegisterListener(AddonEvent.PostReceiveEvent ,"FreeCompany", CloseFcWindow);
_addonLifecycle.RegisterListener(AddonEvent.PostReceiveEvent, "FreeCompany", CloseFcWindow);
foreach (var file in _pluginInterface.ConfigDirectory.GetFiles("f.*.json"))
{
@ -70,6 +75,12 @@ public class FcStatsCalculator : IDisposable
private unsafe void CheckCharacterPostProcess()
{
bool includeFc = _configuration.IncludedCharacters.Any(x =>
x.LocalContentId == _clientState.LocalContentId &&
x.IncludeFreeCompany);
if (!includeFc)
return;
var infoProxy = Framework.Instance()->UIModule->GetInfoModule()->GetInfoProxyById(InfoProxyId.FreeCompany);
if (infoProxy != null)
{
@ -89,10 +100,18 @@ public class FcStatsCalculator : IDisposable
private void DoCharacterPostProcess()
{
closeFcWindow = true;
Chat.Instance.SendMessage("/freecompanycmd");
unsafe
{
AtkUnitBase* addon = (AtkUnitBase*)_gameGui.GetAddonByName("FreeCompany");
if (addon != null && addon->IsVisible)
CloseFcWindow(AddonEvent.PostReceiveEvent);
else
Chat.Instance.SendMessage("/freecompanycmd");
}
}
private void CloseFcWindow(AddonEvent type, AddonArgs args)
private void CloseFcWindow(AddonEvent type, AddonArgs? args = null)
{
_framework.RunOnTick(() => UpdateOnTick(0), TimeSpan.FromMilliseconds(100));
}
@ -191,7 +210,7 @@ public class FcStatsCalculator : IDisposable
public void Dispose()
{
_addonLifecycle.UnregisterListener(AddonEvent.PostReceiveEvent ,"FreeCompany", CloseFcWindow);
_addonLifecycle.UnregisterListener(AddonEvent.PostReceiveEvent, "FreeCompany", CloseFcWindow);
_autoRetainerApi.OnCharacterPostprocessStep -= CheckCharacterPostProcess;
_autoRetainerApi.OnCharacterReadyToPostProcess -= DoCharacterPostProcess;
_autoRetainerApi.Dispose();

View File

@ -155,7 +155,7 @@ internal sealed class ConfigurationWindow : Window
foreach (var characterInfo in world)
{
ImGui.Selectable(
$"{characterInfo.CachedPlayerName} @ {characterInfo.CachedWorldName} ({characterInfo.LocalContentId:X})");
$"{characterInfo.CachedPlayerName} @ {characterInfo.CachedWorldName} ({characterInfo.LocalContentId:X}{(!characterInfo.IncludeFreeCompany ? ", no FC" : "")})");
}
ImGui.Unindent(30);