qstbak/Questionable/Questionable.Windows/ConfigWindow.cs
2025-11-17 11:31:27 +10:00

82 lines
2.8 KiB
C#

using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using LLib.ImGui;
using Questionable.Windows.ConfigComponents;
namespace Questionable.Windows;
internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
{
private readonly IDalamudPluginInterface _pluginInterface;
private readonly GeneralConfigComponent _generalConfigComponent;
private readonly PluginConfigComponent _pluginConfigComponent;
private readonly DutyConfigComponent _dutyConfigComponent;
private readonly SinglePlayerDutyConfigComponent _singlePlayerDutyConfigComponent;
private readonly StopConditionComponent _stopConditionComponent;
private readonly NotificationConfigComponent _notificationConfigComponent;
private readonly DebugConfigComponent _debugConfigComponent;
private readonly Configuration _configuration;
public WindowConfig WindowConfig => _configuration.ConfigWindowConfig;
public ConfigWindow(IDalamudPluginInterface pluginInterface, GeneralConfigComponent generalConfigComponent, PluginConfigComponent pluginConfigComponent, DutyConfigComponent dutyConfigComponent, SinglePlayerDutyConfigComponent singlePlayerDutyConfigComponent, StopConditionComponent stopConditionComponent, NotificationConfigComponent notificationConfigComponent, DebugConfigComponent debugConfigComponent, Configuration configuration, ChangelogWindow changelogWindow)
: base("Config - Questionable###QuestionableConfig", ImGuiWindowFlags.AlwaysAutoResize)
{
_pluginInterface = pluginInterface;
_generalConfigComponent = generalConfigComponent;
_pluginConfigComponent = pluginConfigComponent;
_dutyConfigComponent = dutyConfigComponent;
_singlePlayerDutyConfigComponent = singlePlayerDutyConfigComponent;
_stopConditionComponent = stopConditionComponent;
_notificationConfigComponent = notificationConfigComponent;
_debugConfigComponent = debugConfigComponent;
_configuration = configuration;
base.TitleBarButtons.Add(new TitleBarButton
{
Icon = FontAwesomeIcon.FileAlt,
IconOffset = new Vector2(1.5f, 1f),
Click = delegate
{
changelogWindow.IsOpenAndUncollapsed = true;
},
ShowTooltip = delegate
{
ImGui.BeginTooltip();
ImGui.Text("View Changelog");
ImGui.EndTooltip();
}
});
}
public override void DrawContent()
{
using ImRaii.IEndObject endObject = ImRaii.TabBar("QuestionableConfigTabs");
if (!(!endObject))
{
_generalConfigComponent.DrawTab();
_pluginConfigComponent.DrawTab();
_dutyConfigComponent.DrawTab();
_singlePlayerDutyConfigComponent.DrawTab();
_stopConditionComponent.DrawTab();
_notificationConfigComponent.DrawTab();
_debugConfigComponent.DrawTab();
}
}
public void SaveWindowConfig()
{
_pluginInterface.SavePluginConfig(_configuration);
}
}