Update Combos.

This commit is contained in:
Ottermandias 2024-02-12 23:32:45 +01:00
parent 95d5d6c4b0
commit d2bfcefb89
6 changed files with 19 additions and 36 deletions

View file

@ -32,7 +32,8 @@ public static class TextureDrawer
if (texture.LoadError is DllNotFoundException)
{
ImGuiUtil.TextColored(Colors.RegexWarningBorder, "A texture handling dependency could not be found. Try installing a current Microsoft VC Redistributable.");
ImGuiUtil.TextColored(Colors.RegexWarningBorder,
"A texture handling dependency could not be found. Try installing a current Microsoft VC Redistributable.");
if (ImGui.Button("Microsoft VC Redistributables"))
Dalamud.Utility.Util.OpenLink(link);
ImGuiUtil.HoverTooltip($"Open {link} in your browser.");
@ -111,14 +112,12 @@ public static class TextureDrawer
}
}
public sealed class PathSelectCombo : FilterComboCache<(string Path, bool Game, bool IsOnPlayer)>
public sealed class PathSelectCombo(TextureManager textures, ModEditor editor, Func<ISet<string>> getPlayerResources)
: FilterComboCache<(string Path, bool Game, bool IsOnPlayer)>(() => CreateFiles(textures, editor, getPlayerResources),
MouseWheelType.None, Penumbra.Log)
{
private int _skipPrefix = 0;
public PathSelectCombo(TextureManager textures, ModEditor editor, Func<ISet<string>> getPlayerResources)
: base(() => CreateFiles(textures, editor, getPlayerResources), Penumbra.Log)
{ }
protected override string ToString((string Path, bool Game, bool IsOnPlayer) obj)
=> obj.Path;
@ -140,7 +139,8 @@ public static class TextureDrawer
return ret;
}
private static IReadOnlyList<(string Path, bool Game, bool IsOnPlayer)> CreateFiles(TextureManager textures, ModEditor editor, Func<ISet<string>> getPlayerResources)
private static IReadOnlyList<(string Path, bool Game, bool IsOnPlayer)> CreateFiles(TextureManager textures, ModEditor editor,
Func<ISet<string>> getPlayerResources)
{
var playerResources = getPlayerResources();

View file

@ -12,7 +12,7 @@ public class ModCombo : FilterComboCache<Mod>
=> obj.Name.Text;
public ModCombo(Func<IReadOnlyList<Mod>> generator)
: base(generator, Penumbra.Log)
: base(generator, MouseWheelType.None, Penumbra.Log)
{ }
}

View file

@ -13,7 +13,7 @@ namespace Penumbra.Services;
public class StainService : IService
{
public sealed class StainTemplateCombo(FilterComboColors stainCombo, StmFile stmFile)
: FilterComboCache<ushort>(stmFile.Entries.Keys.Prepend((ushort)0), Penumbra.Log)
: FilterComboCache<ushort>(stmFile.Entries.Keys.Prepend((ushort)0), MouseWheelType.None, Penumbra.Log)
{
protected override float GetFilterWidth()
{
@ -70,8 +70,8 @@ public class StainService : IService
public StainService(IDataManager dataManager, DictStain stainData)
{
StainData = stainData;
StainCombo = new FilterComboColors(140,
() => StainData.Value.Prepend(new KeyValuePair<byte, (string Name, uint Dye, bool Gloss)>(0, ("None", 0, false))).ToList(),
StainCombo = new FilterComboColors(140, MouseWheelType.None,
() => StainData.Value.Prepend(new KeyValuePair<byte, (string Name, uint Dye, bool Gloss)>(0, ("None", 0, false))).ToList(),
Penumbra.Log);
StmFile = new StmFile(dataManager);
TemplateCombo = new StainTemplateCombo(StainCombo, StmFile);

View file

@ -278,7 +278,7 @@ public class FileEditor<T> : IDisposable where T : class, IWritable
private readonly Configuration _config;
public Combo(Configuration config, Func<IReadOnlyList<FileRegistry>> generator)
: base(generator, Penumbra.Log)
: base(generator, MouseWheelType.None, Penumbra.Log)
=> _config = config;
protected override bool DrawSelectable(int globalIdx, bool selected)

View file

@ -125,26 +125,13 @@ public class ItemSwapTab : IDisposable, ITab
Weapon,
}
private class ItemSelector : FilterComboCache<EquipItem>
private class ItemSelector(ItemData data, FullEquipType type)
: FilterComboCache<EquipItem>(() => data.ByType[type], MouseWheelType.None, Penumbra.Log)
{
public ItemSelector(ItemData data, FullEquipType type)
: base(() => data.ByType[type], Penumbra.Log)
{ }
protected override string ToString(EquipItem obj)
=> obj.Name;
}
private class WeaponSelector : FilterComboCache<FullEquipType>
{
public WeaponSelector()
: base(FullEquipTypeExtensions.WeaponTypes.Concat(FullEquipTypeExtensions.ToolTypes), Penumbra.Log)
{ }
protected override string ToString(FullEquipType type)
=> type.ToName();
}
private readonly Dictionary<SwapType, (ItemSelector Source, ItemSelector Target, string TextFrom, string TextTo)> _selectors;
private readonly ItemSwapContainer _swapData;

View file

@ -7,14 +7,10 @@ using Penumbra.GameData.Actors;
namespace Penumbra.UI.CollectionTab;
public sealed class CollectionCombo : FilterComboCache<ModCollection>
public sealed class CollectionCombo(CollectionManager manager, Func<IReadOnlyList<ModCollection>> items)
: FilterComboCache<ModCollection>(items, MouseWheelType.None, Penumbra.Log)
{
private readonly CollectionManager _collectionManager;
private readonly ImRaii.Color _color = new();
public CollectionCombo(CollectionManager manager, Func<IReadOnlyList<ModCollection>> items)
: base(items, Penumbra.Log)
=> _collectionManager = manager;
private readonly ImRaii.Color _color = new();
protected override void DrawFilter(int currentSelected, float width)
{
@ -24,11 +20,11 @@ public sealed class CollectionCombo : FilterComboCache<ModCollection>
public void Draw(string label, float width, uint color)
{
var current = _collectionManager.Active.ByType(CollectionType.Current, ActorIdentifier.Invalid);
var current = manager.Active.ByType(CollectionType.Current, ActorIdentifier.Invalid);
_color.Push(ImGuiCol.FrameBg, color).Push(ImGuiCol.FrameBgHovered, color);
if (Draw(label, current?.Name ?? string.Empty, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()) && CurrentSelection != null)
_collectionManager.Active.SetCollection(CurrentSelection, CollectionType.Current);
manager.Active.SetCollection(CurrentSelection, CollectionType.Current);
_color.Dispose();
}