Settings button can now select specific tab
This commit is contained in:
@@ -74,6 +74,12 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
SettingsWindow.BringToFront();
|
SettingsWindow.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OpenSettingsTab(string selectedTabLabel)
|
||||||
|
{
|
||||||
|
OpenSettingsWindow();
|
||||||
|
SettingsWindow.SelectTab(selectedTabLabel);
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
SimulatorWindow?.Dispose();
|
SimulatorWindow?.Dispose();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
|
|||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGuiComponents.IconButton("synthSettingsButton", FontAwesomeIcon.Cog))
|
if (ImGuiComponents.IconButton("synthSettingsButton", FontAwesomeIcon.Cog))
|
||||||
Service.Plugin.OpenSettingsWindow();
|
Service.Plugin.OpenSettingsTab(Settings.TabSynthHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawActions()
|
private void DrawActions()
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ public class Settings : Window
|
|||||||
private const int OptionWidth = 200;
|
private const int OptionWidth = 200;
|
||||||
private static Vector2 OptionButtonSize => new(OptionWidth, ImGuiUtils.ButtonHeight);
|
private static Vector2 OptionButtonSize => new(OptionWidth, ImGuiUtils.ButtonHeight);
|
||||||
|
|
||||||
|
public const string TabGeneral = "General";
|
||||||
|
public const string TabSimulator = "Simulator";
|
||||||
|
public const string TabSynthHelper = "Synthesis Helper";
|
||||||
|
public const string TabAbout = "About";
|
||||||
|
|
||||||
|
private string? SelectedTab { get; set; }
|
||||||
|
|
||||||
public Settings() : base("Craftimizer Settings")
|
public Settings() : base("Craftimizer Settings")
|
||||||
{
|
{
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
@@ -27,6 +34,23 @@ public class Settings : Window
|
|||||||
SizeCondition = ImGuiCond.Appearing;
|
SizeCondition = ImGuiCond.Appearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SelectTab(string label)
|
||||||
|
{
|
||||||
|
SelectedTab = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool BeginTabItem(string label)
|
||||||
|
{
|
||||||
|
var isSelected = string.Equals(SelectedTab, label, StringComparison.Ordinal);
|
||||||
|
if (isSelected)
|
||||||
|
{
|
||||||
|
SelectedTab = null;
|
||||||
|
var open = true;
|
||||||
|
return ImGui.BeginTabItem(label, ref open, ImGuiTabItemFlags.SetSelected);
|
||||||
|
}
|
||||||
|
return ImGui.BeginTabItem(label);
|
||||||
|
}
|
||||||
|
|
||||||
private static void DrawOption(string label, string tooltip, bool val, Action<bool> setter, ref bool isDirty)
|
private static void DrawOption(string label, string tooltip, bool val, Action<bool> setter, ref bool isDirty)
|
||||||
{
|
{
|
||||||
if (ImGui.Checkbox(label, ref val))
|
if (ImGui.Checkbox(label, ref val))
|
||||||
@@ -101,9 +125,9 @@ public class Settings : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawTabGeneral()
|
private void DrawTabGeneral()
|
||||||
{
|
{
|
||||||
if (!ImGui.BeginTabItem("General"))
|
if (!BeginTabItem("General"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
ImGuiHelpers.ScaledDummy(5);
|
||||||
@@ -352,9 +376,9 @@ public class Settings : Window
|
|||||||
configRef = config;
|
configRef = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawTabSimulator()
|
private void DrawTabSimulator()
|
||||||
{
|
{
|
||||||
if (!ImGui.BeginTabItem("Simulator"))
|
if (!BeginTabItem("Simulator"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
ImGuiHelpers.ScaledDummy(5);
|
||||||
@@ -397,9 +421,9 @@ public class Settings : Window
|
|||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawTabSynthHelper()
|
private void DrawTabSynthHelper()
|
||||||
{
|
{
|
||||||
if (!ImGui.BeginTabItem("Synthesis Helper"))
|
if (!BeginTabItem("Synthesis Helper"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
ImGuiHelpers.ScaledDummy(5);
|
||||||
@@ -432,9 +456,9 @@ public class Settings : Window
|
|||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawTabAbout()
|
private void DrawTabAbout()
|
||||||
{
|
{
|
||||||
if (!ImGui.BeginTabItem("About"))
|
if (!BeginTabItem("About"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
ImGuiHelpers.ScaledDummy(5);
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ public sealed partial class Simulator : Window, IDisposable
|
|||||||
ImGui.PopFont();
|
ImGui.PopFont();
|
||||||
ImGui.SameLine(0, totalWidth - ImGui.GetStyle().ItemSpacing.X - checkboxWidth - cogWidth);
|
ImGui.SameLine(0, totalWidth - ImGui.GetStyle().ItemSpacing.X - checkboxWidth - cogWidth);
|
||||||
if (ImGuiComponents.IconButton("simSettingsButton", FontAwesomeIcon.Cog))
|
if (ImGuiComponents.IconButton("simSettingsButton", FontAwesomeIcon.Cog))
|
||||||
Service.Plugin.OpenSettingsWindow();
|
Service.Plugin.OpenSettingsTab(Settings.TabSimulator);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user