diff --git a/Glamourer/Events/TabSelected.cs b/Glamourer/Events/TabSelected.cs
new file mode 100644
index 0000000..f43fee0
--- /dev/null
+++ b/Glamourer/Events/TabSelected.cs
@@ -0,0 +1,33 @@
+using System;
+using Glamourer.Designs;
+using Glamourer.Gui;
+using OtterGui.Classes;
+
+namespace Glamourer.Events;
+
+///
+/// Triggered when an automated design is changed in any way.
+///
+/// - Parameter is the tab to select.
+/// - Parameter is the design to select if the tab is the designs tab.
+///
+///
+public sealed class TabSelected : EventWrapper,
+ TabSelected.Priority>
+{
+ public enum Priority
+ {
+ ///
+ DesignSelector = 0,
+
+ ///
+ MainWindow = 1,
+ }
+
+ public TabSelected()
+ : base(nameof(TabSelected))
+ { }
+
+ public void Invoke(MainWindow.TabType type, Design? design)
+ => Invoke(this, type, design);
+}
diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs
index 7dac26e..25d5d77 100644
--- a/Glamourer/Gui/MainWindow.cs
+++ b/Glamourer/Gui/MainWindow.cs
@@ -2,6 +2,8 @@
using System.Numerics;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
+using Glamourer.Designs;
+using Glamourer.Events;
using Glamourer.Gui.Tabs;
using Glamourer.Gui.Tabs.ActorTab;
using Glamourer.Gui.Tabs.AutomationTab;
@@ -13,7 +15,7 @@ using OtterGui.Widgets;
namespace Glamourer.Gui;
-public class MainWindow : Window
+public class MainWindow : Window, IDisposable
{
public enum TabType
{
@@ -27,8 +29,10 @@ public class MainWindow : Window
}
private readonly Configuration _config;
+ private readonly TabSelected _event;
private readonly ITab[] _tabs;
+
public readonly SettingsTab Settings;
public readonly ActorTab Actors;
public readonly DebugTab Debug;
@@ -39,7 +43,7 @@ public class MainWindow : Window
public TabType SelectTab = TabType.None;
public MainWindow(DalamudPluginInterface pi, Configuration config, SettingsTab settings, ActorTab actors, DesignTab designs,
- DebugTab debugTab, AutomationTab automation, UnlocksTab unlocks)
+ DebugTab debugTab, AutomationTab automation, UnlocksTab unlocks, TabSelected @event)
: base(GetLabel())
{
pi.UiBuilder.DisableGposeUiHide = true;
@@ -54,6 +58,7 @@ public class MainWindow : Window
Automation = automation;
Debug = debugTab;
Unlocks = unlocks;
+ _event = @event;
_config = config;
_tabs = new ITab[]
{
@@ -64,10 +69,14 @@ public class MainWindow : Window
unlocks,
debugTab,
};
+ _event.Subscribe(OnTabSelected, TabSelected.Priority.MainWindow);
IsOpen = _config.DebugMode;
}
+ public void Dispose()
+ => _event.Unsubscribe(OnTabSelected);
+
public override void Draw()
{
if (!TabBar.Draw("##tabs", ImGuiTabBarFlags.None, ToLabel(SelectTab), out var currentTab, () => { }, _tabs))
@@ -103,12 +112,6 @@ public class MainWindow : Window
return TabType.None;
}
- private static string GetLabel()
- => Glamourer.Version.Length == 0
- ? "Glamourer###GlamourerMainWindow"
- : $"Glamourer v{Glamourer.Version}###GlamourerMainWindow";
-
-
/// Draw the support button group on the right-hand side of the window.
public static void DrawSupportButtons()
{
@@ -124,4 +127,12 @@ public class MainWindow : Window
ImGui.SetCursorPos(new Vector2(xPos, ImGui.GetFrameHeightWithSpacing()));
CustomGui.DrawGuideButton(Glamourer.Chat, width);
}
+
+ private void OnTabSelected(TabType type, Design? _)
+ => SelectTab = type;
+
+ private static string GetLabel()
+ => Glamourer.Version.Length == 0
+ ? "Glamourer###GlamourerMainWindow"
+ : $"Glamourer v{Glamourer.Version}###GlamourerMainWindow";
}
diff --git a/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs
index a31601c..65316b8 100644
--- a/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs
+++ b/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs
@@ -1,6 +1,7 @@
using System.Linq;
using Glamourer.Automation;
using Glamourer.Designs;
+using Glamourer.Events;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
@@ -12,12 +13,14 @@ public sealed class DesignCombo : FilterComboCache
{
private readonly AutoDesignManager _manager;
private readonly DesignFileSystem _fileSystem;
+ private readonly TabSelected _tabSelected;
- public DesignCombo(AutoDesignManager manager, DesignManager designs, DesignFileSystem fileSystem)
+ public DesignCombo(AutoDesignManager manager, DesignManager designs, DesignFileSystem fileSystem, TabSelected tabSelected)
: base(() => designs.Designs.OrderBy(d => d.Name).ToList())
{
- _manager = manager;
- _fileSystem = fileSystem;
+ _manager = manager;
+ _fileSystem = fileSystem;
+ _tabSelected = tabSelected;
}
protected override bool DrawSelectable(int globalIdx, bool selected)
@@ -26,7 +29,7 @@ public sealed class DesignCombo : FilterComboCache
if (_fileSystem.FindLeaf(Items[globalIdx], out var leaf))
{
- var fullName = leaf.FullName();
+ var fullName = leaf.FullName();
if (!fullName.StartsWith(Items[globalIdx].Name))
{
using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled));
@@ -52,6 +55,13 @@ public sealed class DesignCombo : FilterComboCache
else
_manager.AddDesign(set, CurrentSelection);
}
+
+ if (design != null)
+ {
+ if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && ImGui.GetIO().KeyCtrl)
+ _tabSelected.Invoke(MainWindow.TabType.Designs, design.Design);
+ ImGuiUtil.HoverTooltip("Control + Right-Click to move to design.");
+ }
}
protected override string ToString(Design obj)
diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs
index 4ada443..02c9750 100644
--- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs
+++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs
@@ -22,6 +22,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector SortMode
@@ -197,6 +201,12 @@ public sealed class DesignFileSystemSelector : FileSystemSelector()
.AddSingleton()
.AddSingleton()
- .AddSingleton();
+ .AddSingleton()
+ .AddSingleton();
private static IServiceCollection AddData(this IServiceCollection services)
=> services.AddSingleton()