MouseWheels are pretty great.

This commit is contained in:
Ottermandias 2024-02-05 15:21:29 +01:00
parent 5e37f8d2e8
commit 1fefe7366c
22 changed files with 250 additions and 88 deletions

View file

@ -26,6 +26,7 @@ public sealed class Design : DesignBase, ISavable
{
Tags = [.. other.Tags];
Description = other.Description;
QuickDesign = other.QuickDesign;
AssociatedMods = new SortedList<Mod, ModSettings>(other.AssociatedMods);
}
@ -39,6 +40,7 @@ public sealed class Design : DesignBase, ISavable
public string Description { get; internal set; } = string.Empty;
public string[] Tags { get; internal set; } = [];
public int Index { get; internal set; }
public bool QuickDesign { get; internal set; } = true;
public string Color { get; internal set; } = string.Empty;
public SortedList<Mod, ModSettings> AssociatedMods { get; private set; } = [];
public LinkContainer Links { get; private set; } = [];
@ -64,6 +66,7 @@ public sealed class Design : DesignBase, ISavable
["Name"] = Name.Text,
["Description"] = Description,
["Color"] = Color,
["QuickDesign"] = QuickDesign,
["Tags"] = JArray.FromObject(Tags),
["WriteProtected"] = WriteProtected(),
["Equipment"] = SerializeEquipment(),
@ -124,6 +127,7 @@ public sealed class Design : DesignBase, ISavable
Description = json["Description"]?.ToObject<string>() ?? string.Empty,
Tags = ParseTags(json),
LastEdit = json["LastEdit"]?.ToObject<DateTimeOffset>() ?? creationDate,
QuickDesign = json["QuickDesign"]?.ToObject<bool>() ?? true,
};
if (design.LastEdit < creationDate)
design.LastEdit = creationDate;

View file

@ -284,6 +284,18 @@ public sealed class DesignManager : DesignEditor
DesignChanged.Invoke(DesignChanged.Type.WriteProtection, design, value);
}
/// <summary> Set the quick design bar display status of a design. </summary>
public void SetQuickDesign(Design design, bool value)
{
if (value == design.QuickDesign)
return;
design.QuickDesign = value;
SaveService.QueueSave(design);
Glamourer.Log.Debug($"Set design {design.Identifier} to {(!value ? "no longer be " : string.Empty)} displayed in the quick design bar.");
DesignChanged.Invoke(DesignChanged.Type.QuickDesignBar, design, value);
}
#endregion
#region Edit Application Rules

View file

@ -92,6 +92,9 @@ public sealed class DesignChanged()
/// <summary> An existing design changed its write protection status. Data is the new value [bool]. </summary>
WriteProtection,
/// <summary> An existing design changed its display status for the quick design bar. Data is the new value [bool]. </summary>
QuickDesignBar,
/// <summary> An existing design changed one of the meta flags. Data is the flag, whether it was about their applying and the new value [(MetaFlag, bool, bool)]. </summary>
Other,
}

View file

@ -23,6 +23,11 @@ public partial class CustomizationDrawer
{
if (ImGui.ColorButton($"{_customize[index].Value}##color", color, ImGuiColorEditFlags.None, _framedIconSize))
ImGui.OpenPopup(ColorPickerPopupName);
else if (current >= 0 && CaptureMouseWheel(ref current, 0, _currentCount))
{
var data = _set.Data(_currentIndex, current, _customize.Face);
UpdateValue(data.Value);
}
}
var npc = false;

View file

@ -18,8 +18,9 @@ public partial class CustomizationDrawer
using var bigGroup = ImRaii.Group();
var label = _currentOption;
var current = _set.DataByValue(index, _currentByte, out var custom, _customize.Face);
var npc = false;
var current = _set.DataByValue(index, _currentByte, out var custom, _customize.Face);
var originalCurrent = current;
var npc = false;
if (current < 0)
{
label = $"{_currentOption} (NPC)";
@ -32,7 +33,14 @@ public partial class CustomizationDrawer
using (_ = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw))
{
if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize))
{
ImGui.OpenPopup(IconSelectorPopup);
}
else if (originalCurrent >= 0 && CaptureMouseWheel(ref current, 0, _currentCount))
{
var data = _set.Data(_currentIndex, current, _customize.Face);
UpdateValue(data.Value);
}
}
ImGuiUtil.HoverIconTooltip(icon, _iconSize);

View file

@ -1,6 +1,7 @@
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGuiInternal;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
@ -34,7 +35,8 @@ public partial class CustomizationDrawer
{
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_comboSelectorSize);
if (ImGui.SliderInt("##slider", ref tmp, 0, _currentCount - 1, "%i", ImGuiSliderFlags.AlwaysClamp))
if (ImGui.SliderInt("##slider", ref tmp, 0, _currentCount - 1, "%i", ImGuiSliderFlags.AlwaysClamp)
|| CaptureMouseWheel(ref tmp, 0, _currentCount - 1))
UpdateValue((CustomizeValue)tmp);
}
@ -42,11 +44,10 @@ public partial class CustomizationDrawer
{
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_inputIntSize);
var cap = ImGui.GetIO().KeyCtrl ? byte.MaxValue : _currentCount - 1;
if (ImGui.InputInt("##text", ref tmp, 1, 1))
{
var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl
? Math.Clamp(tmp, 0, byte.MaxValue)
: Math.Clamp(tmp, 0, _currentCount - 1));
var newValue = (CustomizeValue)Math.Clamp(tmp, 0, cap);
UpdateValue(newValue);
}
@ -73,6 +74,10 @@ public partial class CustomizationDrawer
else if (ImGui.GetIO().KeyCtrl)
UpdateValue((CustomizeValue)value);
}
else
{
CheckWheel();
}
if (!_withApply)
ImGuiUtil.HoverTooltip("Hold Control to force updates with invalid/unknown options at your own risk.");
@ -81,15 +86,29 @@ public partial class CustomizationDrawer
if (ImGuiUtil.DrawDisabledButton("-", new Vector2(ImGui.GetFrameHeight()), "Select the previous available option in order.",
currentIndex <= 0))
UpdateValue(_set.Data(_currentIndex, currentIndex - 1, _customize.Face).Value);
else
CheckWheel();
ImGui.SameLine();
if (ImGuiUtil.DrawDisabledButton("+", new Vector2(ImGui.GetFrameHeight()), "Select the next available option in order.",
currentIndex >= _currentCount - 1 || npc))
UpdateValue(_set.Data(_currentIndex, currentIndex + 1, _customize.Face).Value);
else
CheckWheel();
return;
void CheckWheel()
{
if (currentIndex < 0 || !CaptureMouseWheel(ref currentIndex, 0, _currentCount))
return;
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateValue(data.Value);
}
}
private void DrawListSelector(CustomizeIndex index, bool indexedBy1)
{
using var id = SetId(index);
using var id = SetId(index);
using var bigGroup = ImRaii.Group();
using (_ = ImRaii.Disabled(_locked))
@ -122,29 +141,31 @@ public partial class CustomizationDrawer
private void ListCombo0()
{
ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale);
var current = _currentByte.Value;
using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current + 1}");
if (!combo)
return;
for (var i = 0; i < _currentCount; ++i)
var current = (int)_currentByte.Value;
using (var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current + 1}"))
{
if (ImGui.Selectable($"{_currentOption} #{i + 1}##combo", i == current))
UpdateValue((CustomizeValue)i);
if (combo)
for (var i = 0; i < _currentCount; ++i)
{
if (ImGui.Selectable($"{_currentOption} #{i + 1}##combo", i == current))
UpdateValue((CustomizeValue)i);
}
}
if (CaptureMouseWheel(ref current, 0, _currentCount))
UpdateValue((CustomizeValue)current);
}
private void ListInputInt0()
{
var tmp = _currentByte.Value + 1;
ImGui.SetNextItemWidth(_inputIntSize);
var cap = ImGui.GetIO().KeyCtrl ? byte.MaxValue + 1 : _currentCount;
if (ImGui.InputInt("##text", ref tmp, 1, 1))
{
var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl
? Math.Clamp(tmp, 1, byte.MaxValue + 1)
: Math.Clamp(tmp, 1, _currentCount));
UpdateValue(newValue - 1);
var newValue = Math.Clamp(tmp, 1, cap);
UpdateValue((CustomizeValue)(newValue - 1));
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]\n"
@ -154,28 +175,29 @@ public partial class CustomizationDrawer
private void ListCombo1()
{
ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale);
var current = _currentByte.Value;
using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current}");
if (!combo)
return;
for (var i = 1; i <= _currentCount; ++i)
var current = (int)_currentByte.Value;
using (var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current}"))
{
if (ImGui.Selectable($"{_currentOption} #{i}##combo", i == current))
UpdateValue((CustomizeValue)i);
if (combo)
for (var i = 1; i <= _currentCount; ++i)
{
if (ImGui.Selectable($"{_currentOption} #{i}##combo", i == current))
UpdateValue((CustomizeValue)i);
}
}
if (CaptureMouseWheel(ref current, 1, _currentCount))
UpdateValue((CustomizeValue)current);
}
private void ListInputInt1()
{
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_inputIntSize);
var (offset, cap) = ImGui.GetIO().KeyCtrl ? (0, byte.MaxValue) : (1, _currentCount);
if (ImGui.InputInt("##text", ref tmp, 1, 1))
{
var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl
? Math.Clamp(tmp, 0, byte.MaxValue)
: Math.Clamp(tmp, 1, _currentCount));
var newValue = (CustomizeValue)Math.Clamp(tmp, offset, cap);
UpdateValue(newValue);
}
@ -183,6 +205,26 @@ public partial class CustomizationDrawer
+ "Hold Control to force updates with invalid/unknown options at your own risk.");
}
private static bool CaptureMouseWheel(ref int value, int offset, int cap)
{
if (!ImGui.IsItemHovered())
return false;
ImGuiInternal.ItemSetUsingMouseWheel();
var mw = (int)ImGui.GetIO().MouseWheel;
if (mw == 0)
return false;
value -= offset;
value = mw switch
{
< 0 => offset + (value + cap + mw) % cap,
_ => offset + (value + mw) % cap,
};
return true;
}
// Draw a customize checkbox.
private void DrawCheckbox(CustomizeIndex idx)
{

View file

@ -1,7 +1,6 @@
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Glamourer.Automation;
using Glamourer.GameData;
using Glamourer.Designs;
using Glamourer.Events;
using Glamourer.Services;
@ -25,7 +24,7 @@ public abstract class DesignComboBase : FilterComboCache<Tuple<Design, string>>,
protected DesignComboBase(Func<IReadOnlyList<Tuple<Design, string>>> generator, Logger log, DesignChanged designChanged,
TabSelected tabSelected, EphemeralConfig config, DesignColors designColors)
: base(generator, log)
: base(generator, MouseWheelType.Unmodified, log)
{
_designChanged = designChanged;
TabSelected = tabSelected;
@ -38,7 +37,10 @@ public abstract class DesignComboBase : FilterComboCache<Tuple<Design, string>>,
=> _config.IncognitoMode;
void IDisposable.Dispose()
=> _designChanged.Unsubscribe(OnDesignChange);
{
_designChanged.Unsubscribe(OnDesignChange);
GC.SuppressFinalize(this);
}
protected override bool DrawSelectable(int globalIdx, bool selected)
{
@ -118,63 +120,87 @@ public abstract class DesignComboBase : FilterComboCache<Tuple<Design, string>>,
{
case DesignChanged.Type.Created:
case DesignChanged.Type.Renamed:
Cleanup();
break;
case DesignChanged.Type.ChangedColor:
case DesignChanged.Type.Deleted:
Cleanup();
if (CurrentSelection?.Item1 == design)
case DesignChanged.Type.QuickDesignBar:
var priorState = IsInitialized;
if (priorState)
Cleanup();
CurrentSelectionIdx = Items.IndexOf(s => ReferenceEquals(s.Item1, CurrentSelection?.Item1));
if (CurrentSelectionIdx >= 0)
{
CurrentSelectionIdx = Items.Count > 0 ? 0 : -1;
CurrentSelection = Items[CurrentSelectionIdx];
CurrentSelection = Items[CurrentSelectionIdx];
}
else if (Items.Count > 0)
{
CurrentSelectionIdx = 0;
CurrentSelection = Items[0];
}
else
{
CurrentSelection = null;
}
if (!priorState)
Cleanup();
break;
}
}
}
public sealed class DesignCombo : DesignComboBase
public abstract class DesignCombo : DesignComboBase
{
private readonly DesignManager _manager;
public DesignCombo(DesignManager designs, DesignFileSystem fileSystem, Logger log, DesignChanged designChanged, TabSelected tabSelected,
EphemeralConfig config, DesignColors designColors)
: base(() => designs.Designs
.Select(d => new Tuple<Design, string>(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty))
.OrderBy(d => d.Item2)
.ToList(), log, designChanged, tabSelected, config, designColors)
protected DesignCombo(Logger log, DesignChanged designChanged, TabSelected tabSelected,
EphemeralConfig config, DesignColors designColors, Func<IReadOnlyList<Tuple<Design, string>>> generator)
: base(generator, log, designChanged, tabSelected, config, designColors)
{
_manager = designs;
if (designs.Designs.Count == 0)
if (Items.Count == 0)
return;
CurrentSelection = Items[0];
CurrentSelectionIdx = 0;
base.Cleanup();
}
public Design? Design
=> CurrentSelection?.Item1;
public void Draw(float width)
{
Draw(Design, (Incognito ? Design?.Incognito : Design?.Name.Text) ?? string.Empty, width);
if (ImGui.IsItemHovered() && _manager.Designs.Count > 1)
{
var mouseWheel = -(int)ImGui.GetIO().MouseWheel % _manager.Designs.Count;
CurrentSelectionIdx = mouseWheel switch
{
< 0 when CurrentSelectionIdx < 0 => _manager.Designs.Count - 1 + mouseWheel,
< 0 => (CurrentSelectionIdx + _manager.Designs.Count + mouseWheel) % _manager.Designs.Count,
> 0 when CurrentSelectionIdx < 0 => mouseWheel,
> 0 => (CurrentSelectionIdx + mouseWheel) % _manager.Designs.Count,
_ => CurrentSelectionIdx,
};
CurrentSelection = Items[CurrentSelectionIdx];
}
}
=> Draw(Design, (Incognito ? Design?.Incognito : Design?.Name.Text) ?? string.Empty, width);
}
public sealed class RevertDesignCombo : DesignComboBase, IDisposable
public sealed class QuickDesignCombo(
DesignManager designs,
DesignFileSystem fileSystem,
Logger log,
DesignChanged designChanged,
TabSelected tabSelected,
EphemeralConfig config,
DesignColors designColors)
: DesignCombo(log, designChanged, tabSelected, config, designColors, () =>
[
.. designs.Designs
.Where(d => d.QuickDesign)
.Select(d => new Tuple<Design, string>(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty))
.OrderBy(d => d.Item2),
]);
public sealed class LinkDesignCombo(
DesignManager designs,
DesignFileSystem fileSystem,
Logger log,
DesignChanged designChanged,
TabSelected tabSelected,
EphemeralConfig config,
DesignColors designColors)
: DesignCombo(log, designChanged, tabSelected, config, designColors, () =>
[
.. designs.Designs
.Select(d => new Tuple<Design, string>(d, fileSystem.FindLeaf(d, out var l) ? l.FullName() : string.Empty))
.OrderBy(d => d.Item2),
]);
public sealed class RevertDesignCombo : DesignComboBase
{
public const int RevertDesignIndex = -1228;
public readonly Design RevertDesign;

View file

@ -24,7 +24,7 @@ public sealed class DesignQuickBar : Window, IDisposable
: ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoFocusOnAppearing;
private readonly Configuration _config;
private readonly DesignCombo _designCombo;
private readonly QuickDesignCombo _designCombo;
private readonly StateManager _stateManager;
private readonly AutoDesignApplier _autoDesignApplier;
private readonly ObjectManager _objects;
@ -34,7 +34,7 @@ public sealed class DesignQuickBar : Window, IDisposable
private DateTime _keyboardToggle = DateTime.UnixEpoch;
private int _numButtons;
public DesignQuickBar(Configuration config, DesignCombo designCombo, StateManager stateManager, IKeyState keyState,
public DesignQuickBar(Configuration config, QuickDesignCombo designCombo, StateManager stateManager, IKeyState keyState,
ObjectManager objects, AutoDesignApplier autoDesignApplier)
: base("Glamourer Quick Bar", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDocking)
{
@ -299,7 +299,8 @@ public sealed class DesignQuickBar : Window, IDisposable
(true, false) => 3,
(false, false) => 2,
};
Size = new Vector2((7 + _numButtons) * ImGui.GetFrameHeight() + _numButtons * ImGui.GetStyle().ItemInnerSpacing.X, ImGui.GetFrameHeight());
Size = new Vector2((7 + _numButtons) * ImGui.GetFrameHeight() + _numButtons * ImGui.GetStyle().ItemInnerSpacing.X,
ImGui.GetFrameHeight());
return Size.Value.X;
}
}

View file

@ -10,7 +10,7 @@ using Penumbra.GameData.Structs;
namespace Glamourer.Gui.Equipment;
public sealed class GlamourerColorCombo(float _comboWidth, DictStain _stains, FavoriteManager _favorites)
: FilterComboColors(_comboWidth, CreateFunc(_stains, _favorites), Glamourer.Log)
: FilterComboColors(_comboWidth, MouseWheelType.Unmodified, CreateFunc(_stains, _favorites), Glamourer.Log)
{
protected override bool DrawSelectable(int globalIdx, bool selected)
{
@ -36,6 +36,9 @@ public sealed class GlamourerColorCombo(float _comboWidth, DictStain _stains, Fa
return base.DrawSelectable(globalIdx, selected);
}
public override bool Draw(string label, uint color, string name, bool found, bool gloss, float previewWidth)
=> base.Draw(label, color, name, found, gloss, previewWidth);
private static Func<IReadOnlyList<KeyValuePair<byte, (string Name, uint Color, bool Gloss)>>> CreateFunc(DictStain stains,
FavoriteManager favorites)
=> () => stains.Select(kvp => (kvp, favorites.Contains(kvp.Key))).OrderBy(p => !p.Item2).Select(p => p.kvp)

View file

@ -24,7 +24,7 @@ public sealed class ItemCombo : FilterComboCache<EquipItem>
public Variant CustomVariant { get; private set; }
public ItemCombo(IDataManager gameData, ItemManager items, EquipSlot slot, Logger log, FavoriteManager favorites)
: base(() => GetItems(favorites, items, slot), log)
: base(() => GetItems(favorites, items, slot), MouseWheelType.Unmodified, log)
{
_favorites = favorites;
Label = GetLabel(gameData, slot);

View file

@ -17,7 +17,7 @@ public sealed class WeaponCombo : FilterComboCache<EquipItem>
private float _innerWidth;
public WeaponCombo(ItemManager items, FullEquipType type, Logger log)
: base(() => GetWeapons(items, type), log)
: base(() => GetWeapons(items, type), MouseWheelType.Unmodified, log)
{
Label = GetLabel(type);
SearchByParts = true;

View file

@ -16,7 +16,7 @@ public sealed class HumanNpcCombo(
DictBNpc bNpcs,
HumanModelList humans,
Logger log)
: FilterComboCache<(string Name, ObjectKind Kind, uint[] Ids)>(() => CreateList(modelCharaDict, bNpcNames, bNpcs, humans), log)
: FilterComboCache<(string Name, ObjectKind Kind, uint[] Ids)>(() => CreateList(modelCharaDict, bNpcNames, bNpcs, humans), MouseWheelType.None, log)
{
protected override string ToString((string Name, ObjectKind Kind, uint[] Ids) obj)
=> obj.Name;

View file

@ -429,7 +429,7 @@ public class SetPanel(
}
private sealed class JobGroupCombo(AutoDesignManager manager, JobService jobs, Logger log)
: FilterComboCache<JobGroup>(() => jobs.JobGroups.Values.ToList(), log)
: FilterComboCache<JobGroup>(() => jobs.JobGroups.Values.ToList(), MouseWheelType.None, log)
{
public void Draw(AutoDesignSet set, AutoDesign design, int autoDesignIndex)
{

View file

@ -10,8 +10,15 @@ public sealed class DesignColorCombo(DesignColors _designColors, bool _skipAutom
FilterComboCache<string>(_skipAutomatic
? _designColors.Keys.OrderBy(k => k)
: _designColors.Keys.OrderBy(k => k).Prepend(DesignColors.AutomaticName),
Glamourer.Log)
MouseWheelType.Shift, Glamourer.Log)
{
protected override void OnMouseWheel(string preview, ref int current, int steps)
{
if (CurrentSelectionIdx < 0)
CurrentSelectionIdx = Items.IndexOf(preview);
base.OnMouseWheel(preview, ref current, steps);
}
protected override bool DrawSelectable(int globalIdx, bool selected)
{
var isAutomatic = !_skipAutomatic && globalIdx == 0;

View file

@ -125,10 +125,23 @@ public class DesignDetailTab
Glamourer.Messager.NotificationMessage(ex, ex.Message, "Could not rename or move design", NotificationType.Error);
}
ImGuiUtil.DrawFrameColumn("Quick Design Bar");
ImGui.TableNextColumn();
if (ImGui.RadioButton("Display##qdb", _selector.Selected.QuickDesign))
_manager.SetQuickDesign(_selector.Selected!, true);
var hovered = ImGui.IsItemHovered();
ImGui.SameLine();
if (ImGui.RadioButton("Hide##qdb", !_selector.Selected.QuickDesign))
_manager.SetQuickDesign(_selector.Selected!, false);
if (hovered || ImGui.IsItemHovered())
ImGui.SetTooltip("Display or hide this design in your quick design bar.");
ImGuiUtil.DrawFrameColumn("Color");
var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color;
ImGui.TableNextColumn();
if (_colorCombo.Draw("##colorCombo", colorName, "Associate a color with this design. Right-Click to revert to automatic coloring.",
if (_colorCombo.Draw("##colorCombo", colorName, "Associate a color with this design.\n"
+ "Right-Click to revert to automatic coloring.\n"
+ "Hold Control and scroll the mousewheel to scroll.",
width.X - ImGui.GetStyle().ItemSpacing.X - ImGui.GetFrameHeight(), ImGui.GetTextLineHeight())
&& _colorCombo.CurrentSelection != null)
{

View file

@ -10,7 +10,7 @@ using OtterGui.Services;
namespace Glamourer.Gui.Tabs.DesignTab;
public class DesignLinkDrawer(DesignLinkManager _linkManager, DesignFileSystemSelector _selector, DesignCombo _combo) : IUiService
public class DesignLinkDrawer(DesignLinkManager _linkManager, DesignFileSystemSelector _selector, LinkDesignCombo _combo) : IUiService
{
private int _dragDropIndex = -1;
private LinkOrder _dragDropOrder = LinkOrder.None;

View file

@ -11,7 +11,7 @@ namespace Glamourer.Gui.Tabs.DesignTab;
public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings)>
{
public ModCombo(PenumbraService penumbra, Logger log)
: base(penumbra.GetMods, log)
: base(penumbra.GetMods, MouseWheelType.None, log)
{
SearchByParts = false;
}

View file

@ -3,6 +3,7 @@ using Dalamud.Interface.Utility;
using Glamourer.Designs;
using ImGuiNET;
using OtterGui;
using OtterGui.Filesystem;
using OtterGui.Raii;
namespace Glamourer.Gui.Tabs.DesignTab;
@ -21,6 +22,7 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager
DrawDesignList();
var offset = DrawMultiTagger(width);
DrawMultiColor(width, offset);
DrawMultiQuickDesignBar(offset);
}
private void DrawDesignList()
@ -35,6 +37,8 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager
var sizeMods = availableSizePercent * 35;
var sizeFolders = availableSizePercent * 65;
_numQuickDesignEnabled = 0;
_numDesigns = 0;
using (var table = ImRaii.Table("mods", 3, ImGuiTableFlags.RowBg))
{
if (!table)
@ -61,15 +65,24 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager
ImGui.TableNextColumn();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(fullName);
if (path is not DesignFileSystem.Leaf l2)
continue;
++_numDesigns;
if (l2.Value.QuickDesign)
++_numQuickDesignEnabled;
}
}
ImGui.Separator();
}
private string _tag = string.Empty;
private readonly List<Design> _addDesigns = [];
private readonly List<(Design, int)> _removeDesigns = [];
private string _tag = string.Empty;
private int _numQuickDesignEnabled;
private int _numDesigns;
private readonly List<Design> _addDesigns = [];
private readonly List<(Design, int)> _removeDesigns = [];
private float DrawMultiTagger(Vector2 width)
{
@ -110,6 +123,30 @@ public class MultiDesignPanel(DesignFileSystemSelector _selector, DesignManager
return offset;
}
private void DrawMultiQuickDesignBar(float offset)
{
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Multi QDB:");
ImGui.SameLine(offset, ImGui.GetStyle().ItemSpacing.X);
var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) / 2, 0);
var diff = _numDesigns - _numQuickDesignEnabled;
var tt = diff == 0
? $"All {_numDesigns} selected designs are already displayed in the quick design bar."
: $"Display all {_numDesigns} selected designs in the quick design bar. Changes {diff} designs.";
if (ImGuiUtil.DrawDisabledButton("Display Selected Designs in QDB", buttonWidth, tt, diff == 0))
foreach(var design in _selector.SelectedPaths.OfType<DesignFileSystem.Leaf>())
_editor.SetQuickDesign(design.Value, true);
ImGui.SameLine();
tt = _numQuickDesignEnabled == 0
? $"All {_numDesigns} selected designs are already hidden in the quick design bar."
: $"Hide all {_numDesigns} selected designs in the quick design bar. Changes {_numQuickDesignEnabled} designs.";
if (ImGuiUtil.DrawDisabledButton("Hide Selected Designs in QDB", buttonWidth, tt, _numQuickDesignEnabled == 0))
foreach (var design in _selector.SelectedPaths.OfType<DesignFileSystem.Leaf>())
_editor.SetQuickDesign(design.Value, false);
ImGui.Separator();
}
private void DrawMultiColor(Vector2 width, float offset)
{
ImGui.AlignTextToFramePadding();

View file

@ -4,7 +4,7 @@ using OtterGui.Widgets;
namespace Glamourer.Gui.Tabs;
public class NpcCombo(NpcCustomizeSet npcCustomizeSet)
: FilterComboCache<NpcData>(npcCustomizeSet, Glamourer.Log)
: FilterComboCache<NpcData>(npcCustomizeSet, MouseWheelType.None, Glamourer.Log)
{
protected override string ToString(NpcData obj)
=> obj.Name;

View file

@ -146,7 +146,8 @@ public static class ServiceManagerA
.AddSingleton<MultiDesignPanel>()
.AddSingleton<DesignPanel>()
.AddSingleton<DesignTab>()
.AddSingleton<DesignCombo>()
.AddSingleton<QuickDesignCombo>()
.AddSingleton<LinkDesignCombo>()
.AddSingleton<RevertDesignCombo>()
.AddSingleton<ModAssociationsTab>()
.AddSingleton<DesignDetailTab>()

@ -1 +1 @@
Subproject commit 04eb0b5ed3930e9cb87ad00dffa9c8be90b58bb3
Subproject commit 2d8a03eebd80e19c6936a28ab2e3a8c164cc17f3

@ -1 +1 @@
Subproject commit 260ac69cd6f17050eaf9b7e0b5ce9a8843edfee4
Subproject commit fb18c80551203a1cf6cd01ec2b0850fbc8e44240