1
0
forked from liza/Influx

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.
This commit is contained in:
Stephen Baydush 2025-01-06 12:48:38 -05:00
parent ade0ed4754
commit 2f10811afe
3 changed files with 25 additions and 17 deletions

View File

@ -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)

View File

@ -243,6 +243,8 @@ internal sealed class LocalStatsCalculator : IDisposable
}
}
private unsafe List<short> ExtractClassJobLevels(PlayerState* playerState)
{
List<short> levels = new();

View File

@ -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);