diff --git a/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs new file mode 100644 index 0000000..03ffb45 --- /dev/null +++ b/Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs @@ -0,0 +1,59 @@ +using System.Linq; +using Glamourer.Automation; +using Glamourer.Designs; +using ImGuiNET; +using OtterGui; +using OtterGui.Raii; +using OtterGui.Widgets; + +namespace Glamourer.Gui.Tabs.AutomationTab; + +public sealed class DesignCombo : FilterComboCache +{ + private readonly AutoDesignManager _manager; + private readonly DesignFileSystem _fileSystem; + + public DesignCombo(AutoDesignManager manager, DesignManager designs, DesignFileSystem fileSystem) + : base(() => designs.Designs.OrderBy(d => d.Name).ToList()) + { + _manager = manager; + _fileSystem = fileSystem; + } + + protected override bool DrawSelectable(int globalIdx, bool selected) + { + var ret = base.DrawSelectable(globalIdx, selected); + + if (_fileSystem.FindLeaf(Items[globalIdx], out var leaf)) + { + var fullName = leaf.FullName(); + if (fullName != Items[globalIdx].Name) + { + using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGui.SameLine(); + ImGuiUtil.RightAlign(fullName); + } + } + + return ret; + } + + public void Draw(AutoDesignSet set, AutoDesign? design, int autoDesignIndex, bool incognito) + { + CurrentSelection = design?.Design ?? (Items.Count > 0 ? Items[0] : null); + CurrentSelectionIdx = design?.Design.Index ?? (Items.Count > 0 ? 0 : -1); + var name = (incognito ? CurrentSelection?.Incognito : CurrentSelection?.Name.Text) ?? string.Empty; + if (Draw("##design", name, string.Empty, ImGui.GetContentRegionAvail().X, + ImGui.GetTextLineHeight()) + && CurrentSelection != null) + { + if (autoDesignIndex >= 0) + _manager.ChangeDesign(set, autoDesignIndex, CurrentSelection); + else + _manager.AddDesign(set, CurrentSelection); + } + } + + protected override string ToString(Design obj) + => obj.Name.Text; +} diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 8e1f574..731caa5 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -33,7 +33,6 @@ public class SetPanel private readonly DesignCombo _designCombo; private readonly JobGroupCombo _jobGroupCombo; private readonly IdentifierDrawer _identifierDrawer; - private readonly CodeService _codeService; private string? _tempName; private int _dragIndex = -1; @@ -41,8 +40,7 @@ public class SetPanel private Action? _endAction; public SetPanel(SetSelector selector, AutoDesignManager manager, DesignManager designs, JobService jobs, ItemUnlockManager itemUnlocks, - CustomizeUnlockManager customizeUnlocks, CustomizationService customizations, IdentifierDrawer identifierDrawer, - CodeService codeService, Configuration config) + CustomizeUnlockManager customizeUnlocks, CustomizationService customizations, IdentifierDrawer identifierDrawer, Configuration config, DesignCombo designCombo) { _selector = selector; _manager = manager; @@ -50,9 +48,8 @@ public class SetPanel _customizeUnlocks = customizeUnlocks; _customizations = customizations; _identifierDrawer = identifierDrawer; - _codeService = codeService; _config = config; - _designCombo = new DesignCombo(_manager, designs); + _designCombo = designCombo; _jobGroupCombo = new JobGroupCombo(manager, jobs); } @@ -368,36 +365,4 @@ public class SetPanel protected override string ToString(JobGroup obj) => obj.Name; } - - private sealed class DesignCombo : FilterComboCache - { - private readonly AutoDesignManager _manager; - private readonly DesignManager _designs; - - public DesignCombo(AutoDesignManager manager, DesignManager designs) - : base(() => designs.Designs.OrderBy(d => d.Name).ToList()) - { - _designs = designs; - _manager = manager; - } - - public void Draw(AutoDesignSet set, AutoDesign? design, int autoDesignIndex, bool incognito) - { - CurrentSelection = design?.Design ?? (Items.Count > 0 ? Items[0] : null); - CurrentSelectionIdx = design?.Design.Index ?? (Items.Count > 0 ? 0 : -1); - var name = (incognito ? CurrentSelection?.Incognito : CurrentSelection?.Name.Text) ?? string.Empty; - if (Draw("##design", name, string.Empty, ImGui.GetContentRegionAvail().X, - ImGui.GetTextLineHeight()) - && CurrentSelection != null) - { - if (autoDesignIndex >= 0) - _manager.ChangeDesign(set, autoDesignIndex, CurrentSelection); - else - _manager.AddDesign(set, CurrentSelection); - } - } - - protected override string ToString(Design obj) - => obj.Name.Text; - } -} +} \ No newline at end of file diff --git a/Glamourer/Services/ServiceManager.cs b/Glamourer/Services/ServiceManager.cs index 294a594..f1c9746 100644 --- a/Glamourer/Services/ServiceManager.cs +++ b/Glamourer/Services/ServiceManager.cs @@ -118,6 +118,7 @@ public static class ServiceManager .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton()