90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Utility;
|
|
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 : ThemedWindow, IPersistableWindowConfig
|
|
{
|
|
private static readonly SidebarNav.Group[] NavGroups = new SidebarNav.Group[4]
|
|
{
|
|
new SidebarNav.Group("Gameplay", new SidebarNav.Item[3]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Cog, "General"),
|
|
new SidebarNav.Item(FontAwesomeIcon.BookOpen, "Quests"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Route, "Navigation")
|
|
}),
|
|
new SidebarNav.Group("Duties", new SidebarNav.Item[2]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Users, "Group Duties"),
|
|
new SidebarNav.Item(FontAwesomeIcon.FistRaised, "Quest Battles")
|
|
}),
|
|
new SidebarNav.Group("Control", new SidebarNav.Item[2]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.StopCircle, "Stop"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Ban, "Blacklist")
|
|
}),
|
|
new SidebarNav.Group("System", new SidebarNav.Item[3]
|
|
{
|
|
new SidebarNav.Item(FontAwesomeIcon.Plug, "Dependencies"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Bell, "Notifications"),
|
|
new SidebarNav.Item(FontAwesomeIcon.Flask, "Advanced")
|
|
})
|
|
};
|
|
|
|
private static readonly int DependenciesPageIndex = NavGroups.SelectMany((SidebarNav.Group g) => g.Items).ToList().FindIndex((SidebarNav.Item i) => i.Label == "Dependencies");
|
|
|
|
private readonly IDalamudPluginInterface _pluginInterface;
|
|
|
|
private readonly Configuration _configuration;
|
|
|
|
private readonly ConfigComponent[] _pages;
|
|
|
|
private int _selectedTab;
|
|
|
|
public WindowConfig WindowConfig => _configuration.ConfigWindowConfig;
|
|
|
|
public ConfigWindow(IDalamudPluginInterface pluginInterface, GeneralConfigComponent generalConfigComponent, QuestsConfigComponent questsConfigComponent, PluginConfigComponent pluginConfigComponent, DutyConfigComponent dutyConfigComponent, SinglePlayerDutyConfigComponent singlePlayerDutyConfigComponent, StopConditionComponent stopConditionComponent, BlacklistConfigComponent blacklistConfigComponent, NavigationConfigComponent navigationConfigComponent, NotificationConfigComponent notificationConfigComponent, DebugConfigComponent debugConfigComponent, Configuration configuration)
|
|
: base("Config - Questionable###QuestionableConfig")
|
|
{
|
|
base.Size = new Vector2(760f, 620f);
|
|
base.SizeCondition = ImGuiCond.FirstUseEver;
|
|
base.SizeConstraints = new WindowSizeConstraints
|
|
{
|
|
MinimumSize = new Vector2(640f, 480f)
|
|
};
|
|
_pluginInterface = pluginInterface;
|
|
_configuration = configuration;
|
|
_pages = new ConfigComponent[10] { generalConfigComponent, questsConfigComponent, navigationConfigComponent, dutyConfigComponent, singlePlayerDutyConfigComponent, stopConditionComponent, blacklistConfigComponent, pluginConfigComponent, notificationConfigComponent, debugConfigComponent };
|
|
generalConfigComponent.OpenDependenciesTab = delegate
|
|
{
|
|
_selectedTab = DependenciesPageIndex;
|
|
};
|
|
}
|
|
|
|
public override void DrawContent()
|
|
{
|
|
_selectedTab = SidebarNav.Draw(NavGroups, _selectedTab);
|
|
using ImRaii.ChildDisposable childDisposable = ImRaii.Child("##qstConfigContent", Vector2.Zero);
|
|
if ((bool)childDisposable)
|
|
{
|
|
using (ImRaii.PushIndent(8f * ImGuiHelpers.GlobalScale))
|
|
{
|
|
_pages[_selectedTab].DrawTab();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SaveWindowConfig()
|
|
{
|
|
_pluginInterface.SavePluginConfig(_configuration);
|
|
}
|
|
}
|