mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Make designs better discernible in the design combo.
This commit is contained in:
parent
b1d1f9c2eb
commit
edb05946dd
3 changed files with 63 additions and 38 deletions
59
Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs
Normal file
59
Glamourer/Gui/Tabs/AutomationTab/DesignCombo.cs
Normal file
|
|
@ -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<Design>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
@ -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<Design>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +118,7 @@ public static class ServiceManager
|
|||
.AddSingleton<DesignFileSystemSelector>()
|
||||
.AddSingleton<DesignPanel>()
|
||||
.AddSingleton<DesignTab>()
|
||||
.AddSingleton<DesignCombo>()
|
||||
.AddSingleton<ModAssociationsTab>()
|
||||
.AddSingleton<DesignDetailTab>()
|
||||
.AddSingleton<UnlockTable>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue