Files
HSRTools/HSRTools/UI/ConfigWindow.cs
T

125 lines
5.3 KiB
C#

using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Windowing;
using HSRTools.Configuration;
namespace HSRTools.UI;
public sealed class ConfigWindow : Window
{
private readonly HSRToolsConfiguration _config;
private string _triggerTextInput = string.Empty;
private bool _caseSensitive;
private bool _triggerExactMatch;
private bool _monitorFreeCompany;
private bool _monitorLinkShell;
private bool _monitorCrossWorldLinkShell;
private bool _monitorTell;
private bool _enabled;
private bool _debug;
private bool _autoAcceptEnabled;
private bool _autoAcceptFromFriends;
private bool _autoAcceptFromFreeCompany;
private bool _autoAcceptScanAddons;
private bool _cacheFriendsAndFcOnLogin;
public ConfigWindow(HSRToolsConfiguration config)
: base("HSRTools Configuration", ImGuiWindowFlags.AlwaysAutoResize)
{
_config = config;
SyncFromConfig();
}
private void SyncFromConfig()
{
_triggerTextInput = _config.TriggerText ?? string.Empty;
_caseSensitive = _config.CaseSensitive;
_triggerExactMatch = _config.TriggerExactMatch;
_monitorFreeCompany = _config.MonitorFreeCompany;
_monitorLinkShell = _config.MonitorLinkShell;
_monitorCrossWorldLinkShell = _config.MonitorCrossWorldLinkShell;
_monitorTell = _config.MonitorTell;
_enabled = _config.Enabled;
_debug = _config.Debug;
_autoAcceptEnabled = _config.AutoAcceptEnabled;
_autoAcceptFromFriends = _config.AutoAcceptFromFriends;
_autoAcceptFromFreeCompany = _config.AutoAcceptFromFreeCompany;
_autoAcceptScanAddons = _config.AutoAcceptScanAddons;
_cacheFriendsAndFcOnLogin = _config.CacheFriendsAndFcOnLogin;
}
public override void Draw()
{
if (ImGui.Button("Reset to defaults"))
{
_config.TriggerText = "inv";
_config.CaseSensitive = false;
_config.TriggerExactMatch = false;
_config.MonitorFreeCompany = true;
_config.MonitorLinkShell = true;
_config.MonitorCrossWorldLinkShell = true;
_config.MonitorTell = true;
_config.Enabled = true;
_config.Debug = false;
_config.AutoAcceptEnabled = false;
_config.AutoAcceptFromFriends = true;
_config.AutoAcceptFromFreeCompany = true;
_config.AutoAcceptScanAddons = false;
_config.CacheFriendsAndFcOnLogin = true;
SyncFromConfig();
}
ImGui.Separator();
ImGui.Checkbox("Plugin enabled", ref _enabled);
_config.Enabled = _enabled;
ImGui.Spacing();
ImGui.Text("Trigger text (word or phrase that triggers an invite when seen in chat):");
if (ImGui.InputText("##trigger", ref _triggerTextInput, 128))
_config.TriggerText = _triggerTextInput.Trim();
if (ImGui.Checkbox("Case sensitive", ref _caseSensitive))
_config.CaseSensitive = _caseSensitive;
if (ImGui.Checkbox("Exact match (whole message must equal trigger)", ref _triggerExactMatch))
_config.TriggerExactMatch = _triggerExactMatch;
ImGui.Separator();
ImGui.Text("Monitor these channels:");
ImGui.Indent();
if (ImGui.Checkbox("Free Company", ref _monitorFreeCompany))
_config.MonitorFreeCompany = _monitorFreeCompany;
if (ImGui.Checkbox("Link Shell (1-8)", ref _monitorLinkShell))
_config.MonitorLinkShell = _monitorLinkShell;
if (ImGui.Checkbox("Cross-World Link Shell (1-8)", ref _monitorCrossWorldLinkShell))
_config.MonitorCrossWorldLinkShell = _monitorCrossWorldLinkShell;
if (ImGui.Checkbox("Tells / Whispers", ref _monitorTell))
_config.MonitorTell = _monitorTell;
ImGui.Unindent();
ImGui.Separator();
if (ImGui.Checkbox("Debug logging (diagnose cross-world invite)", ref _debug))
_config.Debug = _debug;
ImGui.Separator();
ImGui.Text("Auto-accept party invites:");
ImGui.Indent();
if (ImGui.Checkbox("Auto-accept from friends and FC members", ref _autoAcceptEnabled))
_config.AutoAcceptEnabled = _autoAcceptEnabled;
if (_autoAcceptEnabled)
{
if (ImGui.Checkbox(" From friends", ref _autoAcceptFromFriends))
_config.AutoAcceptFromFriends = _autoAcceptFromFriends;
if (ImGui.Checkbox(" From Free Company members", ref _autoAcceptFromFreeCompany))
_config.AutoAcceptFromFreeCompany = _autoAcceptFromFreeCompany;
}
if (ImGui.Checkbox("Scan mode: log all addons that open", ref _autoAcceptScanAddons))
_config.AutoAcceptScanAddons = _autoAcceptScanAddons;
if (_autoAcceptScanAddons)
ImGui.TextColored(new System.Numerics.Vector4(1, 0.8f, 0, 1), " Enable, get a party invite, check log for addon name. Disable after.");
if (ImGui.Checkbox("Cache friends & FC on login", ref _cacheFriendsAndFcOnLogin))
_config.CacheFriendsAndFcOnLogin = _cacheFriendsAndFcOnLogin;
if (_cacheFriendsAndFcOnLogin)
ImGui.TextColored(new System.Numerics.Vector4(0.7f, 0.7f, 0.7f, 1f), " Opens Friends and FC windows briefly on login to cache names, then closes them.");
ImGui.Unindent();
}
}