Added auto enroll feature #1

Open
Asuna wants to merge 4 commits from Asuna/Influx:master into master
3 changed files with 25 additions and 17 deletions
Showing only changes of commit 2f10811afe - Show all commits

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;
Review

This is probably missing a Save(true); if I'm not mistaken.

This is probably missing a `Save(true);` if I'm not mistaken.
Review

Thanks!! Fixed and will repush in a sec

Thanks!! Fixed and will repush in a sec
Save(true);
}
if (_clientState is { IsLoggedIn: true, LocalContentId: > 0, LocalPlayer.HomeWorld.RowId: > 0 })
@ -141,7 +142,9 @@ internal sealed class ConfigurationWindow : Window
}
else
{
Outdated
Review

The way this is phrased should probably be running in a IClientState.Login event, and not only when you open the configuration AND this tab in the UI.

The way this is phrased should probably be running in a `IClientState.Login` event, and not only when you open the configuration AND this tab in the UI.
Outdated
Review

Thanks for the input, i made some modifications and will push in a minute

Thanks for the input, i made some modifications and will push in a minute
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);