mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Add support for jumping to Designs from Automated Design tab (later IPC probably).
This commit is contained in:
parent
56ad7dc968
commit
b47164ad4f
5 changed files with 83 additions and 18 deletions
33
Glamourer/Events/TabSelected.cs
Normal file
33
Glamourer/Events/TabSelected.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Gui;
|
||||
using OtterGui.Classes;
|
||||
|
||||
namespace Glamourer.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an automated design is changed in any way.
|
||||
/// <list type="number">
|
||||
/// <item>Parameter is the tab to select. </item>
|
||||
/// <item>Parameter is the design to select if the tab is the designs tab. </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public sealed class TabSelected : EventWrapper<Action<MainWindow.TabType, Design?>,
|
||||
TabSelected.Priority>
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
/// <seealso cref="Gui.Tabs.DesignTab.DesignFileSystemSelector.OnTabSelected"/>
|
||||
DesignSelector = 0,
|
||||
|
||||
/// <seealso cref="Gui.MainWindow.OnTabSelected"/>
|
||||
MainWindow = 1,
|
||||
}
|
||||
|
||||
public TabSelected()
|
||||
: base(nameof(TabSelected))
|
||||
{ }
|
||||
|
||||
public void Invoke(MainWindow.TabType type, Design? design)
|
||||
=> Invoke(this, type, design);
|
||||
}
|
||||
|
|
@ -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";
|
||||
|
||||
|
||||
/// <summary> Draw the support button group on the right-hand side of the window. </summary>
|
||||
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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Design>
|
|||
{
|
||||
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<Design>
|
|||
|
||||
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<Design>
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
private readonly DesignChanged _event;
|
||||
private readonly Configuration _config;
|
||||
private readonly DesignConverter _converter;
|
||||
private readonly TabSelected _selectionEvent;
|
||||
|
||||
private string? _clipboardText;
|
||||
private Design? _cloneDesign = null;
|
||||
|
|
@ -46,14 +47,16 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
}
|
||||
|
||||
public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, KeyState keyState, DesignChanged @event,
|
||||
Configuration config, DesignConverter converter)
|
||||
Configuration config, DesignConverter converter, TabSelected selectionEvent)
|
||||
: base(fileSystem, keyState)
|
||||
{
|
||||
_designManager = designManager;
|
||||
_event = @event;
|
||||
_config = config;
|
||||
_converter = converter;
|
||||
_designManager = designManager;
|
||||
_event = @event;
|
||||
_config = config;
|
||||
_converter = converter;
|
||||
_selectionEvent = selectionEvent;
|
||||
_event.Subscribe(OnDesignChange, DesignChanged.Priority.DesignFileSystemSelector);
|
||||
_selectionEvent.Subscribe(OnTabSelected, TabSelected.Priority.DesignSelector);
|
||||
|
||||
AddButton(NewDesignButton, 0);
|
||||
AddButton(ImportDesignButton, 10);
|
||||
|
|
@ -79,6 +82,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
{
|
||||
base.Dispose();
|
||||
_event.Unsubscribe(OnDesignChange);
|
||||
_selectionEvent.Unsubscribe(OnTabSelected);
|
||||
}
|
||||
|
||||
public override ISortMode<Design> SortMode
|
||||
|
|
@ -197,6 +201,12 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
_newName = string.Empty;
|
||||
}
|
||||
|
||||
private void OnTabSelected(MainWindow.TabType type, Design? design)
|
||||
{
|
||||
if (type == MainWindow.TabType.Designs && design != null)
|
||||
SelectByValue(design);
|
||||
}
|
||||
|
||||
#region Filters
|
||||
|
||||
private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ public static class ServiceManager
|
|||
.AddSingleton<WeaponLoading>()
|
||||
.AddSingleton<HeadGearVisibilityChanged>()
|
||||
.AddSingleton<WeaponVisibilityChanged>()
|
||||
.AddSingleton<ObjectUnlocked>();
|
||||
.AddSingleton<ObjectUnlocked>()
|
||||
.AddSingleton<TabSelected>();
|
||||
|
||||
private static IServiceCollection AddData(this IServiceCollection services)
|
||||
=> services.AddSingleton<IdentifierService>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue