From 97a14db4d530529bd638bd87245c423f3aaa9303 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 21 Dec 2025 00:45:13 +0100 Subject: [PATCH] Update IEditors to use Luna, update Combos. --- Luna | 2 +- .../Api/IpcTester/CollectionsIpcTester.cs | 3 +- Penumbra/Api/IpcTester/EditingIpcTester.cs | 3 +- .../Api/IpcTester/ResourceTreeIpcTester.cs | 3 +- Penumbra/Api/IpcTester/UiIpcTester.cs | 3 +- Penumbra/Meta/Manipulations/Est.cs | 2 +- Penumbra/Penumbra.csproj.DotSettings | 1 + Penumbra/Services/StainService.cs | 2 +- Penumbra/UI/AdvancedWindow/ItemSwapTab.cs | 12 ++--- .../Materials/ConstantEditors.cs | 18 ++++--- .../Materials/MaterialTemplatePickers.cs | 1 - .../Materials/MtrlTab.Constants.cs | 29 +++++------ .../Materials/MtrlTab.Devkit.cs | 8 ++-- .../UI/AdvancedWindow/Meta/AtchMetaDrawer.cs | 3 +- .../UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs | 9 ++-- .../UI/AdvancedWindow/Meta/EqpMetaDrawer.cs | 3 +- .../UI/AdvancedWindow/Meta/EstMetaDrawer.cs | 9 ++-- .../UI/AdvancedWindow/Meta/ImcMetaDrawer.cs | 8 ++-- Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs | 18 ++----- .../UI/AdvancedWindow/Meta/RspMetaDrawer.cs | 6 +-- .../UI/AdvancedWindow/ModEditWindow.Models.cs | 3 +- Penumbra/UI/AdvancedWindow/ModEditWindow.cs | 3 -- Penumbra/UI/Combos/AtchPointCombo.cs | 2 +- Penumbra/UI/Combos/Combos.cs | 48 ++++++++----------- Penumbra/UI/Combos/OptionSelectCombo.cs | 2 +- Penumbra/UI/{Classes => Combos}/StainCombo.cs | 2 +- 26 files changed, 87 insertions(+), 116 deletions(-) rename Penumbra/UI/{Classes => Combos}/StainCombo.cs (99%) diff --git a/Luna b/Luna index 3d5e7105..e52d0dab 160000 --- a/Luna +++ b/Luna @@ -1 +1 @@ -Subproject commit 3d5e7105f2671d741416988be95a5dba773adaf5 +Subproject commit e52d0dab9fd7f64d108125b79e387052fae2434f diff --git a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs index 121fdd45..0ec1deb3 100644 --- a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs +++ b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs @@ -4,6 +4,7 @@ using Luna; using Penumbra.Api.Enums; using Penumbra.Api.IpcSubscribers; using Penumbra.GameData.Data; +using Penumbra.UI; namespace Penumbra.Api.IpcTester; @@ -26,7 +27,7 @@ public class CollectionsIpcTester(IDalamudPluginInterface pi) : IUiService if (!_) return; - EnumCombo.Instance.Draw("Collection Type"u8, ref _type, default, 200 * Im.Style.GlobalScale); + Combos.ApiCollectionType.Draw("Collection Type"u8, ref _type, default, 200 * Im.Style.GlobalScale); Im.Input.Scalar("Object Index##Collections"u8, ref _objectIdx); if (_collectionId.HasValue) { diff --git a/Penumbra/Api/IpcTester/EditingIpcTester.cs b/Penumbra/Api/IpcTester/EditingIpcTester.cs index fd4fb206..ce0e39a7 100644 --- a/Penumbra/Api/IpcTester/EditingIpcTester.cs +++ b/Penumbra/Api/IpcTester/EditingIpcTester.cs @@ -2,6 +2,7 @@ using Dalamud.Plugin; using ImSharp; using Penumbra.Api.Enums; using Penumbra.Api.IpcSubscribers; +using Penumbra.UI; namespace Penumbra.Api.IpcTester; @@ -28,7 +29,7 @@ public class EditingIpcTester(IDalamudPluginInterface pi) : Luna.IUiService Im.Input.Text("##outputPath"u8, ref _outputPath, "Output Texture Path..."u8); Im.Input.Text("##inputPath2"u8, ref _inputPath2, "Input Texture Path 2..."u8); Im.Input.Text("##outputPath2"u8, ref _outputPath2, "Output Texture Path 2..."u8); - EnumCombo.Instance.Draw("Convert To"u8, ref _typeSelector, StringU8.Empty, 200 * Im.Style.GlobalScale); + Combos.TextureType.Draw("Convert To"u8, ref _typeSelector, StringU8.Empty, 200 * Im.Style.GlobalScale); Im.Checkbox("Add MipMaps"u8, ref _mipMaps); using var table = Im.Table.Begin("..."u8, 3, TableFlags.SizingFixedFit); diff --git a/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs b/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs index d7b7dce8..d68c477a 100644 --- a/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs +++ b/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs @@ -8,6 +8,7 @@ using Penumbra.Api.IpcSubscribers; using Penumbra.GameData.Enums; using Penumbra.GameData.Interop; using Penumbra.GameData.Structs; +using Penumbra.UI; namespace Penumbra.Api.IpcTester; @@ -34,7 +35,7 @@ public class ResourceTreeIpcTester(IDalamudPluginInterface pi, ObjectManager obj return; Im.Input.Text("GameObject indices"u8, ref _gameObjectIndices); - EnumCombo.Instance.Draw("Resource type"u8, ref _type, default, Im.Item.CalculateWidth()); + Combos.ResourceType.Draw("Resource type"u8, ref _type, default, Im.Item.CalculateWidth()); Im.Checkbox("Also get names and icons"u8, ref _withUiData); using var table = Im.Table.Begin(StringU8.Empty, 3, TableFlags.SizingFixedFit); diff --git a/Penumbra/Api/IpcTester/UiIpcTester.cs b/Penumbra/Api/IpcTester/UiIpcTester.cs index 402dac77..9fdaceb4 100644 --- a/Penumbra/Api/IpcTester/UiIpcTester.cs +++ b/Penumbra/Api/IpcTester/UiIpcTester.cs @@ -3,6 +3,7 @@ using ImSharp; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; using Penumbra.Api.IpcSubscribers; +using Penumbra.UI; using MouseButton = Penumbra.Api.Enums.MouseButton; namespace Penumbra.Api.IpcTester; @@ -61,7 +62,7 @@ public class UiIpcTester : Luna.IUiService, IDisposable return; Im.Input.Text("##openMod"u8, ref _modName, "Mod to Open at..."u8); - EnumCombo.Instance.Draw("Tab to Open at"u8, ref _selectTab, default, Im.Item.CalculateWidth()); + Combos.TabType.Draw("Tab to Open at"u8, ref _selectTab, default, Im.Item.CalculateWidth()); using var table = Im.Table.Begin(StringU8.Empty, 3, TableFlags.SizingFixedFit); if (!table) return; diff --git a/Penumbra/Meta/Manipulations/Est.cs b/Penumbra/Meta/Manipulations/Est.cs index a92c710b..ff18f211 100644 --- a/Penumbra/Meta/Manipulations/Est.cs +++ b/Penumbra/Meta/Manipulations/Est.cs @@ -122,7 +122,7 @@ public readonly record struct EstEntry(ushort Value) } } -public static partial class EstTypeExtension +public static partial class EstTypeExtensions { public static string ToSuffix(this EstType type) => type switch diff --git a/Penumbra/Penumbra.csproj.DotSettings b/Penumbra/Penumbra.csproj.DotSettings index 7aba8b1b..21db684f 100644 --- a/Penumbra/Penumbra.csproj.DotSettings +++ b/Penumbra/Penumbra.csproj.DotSettings @@ -1,3 +1,4 @@  + True True True \ No newline at end of file diff --git a/Penumbra/Services/StainService.cs b/Penumbra/Services/StainService.cs index 97da119d..78563d4b 100644 --- a/Penumbra/Services/StainService.cs +++ b/Penumbra/Services/StainService.cs @@ -8,7 +8,7 @@ using Penumbra.GameData.Files.StainMapStructs; using Penumbra.Interop.Services; using Penumbra.Interop.Structs; using Penumbra.UI.AdvancedWindow.Materials; -using FilterComboColors = Penumbra.UI.Classes.FilterComboColors; +using FilterComboColors = Penumbra.UI.FilterComboColors; using MouseWheelType = OtterGui.Widgets.MouseWheelType; namespace Penumbra.Services; diff --git a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs index d4565cb1..989756d9 100644 --- a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs +++ b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs @@ -2,7 +2,6 @@ using Dalamud.Interface.ImGuiNotification; using ImSharp; using Luna; using Luna.Generators; -using OtterGui; using OtterGui.Widgets; using Penumbra.Api.Enums; using Penumbra.Collections.Manager; @@ -711,11 +710,11 @@ public class ItemSwapTab : IDisposable, ITab table.DrawFrameColumn(text); table.NextColumn(); - _dirty |= Combos.Combos.Gender("##Gender", _currentGender, out _currentGender); + _dirty |= Combos.Gender.Draw("##Gender"u8, ref _currentGender, StringU8.Empty, 120 * Im.Style.GlobalScale); if (drawRace is 1) { Im.Line.Same(); - _dirty |= Combos.Combos.Race("##Race", _currentRace, out _currentRace, InputWidth); + _dirty |= Combos.ModelRace.Draw("##Race"u8, ref _currentRace, StringU8.Empty, InputWidth); } else if (drawRace is 2) { @@ -723,12 +722,7 @@ public class ItemSwapTab : IDisposable, ITab if (_currentRace is not ModelRace.Miqote and not ModelRace.AuRa and not ModelRace.Hrothgar) _currentRace = ModelRace.Miqote; - _dirty |= ImGuiUtil.GenericEnumCombo("##Race", InputWidth, _currentRace, out _currentRace, [ - ModelRace.Miqote, - ModelRace.AuRa, - ModelRace.Hrothgar, - ], - ModelRaceExtensions.ToName); + _dirty |= Combos.TailedRace.Draw("##Race"u8, ref _currentRace, StringU8.Empty, InputWidth); } } diff --git a/Penumbra/UI/AdvancedWindow/Materials/ConstantEditors.cs b/Penumbra/UI/AdvancedWindow/Materials/ConstantEditors.cs index 690580df..682b2633 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/ConstantEditors.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/ConstantEditors.cs @@ -1,5 +1,5 @@ using System.Collections.Frozen; -using OtterGui.Text.Widget.Editors; +using Luna; using Penumbra.GameData.Files.ShaderStructs; namespace Penumbra.UI.AdvancedWindow.Materials; @@ -20,7 +20,8 @@ public static class ConstantEditors static ConstantEditors() { - IReadOnlyList knownIntConstants = [ + IReadOnlyList knownIntConstants = + [ "g_ToonIndex", "g_ToonSpecIndex", ]; @@ -30,11 +31,11 @@ public static class ConstantEditors public static IEditor DefaultFor(Name name, MaterialTemplatePickers? materialTemplatePickers = null) { - if (materialTemplatePickers != null) + if (materialTemplatePickers is not null) { if (name == Names.SphereMapIndexConstantName) return materialTemplatePickers.SphereMapIndexPicker; - else if (name == Names.TileIndexConstantName) + if (name == Names.TileIndexConstantName) return materialTemplatePickers.TileIndexPicker; } @@ -60,11 +61,16 @@ public static class ConstantEditors where T : unmanaged, IPowerFunctions, IComparisonOperators => exponent == T.MultiplicativeIdentity ? inner - : inner.Converting(value => value < T.Zero ? -T.Pow(-value, T.MultiplicativeIdentity / exponent) : T.Pow(value, T.MultiplicativeIdentity / exponent), value => value < T.Zero ? -T.Pow(-value, exponent) : T.Pow(value, exponent)); + : inner.Converting( + value => value < T.Zero + ? -T.Pow(-value, T.MultiplicativeIdentity / exponent) + : T.Pow(value, T.MultiplicativeIdentity / exponent), + value => value < T.Zero ? -T.Pow(-value, exponent) : T.Pow(value, exponent)); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEditor WithFactorAndBias(this IEditor inner, T factor, T bias) - where T : unmanaged, IMultiplicativeIdentity, IAdditiveIdentity, IMultiplyOperators, IAdditionOperators, ISubtractionOperators, IDivisionOperators, IEqualityOperators + where T : unmanaged, IMultiplicativeIdentity, IAdditiveIdentity, IMultiplyOperators, IAdditionOperators, + ISubtractionOperators, IDivisionOperators, IEqualityOperators => factor == T.MultiplicativeIdentity && bias == T.AdditiveIdentity ? inner : inner.Converting(value => (value - bias) / factor, value => value * factor + bias); diff --git a/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs b/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs index b2eb748b..7e2403ca 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs @@ -1,6 +1,5 @@ using ImSharp; using Luna; -using OtterGui.Text.Widget.Editors; using Penumbra.Interop.Services; using Penumbra.Interop.Structs; diff --git a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Constants.cs b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Constants.cs index b6297a45..2dee1006 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Constants.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Constants.cs @@ -1,6 +1,5 @@ using ImSharp; using Luna; -using OtterGui.Text.Widget.Editors; using Penumbra.GameData.Files.ShaderStructs; using static Penumbra.GameData.Files.ShpkFile; @@ -16,19 +15,6 @@ public partial class MtrlTab private void UpdateConstants() { - static List FindOrAddGroup(List<(string, List)> groups, string name) - { - foreach (var (groupName, group) in groups) - { - if (string.Equals(name, groupName, StringComparison.Ordinal)) - return group; - } - - var newGroup = new List(16); - groups.Add((name, newGroup)); - return newGroup; - } - Constants.Clear(); string mpPrefix; if (_associatedShpk == null) @@ -137,6 +123,21 @@ public partial class MtrlTab x.MonoFont ? x.Label.Replace("].w", "].{").Replace(mpPrefix, "}_MaterialParameter") : x.Label, y.MonoFont ? y.Label.Replace("].w", "].{").Replace(mpPrefix, "}_MaterialParameter") : y.Label)); } + + return; + + static List FindOrAddGroup(List<(string, List)> groups, string name) + { + foreach (var (groupName, group) in groups) + { + if (string.Equals(name, groupName, StringComparison.Ordinal)) + return group; + } + + var newGroup = new List(16); + groups.Add((name, newGroup)); + return newGroup; + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Devkit.cs b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Devkit.cs index 26fe3dcb..60dc3227 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Devkit.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Devkit.cs @@ -1,6 +1,7 @@ +using ImSharp; using JetBrains.Annotations; +using Luna; using Newtonsoft.Json.Linq; -using OtterGui.Text.Widget.Editors; using Penumbra.String.Classes; using static Penumbra.GameData.Files.ShpkFile; @@ -228,7 +229,7 @@ public partial class MtrlTab private EnumEditor CreateEnumEditor(Func convertValue) where T : unmanaged, IUtf8SpanFormattable, IEqualityOperators - => new(Array.ConvertAll(Values, value => (ToUtf8(value.Label), convertValue(value.Value), ToUtf8(value.Description)))); + => new(Array.ConvertAll(Values, value => (new StringU8(value.Label), convertValue(value.Value), new StringU8(value.Description)))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static T ToInteger(float value) where T : struct, INumberBase @@ -245,8 +246,5 @@ public partial class MtrlTab [MethodImpl(MethodImplOptions.AggressiveInlining)] private static T? ToFloat(float? value) where T : struct, INumberBase => value.HasValue ? T.CreateSaturating(value.Value) : null; - - private static ReadOnlyMemory ToUtf8(string value) - => Encoding.UTF8.GetBytes(value); } } diff --git a/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs index 3df00317..c53eed97 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs @@ -11,7 +11,6 @@ using Penumbra.GameData.Files.AtchStructs; using Penumbra.Meta; using Penumbra.Meta.Manipulations; using Penumbra.Mods.Editor; -using Penumbra.UI.Combos; using Notification = Luna.Notification; namespace Penumbra.UI.AdvancedWindow.Meta; @@ -237,7 +236,7 @@ public sealed class AtchMetaDrawer : MetaDrawer private static bool DrawRace(ref AtchIdentifier identifier, float unscaledWidth = 100) { - var ret = Combos.Combos.Race("##atchRace", identifier.Race, out var race, unscaledWidth); + var ret = Combos.ModelRace.Draw("##atchRace"u8, identifier.Race, StringU8.Empty, unscaledWidth * Im.Style.GlobalScale, out var race); Im.Tooltip.OnHover("Model Race"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; diff --git a/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs index bf2ea4d4..b2287c9e 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs @@ -135,8 +135,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawRace(ref EqdpIdentifier identifier, float unscaledWidth = 100) { - var ret = Combos.Combos.Race("##eqdpRace", identifier.Race, out var race, unscaledWidth); - Im.Tooltip.OnHover("Model Race"u8); + var ret = Combos.ModelRace.Draw("##eqdpRace"u8, identifier.Race, "Model Race"u8, unscaledWidth * Im.Style.GlobalScale, out var race); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; return ret; @@ -144,8 +143,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawGender(ref EqdpIdentifier identifier, float unscaledWidth = 120) { - var ret = Combos.Combos.Gender("##eqdpGender", identifier.Gender, out var gender, unscaledWidth); - Im.Tooltip.OnHover("Gender"u8); + var ret = Combos.Gender.Draw("##eqdpGender"u8, identifier.Gender, "Gender"u8, unscaledWidth * Im.Style.GlobalScale, out var gender); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(gender, identifier.Race) }; return ret; @@ -153,8 +151,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawEquipSlot(ref EqdpIdentifier identifier, float unscaledWidth = 100) { - var ret = Combos.Combos.EqdpEquipSlot("##eqdpSlot", identifier.Slot, out var slot, unscaledWidth); - Im.Tooltip.OnHover("Equip Slot"u8); + var ret = Combos.EqdpEquipSlot.Draw("##eqdpSlot"u8, identifier.Slot, "Equip Slot"u8, unscaledWidth, out var slot); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs index 56b21778..d2f122cd 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs @@ -128,8 +128,7 @@ public sealed class EqpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawEquipSlot(ref EqpIdentifier identifier, float unscaledWidth = 100) { - var ret = Combos.Combos.EqpEquipSlot("##eqpSlot", identifier.Slot, out var slot, unscaledWidth); - Im.Tooltip.OnHover("Equip Slot"u8); + var ret = Combos.EqpEquipSlot.Draw("##eqpSlot"u8, identifier.Slot, "Equip Slot"u8, unscaledWidth * Im.Style.GlobalScale, out var slot); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs index 946c1987..309f361c 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs @@ -125,8 +125,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawRace(ref EstIdentifier identifier, float unscaledWidth = 100) { - var ret = Combos.Combos.Race("##estRace", identifier.Race, out var race, unscaledWidth); - Im.Tooltip.OnHover("Model Race"u8); + var ret = Combos.ModelRace.Draw("##estRace"u8, identifier.Race, "Model Race"u8, unscaledWidth * Im.Style.GlobalScale, out var race); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; return ret; @@ -134,8 +133,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawGender(ref EstIdentifier identifier, float unscaledWidth = 120) { - var ret = Combos.Combos.Gender("##estGender", identifier.Gender, out var gender, unscaledWidth); - Im.Tooltip.OnHover("Gender"u8); + var ret = Combos.Gender.Draw("##estGender"u8, identifier.Gender, "Gender"u8, unscaledWidth * Im.Style.GlobalScale, out var gender); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(gender, identifier.Race) }; return ret; @@ -143,8 +141,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawSlot(ref EstIdentifier identifier, float unscaledWidth = 200) { - var ret = Combos.Combos.EstSlot("##estSlot", identifier.Slot, out var slot, unscaledWidth); - Im.Tooltip.OnHover("Extra Skeleton Type"u8); + var ret = Combos.EstSlot.Draw("##estSlot"u8, identifier.Slot, "Extra Skeleton Type"u8, unscaledWidth * Im.Style.GlobalScale, out var slot); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs index 7aea46ba..fde4777f 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs @@ -150,8 +150,7 @@ public sealed class ImcMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawObjectType(ref ImcIdentifier identifier, float width = 110) { - var ret = Combos.Combos.ImcType("##imcType", identifier.ObjectType, out var type, width); - Im.Tooltip.OnHover("Object Type"u8); + var ret = Combos.ImcType.Draw("##imcType"u8, identifier.ObjectType, "Object Type"u8, width * Im.Style.GlobalScale, out var type); if (ret) { @@ -211,13 +210,12 @@ public sealed class ImcMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { case ObjectType.Equipment: case ObjectType.DemiHuman: - ret = Combos.Combos.EqpEquipSlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); + ret = Combos.EqpEquipSlot.Draw("##slot"u8, identifier.EquipSlot, "Equip Slot"u8, unscaledWidth * Im.Style.GlobalScale, out slot); break; - case ObjectType.Accessory: ret = Combos.Combos.AccessorySlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); break; + case ObjectType.Accessory: ret = Combos.AccessorySlot.Draw("##slot"u8, identifier.EquipSlot, "Equip Slot"u8, unscaledWidth * Im.Style.GlobalScale, out slot); break; default: return false; } - Im.Tooltip.OnHover("Equip Slot"u8); if (ret) identifier = identifier with { EquipSlot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs index fb78916c..88ef8200 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs @@ -1,7 +1,6 @@ using ImSharp; using Luna; using Newtonsoft.Json.Linq; -using OtterGui; using Penumbra.Meta; using Penumbra.Meta.Manipulations; using Penumbra.Mods.Editor; @@ -40,17 +39,10 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta using var id = Im.Id.Push((int)Identifier.Type); DrawNew(); - var height = ColumnHeight; - var skips = ImGuiClip.GetNecessarySkipsAtPos(height, Im.Cursor.Y, Count); - if (skips < Count) - { - var remainder = ImGuiClip.ClippedTableDraw(Enumerate(), skips, DrawLine, Count); - if (remainder > 0) - ImGuiClip.DrawEndDummy(remainder, height); - } - - void DrawLine((TIdentifier Identifier, TEntry Value) pair) - => DrawEntry(pair.Identifier, pair.Value); + var height = ColumnHeight; + using var clipper = new Im.ListClipper(Count, height); + foreach (var (identifier, value) in clipper.Iterate(Enumerate())) + DrawEntry(identifier, value); } public abstract ReadOnlySpan Label { get; } @@ -152,7 +144,7 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta if (!ImEx.Icon.Button(LunaStyle.ToClipboardIcon, tooltip)) return; - var text = Functions.ToCompressedBase64(manipulations.Value, 0); + var text = CompressionFunctions.ToCompressedBase64(manipulations.Value, 0); if (text.Length > 0) Im.Clipboard.Set(text); } diff --git a/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs index 306a643c..3a0eef1a 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs @@ -98,8 +98,7 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawSubRace(ref RspIdentifier identifier, float unscaledWidth = 150) { - var ret = Combos.Combos.SubRace("##rspSubRace", identifier.SubRace, out var subRace, unscaledWidth); - Im.Tooltip.OnHover("Racial Clan"u8); + var ret = Combos.Clan.Draw("##rspSubRace"u8, identifier.SubRace, "Racial Clan"u8, unscaledWidth * Im.Style.GlobalScale, out var subRace); if (ret) identifier = identifier with { SubRace = subRace }; return ret; @@ -107,8 +106,7 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawAttribute(ref RspIdentifier identifier, float unscaledWidth = 200) { - var ret = Combos.Combos.RspAttribute("##rspAttribute", identifier.Attribute, out var attribute, unscaledWidth); - Im.Tooltip.OnHover("Scaling Attribute"u8); + var ret = Combos.RspType.Draw("##rspAttribute"u8, identifier.Attribute, "Scaling Attribute"u8, unscaledWidth, out var attribute); if (ret) identifier = identifier with { Attribute = attribute }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs index 25287cab..7c2bcdc4 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs @@ -2,7 +2,6 @@ using Dalamud.Interface; using ImSharp; using Lumina.Data.Parsing; using Luna; -using OtterGui.Widgets; using Penumbra.GameData; using Penumbra.GameData.Files; using Penumbra.Import.Models; @@ -646,7 +645,7 @@ public partial class ModEditWindow { using var t = Im.Tree.Node($"Additional Data (Size: {data.LastFile.RemainingData.Length})###AdditionalData"); if (t) - Widget.DrawHexViewer(data.LastFile.RemainingData); + ImEx.HexViewer(data.LastFile.RemainingData); } return ret; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs index 5087cfab..f26c0afd 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs @@ -1,10 +1,8 @@ using System.Collections.Frozen; -using Dalamud.Interface.Components; using Dalamud.Interface.DragDrop; using Dalamud.Plugin.Services; using ImSharp; using Luna; -using OtterGui; using Penumbra.Api.Enums; using Penumbra.Collections.Manager; using Penumbra.Communication; @@ -24,7 +22,6 @@ using Penumbra.String.Classes; using Penumbra.UI.AdvancedWindow.Materials; using Penumbra.UI.AdvancedWindow.Meta; using Penumbra.UI.Classes; -using Penumbra.UI.Combos; using MdlMaterialEditor = Penumbra.Mods.Editor.MdlMaterialEditor; namespace Penumbra.UI.AdvancedWindow; diff --git a/Penumbra/UI/Combos/AtchPointCombo.cs b/Penumbra/UI/Combos/AtchPointCombo.cs index b3f758c9..39f6fb04 100644 --- a/Penumbra/UI/Combos/AtchPointCombo.cs +++ b/Penumbra/UI/Combos/AtchPointCombo.cs @@ -2,7 +2,7 @@ using ImSharp; using Penumbra.GameData.Files.AtchStructs; using Penumbra.UI.AdvancedWindow.Meta; -namespace Penumbra.UI.Combos; +namespace Penumbra.UI; internal sealed class AtchPointCombo(AtchMetaDrawer parent) : SimpleFilterCombo(SimpleFilterType.Text) diff --git a/Penumbra/UI/Combos/Combos.cs b/Penumbra/UI/Combos/Combos.cs index 8e505315..9ad45bb8 100644 --- a/Penumbra/UI/Combos/Combos.cs +++ b/Penumbra/UI/Combos/Combos.cs @@ -1,42 +1,34 @@ using ImSharp; -using OtterGui; +using Penumbra.Api.Enums; using Penumbra.GameData.Enums; using Penumbra.Meta.Manipulations; -namespace Penumbra.UI.Combos; +namespace Penumbra.UI; public static class Combos { - // Different combos to use with enums. - public static bool Race(string label, ModelRace current, out ModelRace race, float unscaledWidth = 100) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out race, ModelRaceExtensions.ToName, 1); + public static readonly EnumCombo ModelRace = new(ModelRaceExtensions.ToNameU8, ModelRaceExtensions.ToName); + public static readonly EnumCombo TailedRace = new(ModelRaceExtensions.ToNameU8, ModelRaceExtensions.ToName, null, [GameData.Enums.ModelRace.Miqote, GameData.Enums.ModelRace.AuRa, GameData.Enums.ModelRace.Hrothgar]); + public static readonly EnumCombo Gender = new(GenderExtensions.ToNameU8, GenderExtensions.ToName); - public static bool Gender(string label, Gender current, out Gender gender, float unscaledWidth = 120) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth, current, out gender, GenderExtensions.ToName, 1); + public static readonly EnumCombo EqdpEquipSlot = new(EquipSlotExtensions.ToNameU8, EquipSlotExtensions.ToName, null, + EquipSlotExtensions.EqdpSlots); - public static bool EqdpEquipSlot(string label, EquipSlot current, out EquipSlot slot, float unscaledWidth = 100) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out slot, EquipSlotExtensions.EqdpSlots, - EquipSlotExtensions.ToName); + public static readonly EnumCombo EqpEquipSlot = new(EquipSlotExtensions.ToNameU8, EquipSlotExtensions.ToName, null, + EquipSlotExtensions.EquipmentSlots); - public static bool EqpEquipSlot(string label, EquipSlot current, out EquipSlot slot, float unscaledWidth = 100) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out slot, EquipSlotExtensions.EquipmentSlots, - EquipSlotExtensions.ToName); + public static readonly EnumCombo AccessorySlot = new(EquipSlotExtensions.ToNameU8, EquipSlotExtensions.ToName, null, + EquipSlotExtensions.AccessorySlots); - public static bool AccessorySlot(string label, EquipSlot current, out EquipSlot slot, float unscaledWidth = 100) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out slot, EquipSlotExtensions.AccessorySlots, - EquipSlotExtensions.ToName); + public static readonly EnumCombo Clan = new(SubRaceExtensions.ToNameU8, SubRaceExtensions.ToName); + public static readonly EnumCombo RspType = new(RspAttributeExtensions.ToNameU8, RspAttributeExtensions.ToName); + public static readonly EnumCombo EstSlot = new(EstTypeExtensions.ToNameU8, EstTypeExtensions.ToName); - public static bool SubRace(string label, SubRace current, out SubRace subRace, float unscaledWidth = 150) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out subRace, SubRaceExtensions.ToName, 1); + public static readonly EnumCombo ImcType = new(ObjectTypeExtensions.ToNameU8, ObjectTypeExtensions.ToName, null, + ObjectTypeExtensions.ValidImcTypes); - public static bool RspAttribute(string label, RspAttribute current, out RspAttribute attribute, float unscaledWidth = 200) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out attribute, - RspAttributeExtensions.ToName, 0, 1); - - public static bool EstSlot(string label, EstType current, out EstType attribute, float unscaledWidth = 200) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out attribute); - - public static bool ImcType(string label, ObjectType current, out ObjectType type, float unscaledWidth = 110) - => ImGuiUtil.GenericEnumCombo(label, unscaledWidth * Im.Style.GlobalScale, current, out type, ObjectTypeExtensions.ValidImcTypes, - ObjectTypeExtensions.ToName); + public static readonly EnumCombo ApiCollectionType = new(); + public static readonly EnumCombo TextureType = new(); + public static readonly EnumCombo ResourceType = new(); + public static readonly EnumCombo TabType = new(); } diff --git a/Penumbra/UI/Combos/OptionSelectCombo.cs b/Penumbra/UI/Combos/OptionSelectCombo.cs index 7a30d68f..72c46259 100644 --- a/Penumbra/UI/Combos/OptionSelectCombo.cs +++ b/Penumbra/UI/Combos/OptionSelectCombo.cs @@ -4,7 +4,7 @@ using Penumbra.Mods.SubMods; using Penumbra.UI.AdvancedWindow; using Penumbra.UI.Classes; -namespace Penumbra.UI.Combos; +namespace Penumbra.UI; public sealed class OptionSelectCombo : FilterComboBase { diff --git a/Penumbra/UI/Classes/StainCombo.cs b/Penumbra/UI/Combos/StainCombo.cs similarity index 99% rename from Penumbra/UI/Classes/StainCombo.cs rename to Penumbra/UI/Combos/StainCombo.cs index 8fbcda0c..33692073 100644 --- a/Penumbra/UI/Classes/StainCombo.cs +++ b/Penumbra/UI/Combos/StainCombo.cs @@ -6,7 +6,7 @@ using OtterGui.Log; using OtterGui.Raii; using OtterGui.Widgets; -namespace Penumbra.UI.Classes; +namespace Penumbra.UI; public class FilterComboColors : FilterComboCache> {