From d2bfcefb899d7e8ede7f4a424ea5de9da66c681e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 12 Feb 2024 23:32:45 +0100 Subject: [PATCH] Update Combos. --- Penumbra/Import/Textures/TextureDrawer.cs | 14 +++++++------- Penumbra/Mods/Manager/ModStorage.cs | 2 +- Penumbra/Services/StainService.cs | 6 +++--- Penumbra/UI/AdvancedWindow/FileEditor.cs | 2 +- Penumbra/UI/AdvancedWindow/ItemSwapTab.cs | 17 ++--------------- Penumbra/UI/CollectionTab/CollectionCombo.cs | 14 +++++--------- 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/Penumbra/Import/Textures/TextureDrawer.cs b/Penumbra/Import/Textures/TextureDrawer.cs index 04422116..427db92d 100644 --- a/Penumbra/Import/Textures/TextureDrawer.cs +++ b/Penumbra/Import/Textures/TextureDrawer.cs @@ -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> 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> 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> getPlayerResources) + private static IReadOnlyList<(string Path, bool Game, bool IsOnPlayer)> CreateFiles(TextureManager textures, ModEditor editor, + Func> getPlayerResources) { var playerResources = getPlayerResources(); diff --git a/Penumbra/Mods/Manager/ModStorage.cs b/Penumbra/Mods/Manager/ModStorage.cs index 490381d6..1e5df6b9 100644 --- a/Penumbra/Mods/Manager/ModStorage.cs +++ b/Penumbra/Mods/Manager/ModStorage.cs @@ -12,7 +12,7 @@ public class ModCombo : FilterComboCache => obj.Name.Text; public ModCombo(Func> generator) - : base(generator, Penumbra.Log) + : base(generator, MouseWheelType.None, Penumbra.Log) { } } diff --git a/Penumbra/Services/StainService.cs b/Penumbra/Services/StainService.cs index 00fc0737..26b39229 100644 --- a/Penumbra/Services/StainService.cs +++ b/Penumbra/Services/StainService.cs @@ -13,7 +13,7 @@ namespace Penumbra.Services; public class StainService : IService { public sealed class StainTemplateCombo(FilterComboColors stainCombo, StmFile stmFile) - : FilterComboCache(stmFile.Entries.Keys.Prepend((ushort)0), Penumbra.Log) + : FilterComboCache(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(0, ("None", 0, false))).ToList(), + StainCombo = new FilterComboColors(140, MouseWheelType.None, + () => StainData.Value.Prepend(new KeyValuePair(0, ("None", 0, false))).ToList(), Penumbra.Log); StmFile = new StmFile(dataManager); TemplateCombo = new StainTemplateCombo(StainCombo, StmFile); diff --git a/Penumbra/UI/AdvancedWindow/FileEditor.cs b/Penumbra/UI/AdvancedWindow/FileEditor.cs index 16cacaa4..89d47eb2 100644 --- a/Penumbra/UI/AdvancedWindow/FileEditor.cs +++ b/Penumbra/UI/AdvancedWindow/FileEditor.cs @@ -278,7 +278,7 @@ public class FileEditor : IDisposable where T : class, IWritable private readonly Configuration _config; public Combo(Configuration config, Func> generator) - : base(generator, Penumbra.Log) + : base(generator, MouseWheelType.None, Penumbra.Log) => _config = config; protected override bool DrawSelectable(int globalIdx, bool selected) diff --git a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs index d31a08ae..0205f3c6 100644 --- a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs +++ b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs @@ -125,26 +125,13 @@ public class ItemSwapTab : IDisposable, ITab Weapon, } - private class ItemSelector : FilterComboCache + private class ItemSelector(ItemData data, FullEquipType type) + : FilterComboCache(() => 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 - { - public WeaponSelector() - : base(FullEquipTypeExtensions.WeaponTypes.Concat(FullEquipTypeExtensions.ToolTypes), Penumbra.Log) - { } - - protected override string ToString(FullEquipType type) - => type.ToName(); - } - private readonly Dictionary _selectors; private readonly ItemSwapContainer _swapData; diff --git a/Penumbra/UI/CollectionTab/CollectionCombo.cs b/Penumbra/UI/CollectionTab/CollectionCombo.cs index b2ee5c3b..9d195eed 100644 --- a/Penumbra/UI/CollectionTab/CollectionCombo.cs +++ b/Penumbra/UI/CollectionTab/CollectionCombo.cs @@ -7,14 +7,10 @@ using Penumbra.GameData.Actors; namespace Penumbra.UI.CollectionTab; -public sealed class CollectionCombo : FilterComboCache +public sealed class CollectionCombo(CollectionManager manager, Func> items) + : FilterComboCache(items, MouseWheelType.None, Penumbra.Log) { - private readonly CollectionManager _collectionManager; - private readonly ImRaii.Color _color = new(); - - public CollectionCombo(CollectionManager manager, Func> 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 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(); }