From 2f10811afe08f560e915df99fe8c978ea9ab6a8a Mon Sep 17 00:00:00 2001 From: Stephen Baydush Date: Mon, 6 Jan 2025 12:48:38 -0500 Subject: [PATCH] Modified how it auto enrolls to use the IClientState.Login event instead. Changed the wording of the option itself Fixed a bug where it wouldn't save to the config that you had auto enroll enabled. --- Influx/InfluxPlugin.cs | 18 +++++++++++++++ .../LocalStatistics/LocalStatsCalculator.cs | 2 ++ Influx/Windows/ConfigurationWindow.cs | 22 +++++-------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Influx/InfluxPlugin.cs b/Influx/InfluxPlugin.cs index 4f6f0e7..20853eb 100644 --- a/Influx/InfluxPlugin.cs +++ b/Influx/InfluxPlugin.cs @@ -85,6 +85,8 @@ internal sealed class InfluxPlugin : IDalamudPlugin _pluginInterface.UiBuilder.OpenConfigUi += _configurationWindow.Toggle; _pluginInterface.UiBuilder.OpenMainUi += _statisticsWindow.Toggle; _condition.ConditionChange += UpdateOnLogout; + _clientState.Login += AutoEnrollCharacter; + } private Configuration LoadConfig() @@ -204,6 +206,22 @@ internal sealed class InfluxPlugin : IDalamudPlugin return allSubs; } + + private void AutoEnrollCharacter() + { + if (_configuration.AutoEnrollCharacters) + { + _configuration.IncludedCharacters.Add(new Configuration.CharacterInfo + { + LocalContentId = _clientState.LocalContentId, + CachedPlayerName = _clientState.LocalPlayer?.Name.ToString() ?? "??", + CachedWorldName = _clientState.LocalPlayer?.HomeWorld.Value.Name.ToString(), + }); + _pluginInterface.SavePluginConfig(_configuration); + } + } + + private void UpdateOnLogout(ConditionFlag flag, bool value) { if (flag == ConditionFlag.LoggingOut && value) diff --git a/Influx/LocalStatistics/LocalStatsCalculator.cs b/Influx/LocalStatistics/LocalStatsCalculator.cs index 7d2eb88..01f924f 100644 --- a/Influx/LocalStatistics/LocalStatsCalculator.cs +++ b/Influx/LocalStatistics/LocalStatsCalculator.cs @@ -243,6 +243,8 @@ internal sealed class LocalStatsCalculator : IDisposable } } + + private unsafe List ExtractClassJobLevels(PlayerState* playerState) { List levels = new(); diff --git a/Influx/Windows/ConfigurationWindow.cs b/Influx/Windows/ConfigurationWindow.cs index 6befb8b..3bce2fa 100644 --- a/Influx/Windows/ConfigurationWindow.cs +++ b/Influx/Windows/ConfigurationWindow.cs @@ -104,9 +104,10 @@ internal sealed class ConfigurationWindow : Window return; var refIncludeAll = _configuration.AutoEnrollCharacters; - if (ImGui.Checkbox("Auto enroll characters", ref refIncludeAll)) + if (ImGui.Checkbox("Auto enroll characters on login", ref refIncludeAll)) { _configuration.AutoEnrollCharacters = refIncludeAll; + Save(true); } if (_clientState is { IsLoggedIn: true, LocalContentId: > 0, LocalPlayer.HomeWorld.RowId: > 0 }) @@ -141,7 +142,9 @@ internal sealed class ConfigurationWindow : Window } else { - if (_configuration.AutoEnrollCharacters) + ImGui.TextColored(ImGuiColors.DalamudRed, + "This character is currently excluded."); + if (ImGui.Button("Include current character")) { _configuration.IncludedCharacters.Add(new Configuration.CharacterInfo { @@ -151,21 +154,6 @@ internal sealed class ConfigurationWindow : Window }); Save(); } - else - { - ImGui.TextColored(ImGuiColors.DalamudRed, - "This character is currently excluded."); - if (ImGui.Button("Include current character")) - { - _configuration.IncludedCharacters.Add(new Configuration.CharacterInfo - { - LocalContentId = _clientState.LocalContentId, - CachedPlayerName = _clientState.LocalPlayer?.Name.ToString() ?? "??", - CachedWorldName = worldName, - }); - Save(); - } - } } ImGui.Unindent(30);