diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index b565736..12e04a4 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -5,6 +5,7 @@ using Glamourer.Designs; using Glamourer.Gui; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Services; +using ImSharp; using Newtonsoft.Json; using OtterGui.Filesystem; using Luna; @@ -99,7 +100,7 @@ public class Configuration : IPluginConfiguration, ISavable public int Version { get; set; } = Constants.CurrentVersion; public Dictionary Colors { get; private set; } - = Enum.GetValues().ToDictionary(c => c, c => c.Data().DefaultColor); + = ColorId.Values.ToDictionary(c => c, c => c.Data().DefaultColor); [JsonIgnore] private readonly SaveService _saveService; diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 90e1528..e660844 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -2,6 +2,7 @@ using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; +using ImSharp; using Newtonsoft.Json.Linq; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -303,7 +304,7 @@ public class DesignBase var customize = _designData.Customize; if (_designData.IsHuman) - foreach (var idx in Enum.GetValues()) + foreach (var idx in CustomizeIndex.Values) { ret[idx.ToString()] = new JObject() { diff --git a/Glamourer/Designs/DesignColors.cs b/Glamourer/Designs/DesignColors.cs index 1371d91..b5b2c4b 100644 --- a/Glamourer/Designs/DesignColors.cs +++ b/Glamourer/Designs/DesignColors.cs @@ -254,10 +254,10 @@ public class DesignColors : ISavable, IReadOnlyDictionary return false; } - public static uint AutoColor(DesignBase design) + public static Rgba32 AutoColor(DesignBase design) { - var customize = design.ApplyCustomizeExcludingBodyType == 0; - var equip = design.Application.Equip == 0; + var customize = design.ApplyCustomizeExcludingBodyType is 0; + var equip = design.Application.Equip is 0; return (customize, equip) switch { (true, true) => ColorId.StateDesign.Value(), diff --git a/Glamourer/Designs/DesignEditor.cs b/Glamourer/Designs/DesignEditor.cs index 448e373..e5c0357 100644 --- a/Glamourer/Designs/DesignEditor.cs +++ b/Glamourer/Designs/DesignEditor.cs @@ -4,6 +4,8 @@ using Glamourer.Events; using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; +using ImSharp; +using Luna; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -71,7 +73,7 @@ public class DesignEditor( } design.LastEdit = DateTimeOffset.UtcNow; - Glamourer.Log.Debug($"Changed customize {idx.ToDefaultName()} in design {design.Identifier} from {oldValue.Value} to {value.Value}."); + Glamourer.Log.Debug($"Changed customize {idx.ToName()} in design {design.Identifier} from {oldValue.Value} to {value.Value}."); SaveService.QueueSave(design); DesignChanged.Invoke(DesignChanged.Type.Customize, design, new CustomizeTransaction(idx, oldValue, value)); } @@ -336,7 +338,7 @@ public class DesignEditor( ChangeBonusItem(design, slot, other.DesignData.BonusItem(slot)); } - foreach (var slot in Enum.GetValues().Where(other.DoApplyCrest)) + foreach (var slot in CrestFlag.Values.Where(other.DoApplyCrest)) ChangeCrest(design, slot, other.DesignData.Crest(slot)); foreach (var parameter in CustomizeParameterExtensions.AllFlags.Where(other.DoApplyParameter)) diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 92f8398..9c9122b 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -377,7 +377,7 @@ public sealed class DesignManager : DesignEditor design.LastEdit = DateTimeOffset.UtcNow; SaveService.QueueSave(design); - Glamourer.Log.Debug($"Set applying of customization {idx.ToDefaultName()} to {value}."); + Glamourer.Log.Debug($"Set applying of customization {idx.ToName()} to {value}."); DesignChanged.Invoke(DesignChanged.Type.ApplyCustomize, design, new ApplicationTransaction(idx, !value, value)); } diff --git a/Glamourer/Designs/Links/DesignMerger.cs b/Glamourer/Designs/Links/DesignMerger.cs index a878c44..927a7d7 100644 --- a/Glamourer/Designs/Links/DesignMerger.cs +++ b/Glamourer/Designs/Links/DesignMerger.cs @@ -5,6 +5,7 @@ using Glamourer.Interop.Material; using Glamourer.Services; using Glamourer.State; using Glamourer.Unlocks; +using ImSharp; using Luna; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -284,7 +285,7 @@ public class DesignMerger( var set = customizeService.Manager.GetSet(customize.Clan, customize.Gender); var face = customize.Face; - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) { var flag = index.ToFlag(); if (!customizeFlags.HasFlag(flag)) @@ -314,7 +315,7 @@ public class DesignMerger( var source = ret.Design.DoApplyCustomize(CustomizeIndex.Clan) ? ret.Sources[CustomizeIndex.Clan] : ret.Sources[CustomizeIndex.Gender]; - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) { var flag = index.ToFlag(); if (!fixFlags.HasFlag(flag)) diff --git a/Glamourer/GameData/CustomizeManager.cs b/Glamourer/GameData/CustomizeManager.cs index bb8120c..7ebbf0b 100644 --- a/Glamourer/GameData/CustomizeManager.cs +++ b/Glamourer/GameData/CustomizeManager.cs @@ -1,7 +1,6 @@ using Dalamud.Interface.Textures; using Dalamud.Plugin.Services; using Luna; -using OtterGui.Classes; using Penumbra.GameData.Enums; using Race = Penumbra.GameData.Enums.Race; @@ -33,7 +32,7 @@ public class CustomizeManager : IAsyncDataContainer /// Get specific icons. public ISharedImmediateTexture GetIcon(uint id) - => _icons.TextureProvider.GetFromGameIcon(id); + => _textures.GetFromGameIcon(id); /// Iterate over all supported genders and clans. public static IEnumerable<(SubRace Clan, Gender Gender)> AllSets() @@ -47,12 +46,12 @@ public class CustomizeManager : IAsyncDataContainer public CustomizeManager(ITextureProvider textures, IDataManager gameData, IPluginLog log, NpcCustomizeSet npcCustomizeSet) { - _icons = new TextureCache(gameData, textures); + _textures = textures; var stopwatch = new Stopwatch(); var tmpTask = Task.Run(() => { stopwatch.Start(); - return new CustomizeSetFactory(gameData, log, _icons, npcCustomizeSet); + return new CustomizeSetFactory(gameData, textures, log, npcCustomizeSet); }); var setTasks = AllSets().Select(p => tmpTask.ContinueWith(t => _customizationSets[ToIndex(p.Clan, p.Gender)] = t.Result.CreateSet(p.Clan, p.Gender))); @@ -72,9 +71,9 @@ public class CustomizeManager : IAsyncDataContainer public bool Finished => Awaiter.IsCompletedSuccessfully; - private readonly TextureCache _icons; - private static readonly int ListSize = Clans.Count * Genders.Count; - private readonly CustomizeSet[] _customizationSets = new CustomizeSet[ListSize]; + private readonly ITextureProvider _textures; + private static readonly int ListSize = Clans.Count * Genders.Count; + private readonly CustomizeSet[] _customizationSets = new CustomizeSet[ListSize]; /// Get the index for the given pair of tribe and gender. private static int ToIndex(SubRace race, Gender gender) diff --git a/Glamourer/GameData/CustomizeParameterFlag.cs b/Glamourer/GameData/CustomizeParameterFlag.cs index cc4d7e8..d3abf6e 100644 --- a/Glamourer/GameData/CustomizeParameterFlag.cs +++ b/Glamourer/GameData/CustomizeParameterFlag.cs @@ -1,4 +1,5 @@ -using Luna.Generators; +using ImSharp; +using Luna.Generators; namespace Glamourer.GameData; @@ -69,7 +70,7 @@ public static partial class CustomizeParameterExtensions public const CustomizeParameterFlag Values = CustomizeParameterFlag.FacePaintUvOffset | CustomizeParameterFlag.FacePaintUvMultiplier; public static readonly IReadOnlyList AllFlags = - [.. Enum.GetValues().Where(f => All.HasFlag(f))]; + [.. CustomizeParameterFlag.Values.Where(f => All.HasFlag(f))]; public static readonly IReadOnlyList RgbaFlags = AllFlags.Where(f => RgbaQuadruples.HasFlag(f)).ToArray(); public static readonly IReadOnlyList RgbFlags = AllFlags.Where(f => RgbTriples.HasFlag(f)).ToArray(); diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 77a6973..039f7c2 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -1,8 +1,10 @@ using Dalamud.Game; +using Dalamud.Interface.Textures; using Dalamud.Plugin.Services; +using ImSharp; using Lumina.Excel; using Lumina.Excel.Sheets; -using OtterGui.Classes; +using Luna; using Penumbra.GameData; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -11,24 +13,24 @@ using Race = Penumbra.GameData.Enums.Race; namespace Glamourer.GameData; internal class CustomizeSetFactory( - IDataManager _gameData, - IPluginLog _log, - TextureCache _icons, - NpcCustomizeSet _npcCustomizeSet, - ColorParameters _colors) + IDataManager gameData, + ITextureProvider textures, + IPluginLog log, + NpcCustomizeSet npcCustomizeSet, + ColorParameters colors) { - public CustomizeSetFactory(IDataManager gameData, IPluginLog log, TextureCache icons, NpcCustomizeSet npcCustomizeSet) - : this(gameData, log, icons, npcCustomizeSet, new ColorParameters(gameData, log)) + public CustomizeSetFactory(IDataManager gameData, ITextureProvider textures, IPluginLog log, NpcCustomizeSet npcCustomizeSet) + : this(gameData, textures, log, npcCustomizeSet, new ColorParameters(gameData, log)) { } /// Create the set of all available customization options for a given clan and gender. public CustomizeSet CreateSet(SubRace race, Gender gender) { var (skin, hair) = GetSkinHairColors(race, gender); - var row = _charaMakeSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender)!; + var row = _charaMakeSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender); var hrothgar = race.ToRace() == Race.Hrothgar; // Create the initial set with all the easily accessible parameters available for anyone. - var set = new CustomizeSet(_npcCustomizeSet, race, gender) + var set = new CustomizeSet(npcCustomizeSet, race, gender) { Name = GetName(race, gender), Voices = row.VoiceStruct, @@ -79,12 +81,12 @@ internal class CustomizeSetFactory( CustomizeIndex.TailShape, }; - var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>() + var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)> { (CustomizeIndex.Height, CustomizeValue.Max), }; - _npcCustomizeSet.Awaiter.Wait(); - foreach (var customize in _npcCustomizeSet.Select(s => s.Customize) + npcCustomizeSet.Awaiter.Wait(); + foreach (var customize in npcCustomizeSet.Select(s => s.Customize) .Where(c => c.Clan == race && c.Gender == gender && c.BodyType.Value == 1)) { foreach (var customizeIndex in customizeIndices) @@ -103,22 +105,22 @@ internal class CustomizeSetFactory( set.NpcOptions = npcCustomizations.OrderBy(p => p.Item1).ThenBy(p => p.Item2.Value).ToArray(); } - private readonly ColorParameters _colorParameters = new(_gameData, _log); - private readonly ExcelSheet _customizeSheet = _gameData.GetExcelSheet(ClientLanguage.English); - private readonly ExcelSheet _lobbySheet = _gameData.GetExcelSheet(ClientLanguage.English); - private readonly ExcelSheet _hairSheet = _gameData.GetExcelSheet(ClientLanguage.English, "HairMakeType"); - private readonly ExcelSheet _tribeSheet = _gameData.GetExcelSheet(ClientLanguage.English); + private readonly ColorParameters _colorParameters = new(gameData, log); + private readonly ExcelSheet _customizeSheet = gameData.GetExcelSheet(ClientLanguage.English); + private readonly ExcelSheet _lobbySheet = gameData.GetExcelSheet(ClientLanguage.English); + private readonly ExcelSheet _hairSheet = gameData.GetExcelSheet(ClientLanguage.English, "HairMakeType"); + private readonly ExcelSheet _tribeSheet = gameData.GetExcelSheet(ClientLanguage.English); // Those color pickers are shared between all races. - private readonly CustomizeData[] _highlightPicker = CreateColors(_colors, CustomizeIndex.HighlightsColor, 256, 192); - private readonly CustomizeData[] _lipColorPickerDark = CreateColors(_colors, CustomizeIndex.LipColor, 512, 96); - private readonly CustomizeData[] _lipColorPickerLight = CreateColors(_colors, CustomizeIndex.LipColor, 1024, 96, true); - private readonly CustomizeData[] _eyeColorPicker = CreateColors(_colors, CustomizeIndex.EyeColorLeft, 0, 192); - private readonly CustomizeData[] _facePaintColorPickerDark = CreateColors(_colors, CustomizeIndex.FacePaintColor, 640, 96); - private readonly CustomizeData[] _facePaintColorPickerLight = CreateColors(_colors, CustomizeIndex.FacePaintColor, 1152, 96, true); - private readonly CustomizeData[] _tattooColorPicker = CreateColors(_colors, CustomizeIndex.TattooColor, 0, 192); + private readonly CustomizeData[] _highlightPicker = CreateColors(colors, CustomizeIndex.HighlightsColor, 256, 192); + private readonly CustomizeData[] _lipColorPickerDark = CreateColors(colors, CustomizeIndex.LipColor, 512, 96); + private readonly CustomizeData[] _lipColorPickerLight = CreateColors(colors, CustomizeIndex.LipColor, 1024, 96, true); + private readonly CustomizeData[] _eyeColorPicker = CreateColors(colors, CustomizeIndex.EyeColorLeft, 0, 192); + private readonly CustomizeData[] _facePaintColorPickerDark = CreateColors(colors, CustomizeIndex.FacePaintColor, 640, 96); + private readonly CustomizeData[] _facePaintColorPickerLight = CreateColors(colors, CustomizeIndex.FacePaintColor, 1152, 96, true); + private readonly CustomizeData[] _tattooColorPicker = CreateColors(colors, CustomizeIndex.TattooColor, 0, 192); - private readonly ExcelSheet _charaMakeSheet = _gameData.Excel.GetSheet(); + private readonly ExcelSheet _charaMakeSheet = gameData.Excel.GetSheet(); /// Obtain available skin and hair colors for the given clan and gender. private (CustomizeData[] Skin, CustomizeData[] Hair) GetSkinHairColors(SubRace race, Gender gender) @@ -134,12 +136,12 @@ internal class CustomizeSetFactory( } /// Obtain the gender-specific clan name. - private string GetName(SubRace race, Gender gender) + private StringU8 GetName(SubRace race, Gender gender) => gender switch { - Gender.Male => _tribeSheet.TryGetRow((uint)race, out var row) ? row.Masculine.ExtractText() : race.ToName(), - Gender.Female => _tribeSheet.TryGetRow((uint)race, out var row) ? row.Feminine.ExtractText() : race.ToName(), - _ => "Unknown", + Gender.Male => _tribeSheet.TryGetRow((uint)race, out var row) ? new StringU8(row.Masculine.ExtractText()) : race.ToNameU8(), + Gender.Female => _tribeSheet.TryGetRow((uint)race, out var row) ? new StringU8(row.Feminine.ExtractText()) : race.ToNameU8(), + _ => new StringU8("Unknown"u8), }; /// Obtain available hairstyles via reflection from the Hair sheet for the given subrace and gender. @@ -160,7 +162,7 @@ internal class CustomizeSetFactory( // Hair Row from CustomizeSheet might not be set in case of unlockable hair. if (!_customizeSheet.TryGetRow(customizeIdx, out var hairRow)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)i, customizeIdx)); - else if (_icons.IconExists(hairRow.Icon)) + else if (IconExists(hairRow.Icon)) hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)hairRow.FeatureID, hairRow.Icon, (ushort)hairRow.RowId)); } @@ -168,6 +170,7 @@ internal class CustomizeSetFactory( return [.. hairList.OrderBy(h => h.Value.Value)]; } + /// Specific icons for tails or ears. private CustomizeData[] GetTailEarShapes(CharaMakeType row) => ExtractValues(row, CustomizeIndex.TailShape); @@ -189,11 +192,11 @@ internal class CustomizeSetFactory( /// Get face paints from the hair sheet via reflection since there are also unlockable face paints. private CustomizeData[] GetFacePaints(SubRace race, Gender gender) { - var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender); + var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender); // Number of available face paints is at Unknown37. - var numPaints = row.ReadUInt8Column(37); + var numPaints = row.ReadUInt8Column(37); var paintList = new List(numPaints); - + for (var i = 0; i < numPaints; ++i) { // Face paints start at Unknown73. @@ -242,43 +245,43 @@ internal class CustomizeSetFactory( } /// Set the specific option names for the given set of parameters. - private string[] GetOptionNames(CharaMakeType row) + private StringU8[] GetOptionNames(CharaMakeType row) { - var nameArray = Enum.GetValues().Select(c => + var nameArray = CustomizeIndex.Values.Select(c => { // Find the first menu that corresponds to the Id. var byteId = c.ToByteAndMask().ByteIdx; var menu = row.CharaMakeStruct.FirstOrNull(m => m.Customize == byteId); - if (menu == null) + if (menu is null) { // If none exists and the id corresponds to highlights, set the Highlights name. if (c == CustomizeIndex.Highlights) - return string.Intern(_lobbySheet.TryGetRow(237, out var text) ? text.Text.ExtractText() : "Highlights"); + return _lobbySheet.TryGetRow(237, out var text) ? new StringU8(text.Text.ExtractText()) : new StringU8("Highlights"u8); // Otherwise there is an error and we use the default name. - return c.ToDefaultName(); + return c.ToNameU8(); } // Otherwise all is normal, get the menu name or if it does not work the default name. - return string.Intern(_lobbySheet.TryGetRow(menu.Value.Menu.RowId, out var textRow) - ? textRow.Text.ExtractText() - : c.ToDefaultName()); + return _lobbySheet.TryGetRow(menu.Value.Menu.RowId, out var textRow) + ? new StringU8(textRow.Text.ExtractText()) + : c.ToNameU8(); }).ToArray(); // Add names for both eye colors. - nameArray[(int)CustomizeIndex.EyeColorLeft] = CustomizeIndex.EyeColorLeft.ToDefaultName(); - nameArray[(int)CustomizeIndex.EyeColorRight] = CustomizeIndex.EyeColorRight.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature1] = CustomizeIndex.FacialFeature1.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature2] = CustomizeIndex.FacialFeature2.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature3] = CustomizeIndex.FacialFeature3.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature4] = CustomizeIndex.FacialFeature4.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature5] = CustomizeIndex.FacialFeature5.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature6] = CustomizeIndex.FacialFeature6.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacialFeature7] = CustomizeIndex.FacialFeature7.ToDefaultName(); - nameArray[(int)CustomizeIndex.LegacyTattoo] = CustomizeIndex.LegacyTattoo.ToDefaultName(); - nameArray[(int)CustomizeIndex.SmallIris] = CustomizeIndex.SmallIris.ToDefaultName(); - nameArray[(int)CustomizeIndex.Lipstick] = CustomizeIndex.Lipstick.ToDefaultName(); - nameArray[(int)CustomizeIndex.FacePaintReversed] = CustomizeIndex.FacePaintReversed.ToDefaultName(); + nameArray[(int)CustomizeIndex.EyeColorLeft] = CustomizeIndex.EyeColorLeft.ToNameU8(); + nameArray[(int)CustomizeIndex.EyeColorRight] = CustomizeIndex.EyeColorRight.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature1] = CustomizeIndex.FacialFeature1.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature2] = CustomizeIndex.FacialFeature2.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature3] = CustomizeIndex.FacialFeature3.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature4] = CustomizeIndex.FacialFeature4.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature5] = CustomizeIndex.FacialFeature5.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature6] = CustomizeIndex.FacialFeature6.ToNameU8(); + nameArray[(int)CustomizeIndex.FacialFeature7] = CustomizeIndex.FacialFeature7.ToNameU8(); + nameArray[(int)CustomizeIndex.LegacyTattoo] = CustomizeIndex.LegacyTattoo.ToNameU8(); + nameArray[(int)CustomizeIndex.SmallIris] = CustomizeIndex.SmallIris.ToNameU8(); + nameArray[(int)CustomizeIndex.Lipstick] = CustomizeIndex.Lipstick.ToNameU8(); + nameArray[(int)CustomizeIndex.FacePaintReversed] = CustomizeIndex.FacePaintReversed.ToNameU8(); return nameArray; } @@ -286,7 +289,7 @@ internal class CustomizeSetFactory( private static MenuType[] GetMenuTypes(CharaMakeType row) { // Set up the menu types for all customizations. - return Enum.GetValues().Select(c => + return CustomizeIndex.Values.Select(c => { // Those types are not correctly given in the menu, so special case them to color pickers. switch (c) @@ -370,13 +373,13 @@ internal class CustomizeSetFactory( internal static void SetOrder(CustomizeSet set) { - var ret = Enum.GetValues().ToArray(); + var ret = CustomizeIndex.Values.ToArray(); ret[(int)CustomizeIndex.TattooColor] = CustomizeIndex.EyeColorLeft; ret[(int)CustomizeIndex.EyeColorLeft] = CustomizeIndex.EyeColorRight; ret[(int)CustomizeIndex.EyeColorRight] = CustomizeIndex.TattooColor; var dict = ret.Skip(2).Where(set.IsAvailable).GroupBy(set.Type).ToDictionary(k => k.Key, k => k.ToArray()); - foreach (var type in Enum.GetValues()) + foreach (var type in MenuType.Values) dict.TryAdd(type, []); set.Order = dict; } @@ -443,4 +446,9 @@ internal class CustomizeSetFactory( static (CustomizeData, CustomizeData) Create(CustomizeIndex i, uint data) => (new CustomizeData(i, CustomizeValue.Zero, data), new CustomizeData(i, CustomizeValue.Max, data, 1)); } + + /// Check whether an icon exists. + private bool IconExists(uint iconId) + => textures.TryGetIconPath(new GameIconLookup(iconId), out _) + || textures.TryGetIconPath(new GameIconLookup(iconId, false, false), out _); } diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index e614e5c..47179ad 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -6,6 +6,7 @@ using Glamourer.Gui; using Glamourer.Interop; using Glamourer.Services; using Glamourer.State; +using ImSharp; using Luna; using Penumbra.GameData.Interop; using Logger = OtterGui.Log.Logger; @@ -109,7 +110,7 @@ public class Glamourer : IDalamudPlugin sb.AppendLine("**State**"); foreach (var (ident, state) in states) { - var sources = Enum.GetValues().Select(s => (0, s)).ToArray(); + var sources = StateSource.Values.Select(s => (0, s)).ToArray(); foreach (var source in StateIndex.All.Select(s => state.Sources[s])) ++sources[(int)source].Item1; foreach (var material in state.Materials.Values) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index deab4d6..f759698 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -21,11 +21,11 @@ public partial class CustomizationDrawer if (_withApply) { using var disabled = Im.Disabled(_locked); - if (UiHelpers.DrawCheckbox("##applyGender", "Apply gender of this design.", ChangeApply.HasFlag(CustomizeFlag.Gender), + if (UiHelpers.DrawCheckbox("##applyGender"u8, "Apply gender of this design."u8, ChangeApply.HasFlag(CustomizeFlag.Gender), out var applyGender, _locked)) ChangeApply = applyGender ? ChangeApply | CustomizeFlag.Gender : ChangeApply & ~CustomizeFlag.Gender; Im.Line.Same(); - if (UiHelpers.DrawCheckbox("##applyClan", "Apply clan of this design.", ChangeApply.HasFlag(CustomizeFlag.Clan), out var applyClan, + if (UiHelpers.DrawCheckbox("##applyClan"u8, "Apply clan of this design."u8, ChangeApply.HasFlag(CustomizeFlag.Clan), out var applyClan, _locked)) ChangeApply = applyClan ? ChangeApply | CustomizeFlag.Clan : ChangeApply & ~CustomizeFlag.Clan; Im.Line.Same(); diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 2976e8f..4aab41f 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -252,7 +252,7 @@ public partial class CustomizationDrawer var tmp = _currentByte != CustomizeValue.Zero; if (_withApply) { - switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), tmp, _currentApply, out var newValue, out var newApply, _locked)) + switch (UiHelpers.DrawMetaToggle(_currentIndex.ToNameU8(), tmp, _currentApply, out var newValue, out var newApply, _locked)) { case (true, false): _customize.Set(idx, newValue ? CustomizeValue.Max : CustomizeValue.Zero); @@ -278,20 +278,20 @@ public partial class CustomizationDrawer } Im.Line.Same(); - Im.Text(_currentIndex.ToDefaultName()); + Im.Text(_currentIndex.ToNameU8()); } } private void ApplyCheckbox() { - if (UiHelpers.DrawCheckbox("##apply", $"Apply the {_currentOption} customization in this design.", _currentApply, out _, _locked)) + if (UiHelpers.DrawCheckbox("##apply"u8, $"Apply the {_currentOption} customization in this design.", _currentApply, out _, _locked)) ToggleApply(); } private void ApplyCheckbox(CustomizeIndex index) { using var id = SetId(index); - if (UiHelpers.DrawCheckbox("##apply", $"Apply the {_currentOption} customization in this design.", _currentApply, out _, _locked)) + if (UiHelpers.DrawCheckbox("##apply"u8, $"Apply the {_currentOption} customization in this design.", _currentApply, out _, _locked)) ToggleApply(); } diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs index 1b4c367..07bb9e0 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs @@ -262,7 +262,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import private static void DrawApply(in CustomizeParameterDrawData data) { - if (UiHelpers.DrawCheckbox("##apply", "Apply this custom parameter when applying the Design.", data.CurrentApply, out var enabled, + if (UiHelpers.DrawCheckbox("##apply"u8, "Apply this custom parameter when applying the Design."u8, data.CurrentApply, out var enabled, data.Locked)) data.ChangeApplyParameter(enabled); } diff --git a/Glamourer/Gui/DesignCombo.cs b/Glamourer/Gui/DesignCombo.cs index 2cd845d..4ba13fc 100644 --- a/Glamourer/Gui/DesignCombo.cs +++ b/Glamourer/Gui/DesignCombo.cs @@ -60,7 +60,7 @@ public abstract class DesignComboBase : FilterComboCache= 0) diff --git a/Glamourer/Gui/Equipment/BonusItemCombo.cs b/Glamourer/Gui/Equipment/BonusItemCombo.cs index 4e1f901..6b1445e 100644 --- a/Glamourer/Gui/Equipment/BonusItemCombo.cs +++ b/Glamourer/Gui/Equipment/BonusItemCombo.cs @@ -57,7 +57,7 @@ public sealed class BonusItemCombo : FilterComboCache _innerWidth = innerWidth; _currentItem = previewIdx; CustomVariant = 0; - return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()); + return Draw($"##{Label}", previewName, string.Empty, width, Im.Style.TextHeightWithSpacing); } protected override float GetFilterWidth() @@ -77,7 +77,7 @@ public sealed class BonusItemCombo : FilterComboCache Im.Line.Same(); var ret = ImGui.Selectable(name, selected); Im.Line.Same(); - using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); + using var color = ImGuiColor.Text.Push(0xFF808080); ImGuiUtil.RightAlign($"({obj.PrimaryId.Id}-{obj.Variant.Id})"); return ret; } @@ -110,7 +110,7 @@ public sealed class BonusItemCombo : FilterComboCache protected override void OnClosePopup() { // If holding control while the popup closes, try to parse the input as a full pair of set id and variant, and set a custom item for that. - if (!ImGui.GetIO().KeyCtrl) + if (!Im.Io.KeyControl) return; var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index d1dda3a..5841ad5 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -1,16 +1,15 @@ using Dalamud.Interface.Components; -using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; using Glamourer.Events; using Glamourer.Gui.Materials; using Glamourer.Services; using Glamourer.Unlocks; using ImSharp; +using Luna; using Penumbra.GameData.Data; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; -using MouseWheelType = OtterGui.Widgets.MouseWheelType; namespace Glamourer.Gui.Equipment; @@ -51,7 +50,7 @@ public class EquipmentDrawer _itemCombo = EquipSlotExtensions.EqdpSlots.Select(e => new ItemCombo(gameData, items, e, Glamourer.Log, favorites)).ToArray(); _bonusItemCombo = BonusExtensions.AllFlags.Select(f => new BonusItemCombo(gameData, items, f, Glamourer.Log, favorites)).ToArray(); _weaponCombo = new Dictionary(FullEquipTypeExtensions.WeaponTypes.Count * 2); - foreach (var type in Enum.GetValues()) + foreach (var type in FullEquipType.Values) { if (type.ToSlot() is EquipSlot.MainHand) _weaponCombo.TryAdd(type, new WeaponCombo(items, type, Glamourer.Log, favorites)); @@ -142,7 +141,7 @@ public class EquipmentDrawer { if (data.DisplayApplication) { - var (valueChanged, applyChanged) = UiHelpers.DrawMetaToggle(data.Label.ToString(), data.CurrentValue, data.CurrentApply, + var (valueChanged, applyChanged) = UiHelpers.DrawMetaToggle(data.Label, data.CurrentValue, data.CurrentApply, out var newValue, out var newApply, data.Locked); if (valueChanged) @@ -152,7 +151,7 @@ public class EquipmentDrawer } else { - if (UiHelpers.DrawCheckbox(data.Label.ToString(), data.Tooltip.ToString(), data.CurrentValue, out var newValue, data.Locked)) + if (UiHelpers.DrawCheckbox(data.Label, data.Tooltip, data.CurrentValue, out var newValue, data.Locked)) data.SetValue(newValue); } } @@ -160,7 +159,7 @@ public class EquipmentDrawer public bool DrawAllStain(out StainIds ret, bool locked) { using var disabled = Im.Disabled(locked); - var change = _stainCombo.Draw("Dye All Slots", Stain.None.RgbaColor, string.Empty, false, false, MouseWheelType.None); + var change = _stainCombo.Draw("Dye All Slots", Stain.None.RgbaColor, string.Empty, false, false, OtterGui.Widgets.MouseWheelType.None); ret = StainIds.None; if (change) if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out var stain)) @@ -210,7 +209,8 @@ public class EquipmentDrawer private void DrawBonusItemSmall(in BonusDrawData bonusDrawData) { - ImGui.Dummy(new Vector2(StainId.NumStains * ImUtf8.FrameHeight + (StainId.NumStains - 1) * ImUtf8.ItemSpacing.X, ImUtf8.FrameHeight)); + Im.Dummy(new Vector2(StainId.NumStains * Im.Style.FrameHeight + (StainId.NumStains - 1) * Im.Style.ItemSpacing.X, + Im.Style.FrameHeight)); Im.Line.Same(); DrawBonusItem(bonusDrawData, out var label, true, false, false); if (bonusDrawData.DisplayApplication) @@ -275,10 +275,10 @@ public class EquipmentDrawer private void DrawEquipNormal(in EquipDrawData equipDrawData) { equipDrawData.CurrentItem.DrawIcon(_textures, _iconSize, equipDrawData.Slot); - var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); - var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); + var right = Im.Item.RightClicked(); + var left = Im.Item.Clicked(); Im.Line.Same(); - using var group = ImRaii.Group(); + using var group = Im.Group(); DrawItem(equipDrawData, out var label, false, right, left); if (equipDrawData.DisplayApplication) { @@ -302,15 +302,15 @@ public class EquipmentDrawer if (VerifyRestrictedGear(equipDrawData)) { Im.Line.Same(); - ImUtf8.Text("(Restricted)"u8); + Im.Text("(Restricted)"u8); } } private void DrawBonusItemNormal(in BonusDrawData bonusDrawData) { bonusDrawData.CurrentItem.DrawIcon(_textures, _iconSize, bonusDrawData.Slot); - var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); - var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); + var right = Im.Item.RightClicked(); + var left = Im.Item.Clicked(); Im.Line.Same(); DrawBonusItem(bonusDrawData, out var label, false, right, left); if (bonusDrawData.DisplayApplication) @@ -328,13 +328,12 @@ public class EquipmentDrawer private void DrawWeaponsNormal(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { - using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, - Im.Style.ItemInnerSpacing with { Y = Im.Style.ItemSpacing.Y }); + using var style = ImStyleDouble.ItemSpacing.PushX(Im.Style.ItemInnerSpacing.X); mainhand.CurrentItem.DrawIcon(_textures, _iconSize, EquipSlot.MainHand); - var left = ImGui.IsItemClicked(ImGuiMouseButton.Left); + var left = Im.Item.Clicked(); Im.Line.Same(); - using (ImUtf8.Group()) + using (Im.Group()) { DrawMainhand(ref mainhand, ref offhand, out var mainhandLabel, allWeapons, false, left); if (mainhand.DisplayApplication) @@ -362,10 +361,10 @@ public class EquipmentDrawer return; offhand.CurrentItem.DrawIcon(_textures, _iconSize, EquipSlot.OffHand); - var right = ImGui.IsItemClicked(ImGuiMouseButton.Right); - left = ImGui.IsItemClicked(ImGuiMouseButton.Left); + var right = Im.Item.RightClicked(); + left = Im.Item.Clicked(); Im.Line.Same(); - using (ImUtf8.Group()) + using (Im.Group()) { DrawOffhand(mainhand, offhand, out var offhandLabel, false, right, left); if (offhand.DisplayApplication) @@ -391,11 +390,11 @@ public class EquipmentDrawer private void DrawStain(in EquipDrawData data, bool small) { - using var disabled = ImRaii.Disabled(data.Locked); - var width = (_comboLength - ImUtf8.ItemInnerSpacing.X * (data.CurrentStains.Count - 1)) / data.CurrentStains.Count; - foreach (var (stainId, index) in data.CurrentStains.WithIndex()) + using var disabled = Im.Disabled(data.Locked); + var width = (_comboLength - Im.Style.ItemInnerSpacing.X * (data.CurrentStains.Count - 1)) / data.CurrentStains.Count; + foreach (var (index, stainId) in data.CurrentStains.Index()) { - using var id = ImUtf8.PushId(index); + using var id = Im.Id.Push(index); var found = _stainData.TryGetValue(stainId, out var stain); var change = small ? _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss) @@ -406,7 +405,7 @@ public class EquipmentDrawer DrawStainDragDrop(data, index, stain, found); if (index < data.CurrentStains.Count - 1) - ImUtf8.SameLineInner(); + Im.Line.SameInner(); if (change) if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out stain)) @@ -423,16 +422,16 @@ public class EquipmentDrawer { if (found) { - using var dragSource = ImUtf8.DragDropSource(); + using var dragSource = Im.DragDrop.Source(); if (dragSource.Success) { - DragDropSource.SetPayload("stainDragDrop"u8); + dragSource.SetPayload("stainDragDrop"u8); _draggedStain = stain; - ImUtf8.Text($"Dragging {stain.Name}..."); + Im.Text($"Dragging {stain.Name}..."); } } - using var dragTarget = ImUtf8.DragDropTarget(); + using var dragTarget = Im.DragDrop.Target(); if (dragTarget.IsDropping("stainDragDrop"u8) && _draggedStain.HasValue) { data.SetStains(data.CurrentStains.With(index, _draggedStain.Value.RowIndex)); @@ -449,7 +448,7 @@ public class EquipmentDrawer if (!data.Locked && open) UiHelpers.OpenCombo($"##{combo.Label}"); - using var disabled = ImRaii.Disabled(data.Locked); + using var disabled = Im.Disabled(data.Locked); var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.ItemId, small ? _comboLength - Im.Style.FrameHeight : _comboLength, _requiredComboWidth); DrawGearDragDrop(data); @@ -471,15 +470,15 @@ public class EquipmentDrawer if (!data.Locked && open) UiHelpers.OpenCombo($"##{combo.Label}"); - using var disabled = ImRaii.Disabled(data.Locked); + using var disabled = Im.Disabled(data.Locked); var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.Id.BonusItem, small ? _comboLength - Im.Style.FrameHeight : _comboLength, _requiredComboWidth); - if (ImGui.IsItemHovered() && ImGui.GetIO().KeyCtrl) + if (Im.Item.Hovered() && Im.Io.KeyControl) { - if (ImGui.IsKeyPressed(ImGuiKey.C)) + if (Im.Keyboard.IsPressed(Key.C)) _itemCopy.Copy(combo.CurrentSelection); - else if (ImGui.IsKeyPressed(ImGuiKey.V)) + else if (Im.Keyboard.IsPressed(Key.V)) _itemCopy.Paste(data.Slot.ToEquipType(), data.SetItem); } @@ -497,15 +496,15 @@ public class EquipmentDrawer { if (data.CurrentItem.Valid) { - using var dragSource = ImUtf8.DragDropSource(); + using var dragSource = Im.DragDrop.Source(); if (dragSource.Success) { - DragDropSource.SetPayload("equipDragDrop"u8); + dragSource.SetPayload("equipDragDrop"u8); _draggedItem.Update(_items, data.CurrentItem, data.Slot); } } - using var dragTarget = ImUtf8.DragDropTarget(); + using var dragTarget = Im.DragDrop.Target(); if (!dragTarget) return; @@ -521,21 +520,20 @@ public class EquipmentDrawer _draggedItem.Clear(); } - public unsafe void DrawDragDropTooltip() + public void DrawDragDropTooltip() { - var payload = ImGui.GetDragDropPayload().Handle; - if (payload is null) + var payload = Im.DragDrop.PeekPayload(); + if (!payload.Valid) return; - if (!MemoryMarshal.CreateReadOnlySpanFromNullTerminated((byte*)Unsafe.AsPointer(ref payload->DataType_0)) - .SequenceEqual("equipDragDrop"u8)) + if (!payload.CheckType("equipDragDrop"u8)) return; - using var tt = ImUtf8.Tooltip(); + using var tt = Im.Tooltip.Begin(); if (_dragTarget is EquipSlot.Unknown) - ImUtf8.Text($"Dragging {_draggedItem.Dragged.Name}..."); + Im.Text($"Dragging {_draggedItem.Dragged.Name}..."); else - ImUtf8.Text($"Converting to {_draggedItem[_dragTarget].Name}..."); + Im.Text($"Converting to {_draggedItem[_dragTarget].Name}..."); } private static bool ResetOrClear(bool locked, bool clicked, bool allowRevert, bool allowClear, @@ -547,21 +545,25 @@ public class EquipmentDrawer return false; } - clicked = clicked || ImGui.IsItemClicked(ImGuiMouseButton.Right); + clicked = clicked || Im.Item.RightClicked(); (var tt, item, var valid) = (allowRevert && !revertItem.Equals(currentItem), allowClear && !clearItem.Equals(currentItem), - ImGui.GetIO().KeyCtrl) switch + Im.Io.KeyControl) switch { - (true, true, true) => ("Right-click to clear. Control and Right-Click to revert to game.\nControl and mouse wheel to scroll.", + (true, true, true) => RefTuple.Create( + "Right-click to clear. Control and Right-Click to revert to game.\nControl and mouse wheel to scroll."u8, revertItem, true), - (true, true, false) => ("Right-click to clear. Control and Right-Click to revert to game.\nControl and mouse wheel to scroll.", + (true, true, false) => RefTuple.Create( + "Right-click to clear. Control and Right-Click to revert to game.\nControl and mouse wheel to scroll."u8, clearItem, true), - (true, false, true) => ("Control and Right-Click to revert to game.\nControl and mouse wheel to scroll.", revertItem, true), - (true, false, false) => ("Control and Right-Click to revert to game.\nControl and mouse wheel to scroll.", default, false), - (false, true, _) => ("Right-click to clear.\nControl and mouse wheel to scroll.", clearItem, true), - (false, false, _) => ("Control and mouse wheel to scroll.", default, false), + (true, false, true) => RefTuple.Create("Control and Right-Click to revert to game.\nControl and mouse wheel to scroll."u8, + revertItem, true), + (true, false, false) => RefTuple.Create("Control and Right-Click to revert to game.\nControl and mouse wheel to scroll."u8, + (T?)default!, false), + (false, true, _) => RefTuple.Create("Right-click to clear.\nControl and mouse wheel to scroll."u8, clearItem, true), + (false, false, _) => RefTuple.Create("Control and mouse wheel to scroll."u8, (T?)default!, false), }; - ImUtf8.HoverTooltip(tt); + Im.Tooltip.OnHover(tt); return clicked && valid; } @@ -577,9 +579,9 @@ public class EquipmentDrawer label = combo.Label; var unknown = !_gPose.InGPose && mainhand.CurrentItem.Type is FullEquipType.Unknown; - using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Im.Style.ItemInnerSpacing); + using var style = ImStyleDouble.ItemSpacing.Push(Im.Style.ItemInnerSpacing); EquipItem? changedItem = null; - using (var _ = ImRaii.Disabled(mainhand.Locked | unknown)) + using (Im.Disabled(mainhand.Locked | unknown)) { if (!mainhand.Locked && open) UiHelpers.OpenCombo($"##{label}"); @@ -609,7 +611,7 @@ public class EquipmentDrawer } if (unknown) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "The weapon type could not be identified, thus changing it to other weapons of that type is not possible."u8); } @@ -624,7 +626,7 @@ public class EquipmentDrawer label = combo.Label; var locked = offhand.Locked || !_gPose.InGPose && (offhand.CurrentItem.Type.IsUnknown() || mainhand.CurrentItem.Type.IsUnknown()); - using var disabled = ImRaii.Disabled(locked); + using var disabled = Im.Disabled(locked); if (!locked && open) UiHelpers.OpenCombo($"##{combo.Label}"); if (combo.Draw(offhand.CurrentItem.Name, offhand.CurrentItem.ItemId, small ? _comboLength - Im.Style.FrameHeight : _comboLength, @@ -642,21 +644,24 @@ public class EquipmentDrawer private static void DrawApply(in EquipDrawData data) { - if (UiHelpers.DrawCheckbox($"##apply{data.Slot}", "Apply this item when applying the Design.", data.CurrentApply, out var enabled, + using var id = Im.Id.Push((int)data.Slot); + if (UiHelpers.DrawCheckbox("##apply"u8, "Apply this item when applying the Design."u8, data.CurrentApply, out var enabled, data.Locked)) data.SetApplyItem(enabled); } private static void DrawApply(in BonusDrawData data) { - if (UiHelpers.DrawCheckbox($"##apply{data.Slot}", "Apply this bonus item when applying the Design.", data.CurrentApply, out var enabled, + using var id = Im.Id.Push((int)data.Slot); + if (UiHelpers.DrawCheckbox("##apply"u8, "Apply this bonus item when applying the Design."u8, data.CurrentApply, out var enabled, data.Locked)) data.SetApplyItem(enabled); } private static void DrawApplyStain(in EquipDrawData data) { - if (UiHelpers.DrawCheckbox($"##applyStain{data.Slot}", "Apply this dye to the item when applying the Design.", data.CurrentApplyStain, + using var id = Im.Id.Push((int)data.Slot); + if (UiHelpers.DrawCheckbox("##applyStain"u8, "Apply this dye to the item when applying the Design."u8, data.CurrentApplyStain, out var enabled, data.Locked)) data.SetApplyStain(enabled); @@ -666,30 +671,29 @@ public class EquipmentDrawer private void WeaponHelpMarker(bool hasAdvancedDyes, string label, string? type = null) { - Im.Line.Same(); - ImGuiComponents.HelpMarker( - "Changing weapons to weapons of different types can cause crashes, freezes, soft- and hard locks and cheating, " - + "thus it is only allowed to change weapons to other weapons of the same type."); + LunaStyle.DrawAlignedHelpMarker( + "Changing weapons to weapons of different types can cause crashes, freezes, soft- and hard locks and cheating, "u8 + + "thus it is only allowed to change weapons to other weapons of the same type."u8); DrawEquipLabel(hasAdvancedDyes, label); - if (type == null) + if (type is null) return; - var pos = ImGui.GetItemRectMin(); + var pos = Im.Item.UpperLeftCorner; pos.Y += Im.Style.FrameHeightWithSpacing; - ImGui.GetWindowDrawList().AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), $"({type})"); + Im.Window.DrawList.Text(pos, ImGuiColor.Text.Get(), $"({type})"); } [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] private void DrawEquipLabel(bool hasAdvancedDyes, string label) { Im.Line.Same(); - using (ImRaii.PushColor(ImGuiCol.Text, _advancedMaterialColor, hasAdvancedDyes)) + using (ImGuiColor.Text.Push(_advancedMaterialColor, hasAdvancedDyes)) { - ImUtf8.Text(label); + Im.Text(label); } if (hasAdvancedDyes) - ImUtf8.HoverTooltip("This design has advanced dyes setup for this slot."u8); + Im.Tooltip.OnHover("This design has advanced dyes setup for this slot."u8); } } diff --git a/Glamourer/Gui/Equipment/GlamourerColorCombo.cs b/Glamourer/Gui/Equipment/GlamourerColorCombo.cs index 3b3fd3f..002728f 100644 --- a/Glamourer/Gui/Equipment/GlamourerColorCombo.cs +++ b/Glamourer/Gui/Equipment/GlamourerColorCombo.cs @@ -21,7 +21,7 @@ public sealed class GlamourerColorCombo(float _comboWidth, DictStain _stains, Fa if (globalIdx == 0) { using var font = ImRaii.PushFont(UiBuilder.IconFont); - ImGui.Dummy(ImGui.CalcTextSize(FontAwesomeIcon.Star.ToIconString())); + Im.Dummy(ImGui.CalcTextSize(FontAwesomeIcon.Star.ToIconString())); } else { @@ -31,7 +31,7 @@ public sealed class GlamourerColorCombo(float _comboWidth, DictStain _stains, Fa Im.Line.Same(); } - var buttonWidth = ImGui.GetContentRegionAvail().X; + var buttonWidth = Im.ContentRegion.Available.X; var totalWidth = ImGui.GetContentRegionMax().X; using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(buttonWidth / 2 / totalWidth, 0.5f)); diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index 6688fce..8f6898c 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -57,7 +57,7 @@ public sealed class ItemCombo : FilterComboCache _innerWidth = innerWidth; _currentItem = previewIdx; CustomVariant = 0; - return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()); + return Draw($"##{Label}", previewName, string.Empty, width, Im.Style.TextHeightWithSpacing); } protected override float GetFilterWidth() @@ -77,7 +77,7 @@ public sealed class ItemCombo : FilterComboCache Im.Line.Same(); var ret = ImGui.Selectable(name, selected); Im.Line.Same(); - using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); + using var color = ImGuiColor.Text.Push(0xFF808080); ImUtf8.TextRightAligned($"({obj.PrimaryId.Id}-{obj.Variant.Id})"); return ret; } @@ -123,7 +123,7 @@ public sealed class ItemCombo : FilterComboCache protected override void OnClosePopup() { // If holding control while the popup closes, try to parse the input as a full pair of set id and variant, and set a custom item for that. - if (!ImGui.GetIO().KeyCtrl) + if (!Im.Io.KeyControl) return; var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/Glamourer/Gui/Equipment/WeaponCombo.cs b/Glamourer/Gui/Equipment/WeaponCombo.cs index 043f3e4..dd2c1fb 100644 --- a/Glamourer/Gui/Equipment/WeaponCombo.cs +++ b/Glamourer/Gui/Equipment/WeaponCombo.cs @@ -11,6 +11,7 @@ using OtterGui.Widgets; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; using MouseWheelType = OtterGui.Widgets.MouseWheelType; +using Luna; namespace Glamourer.Gui.Equipment; @@ -25,7 +26,7 @@ public sealed class WeaponCombo : FilterComboCache public SecondaryId CustomWeaponId { get; private set; } public Variant CustomVariant { get; private set; } - public WeaponCombo(ItemManager items, FullEquipType type, Logger log, FavoriteManager favorites) + public WeaponCombo(ItemManager items, FullEquipType type, OtterGui.Log.Logger log, FavoriteManager favorites) : base(() => GetWeapons(favorites, items, type), MouseWheelType.Control, log) { _favorites = favorites; @@ -55,7 +56,7 @@ public sealed class WeaponCombo : FilterComboCache _innerWidth = innerWidth; _currentItem = previewIdx; CustomVariant = 0; - return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()); + return Draw($"##{Label}", previewName, string.Empty, width, Im.Style.TextHeightWithSpacing); } protected override float GetFilterWidth() @@ -76,7 +77,7 @@ public sealed class WeaponCombo : FilterComboCache Im.Line.Same(); var ret = ImGui.Selectable(name, selected); Im.Line.Same(); - using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080); + using var color = ImGuiColor.Text.Push(0xFF808080); ImUtf8.TextRightAligned($"({obj.PrimaryId.Id}-{obj.SecondaryId.Id}-{obj.Variant.Id})"); return ret; } @@ -84,7 +85,7 @@ public sealed class WeaponCombo : FilterComboCache protected override void OnClosePopup() { // If holding control while the popup closes, try to parse the input as a full tuple of set id, weapon id and variant, and set a custom item for that. - if (!ImGui.GetIO().KeyCtrl) + if (!Im.Io.KeyControl) return; var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -113,7 +114,7 @@ public sealed class WeaponCombo : FilterComboCache if (type is FullEquipType.Unknown) { var enumerable = Array.Empty().AsEnumerable(); - foreach (var t in Enum.GetValues().Where(e => e.ToSlot() is EquipSlot.MainHand)) + foreach (var t in FullEquipType.Values.Where(e => e.ToSlot() is EquipSlot.MainHand)) { if (items.ItemData.ByType.TryGetValue(t, out var l)) enumerable = enumerable.Concat(l); diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index 3c7e2bd..455cefd 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -1,6 +1,4 @@ using Dalamud.Interface; -using Dalamud.Interface.ImGuiNotification; -using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Render; using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle; @@ -302,7 +300,7 @@ public sealed unsafe class AdvancedDyePopup( catch (Exception ex) { Glamourer.Messager.AddMessage(new Notification(ex, "Could not paste color table from clipboard.", - "Could not paste color table from clipboard.", NotificationType.Error)); + "Could not paste color table from clipboard.")); } table = default; @@ -311,7 +309,7 @@ public sealed unsafe class AdvancedDyePopup( private void DrawAllRow(MaterialValueIndex materialIndex, in ColorTable.Table table) { - using var id = Im.Id.Push(100); + using var id = Im.Id.Push(100); ImEx.Icon.Button(LunaStyle.OnHoverIcon, "Highlight all affected colors on the character."u8); if (Im.Item.Hovered()) preview.OnHover(materialIndex with { RowIndex = byte.MaxValue }, _actor.Index, table); @@ -387,56 +385,55 @@ public sealed unsafe class AdvancedDyePopup( } Im.Line.Same(0, Im.Style.ItemSpacing.X * 2); - var applied = ImEx.ColorPicker("##diffuse"u8, "Change the diffuse value for this row."u8, value.Model.Diffuse, out var newColor, "D"u8); - if (applied) - value.Model.Diffuse = newColor; + var applied = ImEx.ColorPickerButton("##diffuse"u8, "Change the diffuse value for this row."u8, value.Model.Diffuse, + out value.Model.Diffuse, 'D'); var spacing = Im.Style.ItemInnerSpacing; - ImGui.SameLine(0, spacing.X); - applied |= ImUtf8.ColorPicker("##specular"u8, "Change the specular value for this row."u8, value.Model.Specular, - v => value.Model.Specular = v, "S"u8); + Im.Line.Same(0, spacing.X); + applied |= ImEx.ColorPickerButton("##specular"u8, "Change the specular value for this row."u8, value.Model.Specular, + out value.Model.Specular, 'S'); - ImGui.SameLine(0, spacing.X); - applied |= ImUtf8.ColorPicker("##emissive"u8, "Change the emissive value for this row."u8, value.Model.Emissive, - v => value.Model.Emissive = v, "E"u8); + Im.Line.Same(0, spacing.X); + applied |= ImEx.ColorPickerButton("##emissive"u8, "Change the emissive value for this row."u8, value.Model.Emissive, + out value.Model.Emissive, 'E'); - ImGui.SameLine(0, spacing.X); + Im.Line.Same(0, spacing.X); if (_mode is not ColorRow.Mode.Dawntrail) { - ImGui.SetNextItemWidth(100 * Im.Style.GlobalScale); + Im.Item.SetNextWidthScaled(100); applied |= DragGloss(ref value.Model.GlossStrength); - ImUtf8.HoverTooltip("Change the gloss strength for this row."u8); + Im.Tooltip.OnHover("Change the gloss strength for this row."u8); } else { - ImGui.Dummy(new Vector2(100 * Im.Style.GlobalScale, 0)); + Im.Dummy(new Vector2(100 * Im.Style.GlobalScale, 0)); } - ImGui.SameLine(0, spacing.X); + Im.Line.Same(0, spacing.X); if (_mode is not ColorRow.Mode.Dawntrail) { - ImGui.SetNextItemWidth(100 * Im.Style.GlobalScale); + Im.Item.SetNextWidthScaled(100); applied |= DragSpecularStrength(ref value.Model.SpecularStrength); - ImUtf8.HoverTooltip("Change the specular strength for this row."u8); + Im.Tooltip.OnHover("Change the specular strength for this row."u8); } else { - ImGui.Dummy(new Vector2(100 * Im.Style.GlobalScale, 0)); + Im.Dummy(new Vector2(100 * Im.Style.GlobalScale, 0)); } - ImGui.SameLine(0, spacing.X); - if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8, buttonSize)) + Im.Line.Same(0, spacing.X); + if (ImEx.Icon.Button(LunaStyle.ToClipboardIcon, "Export this row to your clipboard."u8)) ColorRowClipboard.Row = value.Model; - ImGui.SameLine(0, spacing.X); - if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8, buttonSize, + Im.Line.Same(0, spacing.X); + if (ImEx.Icon.Button(LunaStyle.FromClipboardIcon, "Import an exported row from your clipboard onto this row."u8, !ColorRowClipboard.IsSet)) { value.Model = ColorRowClipboard.Row; applied = true; } - ImGui.SameLine(0, spacing.X); - if (ImUtf8.IconButton(FontAwesomeIcon.UndoAlt, "Reset this row to game state."u8, buttonSize, !changed)) + Im.Line.Same(0, spacing.X); + if (ImEx.Icon.Button(LunaStyle.UndoIcon, "Reset this row to game state."u8, !changed)) stateManager.ResetMaterialValue(_state, index, ApplySettings.Game); if (applied) @@ -446,9 +443,8 @@ public sealed unsafe class AdvancedDyePopup( public static bool DragGloss(ref float value) { var tmp = value; - var minValue = ImGui.GetIO().KeyCtrl ? 0f : (float)Half.Epsilon; - if (!ImUtf8.DragScalar("##Gloss"u8, ref tmp, "%.1f G"u8, 0.001f, minValue, Math.Max(0.01f, 0.005f * value), - ImGuiSliderFlags.AlwaysClamp)) + var minValue = Im.Io.KeyControl ? 0f : (float)Half.Epsilon; + if (!Im.Drag("##Gloss"u8, ref tmp, "%.1f G"u8, 0.001f, minValue, Math.Max(0.01f, 0.005f * value), SliderFlags.AlwaysClamp)) return false; var tmp2 = Math.Clamp(tmp, minValue, (float)Half.MaxValue); @@ -462,8 +458,7 @@ public sealed unsafe class AdvancedDyePopup( public static bool DragSpecularStrength(ref float value) { var tmp = value * 100f; - if (!ImUtf8.DragScalar("##SpecularStrength"u8, ref tmp, "%.0f%% SS"u8, 0f, (float)Half.MaxValue * 100f, 0.05f, - ImGuiSliderFlags.AlwaysClamp)) + if (!Im.Drag("##SpecularStrength"u8, ref tmp, "%.0f%% SS"u8, 0f, (float)Half.MaxValue * 100f, 0.05f, SliderFlags.AlwaysClamp)) return false; var tmp2 = Math.Clamp(tmp, 0f, (float)Half.MaxValue * 100f) / 100f; diff --git a/Glamourer/Gui/Materials/MaterialDrawer.cs b/Glamourer/Gui/Materials/MaterialDrawer.cs index 102cb6c..766ff20 100644 --- a/Glamourer/Gui/Materials/MaterialDrawer.cs +++ b/Glamourer/Gui/Materials/MaterialDrawer.cs @@ -49,7 +49,7 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : ? "Enable the application of all contained advanced dyes without deleting them."u8 : "This design does not contain any advanced dyes."u8, !any || disabled)) - designManager.ChangeApplyMulti(design, null, null, null, null, null, null, true, null); + designManager.ChangeApplyMulti(design, null, null, null, null, null, null, true, null); if (disabled && any) Im.Tooltip.OnHover($"Hold {config.DeleteDesignModifier} while clicking to enable."); @@ -134,7 +134,7 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : { var deleteEnabled = config.DeleteDesignModifier.IsActive(); if (!ImEx.Icon.Button(LunaStyle.DeleteIcon, - $"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {config.DeleteDesignModifier} to delete.")}", disabled: + $"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {config.DeleteDesignModifier} to delete.")}", !deleteEnabled || design.WriteProtected())) return; @@ -151,7 +151,7 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : private void PasteButton(Design design, MaterialValueIndex index) { if (ImEx.Icon.Button(LunaStyle.FromClipboardIcon, "Import an exported row from your clipboard onto this row."u8, - disabled: !ColorRowClipboard.IsSet || design.WriteProtected())) + !ColorRowClipboard.IsSet || design.WriteProtected())) designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row); } @@ -222,7 +222,8 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : private void DrawMaterialIdxDrag() { Im.Item.SetNextWidth(Im.Font.CalculateSize("Material AA"u8).X); - if (Im.Drag("##Material"u8, ref _newMaterialIdx, $"Material {(char)('A' + _newMaterialIdx)}", 0, MaterialService.MaterialsPerModel - 1, 0.01f, SliderFlags.NoInput)) + if (Im.Drag("##Material"u8, ref _newMaterialIdx, $"Material {(char)('A' + _newMaterialIdx)}", 0, MaterialService.MaterialsPerModel - 1, + 0.01f, SliderFlags.NoInput)) { _newMaterialIdx = Math.Clamp(_newMaterialIdx, 0, MaterialService.MaterialsPerModel - 1); _newKey = _newKey with { MaterialIndex = (byte)_newMaterialIdx }; @@ -234,7 +235,8 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : private void DrawRowIdxDrag() { Im.Item.SetNextWidth(Im.Font.CalculateSize("Row 0000"u8).X); - if (Im.Drag("##Row"u8, ref _newRowIdx, $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}", 0, ColorTable.NumRows - 1, 0.01f, SliderFlags.NoInput)) + if (Im.Drag("##Row"u8, ref _newRowIdx, $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}", 0, ColorTable.NumRows - 1, 0.01f, + SliderFlags.NoInput)) { _newRowIdx = Math.Clamp(_newRowIdx, 0, ColorTable.NumRows - 1); _newKey = _newKey with { RowIndex = (byte)_newRowIdx }; @@ -247,11 +249,11 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) : { var tmp = row; using var _ = Im.Disabled(disabled); - var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", row.Diffuse, v => tmp.Diffuse = v, "D"); + var applied = ImEx.ColorPickerButton("##diffuse"u8, "Change the diffuse value for this row."u8, row.Diffuse, out tmp.Diffuse, 'D'); Im.Line.SameInner(); - applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", row.Specular, v => tmp.Specular = v, "S"); + applied |= ImEx.ColorPickerButton("##specular"u8, "Change the specular value for this row."u8, row.Specular, out tmp.Specular, 'S'); Im.Line.SameInner(); - applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E"); + applied |= ImEx.ColorPickerButton("##emissive"u8, "Change the emissive value for this row."u8, row.Emissive, out tmp.Emissive, 'E'); Im.Line.SameInner(); Im.Item.SetNextWidth(GlossWidth * Im.Style.GlobalScale); applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength); diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index c98733d..d1fe172 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -1,4 +1,5 @@ -using Dalamud.Game.ClientState.Conditions; +using Dalamud.Bindings.ImGui; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Interface; using Dalamud.Interface.ImGuiNotification; using Dalamud.Plugin.Services; @@ -11,7 +12,6 @@ using Glamourer.Gui.Equipment; using Glamourer.Gui.Materials; using Glamourer.Interop; using Glamourer.State; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; using OtterGui; @@ -133,9 +133,9 @@ public class ActorPanel private void DrawHeader() { - var textColor = !_identifier.IsValid ? ImGui.GetColorU32(ImGuiCol.Text) : + var textColor = !_identifier.IsValid ? ImGuiColor.Text.Get() : _data.Valid ? ColorId.ActorAvailable.Value() : ColorId.ActorUnavailable.Value(); - HeaderDrawer.Draw(_actorName, textColor, ImGui.GetColorU32(ImGuiCol.FrameBg), _leftButtons, _rightButtons); + HeaderDrawer.Draw(_actorName, textColor.Color, ImGuiColor.FrameBackground.Get().Color, _leftButtons, _rightButtons); SaveDesignDrawPopup(); } @@ -153,15 +153,15 @@ public class ActorPanel private unsafe void DrawPanel() { - using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + using var table = Im.Table.Begin("##Panel"u8, 1, TableFlags.BordersOuter | TableFlags.ScrollY, Im.ContentRegion.Available); if (!table || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state)) return; - ImGui.TableSetupScrollFreeze(0, 1); - ImGui.TableNextColumn(); - ImGui.Dummy(Vector2.Zero); + table.SetupScrollFreeze(0, 1); + table.NextColumn(); + Im.Dummy(Vector2.Zero); var transformationId = _actor.IsCharacter ? _actor.AsCharacter->CharacterData.TransformationId : 0; - if (transformationId != 0) + if (transformationId is not 0) ImGuiUtil.DrawTextButton($"Currently transformed to Transformation {transformationId}.", -Vector2.UnitX, Colors.SelectedRed); @@ -170,9 +170,9 @@ public class ActorPanel DrawApplyToTarget(); RevertButtons(); - ImGui.TableNextColumn(); + table.NextColumn(); - using var disabled = ImRaii.Disabled(transformationId != 0); + using var disabled = Im.Disabled(transformationId is not 0); if (_state.ModelData.IsHuman) DrawHumanPanel(); else @@ -198,7 +198,7 @@ public class ActorPanel ? "Customization" : $"Customization (Model Id #{_state.ModelData.ModelId})###Customization"; var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); - using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); + using var h = Im.Tree.HeaderId(header, expand ? TreeNodeFlags.DefaultOpen : TreeNodeFlags.None); if (!h) return; @@ -206,7 +206,7 @@ public class ActorPanel _stateManager.ChangeEntireCustomize(_state, _customizationDrawer.Customize, _customizationDrawer.Changed, ApplySettings.Manual); EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(MetaIndex.Wetness, _stateManager, _state)); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); } private void DrawEquipmentHeader() @@ -236,9 +236,9 @@ public class ActorPanel _equipmentDrawer.DrawBonusItem(data); } - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); DrawEquipmentMetaToggles(); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); _equipmentDrawer.DrawDragDropTooltip(); } @@ -260,7 +260,7 @@ public class ActorPanel if (!h) return; - using var t = ImUtf8.Table("table"u8, 2, ImGuiTableFlags.SizingFixedFit); + using var t = Im.Table.Begin("table"u8, 2, TableFlags.SizingFixedFit); if (!t) return; @@ -280,7 +280,7 @@ public class ActorPanel static void DrawCopyColumn(ref OtterGui.Text.HelperObjects.Utf8StringHandler text) { ImUtf8.DrawTableColumn(ref text); - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + if (Im.Item.RightClicked()) ImUtf8.SetClipboardText(TextStringHandlerBuffer.Span); } } @@ -317,58 +317,57 @@ public class ActorPanel private void DrawMonsterPanel() { var names = _modelChara[_state!.ModelData.ModelId]; - var turnHuman = ImGui.Button("Turn Human"); - ImGui.Separator(); - using (_ = ImRaii.ListBox("##MonsterList", - new Vector2(ImGui.GetContentRegionAvail().X, 10 * ImGui.GetTextLineHeightWithSpacing()))) + var turnHuman = Im.Button("Turn Human"u8); + Im.Separator(); + using (Im.ListBox.Begin("##MonsterList"u8, Im.ContentRegion.Available with { Y = 10 * Im.Style.TextHeightWithSpacing })) { - if (names.Count == 0) - ImGui.TextUnformatted("Unknown Monster"); + if (names.Count is 0) + Im.Text("Unknown Monster"u8); else - ImGuiClip.ClippedDraw(names, p => ImGui.TextUnformatted($"{p.Name} ({p.Kind.ToName()} #{p.Id})"), - ImGui.GetTextLineHeightWithSpacing()); + ImGuiClip.ClippedDraw(names, p => Im.Text($"{p.Name} ({p.Kind.ToName()} #{p.Id})"), + Im.Style.TextHeightWithSpacing); } - ImGui.Separator(); - ImGui.TextUnformatted("Customization Data"); - using (_ = ImRaii.PushFont(UiBuilder.MonoFont)) + Im.Separator(); + Im.Text("Customization Data"u8); + using (Im.Font.PushMono()) { foreach (var b in _state.ModelData.Customize) { - using (_ = ImRaii.Group()) + using (Im.Group()) { - ImGui.TextUnformatted($" {b.Value:X2}"); - ImGui.TextUnformatted($"{b.Value,3}"); + Im.Text($" {b.Value:X2}"); + Im.Text($"{b.Value,3}"); } Im.Line.Same(); - if (ImGui.GetContentRegionAvail().X < Im.Style.ItemSpacing.X + ImGui.CalcTextSize("XXX").X) - ImGui.NewLine(); + if (Im.ContentRegion.Available.X < Im.Style.ItemSpacing.X + Im.Font.CalculateSize("XXX"u8).X) + Im.Line.New(); } - if (ImGui.GetCursorPosX() != 0) - ImGui.NewLine(); + if (Im.Cursor.X is not 0) + Im.Line.New(); } - ImGui.Separator(); - ImGui.TextUnformatted("Equipment Data"); - using (_ = ImRaii.PushFont(UiBuilder.MonoFont)) + Im.Separator(); + Im.Text("Equipment Data"u8); + using (Im.Font.PushMono()) { foreach (var b in _state.ModelData.GetEquipmentBytes()) { - using (_ = ImRaii.Group()) + using (Im.Group()) { - ImGui.TextUnformatted($" {b:X2}"); - ImGui.TextUnformatted($"{b,3}"); + Im.Text($" {b:X2}"); + Im.Text($"{b,3}"); } Im.Line.Same(); - if (ImGui.GetContentRegionAvail().X < Im.Style.ItemSpacing.X + ImGui.CalcTextSize("XXX").X) - ImGui.NewLine(); + if (Im.ContentRegion.Available.X < Im.Style.ItemSpacing.X + Im.Font.CalculateSize("XXX"u8).X) + Im.Line.New(); } - if (ImGui.GetCursorPosX() != 0) - ImGui.NewLine(); + if (Im.Cursor.X is not 0) + Im.Line.New(); } if (turnHuman) @@ -562,10 +561,10 @@ public class ActorPanel protected override bool Disabled => true; - protected override uint BorderColor + protected override Rgba32 BorderColor => ColorId.ActorUnavailable.Value(); - protected override uint TextColor + protected override Rgba32 TextColor => ColorId.ActorUnavailable.Value(); protected override void OnClick() diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index 689970d..4a9d7d5 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -40,7 +40,7 @@ public class ActorSelector(ActorObjectManager objects, ActorManager actors, Ephe public void Draw(float width) { _width = width; - using var group = ImUtf8.Group(); + using var group = Im.Group(); _defaultItemSpacing = Im.Style.ItemSpacing; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero) .Push(ImGuiStyleVar.FrameRounding, 0); @@ -50,30 +50,30 @@ public class ActorSelector(ActorObjectManager objects, ActorManager actors, Ephe { using var tt = ImUtf8.Tooltip(); ImUtf8.Text("Filter for names containing the input."u8); - ImGui.Dummy(new Vector2(0, ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(0, Im.Style.TextHeight / 2)); ImUtf8.Text("Special filters are:"u8); var color = ColorId.HeaderButtons.Value(); - ImUtf8.Text("

"u8, color); + Im.Text("

"u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only player characters."u8); - ImUtf8.Text(""u8, color); + Im.Text(""u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only owned game objects."u8); - ImUtf8.Text(""u8, color); + Im.Text(""u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only NPCs."u8); - ImUtf8.Text(""u8, color); + Im.Text(""u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only retainers."u8); - ImUtf8.Text(""u8, color); + Im.Text(""u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only special screen characters."u8); - ImUtf8.Text(""u8, color); + Im.Text(""u8, color); ImGui.SameLine(0, 0); ImUtf8.Text(": show only players from your world."u8); } @@ -90,10 +90,10 @@ public class ActorSelector(ActorObjectManager objects, ActorManager actors, Ephe _world = new WorldId(objects.Player.Valid ? objects.Player.HomeWorld : (ushort)0); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight()); + var skips = ImGuiClip.GetNecessarySkips(Im.Style.TextHeight); var remainder = ImGuiClip.FilteredClippedDraw(objects.Where(p => p.Value.Objects.Any(a => a.Model)), skips, CheckFilter, DrawSelectable); - ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); + ImGuiClip.DrawEndDummy(remainder, Im.Style.TextHeight); } private bool CheckFilter(KeyValuePair pair) diff --git a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs index 1d3e711..32b7e0c 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/HumanNpcCombo.cs @@ -1,12 +1,14 @@ using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Utility; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui; using OtterGui.Extensions; using OtterGui.Log; using OtterGui.Widgets; using Penumbra.GameData.DataContainers; using OtterGui.Custom; +using MouseWheelType = OtterGui.Widgets.MouseWheelType; namespace Glamourer.Gui.Tabs.AutomationTab; @@ -36,7 +38,7 @@ public sealed class HumanNpcCombo( public bool Draw(float width) => Draw(label, CurrentSelection.Name.IsNullOrEmpty() ? "Human Non-Player-Characters..." : CurrentSelection.Name, string.Empty, width, - ImGui.GetTextLineHeightWithSpacing()); + Im.Style.TextHeightWithSpacing); ///

Compare strings in a way that letters and numbers are sorted before any special symbols. diff --git a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs index 3cae4a9..ca68776 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/RandomRestrictionDrawer.cs @@ -1,15 +1,10 @@ using Dalamud.Interface; -using Dalamud.Interface.Utility; using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Designs.Special; using Glamourer.Events; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; -using OtterGui; -using OtterGui.Raii; -using OtterGui.Text; namespace Glamourer.Gui.Tabs.AutomationTab; @@ -28,7 +23,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private string _newText = string.Empty; private string? _newDefinition; - private Design? _newDesign = null; + private Design? _newDesign; public RandomRestrictionDrawer(AutomationChanged automationChanged, Configuration config, AutoDesignManager autoDesignManager, RandomDesignCombo randomDesignCombo, SetSelector selector, DesignFileSystem designFileSystem, DesignStorage designs) @@ -51,13 +46,12 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable public void DrawButton(AutoDesignSet set, int designIndex) { var isOpen = set == _set && designIndex == _designIndex; - using (var color = ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(ImGuiCol.ButtonActive), isOpen) - .Push(ImGuiCol.Text, ColorId.HeaderButtons.Value(), isOpen) - .Push(ImGuiCol.Border, ColorId.HeaderButtons.Value(), isOpen)) + using (ImGuiColor.Button.Push(Im.Style[ImGuiColor.ButtonActive], isOpen) + .Push(ImGuiColor.Text, ColorId.HeaderButtons.Value(), isOpen) + .Push(ImGuiColor.Border, ColorId.HeaderButtons.Value(), isOpen)) { - using var frame = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * Im.Style.GlobalScale, isOpen); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Edit.ToIconString(), new Vector2(Im.Style.FrameHeight), - string.Empty, false, true)) + using var frame = ImStyleSingle.FrameBorderThickness.Push(2 * Im.Style.GlobalScale, isOpen); + if (ImEx.Icon.Button(LunaStyle.EditIcon)) { if (isOpen) Close(); @@ -66,7 +60,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } } - ImGuiUtil.HoverTooltip("Edit restrictions for this random design."); + Im.Tooltip.OnHover("Edit restrictions for this random design."u8); } private void Open(AutoDesignSet set, int designIndex) @@ -90,7 +84,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable public void Draw() { - if (_set == null || _designIndex < 0 || _designIndex >= _set.Designs.Count) + if (_set is null || _designIndex < 0 || _designIndex >= _set.Designs.Count) return; if (_set != _selector.Selection) @@ -108,28 +102,28 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void DrawWindow(RandomDesign random) { - var flags = ImGuiWindowFlags.NoFocusOnAppearing - | ImGuiWindowFlags.NoCollapse - | ImGuiWindowFlags.NoResize; + var flags = WindowFlags.NoFocusOnAppearing + | WindowFlags.NoCollapse + | WindowFlags.NoResize; // Set position to the right of the main window when attached // The downwards offset is implicit through child position. if (_config.KeepAdvancedDyesAttached) { - var position = ImGui.GetWindowPos(); - position.X += ImGui.GetWindowSize().X + Im.Style.WindowPadding.X; - ImGui.SetNextWindowPos(position); - flags |= ImGuiWindowFlags.NoMove; + var position = Im.Window.Position; + position.X += Im.Window.Size.X + Im.Style.WindowPadding.X; + Im.Window.SetNextPosition(position); + flags |= WindowFlags.NoMove; } - using var color = ImRaii.PushColor(ImGuiCol.TitleBgActive, ImGui.GetColorU32(ImGuiCol.TitleBg)); + using var color = ImGuiColor.TitleBackgroundActive.Push(Im.Style[ImGuiColor.TitleBackground]); var size = new Vector2(7 * Im.Style.FrameHeight + 3 * Im.Style.ItemInnerSpacing.X + 300 * Im.Style.GlobalScale, 18 * Im.Style.FrameHeightWithSpacing + Im.Style.WindowPadding.Y + Im.Style.ItemSpacing.Y); - ImGui.SetNextWindowSize(size); + Im.Window.SetNextSize(size); var open = true; - var window = ImGui.Begin($"{_set!.Name} #{_designIndex + 1:D2}###Glamourer Random Design", ref open, flags); + var window = Im.Window.Begin($"{_set!.Name} #{_designIndex + 1:D2}###Glamourer Random Design", ref open, flags); try { if (window) @@ -137,7 +131,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } finally { - ImGui.End(); + window.Dispose(); } if (!open) @@ -146,41 +140,39 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void DrawTable(RandomDesign random, List list) { - using var table = ImRaii.Table("##table", 3); + using var table = Im.Table.Begin("##table"u8, 3); if (!table) return; - using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Im.Style.ItemInnerSpacing); + using var spacing = ImStyleDouble.ItemSpacing.Push(Im.Style.ItemInnerSpacing); var buttonSize = new Vector2(Im.Style.FrameHeight); - var descWidth = ImGui.CalcTextSize("or that are set to the color").X; - ImGui.TableSetupColumn("desc", ImGuiTableColumnFlags.WidthFixed, descWidth); - ImGui.TableSetupColumn("input", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("del", ImGuiTableColumnFlags.WidthFixed, buttonSize.X * 2 + Im.Style.ItemInnerSpacing.X); + var descWidth = Im.Font.CalculateSize("or that are set to the color"u8).X; + table.SetupColumn("desc"u8, TableColumnFlags.WidthFixed, descWidth); + table.SetupColumn("input"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("del"u8, TableColumnFlags.WidthFixed, buttonSize.X * 2 + Im.Style.ItemInnerSpacing.X); - var orSize = ImGui.CalcTextSize("or "); + var orSize = Im.Font.CalculateSize("or "u8); for (var i = 0; i < random.Predicates.Count; ++i) { - using var id = ImRaii.PushId(i); + using var id = Im.Id.Push(i); var predicate = random.Predicates[i]; - ImGui.TableNextColumn(); - ImGui.AlignTextToFramePadding(); - if (i != 0) - ImGui.TextUnformatted("or "); + table.NextColumn(); + if (i is not 0) + ImEx.TextFrameAligned("or "u8); else - ImGui.Dummy(orSize); - ImGui.SameLine(0, 0); - ImGui.AlignTextToFramePadding(); + Im.Dummy(orSize); + Im.Line.NoSpacing(); switch (predicate) { case RandomPredicate.Contains contains: { - ImGui.TextUnformatted("that contain"); - ImGui.TableNextColumn(); + ImEx.TextFrameAligned("that contain"u8); + table.NextColumn(); var data = contains.Value.Text; - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); - if (ImGui.InputTextWithHint("##match", "Name, Path, or Identifier Contains...", ref data, 128)) + Im.Item.SetNextWidthFull(); + if (Im.Input.Text("##match"u8, ref data, "Name, Path, or Identifier Contains..."u8)) { - if (data.Length == 0) + if (data.Length is 0) list.RemoveAt(i); else list[i] = new RandomPredicate.Contains(data); @@ -191,13 +183,13 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } case RandomPredicate.StartsWith startsWith: { - ImGui.TextUnformatted("whose path starts with"); - ImGui.TableNextColumn(); + ImEx.TextFrameAligned("whose path starts with"u8); + table.NextColumn(); var data = startsWith.Value.Text; - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); - if (ImGui.InputTextWithHint("##startsWith", "Path Starts With...", ref data, 128)) + Im.Item.SetNextWidthFull(); + if (Im.Input.Text("##startsWith"u8, ref data, "Path Starts With..."u8)) { - if (data.Length == 0) + if (data.Length is 0) list.RemoveAt(i); else list[i] = new RandomPredicate.StartsWith(data); @@ -208,13 +200,13 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } case RandomPredicate.Exact { Which: RandomPredicate.Exact.Type.Tag } exact: { - ImGui.TextUnformatted("that contain the tag"); - ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImEx.TextFrameAligned("that contain the tag"u8); + table.NextColumn(); + Im.Item.SetNextWidthFull(); var data = exact.Value.Text; - if (ImGui.InputTextWithHint("##color", "Contained tag...", ref data, 128)) + if (Im.Input.Text("##color"u8, ref data, "Contained tag..."u8)) { - if (data.Length == 0) + if (data.Length is 0) list.RemoveAt(i); else list[i] = new RandomPredicate.Exact(RandomPredicate.Exact.Type.Tag, data); @@ -225,13 +217,13 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } case RandomPredicate.Exact { Which: RandomPredicate.Exact.Type.Color } exact: { - ImGui.TextUnformatted("that are set to the color"); - ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImEx.TextFrameAligned("that are set to the color"u8); + table.NextColumn(); + Im.Item.SetNextWidthFull(); var data = exact.Value.Text; - if (ImGui.InputTextWithHint("##color", "Assigned Color is...", ref data, 128)) + if (Im.Input.Text("##color"u8, ref data, "Assigned Color is..."u8)) { - if (data.Length == 0) + if (data.Length is 0) list.RemoveAt(i); else list[i] = new RandomPredicate.Exact(RandomPredicate.Exact.Type.Color, data); @@ -242,9 +234,9 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } case RandomPredicate.Exact exact: { - ImGui.TextUnformatted("that are exactly"); - ImGui.TableNextColumn(); - if (_randomDesignCombo.Draw(exact, ImGui.GetContentRegionAvail().X) && _randomDesignCombo.Design is Design d) + ImEx.TextFrameAligned("that are exactly"u8); + table.NextColumn(); + if (_randomDesignCombo.Draw(exact, Im.ContentRegion.Available.X) && _randomDesignCombo.Design is Design d) { list[i] = new RandomPredicate.Exact(RandomPredicate.Exact.Type.Identifier, d.Identifier.ToString()); _autoDesignManager.ChangeData(_set!, _designIndex, list); @@ -254,22 +246,22 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable } } - ImGui.TableNextColumn(); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), buttonSize, "Delete this restriction.", false, true)) + table.NextColumn(); + if (ImEx.Icon.Button(LunaStyle.DeleteIcon, "Delete this restriction."u8)) { list.RemoveAt(i); _autoDesignManager.ChangeData(_set!, _designIndex, list); } Im.Line.Same(); - DrawLookup(predicate, buttonSize); + DrawLookup(predicate); } } - private void DrawLookup(IDesignPredicate predicate, Vector2 buttonSize) + private void DrawLookup(IDesignPredicate predicate) { - ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.MagnifyingGlassChart.ToIconString(), buttonSize, string.Empty, false, true); - if (!ImGui.IsItemHovered()) + ImEx.Icon.Button(FontAwesomeIcon.MagnifyingGlassChart.Icon(), StringU8.Empty); + if (!Im.Item.Hovered()) return; var designs = predicate.Get(_designs, _designFileSystem); @@ -278,46 +270,54 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void LookupTooltip(IEnumerable designs) { - using var _ = ImRaii.Tooltip(); - var tt = string.Join('\n', designs.Select(d => _designFileSystem.TryGetValue(d, out var l) ? l.FullName() : d.Name.Text).OrderBy(t => t)); - ImGui.TextUnformatted(tt.Length == 0 - ? "Matches no currently existing designs." - : "Matches the following designs:"); - ImGui.Separator(); - ImGui.TextUnformatted(tt); + using var _ = Im.Tooltip.Begin(); + using var enumerator = designs.GetEnumerator(); + while (enumerator.MoveNext()) + { + Im.Text("Matches the following designs:"u8); + var name = _designFileSystem.TryGetValue(enumerator.Current, out var l) ? l.FullName() : enumerator.Current.Name.Text; + Im.Separator(); + Im.BulletText(name); + while (enumerator.MoveNext()) + { + name = _designFileSystem.TryGetValue(enumerator.Current, out l) ? l.FullName() : enumerator.Current.Name.Text; + Im.BulletText(name); + } + return; + } + Im.Text("Matches no currently existing designs."u8); } private void DrawNewButtons(List list) { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); - ImGui.InputTextWithHint("##newText", "Add New Restriction...", ref _newText, 128); - var spacing = Im.Style.ItemInnerSpacing.X; - var invalid = _newText.Length == 0; + Im.Item.SetNextWidthFull(); + Im.Input.Text("##newText"u8, ref _newText, "Add New Restriction..."u8); + var invalid = _newText.Length is 0; - var buttonSize = new Vector2((ImGui.GetContentRegionAvail().X - 3 * spacing) / 4, 0); - var changed = ImGuiUtil.DrawDisabledButton("Starts With", buttonSize, - "Add a new condition that design paths must start with the given text.", invalid) + var buttonSize = new Vector2((Im.ContentRegion.Available.X - 3 * Im.Style.ItemInnerSpacing.X) / 4, 0); + var changed = ImEx.Button("Starts With"u8, buttonSize, + "Add a new condition that design paths must start with the given text."u8, invalid) && Add(new RandomPredicate.StartsWith(_newText)); - ImGui.SameLine(0, spacing); - changed |= ImGuiUtil.DrawDisabledButton("Contains", buttonSize, - "Add a new condition that design paths, names or identifiers must contain the given text.", invalid) + Im.Line.SameInner(); + changed |= ImEx.Button("Contains"u8, buttonSize, + "Add a new condition that design paths, names or identifiers must contain the given text."u8, invalid) && Add(new RandomPredicate.Contains(_newText)); - ImGui.SameLine(0, spacing); - changed |= ImGuiUtil.DrawDisabledButton("Has Tag", buttonSize, - "Add a new condition that the design must contain the given tag.", invalid) + Im.Line.SameInner(); + changed |= ImEx.Button("Has Tag"u8, buttonSize, + "Add a new condition that the design must contain the given tag."u8, invalid) && Add(new RandomPredicate.Exact(RandomPredicate.Exact.Type.Tag, _newText)); - ImGui.SameLine(0, spacing); - changed |= ImGuiUtil.DrawDisabledButton("Assigned Color", buttonSize, - "Add a new condition that the design must be assigned to the given color.", invalid) + Im.Line.SameInner(); + changed |= ImEx.Button("Assigned Color"u8, buttonSize, + "Add a new condition that the design must be assigned to the given color."u8, invalid) && Add(new RandomPredicate.Exact(RandomPredicate.Exact.Type.Color, _newText)); - if (_randomDesignCombo.Draw(_newDesign, ImGui.GetContentRegionAvail().X - spacing - buttonSize.X)) + if (_randomDesignCombo.Draw(_newDesign, Im.ContentRegion.Available.X - Im.Style.ItemInnerSpacing.X - buttonSize.X)) _newDesign = _randomDesignCombo.CurrentSelection?.Item1 as Design; - ImGui.SameLine(0, spacing); - if (ImGuiUtil.DrawDisabledButton("Exact Design", buttonSize, "Add a single, specific design.", _newDesign == null)) + Im.Line.SameInner(); + if (ImEx.Button("Exact Design"u8, buttonSize, "Add a single, specific design."u8, _newDesign is null)) { Add(new RandomPredicate.Exact(RandomPredicate.Exact.Type.Identifier, _newDesign!.Identifier.ToString())); changed = true; @@ -338,30 +338,29 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void DrawManualInput(IReadOnlyList list) { - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); DrawTotalPreview(list); var currentDefinition = RandomPredicate.GeneratePredicateString(list); var definition = _newDefinition ?? currentDefinition; definition = definition.Replace(";", ";\n\t").Replace("{", "{\n\t").Replace("}", "\n}"); var lines = definition.Count(c => c is '\n'); - if (ImGui.InputTextMultiline("##definition", ref definition, 2000, - new Vector2(ImGui.GetContentRegionAvail().X, (lines + 1) * ImGui.GetTextLineHeight() + Im.Style.FrameHeight), - ImGuiInputTextFlags.CtrlEnterForNewLine)) + if (Im.Input.MultiLine("##definition"u8, ref definition, Im.ContentRegion.Available with { Y = (lines + 1) * Im.Style.TextHeight + Im.Style.FrameHeight }, + InputTextFlags.CtrlEnterForNewLine)) _newDefinition = definition; - if (ImGui.IsItemDeactivatedAfterEdit() && _newDefinition != null && _newDefinition != currentDefinition) + if (Im.Item.DeactivatedAfterEdit && _newDefinition is not null && _newDefinition != currentDefinition) { var predicates = RandomPredicate.GeneratePredicates(_newDefinition.Replace("\n", string.Empty).Replace("\t", string.Empty)); _autoDesignManager.ChangeData(_set!, _designIndex, predicates); _newDefinition = null; } - if (ImGui.Button("Copy to Clipboard Without Line Breaks", new Vector2(ImGui.GetContentRegionAvail().X, 0))) + if (Im.Button("Copy to Clipboard Without Line Breaks"u8, Im.ContentRegion.Available with { Y = 0 })) { try { - ImGui.SetClipboardText(currentDefinition); + Im.Clipboard.Set(currentDefinition); } catch { @@ -373,40 +372,38 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void DrawTotalPreview(IReadOnlyList list) { var designs = IDesignPredicate.Get(list, _designs, _designFileSystem).ToList(); - var button = designs.Count > 0 - ? $"All Restrictions Combined Match {designs.Count} Designs" - : "None of the Restrictions Matches Any Designs"; - ImGuiUtil.DrawDisabledButton(button, new Vector2(ImGui.GetContentRegionAvail().X, 0), - string.Empty, false, false); - if (ImGui.IsItemHovered()) + Im.Button(designs.Count > 0 + ? $"All Restrictions Combined Match {designs.Count} Designs" + : "None of the Restrictions Matches Any Designs"u8, Im.ContentRegion.Available with { Y = 0 }); + if (Im.Item.Hovered()) LookupTooltip(designs); } private void DrawContent(RandomDesign random) { - ImGui.SetCursorPosY(ImGui.GetCursorPosY() - Im.Style.WindowPadding.Y + Im.Style.GlobalScale); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Cursor.Y += Im.Style.GlobalScale - Im.Style.WindowPadding.Y; + Im.Separator(); + Im.Dummy(Vector2.Zero); var reset = random.ResetOnRedraw; - if (ImUtf8.Checkbox("Reset Chosen Design On Every Redraw"u8, ref reset)) + if (Im.Checkbox("Reset Chosen Design On Every Redraw"u8, ref reset)) _autoDesignManager.ChangeData(_set!, _designIndex, reset); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); var list = random.Predicates.ToList(); - if (list.Count == 0) + if (list.Count is 0) { - ImGui.TextUnformatted("No Restrictions Set. Selects among all existing Designs."); + Im.Text("No Restrictions Set. Selects among all existing Designs."u8); } else { - ImGui.TextUnformatted("Select among designs..."); + Im.Text("Select among designs..."u8); DrawTable(random, list); } - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); DrawNewButtons(list); DrawManualInput(list); @@ -414,7 +411,7 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable private void OnAutomationChange(AutomationChanged.Type type, AutoDesignSet? set, object? data) { - if (set != _set || _set == null) + if (set != _set || _set is null) return; switch (type) diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index d6c367b..7d0da57 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -51,7 +51,7 @@ public class SetPanel( } private void DrawHeader() - => HeaderDrawer.Draw(selector.SelectionName, 0, ImGui.GetColorU32(ImGuiCol.FrameBg), [], _rightButtons); + => HeaderDrawer.Draw(selector.SelectionName, 0, ImGuiColor.FrameBackground.Get().Color, [], _rightButtons); private void DrawPanel() { @@ -112,14 +112,14 @@ public class SetPanel( if (config.ShowAutomationSetEditing) { - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); var name = _tempName ?? Selection.Name; - var flags = selector.IncognitoMode ? ImGuiInputTextFlags.ReadOnly | ImGuiInputTextFlags.Password : ImGuiInputTextFlags.None; + var flags = selector.IncognitoMode ? InputTextFlags.ReadOnly | InputTextFlags.Password : InputTextFlags.None; ImGui.SetNextItemWidth(330 * Im.Style.GlobalScale); - if (ImGui.InputText("Rename Set##Name", ref name, 128, flags)) + if (Im.Input.Text("Rename Set##Name"u8, ref name, StringU8.Empty, flags)) _tempName = name; if (ImGui.IsItemDeactivated()) @@ -131,9 +131,9 @@ public class SetPanel( DrawIdentifierSelection(selector.SelectionIndex); } - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); DrawDesignTable(); randomDrawer.Draw(); } @@ -154,7 +154,7 @@ public class SetPanel( + 5 * Im.Style.CellPadding.X + 150 * Im.Style.GlobalScale; - var singleRow = ImGui.GetContentRegionAvail().X >= requiredSizeOneLine || numSpacing == 0; + var singleRow = Im.ContentRegion.Available.X >= requiredSizeOneLine || numSpacing == 0; var numRows = (singleRow, config.ShowUnlockedItemWarnings) switch { (true, true) => 6, @@ -163,40 +163,40 @@ public class SetPanel( (false, false) => 4, }; - using var table = ImUtf8.Table("SetTable"u8, numRows, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX | ImGuiTableFlags.ScrollY); + using var table = Im.Table.Begin("SetTable"u8, numRows, TableFlags.RowBackground | TableFlags.ScrollX | TableFlags.ScrollY); if (!table) return; - ImUtf8.TableSetupColumn("##del"u8, ImGuiTableColumnFlags.WidthFixed, Im.Style.FrameHeight); - ImUtf8.TableSetupColumn("##Index"u8, ImGuiTableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); + table.SetupColumn("##del"u8, TableColumnFlags.WidthFixed, Im.Style.FrameHeight); + table.SetupColumn("##Index"u8, TableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); if (singleRow) { - ImUtf8.TableSetupColumn("Design"u8, ImGuiTableColumnFlags.WidthFixed, 220 * Im.Style.GlobalScale); + table.SetupColumn("Design"u8, TableColumnFlags.WidthFixed, 220 * Im.Style.GlobalScale); if (config.ShowAllAutomatedApplicationRules) - ImUtf8.TableSetupColumn("Application"u8, ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn("Application"u8, TableColumnFlags.WidthFixed, 6 * Im.Style.FrameHeight + 10 * Im.Style.GlobalScale); else - ImUtf8.TableSetupColumn("Use"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); + table.SetupColumn("Use"u8, TableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); } else { - ImUtf8.TableSetupColumn("Design / Job Restrictions"u8, ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn("Design / Job Restrictions"u8, TableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale - (ImGui.GetScrollMaxY() > 0 ? Im.Style.ScrollbarSize : 0)); if (config.ShowAllAutomatedApplicationRules) - ImUtf8.TableSetupColumn("Application"u8, ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn("Application"u8, TableColumnFlags.WidthFixed, 3 * Im.Style.FrameHeight + 4 * Im.Style.GlobalScale); else - ImUtf8.TableSetupColumn("Use"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); + table.SetupColumn("Use"u8, TableColumnFlags.WidthFixed, ImGui.CalcTextSize("Use").X); } if (singleRow) - ImUtf8.TableSetupColumn("Job Restrictions"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Job Restrictions"u8, TableColumnFlags.WidthStretch); if (config.ShowUnlockedItemWarnings) - ImUtf8.TableSetupColumn(""u8, ImGuiTableColumnFlags.WidthFixed, 2 * Im.Style.FrameHeight + 4 * Im.Style.GlobalScale); + table.SetupColumn(""u8, TableColumnFlags.WidthFixed, 2 * Im.Style.FrameHeight + 4 * Im.Style.GlobalScale); - ImGui.TableHeadersRow(); + table.HeaderRow(); foreach (var (design, idx) in Selection.Designs.WithIndex()) { using var id = ImUtf8.PushId(idx); @@ -249,8 +249,8 @@ public class SetPanel( private void DrawSelectable(int idx, IDesignStandIn design) { - var highlight = 0u; - var sb = new StringBuilder(); + var highlight = Rgba32.Transparent; + var sb = new StringBuilder(); if (design is Design d) { var count = design.AllLinks(true).Count(); @@ -275,7 +275,7 @@ public class SetPanel( } } - using (ImRaii.PushColor(ImGuiCol.Text, highlight, highlight != 0)) + using (ImGuiColor.Text.Push(highlight, highlight.IsTransparent)) { ImUtf8.Selectable($"#{idx + 1:D2}"); } @@ -303,7 +303,7 @@ public class SetPanel( if (usingGearset) { var set = 1 + (_tmpGearset == int.MaxValue || _whichIndex != idx ? design.GearsetIndex : _tmpGearset); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); if (ImUtf8.InputScalar("##whichGearset"u8, ref set)) { _whichIndex = idx; @@ -375,12 +375,12 @@ public class SetPanel( continue; if (flag.RequiresRedraw()) - sb.AppendLine($"{type.ToDefaultName()} Customization should not be changed automatically."); + sb.AppendLine($"{type.ToName()} Customization should not be changed automatically."); else if (type is CustomizeIndex.Hairstyle or CustomizeIndex.FacePaint && set.DataByValue(type, customize[type], out var data, customize.Face) >= 0 && !customizeUnlocks.IsUnlocked(data!.Value, out _)) sb2.AppendLine( - $"{type.ToDefaultName()} Customization {customizeUnlocks.Unlockable[data.Value].Name} is not unlocked but should be applied."); + $"{type.ToName()} Customization {customizeUnlocks.Unlockable[data.Value].Name} is not unlocked but should be applied."); } Im.Line.Same(); @@ -448,8 +448,7 @@ public class SetPanel( using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(2 * Im.Style.GlobalScale)); var newType = design.Type; var newTypeInt = (uint)newType; - style.Push(ImGuiStyleVar.FrameBorderSize, Im.Style.GlobalScale); - using (_ = ImRaii.PushColor(ImGuiCol.Border, ColorId.FolderLine.Value())) + using (ImStyleBorder.Frame.Push(ColorId.FolderLine.Value())) { if (ImGui.CheckboxFlags("##all", ref newTypeInt, (uint)ApplicationType.All)) newType = (ApplicationType)newTypeInt; @@ -518,10 +517,10 @@ public class SetPanel( CurrentSelectionIdx = jobs.JobGroups.Values.IndexOf(j => j.Id == design.Jobs.Id); if (Draw("##JobGroups", design.Jobs.Name.ToString(), "Select for which job groups this design should be applied.\nControl + Right-Click to set to all classes.", - ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeightWithSpacing()) + Im.ContentRegion.Available.X, Im.Style.TextHeightWithSpacing) && CurrentSelectionIdx >= 0) manager.ChangeJobCondition(set, autoDesignIndex, CurrentSelection); - else if (ImGui.GetIO().KeyCtrl && ImGui.IsItemClicked(ImGuiMouseButton.Right)) + else if (Im.Io.KeyControl && Im.Item.RightClicked()) manager.ChangeJobCondition(set, autoDesignIndex, jobs.JobGroups[1]); } diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs index 6f8f82b..34fde5b 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetSelector.cs @@ -158,7 +158,7 @@ public class SetSelector : IDisposable var pos = ImGui.GetItemRectMin(); pos.X -= Im.Style.GlobalScale; - ImGui.GetWindowDrawList().AddLine(pos, pos with { Y = ImGui.GetItemRectMax().Y }, ImGui.GetColorU32(ImGuiCol.Border), + ImGui.GetWindowDrawList().AddLine(pos, pos with { Y = ImGui.GetItemRectMax().Y }, ImGuiColor.Border.Get().Color, Im.Style.GlobalScale); ImGuiUtil.HoverTooltip("Filter to show only enabled or disabled sets."); @@ -175,7 +175,7 @@ public class SetSelector : IDisposable UpdateList(); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); - _selectableSize = new Vector2(0, 2 * ImGui.GetTextLineHeight() + Im.Style.ItemSpacing.Y); + _selectableSize = new Vector2(0, 2 * Im.Style.TextHeight + Im.Style.ItemSpacing.Y); ImGuiClip.ClippedDraw(_list, DrawSetSelectable, _selectableSize.Y + 2 * Im.Style.ItemSpacing.Y); _endAction?.Invoke(); _endAction = null; @@ -183,8 +183,8 @@ public class SetSelector : IDisposable private void DrawSetSelectable((AutoDesignSet Set, int Index) pair) { - using var id = ImRaii.PushId(pair.Index); - using (ImRaii.PushColor(ImGuiCol.Text, pair.Set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value())) + using var id = Im.Id.Push(pair.Index); + using (ImGuiColor.Text.Push(pair.Set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value())) { if (ImGui.Selectable(GetSetName(pair.Set, pair.Index), pair.Set == Selection, ImGuiSelectableFlags.None, _selectableSize)) { @@ -195,7 +195,7 @@ public class SetSelector : IDisposable var lineEnd = ImGui.GetItemRectMax(); var lineStart = new Vector2(ImGui.GetItemRectMin().X, lineEnd.Y); - ImGui.GetWindowDrawList().AddLine(lineStart, lineEnd, ImGui.GetColorU32(ImGuiCol.Border), Im.Style.GlobalScale); + ImGui.GetWindowDrawList().AddLine(lineStart, lineEnd, ImGuiColor.Border.Get().Color, Im.Style.GlobalScale); DrawDragDrop(pair.Set, pair.Index); @@ -204,8 +204,8 @@ public class SetSelector : IDisposable text = pair.Set.Identifiers[0].Incognito(text); var textSize = ImGui.CalcTextSize(text); var textColor = pair.Set.Identifiers.Any(_objects.ContainsKey) ? ColorId.AutomationActorAvailable : ColorId.AutomationActorUnavailable; - ImGui.SetCursorPos(new Vector2(ImGui.GetContentRegionAvail().X - textSize.X, - ImGui.GetCursorPosY() - ImGui.GetTextLineHeightWithSpacing())); + ImGui.SetCursorPos(new Vector2(Im.ContentRegion.Available.X - textSize.X, + ImGui.GetCursorPosY() - Im.Style.TextHeightWithSpacing)); Im.Text(text, textColor.Value()); } @@ -229,13 +229,13 @@ public class SetSelector : IDisposable ImGui.OpenPopup("Automation Help"); static void HalfLine() - => ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + => Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); const string longestLine = "A single set can contain multiple automated designs that apply under different conditions and different parts of their design."; ImGuiUtil.HelpPopup("Automation Help", - new Vector2(ImGui.CalcTextSize(longestLine).X + 50 * Im.Style.GlobalScale, 33 * ImGui.GetTextLineHeightWithSpacing()), () => + new Vector2(ImGui.CalcTextSize(longestLine).X + 50 * Im.Style.GlobalScale, 33 * Im.Style.TextHeightWithSpacing), () => { HalfLine(); ImGui.TextUnformatted("What is Automation?"); diff --git a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs index 98af44e..4cda83b 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ActiveStatePanel.cs @@ -1,11 +1,8 @@ -using Dalamud.Interface; -using Glamourer.GameData; +using Glamourer.GameData; using Glamourer.Designs; using Glamourer.State; -using Dalamud.Bindings.ImGui; using ImSharp; -using OtterGui; -using OtterGui.Raii; +using Luna; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Interop; @@ -24,116 +21,119 @@ public sealed class ActiveStatePanel(StateManager stateManager, ActorObjectManag { foreach (var (identifier, actors) in objectManager) { - if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.Trash.ToIconString()}##{actors.Label}", new Vector2(Im.Style.FrameHeight), - string.Empty, !stateManager.ContainsKey(identifier), true)) + using var id = Im.Id.Push(actors.Label); + if (ImEx.Icon.Button(LunaStyle.DeleteIcon, StringU8.Empty, !stateManager.ContainsKey(identifier))) stateManager.DeleteState(identifier); Im.Line.Same(); - using var t = ImRaii.TreeNode(actors.Label); + using var t = Im.Tree.Node(actors.Label); if (!t) continue; if (stateManager.GetOrCreate(identifier, actors.Objects[0], out var state)) DrawState(stateManager, actors, state); else - ImGui.TextUnformatted("Invalid actor."); + Im.Text("Invalid actor."u8); } } public static void DrawState(StateManager stateManager, ActorData data, ActorState state) { - using var table = ImRaii.Table("##state", 7, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##state"u8, 7, TableFlags.RowBackground | TableFlags.SizingFixedFit); if (!table) return; - ImGuiUtil.DrawTableColumn("Name"); - ImGuiUtil.DrawTableColumn(state.Identifier.ToString()); - ImGui.TableNextColumn(); - if (ImGui.Button("Reset")) + table.DrawDataPair("Name"u8, state.Identifier); + table.NextColumn(); + if (Im.Button("Reset"u8)) stateManager.ResetState(state, StateSource.Manual); - ImGui.TableNextRow(); + table.NextRow(); - static void PrintRow(string label, T actor, T model, StateSource source) where T : notnull - { - ImGuiUtil.DrawTableColumn(label); - ImGuiUtil.DrawTableColumn(actor.ToString()!); - ImGuiUtil.DrawTableColumn(model.ToString()!); - ImGuiUtil.DrawTableColumn(source.ToString()); - } - - static string ItemString(in DesignData data, EquipSlot slot) - { - var item = data.Item(slot); - return - $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; - } - - static string BonusItemString(in DesignData data, BonusItemFlag slot) - { - var item = data.BonusItem(slot); - return - $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"; - } - - PrintRow("Model ID", state.BaseData.ModelId, state.ModelData.ModelId, state.Sources[MetaIndex.ModelId]); - ImGui.TableNextRow(); - PrintRow("Wetness", state.BaseData.IsWet(), state.ModelData.IsWet(), state.Sources[MetaIndex.Wetness]); - ImGui.TableNextRow(); + PrintRow("Model ID"u8, state.BaseData.ModelId, state.ModelData.ModelId, state.Sources[MetaIndex.ModelId]); + table.NextRow(); + PrintRow("Wetness"u8, state.BaseData.IsWet(), state.ModelData.IsWet(), state.Sources[MetaIndex.Wetness]); + table.NextRow(); if (state.BaseData.IsHuman && state.ModelData.IsHuman) { - PrintRow("Hat Visible", state.BaseData.IsHatVisible(), state.ModelData.IsHatVisible(), state.Sources[MetaIndex.HatState]); - ImGui.TableNextRow(); - PrintRow("Visor Toggled", state.BaseData.IsVisorToggled(), state.ModelData.IsVisorToggled(), + PrintRow("Hat Visible"u8, state.BaseData.IsHatVisible(), state.ModelData.IsHatVisible(), state.Sources[MetaIndex.HatState]); + table.NextRow(); + PrintRow("Visor Toggled"u8, state.BaseData.IsVisorToggled(), state.ModelData.IsVisorToggled(), state.Sources[MetaIndex.VisorState]); - ImGui.TableNextRow(); - PrintRow("Viera Ears Visible", state.BaseData.AreEarsVisible(), state.ModelData.AreEarsVisible(), + table.NextRow(); + PrintRow("Viera Ears Visible"u8, state.BaseData.AreEarsVisible(), state.ModelData.AreEarsVisible(), state.Sources[MetaIndex.EarState]); - ImGui.TableNextRow(); - PrintRow("Weapon Visible", state.BaseData.IsWeaponVisible(), state.ModelData.IsWeaponVisible(), + table.NextRow(); + PrintRow("Weapon Visible"u8, state.BaseData.IsWeaponVisible(), state.ModelData.IsWeaponVisible(), state.Sources[MetaIndex.WeaponState]); - ImGui.TableNextRow(); + table.NextRow(); foreach (var slot in EquipSlotExtensions.EqdpSlots.Prepend(EquipSlot.OffHand).Prepend(EquipSlot.MainHand)) { - PrintRow(slot.ToName(), ItemString(state.BaseData, slot), ItemString(state.ModelData, slot), state.Sources[slot, false]); - ImGuiUtil.DrawTableColumn(state.BaseData.Stain(slot).ToString()); - ImGuiUtil.DrawTableColumn(state.ModelData.Stain(slot).ToString()); - ImGuiUtil.DrawTableColumn(state.Sources[slot, true].ToString()); + PrintRow(slot.ToNameU8(), ItemString(state.BaseData, slot), ItemString(state.ModelData, slot), state.Sources[slot, false]); + table.DrawColumn($"{state.BaseData.Stain(slot)}"); + table.DrawColumn($"{state.ModelData.Stain(slot)}"); + table.DrawColumn($"{state.Sources[slot, true]}"); } foreach (var slot in BonusExtensions.AllFlags) { - PrintRow(slot.ToName(), BonusItemString(state.BaseData, slot), BonusItemString(state.ModelData, slot), state.Sources[slot]); - ImGui.TableNextRow(); + PrintRow(slot.ToNameU8(), BonusItemString(state.BaseData, slot), BonusItemString(state.ModelData, slot), state.Sources[slot]); + table.NextRow(); } - foreach (var type in Enum.GetValues()) + foreach (var type in CustomizeIndex.Values) { - PrintRow(type.ToDefaultName(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, + PrintRow(type.ToNameU8(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, state.Sources[type]); - ImGui.TableNextRow(); + table.NextRow(); } foreach (var crest in CrestExtensions.AllRelevantSet) { - PrintRow(crest.ToLabel(), state.BaseData.Crest(crest), state.ModelData.Crest(crest), state.Sources[crest]); - ImGui.TableNextRow(); + PrintRow(crest.ToLabelU8(), state.BaseData.Crest(crest), state.ModelData.Crest(crest), state.Sources[crest]); + table.NextRow(); } foreach (var flag in CustomizeParameterExtensions.AllFlags) { - PrintRow(flag.ToString(), state.BaseData.Parameters[flag], state.ModelData.Parameters[flag], state.Sources[flag]); - ImGui.TableNextRow(); + PrintRow(flag.ToNameU8(), state.BaseData.Parameters[flag], state.ModelData.Parameters[flag], state.Sources[flag]); + table.NextRow(); } } else { - ImGuiUtil.DrawTableColumn(string.Join(" ", state.BaseData.GetCustomizeBytes().Select(b => b.ToString("X2")))); - ImGuiUtil.DrawTableColumn(string.Join(" ", state.ModelData.GetCustomizeBytes().Select(b => b.ToString("X2")))); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn(string.Join(" ", state.BaseData.GetEquipmentBytes().Select(b => b.ToString("X2")))); - ImGuiUtil.DrawTableColumn(string.Join(" ", state.ModelData.GetEquipmentBytes().Select(b => b.ToString("X2")))); + table.DrawColumn(StringU8.Join((byte)' ', state.BaseData.GetCustomizeBytes().Select(b => b.ToString("X2")))); + table.DrawColumn(StringU8.Join((byte)' ', state.ModelData.GetCustomizeBytes().Select(b => b.ToString("X2")))); + table.NextRow(); + table.DrawColumn(StringU8.Join((byte)' ', state.BaseData.GetEquipmentBytes().Select(b => b.ToString("X2")))); + table.DrawColumn(StringU8.Join((byte)' ', state.ModelData.GetEquipmentBytes().Select(b => b.ToString("X2")))); + } + + return; + + static StringU8 ItemString(in DesignData data, EquipSlot slot) + { + var item = data.Item(slot); + return + new StringU8( + $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"); + } + + static StringU8 BonusItemString(in DesignData data, BonusItemFlag slot) + { + var item = data.BonusItem(slot); + return + new StringU8( + $"{item.Name} ({item.Id.ToDiscriminatingString()} {item.PrimaryId.Id}{(item.SecondaryId != 0 ? $"-{item.SecondaryId.Id}" : string.Empty)}-{item.Variant})"); + } + + static void PrintRow(ReadOnlySpan label, T actor, T model, StateSource source) where T : notnull + { + Im.Table.DrawColumn(label); + Im.Table.DrawColumn($"{actor}"); + Im.Table.DrawColumn($"{model}"); + Im.Table.DrawColumn(source.ToNameU8()); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs index 3abb071..d9bd092 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AdvancedCustomizationDrawer.cs @@ -1,7 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; -using Dalamud.Bindings.ImGui; -using OtterGui.Raii; -using OtterGui.Text; +using ImSharp; using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Interop; @@ -17,17 +15,17 @@ public sealed unsafe class AdvancedCustomizationDrawer(ActorObjectManager object public void Draw() { - var (player, data) = objects.PlayerData; + var (_, data) = objects.PlayerData; if (!data.Valid) { - ImUtf8.Text("Invalid player."u8); + Im.Text("Invalid player."u8); return; } var model = data.Objects[0].Model; if (!model.IsHuman) { - ImUtf8.Text("Invalid model."u8); + Im.Text("Invalid model."u8); return; } @@ -40,36 +38,36 @@ public sealed unsafe class AdvancedCustomizationDrawer(ActorObjectManager object private static void DrawCBuffer(ReadOnlySpan label, ConstantBuffer* cBuffer, int type) { - using var tree = ImUtf8.TreeNode(label); + using var tree = Im.Tree.Node(label); if (!tree) return; - if (cBuffer == null) + if (cBuffer is null) { - ImUtf8.Text("Invalid CBuffer."u8); + Im.Text("Invalid CBuffer."u8); return; } - ImUtf8.Text($"{cBuffer->ByteSize / 4}"); - ImUtf8.Text($"{cBuffer->Flags}"); - ImUtf8.Text($"0x{(ulong)cBuffer:X}"); + Im.Text($"{cBuffer->ByteSize / 4}"); + Im.Text($"{cBuffer->Flags}"); + Glamourer.Dynamis.DrawPointer(cBuffer); var parameters = (float*)cBuffer->UnsafeSourcePointer; - if (parameters == null) + if (parameters is null) { - ImUtf8.Text("No Parameters."u8); + Im.Text("No Parameters."u8); return; } var start = parameters; - using (ImUtf8.Group()) + using (Im.Group()) { for (var end = start + cBuffer->ByteSize / 4; parameters < end; parameters += 2) DrawParameters(parameters, type, (int)(parameters - start)); } - ImGui.SameLine(0, 50 * ImUtf8.GlobalScale); + Im.Line.Same(0, 50 * Im.Style.GlobalScale); parameters = start + 1; - using (ImUtf8.Group()) + using (Im.Group()) { for (var end = start + cBuffer->ByteSize / 4; parameters < end; parameters += 2) DrawParameters(parameters, type, (int)(parameters - start)); @@ -78,24 +76,24 @@ public sealed unsafe class AdvancedCustomizationDrawer(ActorObjectManager object private static void DrawParameters(float* param, int type, int idx) { - using var id = ImUtf8.PushId((nint)param); - ImUtf8.TextFrameAligned($"{idx:D2}: "); - ImUtf8.SameLineInner(); - ImGui.SetNextItemWidth(200 * ImUtf8.GlobalScale); + using var id = Im.Id.Push((nint)param); + ImEx.TextFrameAligned($"{idx:D2}: "); + Im.Line.SameInner(); + Im.Item.SetNextWidthScaled(200); if (TryGetKnown(type, idx, out var known)) { - ImUtf8.DragScalar(known, ref *param, float.MinValue, float.MaxValue, 0.01f); + Im.Drag(known, ref *param, float.MinValue, float.MaxValue, 0.01f); } else { - using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled)); - ImUtf8.DragScalar($"+0x{idx * 4:X2}", ref *param, float.MinValue, float.MaxValue, 0.01f); + using var color = ImGuiColor.Text.Push(Im.Style[ImGuiColor.TextDisabled]); + Im.Drag($"+0x{idx * 4:X2}", ref *param, float.MinValue, float.MaxValue, 0.01f); } } private static bool TryGetKnown(int type, int idx, out ReadOnlySpan text) { - if (type == 0) + if (type is 0) text = idx switch { 0 => "Diffuse.R"u8, diff --git a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs index f87907e..7ba35fc 100644 --- a/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/AutoDesignPanel.cs @@ -1,8 +1,5 @@ using Glamourer.Automation; -using Dalamud.Bindings.ImGui; -using OtterGui; -using OtterGui.Extensions; -using OtterGui.Raii; +using ImSharp; using Penumbra.GameData.Gui.Debug; namespace Glamourer.Gui.Tabs.DebugTab; @@ -17,33 +14,26 @@ public sealed class AutoDesignPanel(AutoDesignManager autoDesignManager) : IGame public void Draw() { - foreach (var (set, idx) in autoDesignManager.WithIndex()) + foreach (var (idx, set) in autoDesignManager.Index()) { - using var id = ImRaii.PushId(idx); - using var tree = ImRaii.TreeNode(set.Name); + using var id = Im.Id.Push(idx); + using var tree = Im.Tree.Node(set.Name); if (!tree) continue; - using var table = ImRaii.Table("##autoDesign", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##autoDesign"u8, 2, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) continue; - ImGuiUtil.DrawTableColumn("Name"); - ImGuiUtil.DrawTableColumn(set.Name); + table.DrawDataPair("Name"u8, set.Name); + table.DrawDataPair("Index"u8, idx); + table.DrawDataPair("Enabled"u8, set.Enabled); + table.DrawDataPair("Actor"u8, set.Identifiers[0]); - ImGuiUtil.DrawTableColumn("Index"); - ImGuiUtil.DrawTableColumn(idx.ToString()); - - ImGuiUtil.DrawTableColumn("Enabled"); - ImGuiUtil.DrawTableColumn(set.Enabled.ToString()); - - ImGuiUtil.DrawTableColumn("Actor"); - ImGuiUtil.DrawTableColumn(set.Identifiers[0].ToString()); - - foreach (var (design, designIdx) in set.Designs.WithIndex()) + foreach (var (designIdx, design) in set.Designs.Index()) { - ImGuiUtil.DrawTableColumn($"{design.Design.ResolveName(false)} ({designIdx})"); - ImGuiUtil.DrawTableColumn($"{design.Type} {design.Jobs.Name}"); + table.DrawColumn($"{design.Design.ResolveName(false)} ({designIdx})"); + table.DrawColumn($"{design.Type} {design.Jobs.Name}"); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs index e88bc1c..a191fff 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationServicePanel.cs @@ -1,12 +1,7 @@ -using Dalamud.Interface; -using Glamourer.GameData; +using Glamourer.GameData; using Glamourer.Services; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; -using OtterGui; -using OtterGui.Raii; -using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Structs; @@ -34,70 +29,65 @@ public sealed class CustomizationServicePanel(CustomizeService customize) : IGam DrawColorInfo(); } + private void DrawFacepaintInfo() { - using var tree = ImUtf8.TreeNode("NPC Facepaints"u8); + using var tree = Im.Tree.Node("NPC Facepaints"u8); if (!tree) return; - using var table = ImUtf8.Table("data"u8, 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("data"u8, 2, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Id"u8); - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Facepaint"u8); + table.NextColumn(); + table.Header("Id"u8); + table.NextColumn(); + table.Header("Facepaint"u8); for (var i = 0; i < 128; ++i) { var index = new CustomizeValue((byte)i); - ImUtf8.DrawTableColumn($"{i:D3}"); - using var font = ImRaii.PushFont(UiBuilder.IconFont); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaint, index) - ? FontAwesomeIcon.Check.ToIconString() - : FontAwesomeIcon.Times.ToIconString()); + table.DrawColumn($"{i:D3}"); + table.NextColumn(); + ImEx.Icon.Draw(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaint, index) ? LunaStyle.TrueIcon : LunaStyle.FalseIcon); } } private void DrawColorInfo() { - using var tree = ImUtf8.TreeNode("NPC Colors"u8); + using var tree = Im.Tree.Node("NPC Colors"u8); if (!tree) return; - using var table = ImUtf8.Table("data"u8, 5, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("data"u8, 5, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Id"u8); - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Hair"u8); - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Eyes"u8); - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Facepaint"u8); - ImGui.TableNextColumn(); - ImUtf8.TableHeader("Tattoos"u8); + table.NextColumn(); + table.Header("Id"u8); + table.NextColumn(); + table.Header("Hair"u8); + table.NextColumn(); + table.Header("Eyes"u8); + table.NextColumn(); + table.Header("Facepaint"u8); + table.NextColumn(); + table.Header("Tattoos"u8); for (var i = 192; i < 256; ++i) { var index = new CustomizeValue((byte)i); - ImUtf8.DrawTableColumn($"{i:D3}"); - using var font = ImRaii.PushFont(UiBuilder.IconFont); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.HairColor, index) - ? FontAwesomeIcon.Check.ToIconString() - : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.EyeColorLeft, index) - ? FontAwesomeIcon.Check.ToIconString() - : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaintColor, index) - ? FontAwesomeIcon.Check.ToIconString() - : FontAwesomeIcon.Times.ToIconString()); - ImUtf8.DrawTableColumn(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.TattooColor, index) - ? FontAwesomeIcon.Check.ToIconString() - : FontAwesomeIcon.Times.ToIconString()); + table.DrawColumn($"{i:D3}"); + table.NextColumn(); + ImEx.Icon.Draw(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.HairColor, index) ? LunaStyle.TrueIcon : LunaStyle.FalseIcon); + table.NextColumn(); + ImEx.Icon.Draw(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.EyeColorLeft, index) ? LunaStyle.TrueIcon : LunaStyle.FalseIcon); + table.NextColumn(); + ImEx.Icon.Draw( + customize.NpcCustomizeSet.CheckValue(CustomizeIndex.FacePaintColor, index) ? LunaStyle.TrueIcon : LunaStyle.FalseIcon); + table.NextColumn(); + ImEx.Icon.Draw(customize.NpcCustomizeSet.CheckValue(CustomizeIndex.TattooColor, index) ? LunaStyle.TrueIcon : LunaStyle.FalseIcon); } } @@ -113,7 +103,7 @@ public sealed class CustomizationServicePanel(CustomizeService customize) : IGam foreach (var index in CustomizeIndex.Values) { - table.DrawColumn(index.ToDefaultName()); + table.DrawColumn(index.ToNameU8()); table.DrawColumn(set.Option(index)); table.DrawColumn(set.IsAvailable(index) ? "Available"u8 : "Unavailable"u8); table.DrawColumn(set.Type(index).ToNameU8()); @@ -123,18 +113,18 @@ public sealed class CustomizationServicePanel(CustomizeService customize) : IGam private void DrawNpcCustomizationInfo(CustomizeSet set) { - using var tree = ImRaii.TreeNode($"{customize.ClanName(set.Clan, set.Gender)} {set.Gender} (NPC Options)"); + using var tree = Im.Tree.Node($"{customize.ClanName(set.Clan, set.Gender)} {set.Gender} (NPC Options)"); if (!tree) return; - using var table = ImRaii.Table("npc", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("npc"u8, 2, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; foreach (var (index, value) in set.NpcOptions) { - ImGuiUtil.DrawTableColumn(index.ToString()); - ImGuiUtil.DrawTableColumn(value.Value.ToString()); + table.DrawColumn($"{index}"); + table.DrawColumn($"{value.Value}"); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs b/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs index 6e0933c..a5f825b 100644 --- a/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/CustomizationUnlockPanel.cs @@ -1,7 +1,5 @@ using Glamourer.Unlocks; -using Dalamud.Bindings.ImGui; -using OtterGui; -using OtterGui.Raii; +using ImSharp; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; @@ -17,28 +15,25 @@ public sealed class CustomizationUnlockPanel(CustomizeUnlockManager customizeUnl public void Draw() { - using var table = ImRaii.Table("customizationUnlocks", 6, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersOuter, - new Vector2(ImGui.GetContentRegionAvail().X, 12 * ImGui.GetTextLineHeight())); + using var table = Im.Table.Begin("customizationUnlocks"u8, 6, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.ScrollY | TableFlags.BordersOuter, + Im.ContentRegion.Available with { Y = 12 * Im.Style.TextHeight }); if (!table) return; - ImGui.TableNextColumn(); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeightWithSpacing()); - ImGui.TableNextRow(); - var remainder = ImGuiClip.ClippedDraw(customizeUnlocks.Unlockable, skips, t => + using var clipper = new Im.ListClipper(customizeUnlocks.Unlockable.Count, Im.Style.TextHeightWithSpacing); + foreach (var (key, value) in clipper.Iterate(customizeUnlocks.Unlockable)) { - ImGuiUtil.DrawTableColumn(t.Key.Index.ToDefaultName()); - ImGuiUtil.DrawTableColumn(t.Key.CustomizeId.ToString()); - ImGuiUtil.DrawTableColumn(t.Key.Value.Value.ToString()); - ImGuiUtil.DrawTableColumn(t.Value.Data.ToString()); - ImGuiUtil.DrawTableColumn(t.Value.Name); - ImGuiUtil.DrawTableColumn(customizeUnlocks.IsUnlocked(t.Key, out var time) + table.DrawColumn(key.Index.ToNameU8()); + table.DrawColumn($"{key.CustomizeId}"); + table.DrawColumn($"{key.Value.Value}"); + table.DrawColumn($"{value.Data}"); + table.DrawColumn(value.Name); + table.DrawColumn(customizeUnlocks.IsUnlocked(key, out var time) ? time == DateTimeOffset.MinValue - ? "Always" - : time.LocalDateTime.ToString("g") - : "Never"); - }, customizeUnlocks.Unlockable.Count); - ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); + ? "Always"u8 + : $"{time.LocalDateTime:g}" + : "Never"u8); + } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs b/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs index 852a47d..803cf78 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DatFilePanel.cs @@ -1,12 +1,12 @@ using Glamourer.Interop; -using Dalamud.Bindings.ImGui; -using OtterGui; using Penumbra.GameData.Files; using Penumbra.GameData.Gui.Debug; +using ImSharp; +using Luna; namespace Glamourer.Gui.Tabs.DebugTab; -public sealed class DatFilePanel(ImportService importService) : IGameDataDrawer +public sealed class DatFilePanel : IGameDataDrawer { public ReadOnlySpan Label => "Character Dat File"u8; @@ -14,27 +14,41 @@ public sealed class DatFilePanel(ImportService importService) : IGameDataDrawer public bool Disabled => false; - private string _datFilePath = string.Empty; - private DatCharacterFile? _datFile; + public sealed class Cache(ImportService importService) : BasicCache(TimeSpan.FromMinutes(10)), IService + { + private string _datFilePath = string.Empty; + private DatCharacterFile? _datFile; + + public void Draw() + { + using var id = Im.Id.Push("dat"u8); + Im.Input.Text("##datFilePath"u8, ref _datFilePath, "Dat File Path..."u8); + var exists = _datFilePath.Length > 0 && File.Exists(_datFilePath); + if (ImEx.Button("Load"u8, Vector2.Zero, StringU8.Empty, !exists)) + _datFile = importService.LoadDat(_datFilePath, out var tmp) ? tmp : null; + + if (ImEx.Button("Save"u8, Vector2.Zero, StringU8.Empty, _datFilePath.Length is 0 || _datFile is null)) + importService.SaveDesignAsDat(_datFilePath, _datFile!.Value.Customize, _datFile!.Value.Description); + + if (_datFile is null) + return; + + Im.Text($"{_datFile.Value.Magic}"); + Im.Text($"{_datFile.Value.Version}"); + Im.Text($"{_datFile.Value.Time.LocalDateTime:g}"); + Im.Text($"{_datFile.Value.Voice}"); + Im.Text($"{_datFile.Value.Customize}"); + Im.Text(_datFile.Value.Description); + } + + public override void Update() + => Dirty = IManagedCache.DirtyFlags.Clean; + } + public void Draw() { - ImGui.InputTextWithHint("##datFilePath", "Dat File Path...", ref _datFilePath, 256); - var exists = _datFilePath.Length > 0 && File.Exists(_datFilePath); - if (ImGuiUtil.DrawDisabledButton("Load##Dat", Vector2.Zero, string.Empty, !exists)) - _datFile = importService.LoadDat(_datFilePath, out var tmp) ? tmp : null; - - if (ImGuiUtil.DrawDisabledButton("Save##Dat", Vector2.Zero, string.Empty, _datFilePath.Length == 0 || _datFile == null)) - importService.SaveDesignAsDat(_datFilePath, _datFile!.Value.Customize, _datFile!.Value.Description); - - if (_datFile != null) - { - ImGui.TextUnformatted(_datFile.Value.Magic.ToString()); - ImGui.TextUnformatted(_datFile.Value.Version.ToString()); - ImGui.TextUnformatted(_datFile.Value.Time.LocalDateTime.ToString("g")); - ImGui.TextUnformatted(_datFile.Value.Voice.ToString()); - ImGui.TextUnformatted(_datFile.Value.Customize.ToString()); - ImGui.TextUnformatted(_datFile.Value.Description); - } + var cache = CacheManager.Instance.GetOrCreateCache(Im.Id.Current); + cache.Draw(); } -} \ No newline at end of file +} diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs index e5c436b..d7a233e 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs @@ -1,15 +1,13 @@ -using Dalamud.Interface; -using Glamourer.Designs; +using Glamourer.Designs; using Glamourer.Utility; -using Dalamud.Bindings.ImGui; +using ImSharp; +using Luna; using Newtonsoft.Json.Linq; -using OtterGui; -using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; namespace Glamourer.Gui.Tabs.DebugTab; -public sealed class DesignConverterPanel(DesignConverter designConverter) : IGameDataDrawer +public sealed class DesignConverterPanel : IGameDataDrawer { public ReadOnlySpan Label => "Design Converter"u8; @@ -17,81 +15,88 @@ public sealed class DesignConverterPanel(DesignConverter designConverter) : IGam public bool Disabled => false; - private string _clipboardText = string.Empty; - private byte[] _clipboardData = []; - private byte[] _dataUncompressed = []; - private byte _version = 0; - private string _textUncompressed = string.Empty; - private JObject? _json = null; - private DesignBase? _tmpDesign = null; - private Exception? _clipboardProblem = null; + public sealed class Cache(DesignConverter designConverter) : BasicCache(TimeSpan.FromMinutes(10), IManagedCache.DirtyFlags.Clean), IService + { + private StringU8 _clipboardText = StringU8.Empty; + private StringU8 _clipboardData = StringU8.Empty; + private StringU8 _dataUncompressed = StringU8.Empty; + private byte _version; + private StringU8 _textUncompressed = StringU8.Empty; + private JObject? _json; + private DesignBase? _tmpDesign; + private StringU8 _clipboardProblem = StringU8.Empty; + + public override void Update() + => Dirty = IManagedCache.DirtyFlags.Clean; + + public void Draw() + { + if (Im.Button("Import Clipboard"u8)) + { + _clipboardData = StringU8.Empty; + _dataUncompressed = StringU8.Empty; + _textUncompressed = StringU8.Empty; + _json = null; + _tmpDesign = null; + _clipboardProblem = StringU8.Empty; + + try + { + _clipboardText = Im.Clipboard.GetCopy(); + var textU16 = _clipboardText.ToString(); + var clipboardData = Convert.FromBase64String(textU16); + _version = clipboardData[0]; + if (_version is 5) + clipboardData = clipboardData[DesignBase64Migration.Base64SizeV4..]; + _clipboardData = StringU8.Join((byte)' ', clipboardData.Select(b => b.ToString("X2"))); + _version = clipboardData.Decompress(out var dataUncompressed); + _dataUncompressed = StringU8.Join((byte)' ', dataUncompressed.Select(b => b.ToString("X2"))); + _textUncompressed = new StringU8(dataUncompressed); + var textUncompressed = _textUncompressed.ToString(); + _json = JObject.Parse(textUncompressed); + _tmpDesign = designConverter.FromBase64(textU16, true, true, out _); + } + catch (Exception ex) + { + _clipboardProblem = new StringU8($"{ex}"); + } + } + + using var mono = Im.Font.PushMono(); + if (_clipboardText.Length > 0) + Im.TextWrapped(_clipboardText); + + if (_clipboardData.Length > 0) + Im.TextWrapped(_clipboardData); + + if (_dataUncompressed.Length > 0) + Im.TextWrapped(_dataUncompressed); + + if (_textUncompressed.Length > 0) + { + Im.TextWrapped(_textUncompressed); + if (Im.Item.Clicked()) + Im.Clipboard.Set(_textUncompressed); + } + + mono.Pop(); + if (_json is not null) + Im.Text("JSON Parsing Successful!"u8); + + if (_tmpDesign is not null) + DesignManagerPanel.DrawDesign(_tmpDesign, null); + + if (_clipboardProblem.Length > 0) + { + mono.Push(Im.Font.Mono); + Im.Text(_clipboardProblem); + } + } + } public void Draw() { - if (ImGui.Button("Import Clipboard")) - { - _clipboardText = string.Empty; - _clipboardData = []; - _dataUncompressed = []; - _textUncompressed = string.Empty; - _json = null; - _tmpDesign = null; - _clipboardProblem = null; - - try - { - _clipboardText = ImGui.GetClipboardText(); - _clipboardData = Convert.FromBase64String(_clipboardText); - _version = _clipboardData[0]; - if (_version == 5) - _clipboardData = _clipboardData[DesignBase64Migration.Base64SizeV4..]; - _version = _clipboardData.Decompress(out _dataUncompressed); - _textUncompressed = Encoding.UTF8.GetString(_dataUncompressed); - _json = JObject.Parse(_textUncompressed); - _tmpDesign = designConverter.FromBase64(_clipboardText, true, true, out _); - } - catch (Exception ex) - { - _clipboardProblem = ex; - } - } - - if (_clipboardText.Length > 0) - { - using var f = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(_clipboardText); - } - - if (_clipboardData.Length > 0) - { - using var f = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(string.Join(" ", _clipboardData.Select(b => b.ToString("X2")))); - } - - if (_dataUncompressed.Length > 0) - { - using var f = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(string.Join(" ", _dataUncompressed.Select(b => b.ToString("X2")))); - } - - if (_textUncompressed.Length > 0) - { - using var f = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(_textUncompressed); - if (ImGui.IsItemClicked()) - ImGui.SetClipboardText(_textUncompressed); - } - - if (_json != null) - ImGui.TextUnformatted("JSON Parsing Successful!"); - - if (_tmpDesign != null) - DesignManagerPanel.DrawDesign(_tmpDesign, null); - - if (_clipboardProblem != null) - { - using var f = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(_clipboardProblem.ToString()); - } + var cache = CacheManager.Instance.GetOrCreateCache(Im.Id.Current); + cache.Draw(); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs index fbcab76..7da78dd 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignManagerPanel.cs @@ -1,11 +1,6 @@ -using Dalamud.Interface; -using Glamourer.Designs; -using Dalamud.Bindings.ImGui; +using Glamourer.Designs; using ImSharp; -using OtterGui; -using OtterGui.Extensions; -using OtterGui.Raii; -using OtterGui.Text; +using Luna; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; @@ -22,9 +17,10 @@ public sealed class DesignManagerPanel(DesignManager designManager, DesignFileSy public void Draw() { DrawButtons(); - foreach (var (design, idx) in designManager.Designs.WithIndex()) + foreach (var (idx, design) in designManager.Designs.Index()) { - using var t = ImRaii.TreeNode($"{design.Name}##{idx}"); + using var id = Im.Id.Push(idx); + using var t = Im.Tree.Node(design.Name.Text); if (!t) continue; @@ -32,24 +28,24 @@ public sealed class DesignManagerPanel(DesignManager designManager, DesignFileSy var base64 = DesignBase64Migration.CreateOldBase64(design.DesignData, design.Application.Equip, design.Application.Customize, design.Application.Meta, design.WriteProtected()); - using var font = ImRaii.PushFont(UiBuilder.MonoFont); - ImGuiUtil.TextWrapped(base64); - if (ImGui.IsItemClicked()) - ImGui.SetClipboardText(base64); + using var font = Im.Font.PushMono(); + Im.TextWrapped(base64); + if (Im.Item.Clicked()) + Im.Clipboard.Set(base64); } } private void DrawButtons() { - if (ImUtf8.Button("Generate 500 Test Designs"u8)) + if (Im.Button("Generate 500 Test Designs"u8)) for (var i = 0; i < 500; ++i) { var design = designManager.CreateEmpty($"Test Designs/Test Design {i}", true); designManager.AddTag(design, "_DebugTest"); } - ImUtf8.SameLineInner(); - if (ImUtf8.Button("Remove All Test Designs"u8)) + Im.Line.SameInner(); + if (Im.Button("Remove All Test Designs"u8)) { var designs = designManager.Designs.Where(d => d.Tags.Contains("_DebugTest")).ToArray(); foreach (var design in designs) @@ -61,34 +57,29 @@ public sealed class DesignManagerPanel(DesignManager designManager, DesignFileSy public static void DrawDesign(DesignBase design, DesignFileSystem? fileSystem) { - using var table = ImRaii.Table("##equip", 8, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##equip"u8, 8, TableFlags.RowBackground | TableFlags.SizingFixedFit); if (design is Design d) { - ImGuiUtil.DrawTableColumn("Name"); - ImGuiUtil.DrawTableColumn(d.Name); - ImGuiUtil.DrawTableColumn($"({d.Index})"); - ImGui.TableNextColumn(); - ImGui.TextUnformatted("Description (Hover)"); - ImGuiUtil.HoverTooltip(d.Description); - ImGui.TableNextRow(); + table.DrawColumn("Name"u8); + table.DrawColumn(d.Name.Text); + table.DrawColumn($"({d.Index})"); + table.DrawColumn("Description (Hover)"u8); + Im.Tooltip.OnHover(d.Description); + table.NextRow(); - ImGuiUtil.DrawTableColumn("Identifier"); - ImGuiUtil.DrawTableColumn(d.Identifier.ToString()); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn("Design File System Path"); - if (fileSystem != null) - ImGuiUtil.DrawTableColumn(fileSystem.TryGetValue(d, out var leaf) ? leaf.FullName() : "No Path Known"); - ImGui.TableNextRow(); + table.DrawDataPair("Identifier"u8, d.Identifier); + table.NextRow(); + table.DrawColumn("Design File System Path"u8); + if (fileSystem is not null) + table.DrawColumn(fileSystem.TryGetValue(d, out var leaf) ? leaf.FullName() : "No Path Known"u8); + table.NextRow(); - ImGuiUtil.DrawTableColumn("Creation"); - ImGuiUtil.DrawTableColumn(d.CreationDate.ToString()); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn("Update"); - ImGuiUtil.DrawTableColumn(d.LastEdit.ToString()); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn("Tags"); - ImGuiUtil.DrawTableColumn(string.Join(", ", d.Tags)); - ImGui.TableNextRow(); + table.DrawDataPair("Creation"u8, d.CreationDate); + table.NextRow(); + table.DrawDataPair("Update"u8, d.LastEdit); + table.NextRow(); + table.DrawDataPair("Tags"u8, StringU8.Join(", "u8, d.Tags)); + table.NextRow(); } foreach (var slot in EquipSlotExtensions.EqdpSlots.Prepend(EquipSlot.OffHand).Prepend(EquipSlot.MainHand)) @@ -99,36 +90,35 @@ public sealed class DesignManagerPanel(DesignManager designManager, DesignFileSy var applyStain = design.DoApplyStain(slot); var crest = design.DesignData.Crest(slot.ToCrestFlag()); var applyCrest = design.DoApplyCrest(slot.ToCrestFlag()); - ImGuiUtil.DrawTableColumn(slot.ToName()); - ImGuiUtil.DrawTableColumn(item.Name); - ImGuiUtil.DrawTableColumn(item.ItemId.ToString()); - ImGuiUtil.DrawTableColumn(apply ? "Apply" : "Keep"); - ImGuiUtil.DrawTableColumn(stain.ToString()); - ImGuiUtil.DrawTableColumn(applyStain ? "Apply" : "Keep"); - ImGuiUtil.DrawTableColumn(crest.ToString()); - ImGuiUtil.DrawTableColumn(applyCrest ? "Apply" : "Keep"); + table.DrawColumn(slot.ToNameU8()); + table.DrawColumn(item.Name); + table.DrawColumn($"{item.ItemId}"); + table.DrawColumn(apply ? "Apply"u8 : "Keep"u8); + table.DrawColumn($"{stain}"); + table.DrawColumn(applyStain ? "Apply"u8 : "Keep"u8); + table.DrawColumn($"{crest}"); + table.DrawColumn(applyCrest ? "Apply"u8 : "Keep"u8); } foreach (var index in MetaExtensions.AllRelevant) { - ImGuiUtil.DrawTableColumn(index.ToName()); - ImGuiUtil.DrawTableColumn(design.DesignData.GetMeta(index).ToString()); - ImGuiUtil.DrawTableColumn(design.DoApplyMeta(index) ? "Apply" : "Keep"); - ImGui.TableNextRow(); + table.DrawColumn(index.ToNameU8()); + table.DrawColumn($"{design.DesignData.GetMeta(index)}"); + table.DrawColumn(design.DoApplyMeta(index) ? "Apply"u8 : "Keep"u8); + table.NextRow(); } - ImGuiUtil.DrawTableColumn("Model ID"); - ImGuiUtil.DrawTableColumn(design.DesignData.ModelId.ToString()); - ImGui.TableNextRow(); + table.DrawDataPair("Model ID"u8, design.DesignData.ModelId); + table.NextRow(); - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) { var value = design.DesignData.Customize[index]; var apply = design.DoApplyCustomize(index); - ImGuiUtil.DrawTableColumn(index.ToDefaultName()); - ImGuiUtil.DrawTableColumn(value.Value.ToString()); - ImGuiUtil.DrawTableColumn(apply ? "Apply" : "Keep"); - ImGui.TableNextRow(); + table.DrawColumn(index.ToNameU8()); + table.DrawColumn($"{value.Value}"); + table.DrawColumn(apply ? "Apply"u8 : "Keep"u8); + table.NextRow(); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs index 69461d1..55adec0 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DesignTesterPanel.cs @@ -1,14 +1,10 @@ -using Dalamud.Interface; -using Glamourer.Designs; +using Glamourer.Designs; using Glamourer.Services; -using Dalamud.Bindings.ImGui; using ImSharp; -using OtterGui; -using OtterGui.Extensions; -using OtterGui.Raii; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; +using Luna; namespace Glamourer.Gui.Tabs.DebugTab; @@ -36,9 +32,9 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) private void DrawBase64Input() { - ImGui.SetNextItemWidth(-1); - ImGui.InputTextWithHint("##base64", "Base 64 input...", ref _base64, 2047); - if (!ImGui.IsItemDeactivatedAfterEdit()) + Im.Item.SetNextWidthFull(); + Im.Input.Text("##base64"u8, ref _base64, "Base 64 input..."u8); + if (!Im.Item.DeactivatedAfterEdit) return; try @@ -48,16 +44,16 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) } catch (Exception ex) { - _base64Bytes = Array.Empty(); + _base64Bytes = []; _parse64Failure = ex; } - if (_parse64Failure != null) + if (_parse64Failure is not null) return; try { - _parse64 = DesignBase64Migration.MigrateBase64(items, humans, _base64, out var ef, out var cf, out var wp, out var meta); + _parse64 = DesignBase64Migration.MigrateBase64(items, humans, _base64, out var ef, out var cf, out var wp, out var meta); _restore = DesignBase64Migration.CreateOldBase64(in _parse64, ef, cf, meta, wp); _restoreBytes = Convert.FromBase64String(_restore); } @@ -70,9 +66,9 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) private void DrawDesignData() { - if (_parse64Failure != null) + if (_parse64Failure is not null) { - ImGuiUtil.TextWrapped(_parse64Failure.ToString()); + Im.TextWrapped($"{_parse64Failure}"); return; } @@ -80,54 +76,51 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) return; DrawDesignData(_parse64); - using var font = ImRaii.PushFont(UiBuilder.MonoFont); - ImGui.TextUnformatted(_base64); - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Im.Style.ItemSpacing with { X = 0 })) + using var font = Im.Font.PushMono(); + Im.Text(_base64); + foreach (var (c1, c2) in _restore.Zip(_base64)) { - foreach (var (c1, c2) in _restore.Zip(_base64)) - { - using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF4040D0, c1 != c2); - ImGui.TextUnformatted(c1.ToString()); - Im.Line.Same(); - } + using var color = ImGuiColor.Text.Push(0xFF4040D0, c1 != c2); + Im.Text($"{c1}"); + Im.Line.NoSpacing(); } - ImGui.NewLine(); + Im.Line.New(); - foreach (var ((b1, b2), idx) in _base64Bytes.Zip(_restoreBytes).WithIndex()) + foreach (var (idx, (b1, b2)) in _base64Bytes.Zip(_restoreBytes).Index()) { - using (_ = ImRaii.Group()) + using (Im.Group()) { - ImGui.TextUnformatted(idx.ToString("D2")); - ImGui.TextUnformatted(b1.ToString("X2")); - using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF4040D0, b1 != b2); - ImGui.TextUnformatted(b2.ToString("X2")); + Im.Text($"{idx:D2}"); + Im.Text($"{b1:X2}"); + using var color = ImGuiColor.Text.Push(0xFF4040D0, b1 != b2); + Im.Text($"{b2:X2}"); } - Im.Line.Same(); + Im.Line.NoSpacing(); } - ImGui.NewLine(); + Im.Line.New(); } private void DrawBytes() { - if (_parse64Failure == null || _base64Bytes.Length <= 0) + if (_parse64Failure is null || _base64Bytes.Length <= 0) return; - using var font = ImRaii.PushFont(UiBuilder.MonoFont); - foreach (var (b, idx) in _base64Bytes.WithIndex()) + using var font = Im.Font.PushMono(); + foreach (var (idx, b) in _base64Bytes.Index()) { - using (_ = ImRaii.Group()) + using (Im.Group()) { - ImGui.TextUnformatted(idx.ToString("D2")); - ImGui.TextUnformatted(b.ToString("X2")); + Im.Text($"{idx:D2}"); + Im.Text($"{b:X2}"); } Im.Line.Same(); } - ImGui.NewLine(); + Im.Line.New(); } public static void DrawDesignData(in DesignData data) @@ -140,7 +133,7 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) private static void DrawHumanData(in DesignData data) { - using var table = ImRaii.Table("##equip", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##equip"u8, 5, TableFlags.RowBackground | TableFlags.SizingFixedFit); if (!table) return; @@ -149,51 +142,45 @@ public sealed class DesignTesterPanel(ItemManager items, HumanModelList humans) var item = data.Item(slot); var stain = data.Stain(slot); var crest = data.Crest(slot.ToCrestFlag()); - ImGuiUtil.DrawTableColumn(slot.ToName()); - ImGuiUtil.DrawTableColumn(item.Name); - ImGuiUtil.DrawTableColumn(item.ItemId.ToString()); - ImGuiUtil.DrawTableColumn(stain.ToString()); - ImGuiUtil.DrawTableColumn(crest.ToString()); + table.DrawColumn(slot.ToNameU8()); + table.DrawColumn(item.Name); + table.DrawColumn($"{item.ItemId}"); + table.DrawColumn($"{stain}"); + table.DrawColumn($"{crest}"); } - ImGuiUtil.DrawTableColumn("Hat Visible"); - ImGuiUtil.DrawTableColumn(data.IsHatVisible().ToString()); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn("Visor Toggled"); - ImGuiUtil.DrawTableColumn(data.IsVisorToggled().ToString()); - ImGui.TableNextRow(); - ImGuiUtil.DrawTableColumn("Weapon Visible"); - ImGuiUtil.DrawTableColumn(data.IsWeaponVisible().ToString()); - ImGui.TableNextRow(); + table.DrawDataPair("Hat Visible"u8, data.IsHatVisible()); + table.NextRow(); + table.DrawDataPair("Visor Toggled"u8, data.IsVisorToggled()); + table.NextRow(); + table.DrawDataPair("Weapon Visible"u8, data.IsWeaponVisible()); + table.NextRow(); - ImGuiUtil.DrawTableColumn("Model ID"); - ImGuiUtil.DrawTableColumn(data.ModelId.ToString()); - ImGui.TableNextRow(); + table.DrawDataPair("Model ID"u8,data.ModelId); + table.NextRow(); - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) { var value = data.Customize[index]; - ImGuiUtil.DrawTableColumn(index.ToDefaultName()); - ImGuiUtil.DrawTableColumn(value.Value.ToString()); - ImGui.TableNextRow(); + table.DrawDataPair(index.ToNameU8(), value.Value); + table.NextRow(); } - ImGuiUtil.DrawTableColumn("Is Wet"); - ImGuiUtil.DrawTableColumn(data.IsWet().ToString()); - ImGui.TableNextRow(); + table.DrawDataPair("Is Wet"u8, data.IsWet()); + table.NextRow(); } private static void DrawMonsterData(in DesignData data) { - ImGui.TextUnformatted($"Model ID {data.ModelId}"); - ImGui.Separator(); - using var font = ImRaii.PushFont(UiBuilder.MonoFont); - ImGui.TextUnformatted("Customize Array"); - ImGui.Separator(); - ImGuiUtil.TextWrapped(string.Join(" ", data.GetCustomizeBytes().Select(b => b.ToString("X2")))); + Im.Text($"Model ID {data.ModelId}"); + Im.Separator(); + using var font = Im.Font.PushMono(); + Im.Text("Customize Array"u8); + Im.Separator(); + Im.TextWrapped(StringU8.Join((byte)' ', data.GetCustomizeBytes().Select(b => b.ToString("X2")))); - ImGui.TextUnformatted("Equipment Array"); - ImGui.Separator(); - ImGuiUtil.TextWrapped(string.Join(" ", data.GetEquipmentBytes().Select(b => b.ToString("X2")))); + Im.Text("Equipment Array"u8); + Im.Separator(); + Im.TextWrapped(StringU8.Join((byte)' ', data.GetEquipmentBytes().Select(b => b.ToString("X2")))); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs index fed5b75..7044bca 100644 --- a/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/GlamourPlatePanel.cs @@ -59,7 +59,7 @@ public sealed unsafe class GlamourPlatePanel : IGameDataDrawer ImUtf8.Text(manager == null ? "-" : manager->GlamourPlates.Length.ToString()); ImUtf8.Text(manager == null ? "-" : manager->GlamourPlatesRequested.ToString()); Im.Line.Same(); - if (ImUtf8.SmallButton("Request Update"u8)) + if (Im.SmallButton("Request Update"u8)) RequestGlamour(); ImUtf8.Text(manager == null ? "-" : manager->GlamourPlatesLoaded.ToString()); ImUtf8.Text(manager == null ? "-" : manager->IsApplyingGlamourPlate.ToString()); diff --git a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs index 01617ee..ab1a37e 100644 --- a/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/InventoryPanel.cs @@ -1,5 +1,6 @@ using FFXIVClientStructs.FFXIV.Client.Game; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Gui.Debug; @@ -28,7 +29,7 @@ public sealed unsafe class InventoryPanel : IGameDataDrawer ImGuiUtil.CopyOnClickSelectable($"0x{(ulong)equip:X}"); - using var table = ImRaii.Table("items", 4, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("items"u8, 4, TableFlags.RowBackground | TableFlags.SizingFixedFit); if (!table) return; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs index fbf3247..5f9e996 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/DesignIpcTester.cs @@ -4,6 +4,7 @@ using Dalamud.Plugin; using Glamourer.Api.Enums; using Glamourer.Api.IpcSubscribers; using Dalamud.Bindings.ImGui; +using ImSharp; using Luna; using OtterGui; using OtterGui.Raii; @@ -34,10 +35,10 @@ public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiServi IpcTesterHelpers.NameInput(ref _gameObjectName); ImUtf8.InputText("##designName"u8, ref _designName, "Design Name..."u8); ImGuiUtil.GuidInput("##identifier", "Design Identifier...", string.Empty, ref _design, ref _designText, - ImGui.GetContentRegionAvail().X); + Im.ContentRegion.Available.X); IpcTesterHelpers.DrawFlagInput(ref _flags); - using var table = ImRaii.Table("##table", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##table"u8, 2, TableFlags.SizingFixedFit); IpcTesterHelpers.DrawIntro("Last Error"); ImGui.TextUnformatted(_lastError.ToString()); @@ -108,11 +109,11 @@ public class DesignIpcTester(IDalamudPluginInterface pluginInterface) : IUiServi if (!p) return; - using var table = ImRaii.Table("Designs", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("Designs"u8, 2, TableFlags.SizingFixedFit); foreach (var (guid, name) in _designs) { ImGuiUtil.DrawTableColumn(name); - using var f = ImRaii.PushFont(UiBuilder.MonoFont); + using var f = Im.Font.PushMono(); ImGui.TableNextColumn(); ImGuiUtil.CopyOnClickSelectable(guid.ToString()); } diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs index d4d9035..9790764 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterHelpers.cs @@ -30,13 +30,13 @@ public static class IpcTesterHelpers public static void IndexInput(ref int index) { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X / 2); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X / 2); ImGui.InputInt("Game Object Index", ref index, 0, 0); } public static void KeyInput(ref uint key) { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X / 2); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X / 2); var keyI = (int)key; if (ImGui.InputInt("Key", ref keyI, 0, 0)) key = (uint)keyI; @@ -44,7 +44,7 @@ public static class IpcTesterHelpers public static void NameInput(ref string name) { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); ImGui.InputTextWithHint("##gameObject", "Character Name...", ref name, 64); } diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs index 2400fb7..7ecd171 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs @@ -35,7 +35,7 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic DrawItemInput(); IpcTesterHelpers.NameInput(ref _gameObjectName); IpcTesterHelpers.DrawFlagInput(ref _flags); - using var table = ImRaii.Table("##table", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##table"u8, 2, TableFlags.SizingFixedFit); IpcTesterHelpers.DrawIntro("Last Error"); ImGui.TextUnformatted(_lastError.ToString()); @@ -64,7 +64,7 @@ public class ItemsIpcTester(IDalamudPluginInterface pluginInterface) : IUiServic private void DrawItemInput() { var tmp = _customItemId.Id; - var width = ImGui.GetContentRegionAvail().X / 2; + var width = Im.ContentRegion.Available.X / 2; ImGui.SetNextItemWidth(width); if (ImGuiUtil.InputUlong("Custom Item ID", ref tmp)) _customItemId = tmp; diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index 4e640f6..3d0bbc9 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -85,9 +85,9 @@ public class StateIpcTester : IUiService, IDisposable IpcTesterHelpers.KeyInput(ref _key); IpcTesterHelpers.NameInput(ref _gameObjectName); IpcTesterHelpers.DrawFlagInput(ref _flags); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); ImGui.InputTextWithHint("##base64", "Base 64 State...", ref _base64State, 2000); - using var table = ImRaii.Table("##table", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##table"u8, 2, TableFlags.SizingFixedFit); IpcTesterHelpers.DrawIntro("Last Error"); ImGui.TextUnformatted(_lastError.ToString()); @@ -206,7 +206,7 @@ public class StateIpcTester : IUiService, IDisposable ImUtf8.SetClipboardText(DesignConverter.ToBase64(_state)); } - using var font = ImRaii.PushFont(UiBuilder.MonoFont); + using var font = Im.Font.PushMono(); ImUtf8.TextWrapped(_stateString ?? string.Empty); if (ImUtf8.Button("Close"u8, -Vector2.UnitX) || !ImGui.IsWindowFocused()) @@ -219,7 +219,7 @@ public class StateIpcTester : IUiService, IDisposable ImGui.SameLine(0, 0); ImUtf8.Text($" ({_lastStateChangeType})"); Im.Line.Same(); - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { ImUtf8.CopyOnClickSelectable($"0x{_lastStateChangeActor:X}"); } @@ -234,7 +234,7 @@ public class StateIpcTester : IUiService, IDisposable ImGui.SameLine(0, 0); ImUtf8.Text($" ({_lastStateFinalizeType})"); Im.Line.Same(); - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { ImUtf8.CopyOnClickSelectable($"0x{_lastStateFinalizeActor:X}"); } diff --git a/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs index 589edb4..64903e6 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ItemUnlockPanel.cs @@ -2,8 +2,8 @@ using Glamourer.Services; using Glamourer.Unlocks; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui; -using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; using ImGuiClip = OtterGui.ImGuiClip; @@ -20,20 +20,20 @@ public sealed class ItemUnlockPanel(ItemUnlockManager itemUnlocks, ItemManager i public void Draw() { - using var table = ImRaii.Table("itemUnlocks", 5, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersOuter, - new Vector2(ImGui.GetContentRegionAvail().X, 12 * ImGui.GetTextLineHeight())); + using var table = Im.Table.Begin("itemUnlocks"u8, 5, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.ScrollY | TableFlags.BordersOuter, + Im.ContentRegion.Available with { Y = 12 * Im.Style.TextHeight }); if (!table) return; - ImGui.TableSetupColumn("ItemId", ImGuiTableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, 400 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Slot", ImGuiTableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Model", ImGuiTableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Unlock", ImGuiTableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); + table.SetupColumn("ItemId"u8, TableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); + table.SetupColumn("Name"u8, TableColumnFlags.WidthFixed, 400 * Im.Style.GlobalScale); + table.SetupColumn("Slot"u8, TableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); + table.SetupColumn("Model"u8, TableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); + table.SetupColumn("Unlock"u8, TableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); ImGui.TableNextColumn(); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeightWithSpacing()); + var skips = ImGuiClip.GetNecessarySkips(Im.Style.TextHeightWithSpacing); ImGui.TableNextRow(); var remainder = ImGuiClip.ClippedDraw(itemUnlocks, skips, t => { @@ -57,6 +57,6 @@ public sealed class ItemUnlockPanel(ItemUnlockManager itemUnlocks, ItemManager i : time.LocalDateTime.ToString("g") : "Never"); }, itemUnlocks.Count); - ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); + ImGuiClip.DrawEndDummy(remainder, Im.Style.TextHeight); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index 3387bf3..a819edb 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -2,11 +2,7 @@ using Glamourer.GameData; using Glamourer.Interop; using Glamourer.Interop.Structs; -using Dalamud.Bindings.ImGui; using ImSharp; -using OtterGui; -using OtterGui.Raii; -using OtterGui.Text; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; @@ -34,76 +30,72 @@ public sealed unsafe class ModelEvaluationPanel( public void Draw() { - ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0); + Im.Input.Scalar("Game Object Index"u8, ref _gameObjectIndex); var actor = objectManager.Objects[_gameObjectIndex]; var model = actor.Model; - using var table = ImRaii.Table("##evaluationTable", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); - ImGui.TableNextColumn(); - ImGui.TableNextColumn(); - ImGui.TableHeader("Actor"); - ImGui.TableNextColumn(); - ImGui.TableHeader("Model"); - ImGui.TableNextColumn(); + using var table = Im.Table.Begin("##evaluationTable"u8, 4, TableFlags.SizingFixedFit | TableFlags.RowBackground); + table.NextColumn(); + table.NextColumn(); + table.Header("Actor"u8); + table.NextColumn(); + table.Header("Model"u8); + table.NextColumn(); - ImGuiUtil.DrawTableColumn("Address"); - ImGui.TableNextColumn(); + table.DrawColumn("Address"u8); + table.NextColumn(); Glamourer.Dynamis.DrawPointer(actor); - ImGui.TableNextColumn(); + table.NextColumn(); Glamourer.Dynamis.DrawPointer(model); - ImGui.TableNextColumn(); + table.NextColumn(); if (actor.IsCharacter) { - ImGui.TextUnformatted(actor.AsCharacter->ModelContainer.ModelCharaId.ToString()); - if (actor.AsCharacter->CharacterData.TransformationId != 0) - ImGui.TextUnformatted($"Transformation Id: {actor.AsCharacter->CharacterData.TransformationId}"); - if (actor.AsCharacter->ModelContainer.ModelCharaId_2 != -1) - ImGui.TextUnformatted($"ModelChara2 {actor.AsCharacter->ModelContainer.ModelCharaId_2}"); + Im.Text($"{actor.AsCharacter->ModelContainer.ModelCharaId}"); + if (actor.AsCharacter->CharacterData.TransformationId is not 0) + Im.Text($"Transformation Id: {actor.AsCharacter->CharacterData.TransformationId}"); + if (actor.AsCharacter->ModelContainer.ModelCharaId_2 is not -1) + Im.Text($"ModelChara2 {actor.AsCharacter->ModelContainer.ModelCharaId_2}"); - ImGuiUtil.DrawTableColumn("Character Mode"); - ImGuiUtil.DrawTableColumn($"{actor.AsCharacter->Mode}"); - ImGui.TableNextColumn(); - ImGui.TableNextColumn(); + table.DrawDataPair("Character Mode"u8, actor.AsCharacter->Mode); + table.NextColumn(); + table.NextColumn(); - ImGuiUtil.DrawTableColumn("Animation"); - ImGuiUtil.DrawTableColumn($"{((ushort*)&actor.AsCharacter->Timeline)[0x78]}"); - ImGui.TableNextColumn(); - ImGui.TableNextColumn(); + table.DrawDataPair("Animation"u8, ((ushort*)&actor.AsCharacter->Timeline)[0x78]); + table.NextColumn(); + table.NextColumn(); } - ImGuiUtil.DrawTableColumn("Mainhand"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetMainhand().ToString() : "No Character"); + + table.DrawColumn("Mainhand"u8); + table.DrawColumn(actor.IsCharacter ? $"{actor.GetMainhand()}" : "No Character"u8); var (mainhand, offhand, mainModel, offModel) = model.GetWeapons(actor); - ImGuiUtil.DrawTableColumn(mainModel.ToString()); - ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(mainhand.ToString()); + table.DrawColumn($"{mainModel}"); + table.NextColumn(); + Glamourer.Dynamis.DrawPointer(mainhand); - ImGuiUtil.DrawTableColumn("Offhand"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetOffhand().ToString() : "No Character"); - ImGuiUtil.DrawTableColumn(offModel.ToString()); - ImGui.TableNextColumn(); - ImGuiUtil.CopyOnClickSelectable(offhand.ToString()); + table.DrawColumn("Offhand"u8); + table.DrawColumn(actor.IsCharacter ? $"{actor.GetOffhand()}" : "No Character"u8); + table.DrawColumn($"{offModel}"); + table.NextColumn(); + Glamourer.Dynamis.DrawPointer(offhand); - DrawVisor(actor, model); - DrawVieraEars(actor, model); - DrawHatState(actor, model); - DrawWeaponState(actor, model); - DrawWetness(actor, model); - DrawEquip(actor, model); - DrawCustomize(actor, model); - DrawCrests(actor, model); - DrawParameters(actor, model); + DrawVisor(table, actor, model); + DrawVieraEars(table, actor, model); + DrawHatState(table, actor, model); + DrawWeaponState(table, actor, model); + DrawWetness(table, actor, model); + DrawEquip(table, actor, model); + DrawCustomize(table, actor, model); + DrawCrests(table, actor, model); + DrawParameters(table, actor, model); - ImGuiUtil.DrawTableColumn("Scale"); - ImGuiUtil.DrawTableColumn(actor.Valid ? actor.AsObject->Scale.ToString(CultureInfo.InvariantCulture) : "No Character"); - ImGuiUtil.DrawTableColumn(model.Valid ? model.AsDrawObject->Object.Scale.ToString() : "No Model"); - ImGuiUtil.DrawTableColumn(model.IsCharacterBase - ? $"{*(float*)(model.Address + 0x270)} {*(float*)(model.Address + 0x274)}" - : "No CharacterBase"); + table.DrawColumn("Scale"u8); + table.DrawColumn(actor.Valid ? actor.AsObject->Scale.ToString(CultureInfo.InvariantCulture) : "No Character"u8); + table.DrawColumn(model.Valid ? $"{model.AsDrawObject->Object.Scale}" : "No Model"u8); } - private static void DrawParameters(Actor actor, Model model) + private static void DrawParameters(in Im.TableDisposable table, Actor actor, Model model) { if (!model.IsHuman) return; @@ -111,201 +103,211 @@ public sealed unsafe class ModelEvaluationPanel( var convert = model.GetParameterData(); foreach (var flag in CustomizeParameterExtensions.AllFlags) { - ImGuiUtil.DrawTableColumn(flag.ToString()); - ImGuiUtil.DrawTableColumn(string.Empty); - ImGuiUtil.DrawTableColumn(convert[flag].InternalQuadruple.ToString()); - ImGui.TableNextColumn(); + using var id = Im.Id.Push((int)flag); + table.DrawColumn(flag.ToNameU8()); + table.DrawColumn(StringU8.Empty); + var value = convert[flag].InternalQuadruple; + table.DrawColumn($"{value.X:F2} | {value.Y:F2} | {value.Z:F2} | {value.W:F2}"); + table.NextColumn(); } } - private void DrawVisor(Actor actor, Model model) + private void DrawVisor(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Visor"); - ImGuiUtil.DrawTableColumn("Visor State"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.AsCharacter->DrawData.IsVisorToggled.ToString() : "No Character"); - ImGuiUtil.DrawTableColumn(model.IsHuman ? VisorService.GetVisorState(model).ToString() : "No Human"); - ImGui.TableNextColumn(); + using var id = Im.Id.Push("Visor"u8); + table.DrawColumn("Visor State"u8); + table.DrawColumn(actor.IsCharacter ? $"{actor.AsCharacter->DrawData.IsVisorToggled}" : "No Character"u8); + table.DrawColumn(model.IsHuman ? $"{VisorService.GetVisorState(model)}" : "No Human"u8); + table.NextColumn(); if (!model.IsHuman) return; - if (ImGui.SmallButton("Set True")) + if (Im.SmallButton("Set True"u8)) visorService.SetVisorState(model, true); Im.Line.Same(); - if (ImGui.SmallButton("Set False")) + if (Im.SmallButton("Set False"u8)) visorService.SetVisorState(model, false); Im.Line.Same(); - if (ImGui.SmallButton("Toggle")) + if (Im.SmallButton("Toggle"u8)) visorService.SetVisorState(model, !VisorService.GetVisorState(model)); } - private void DrawVieraEars(Actor actor, Model model) + private void DrawVieraEars(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Viera Ears"); - ImGuiUtil.DrawTableColumn("Viera Ears"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.ShowVieraEars.ToString() : "No Character"); - ImGuiUtil.DrawTableColumn(model.IsHuman ? model.VieraEarsVisible.ToString() : "No Human"); - ImGui.TableNextColumn(); + using var id = Im.Id.Push("Viera Ears"u8); + table.DrawColumn("Viera Ears"u8); + table.DrawColumn(actor.IsCharacter ? $"{actor.ShowVieraEars}" : "No Character"u8); + table.DrawColumn(model.IsHuman ? $"{model.VieraEarsVisible}" : "No Human"u8); + table.NextColumn(); if (!model.IsHuman) return; - if (ImGui.SmallButton("Set True")) + if (Im.SmallButton("Set True"u8)) vieraEarService.SetVieraEarState(model, true); Im.Line.Same(); - if (ImGui.SmallButton("Set False")) + if (Im.SmallButton("Set False"u8)) vieraEarService.SetVieraEarState(model, false); Im.Line.Same(); - if (ImGui.SmallButton("Toggle")) + if (Im.SmallButton("Toggle"u8)) vieraEarService.SetVieraEarState(model, !model.VieraEarsVisible); } - private void DrawHatState(Actor actor, Model model) + private void DrawHatState(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("HatState"); - ImGuiUtil.DrawTableColumn("Hat State"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter - ? actor.AsCharacter->DrawData.IsHatHidden ? "Hidden" : actor.GetArmor(EquipSlot.Head).ToString() - : "No Character"); - ImGuiUtil.DrawTableColumn(model.IsHuman - ? model.AsHuman->Head.Value == 0 ? "No Hat" : model.GetArmor(EquipSlot.Head).ToString() - : "No Human"); - ImGui.TableNextColumn(); + using var id = Im.Id.Push("HatState"u8); + table.DrawColumn("Hat State"u8); + table.DrawColumn(actor.IsCharacter + ? actor.AsCharacter->DrawData.IsHatHidden ? "Hidden"u8 : $"{actor.GetArmor(EquipSlot.Head)}" + : "No Character"u8); + table.DrawColumn(model.IsHuman + ? model.AsHuman->Head.Value is 0 ? "No Hat"u8 : $"{model.GetArmor(EquipSlot.Head)}" + : "No Human"u8); + table.NextColumn(); if (!model.IsHuman) return; - if (ImGui.SmallButton("Hide")) + if (Im.SmallButton("Hide"u8)) updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, CharacterArmor.Empty); Im.Line.Same(); - if (ImGui.SmallButton("Show")) + if (Im.SmallButton("Show"u8)) updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, actor.GetArmor(EquipSlot.Head)); Im.Line.Same(); - if (ImGui.SmallButton("Toggle")) + if (Im.SmallButton("Toggle"u8)) updateSlotService.UpdateEquipSlot(model, EquipSlot.Head, model.AsHuman->Head.Value == 0 ? actor.GetArmor(EquipSlot.Head) : CharacterArmor.Empty); } - private static void DrawWeaponState(Actor actor, Model model) + private static void DrawWeaponState(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("WeaponState"); - ImGuiUtil.DrawTableColumn("Weapon State"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter - ? actor.AsCharacter->DrawData.IsWeaponHidden ? "Hidden" : "Visible" - : "No Character"); - string text; + using var id = Im.Id.Push("WeaponState"u8); + table.DrawColumn("Weapon State"u8); + table.DrawColumn(actor.IsCharacter + ? actor.AsCharacter->DrawData.IsWeaponHidden ? "Hidden"u8 : "Visible"u8 + : "No Character"u8); + ReadOnlySpan text; if (!model.IsHuman) { - text = "No Model"; + text = "No Model"u8; } - else if (model.AsDrawObject->Object.ChildObject == null) + else if (model.AsDrawObject->Object.ChildObject is null) { - text = "No Weapon"; + text = "No Weapon"u8; } else { var weapon = (DrawObject*)model.AsDrawObject->Object.ChildObject; - text = (weapon->Flags & 0x09) == 0x09 ? "Visible" : "Hidden"; + text = (weapon->Flags & 0x09) is 0x09 ? "Visible"u8 : "Hidden"u8; } - ImGuiUtil.DrawTableColumn(text); - ImGui.TableNextColumn(); + table.DrawColumn(text); + table.NextColumn(); } - private static void DrawWetness(Actor actor, Model model) + private static void DrawWetness(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Wetness"); - ImGuiUtil.DrawTableColumn("Wetness"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.IsGPoseWet ? "GPose" : "None" : "No Character"); - var modelString = model.IsCharacterBase + using var id = Im.Id.Push("Wetness"u8); + table.DrawColumn("Wetness"u8); + table.DrawColumn(actor.IsCharacter ? actor.IsGPoseWet ? "GPose"u8 : "None"u8 : "No Character"u8); + table.DrawColumn(model.IsCharacterBase ? $"{model.AsCharacterBase->SwimmingWetness:F4} Swimming\n" + $"{model.AsCharacterBase->WeatherWetness:F4} Weather\n" + $"{model.AsCharacterBase->ForcedWetness:F4} Forced\n" + $"{model.AsCharacterBase->WetnessDepth:F4} Depth\n" - : "No CharacterBase"; - ImGuiUtil.DrawTableColumn(modelString); - ImGui.TableNextColumn(); + : "No CharacterBase"u8); + table.NextColumn(); if (!actor.IsCharacter) return; - if (ImGui.SmallButton("GPose On")) + if (Im.SmallButton("GPose On"u8)) actor.IsGPoseWet = true; Im.Line.Same(); - if (ImGui.SmallButton("GPose Off")) + if (Im.SmallButton("GPose Off"u8)) actor.IsGPoseWet = false; Im.Line.Same(); - if (ImGui.SmallButton("GPose Toggle")) + if (Im.SmallButton("GPose Toggle"u8)) actor.IsGPoseWet = !actor.IsGPoseWet; } - private void DrawEquip(Actor actor, Model model) + private void DrawEquip(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Equipment"); + using var id = Im.Id.Push("Equipment"u8); foreach (var slot in EquipSlotExtensions.EqdpSlots) { - using var id2 = ImRaii.PushId((int)slot); - ImGuiUtil.DrawTableColumn(slot.ToName()); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetArmor(slot).ToString() : "No Character"); - ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetArmor(slot).ToString() : "No Human"); - ImGui.TableNextColumn(); + id.Push((int)slot); + table.DrawColumn(slot.ToNameU8()); + table.DrawColumn(actor.IsCharacter ? $"{actor.GetArmor(slot)}" : "No Character"u8); + table.DrawColumn(model.IsHuman ? $"{model.GetArmor(slot)}" : "No Human"u8); + table.NextColumn(); if (!model.IsHuman) continue; - if (ImGui.SmallButton("Change Piece")) + if (Im.SmallButton("Change Piece"u8)) updateSlotService.UpdateArmor(model, slot, - new CharacterArmor((PrimaryId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, StainIds.None)); + new CharacterArmor(slot switch + { + EquipSlot.Hands => 6064, + EquipSlot.Head => 6072, + _ => 1, + }, 1, StainIds.None)); Im.Line.Same(); - if (ImGui.SmallButton("Change Stain")) + if (Im.SmallButton("Change Stain"u8)) updateSlotService.UpdateStain(model, slot, new StainIds(5, 7)); Im.Line.Same(); - if (ImGui.SmallButton("Reset")) + if (Im.SmallButton("Reset"u8)) updateSlotService.UpdateEquipSlot(model, slot, actor.GetArmor(slot)); + id.Pop(); } foreach (var slot in BonusExtensions.AllFlags) { - using var id2 = ImRaii.PushId((int)slot.ToModelIndex()); - ImGuiUtil.DrawTableColumn(slot.ToName()); + id.Push((int)slot.ToModelIndex()); + table.DrawColumn(slot.ToNameU8()); if (!actor.IsCharacter) { - ImGuiUtil.DrawTableColumn("No Character"); + table.DrawColumn("No Character"u8); } else { var glassesId = actor.GetBonusItem(slot); if (bonusItems.TryGetValue(glassesId, out var glasses)) - ImGuiUtil.DrawTableColumn($"{glasses.PrimaryId.Id},{glasses.Variant.Id} ({glassesId})"); + table.DrawColumn($"{glasses.PrimaryId.Id},{glasses.Variant.Id} ({glassesId})"); else - ImGuiUtil.DrawTableColumn($"{glassesId}"); + table.DrawColumn($"{glassesId}"); } - ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetBonus(slot).ToString() : "No Human"); - ImGui.TableNextColumn(); - if (ImUtf8.SmallButton("Change Piece"u8)) + table.DrawColumn(model.IsHuman ? $"{model.GetBonus(slot)}" : "No Human"u8); + table.NextColumn(); + if (Im.SmallButton("Change Piece"u8)) { var data = model.GetBonus(slot); updateSlotService.UpdateBonusSlot(model, slot, data with { Variant = (Variant)((data.Variant.Id + 1) % 12) }); } + + id.Pop(); } } - private void DrawCustomize(Actor actor, Model model) + private void DrawCustomize(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Customize"); + using var id = Im.Id.Push("Customize"u8); var actorCustomize = actor.IsCharacter ? *(CustomizeArray*)&actor.AsCharacter->DrawData.CustomizeData : new CustomizeArray(); var modelCustomize = model.IsHuman ? *(CustomizeArray*)&model.AsHuman->Customize : new CustomizeArray(); - foreach (var type in Enum.GetValues()) + foreach (var type in CustomizeIndex.Values) { - using var id2 = ImRaii.PushId((int)type); - ImGuiUtil.DrawTableColumn(type.ToDefaultName()); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actorCustomize[type].Value.ToString("X2") : "No Character"); - ImGuiUtil.DrawTableColumn(model.IsHuman ? modelCustomize[type].Value.ToString("X2") : "No Human"); - ImGui.TableNextColumn(); + id.Push((int)type); + + table.DrawColumn(type.ToNameU8()); + table.DrawColumn(actor.IsCharacter ? $"{actorCustomize[type].Value:X2}" : "No Character"u8); + table.DrawColumn(model.IsHuman ? $"{modelCustomize[type].Value}" : "No Human"u8); + table.NextColumn(); if (!model.IsHuman || type.ToFlag().RequiresRedraw()) continue; - if (ImGui.SmallButton("++")) + if (Im.SmallButton("++"u8)) { var value = modelCustomize[type].Value; var (_, mask) = type.ToByteAndMask(); @@ -316,7 +318,7 @@ public sealed unsafe class ModelEvaluationPanel( } Im.Line.Same(); - if (ImGui.SmallButton("--")) + if (Im.SmallButton("--"u8)) { var value = modelCustomize[type].Value; var (_, mask) = type.ToByteAndMask(); @@ -327,17 +329,19 @@ public sealed unsafe class ModelEvaluationPanel( } Im.Line.Same(); - if (ImGui.SmallButton("Reset")) + if (Im.SmallButton("Reset"u8)) { modelCustomize.Set(type, actorCustomize[type]); changeCustomizeService.UpdateCustomize(model, modelCustomize); } + + id.Pop(); } } - private void DrawCrests(Actor actor, Model model) + private void DrawCrests(in Im.TableDisposable table, Actor actor, Model model) { - using var id = ImRaii.PushId("Crests"); + using var id = Im.Id.Push("Crests"u8); CrestFlag whichToggle = 0; CrestFlag totalModelFlags = 0; foreach (var crestFlag in CrestExtensions.AllRelevantSet) @@ -346,18 +350,18 @@ public sealed unsafe class ModelEvaluationPanel( var modelCrest = CrestService.GetModelCrest(actor, crestFlag); if (modelCrest) totalModelFlags |= crestFlag; - ImGuiUtil.DrawTableColumn($"{crestFlag.ToLabel()} Crest"); - ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetCrest(crestFlag).ToString() : "No Character"); - ImGuiUtil.DrawTableColumn(modelCrest.ToString()); + table.DrawColumn($"{crestFlag.ToLabel()} Crest"); + table.DrawColumn(actor.IsCharacter ? $"{actor.GetCrest(crestFlag)}" : "No Character"u8); + table.DrawColumn($"{modelCrest}"); - ImGui.TableNextColumn(); - if (model.IsHuman && ImGui.SmallButton("Toggle")) + table.NextColumn(); + if (model.IsHuman && Im.SmallButton("Toggle"u8)) whichToggle = crestFlag; id.Pop(); } - if (whichToggle != 0) + if (whichToggle is not 0) crestService.UpdateCrests(actor, totalModelFlags ^ whichToggle); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs index c30c7a8..a9393e2 100644 --- a/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/NpcAppearancePanel.cs @@ -5,6 +5,7 @@ using Glamourer.Designs; using Glamourer.GameData; using Glamourer.State; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; @@ -29,10 +30,10 @@ public sealed class NpcAppearancePanel(NpcCombo npcCombo, StateManager stateMana public void Draw() { ImUtf8.Checkbox("Compare Customize (or Gear)"u8, ref _customizeOrGear); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); var resetScroll = ImUtf8.InputText("##npcFilter"u8, ref _npcFilter, "Filter..."u8); - using var table = ImRaii.Table("npcs", 7, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit, + using var table = Im.Table.Begin("npcs"u8, 7, TableFlags.RowBackground | TableFlags.ScrollY | TableFlags.SizingFixedFit, new Vector2(-1, 400 * Im.Style.GlobalScale)); if (!table) return; @@ -40,13 +41,13 @@ public sealed class NpcAppearancePanel(NpcCombo npcCombo, StateManager stateMana if (resetScroll) ImGui.SetScrollY(0); - ImUtf8.TableSetupColumn("Button"u8, ImGuiTableColumnFlags.WidthFixed); - ImUtf8.TableSetupColumn("Name"u8, ImGuiTableColumnFlags.WidthFixed, Im.Style.GlobalScale * 300); - ImUtf8.TableSetupColumn("Kind"u8, ImGuiTableColumnFlags.WidthFixed); - ImUtf8.TableSetupColumn("Id"u8, ImGuiTableColumnFlags.WidthFixed); - ImUtf8.TableSetupColumn("Model"u8, ImGuiTableColumnFlags.WidthFixed); - ImUtf8.TableSetupColumn("Visor"u8, ImGuiTableColumnFlags.WidthFixed); - ImUtf8.TableSetupColumn("Compare"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Button"u8, TableColumnFlags.WidthFixed); + table.SetupColumn("Name"u8, TableColumnFlags.WidthFixed, Im.Style.GlobalScale * 300); + table.SetupColumn("Kind"u8, TableColumnFlags.WidthFixed); + table.SetupColumn("Id"u8, TableColumnFlags.WidthFixed); + table.SetupColumn("Model"u8, TableColumnFlags.WidthFixed); + table.SetupColumn("Visor"u8, TableColumnFlags.WidthFixed); + table.SetupColumn("Compare"u8, TableColumnFlags.WidthStretch); ImGui.TableNextColumn(); var skips = ImGuiClip.GetNecessarySkips(Im.Style.FrameHeightWithSpacing); @@ -60,7 +61,7 @@ public sealed class NpcAppearancePanel(NpcCombo npcCombo, StateManager stateMana void DrawData(NpcData data) { - using var id = ImRaii.PushId(idx++); + using var id = Im.Id.Push(idx++); var disabled = !stateManager.GetOrCreate(objectManager.Player, out var state); ImGui.TableNextColumn(); if (ImUtf8.ButtonEx("Apply"u8, ""u8, Vector2.Zero, disabled)) @@ -84,7 +85,7 @@ public sealed class NpcAppearancePanel(NpcCombo npcCombo, StateManager stateMana ImUtf8.DrawFrameColumn(data.VisorToggled ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); } - using var mono = ImRaii.PushFont(UiBuilder.MonoFont); + using var mono = Im.Font.PushMono(); ImUtf8.DrawFrameColumn(_customizeOrGear ? data.Customize.ToString() : data.WriteGear()); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs index 412ad49..3d944aa 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ObjectManagerPanel.cs @@ -1,4 +1,5 @@ using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui; using OtterGui.Text; using Penumbra.GameData.Actors; @@ -21,7 +22,7 @@ public sealed class ObjectManagerPanel(ActorObjectManager objectManager, ActorMa { objectManager.Objects.DrawDebug(); - using (var table = ImUtf8.Table("##data"u8, 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit)) + using (var table = Im.Table.Begin("##data"u8, 3, TableFlags.RowBackground | TableFlags.SizingFixedFit)) { if (!table) return; @@ -57,9 +58,9 @@ public sealed class ObjectManagerPanel(ActorObjectManager objectManager, ActorMa } var filterChanged = ImUtf8.InputText("##Filter"u8, ref _objectFilter, "Filter..."u8); - using var table2 = ImUtf8.Table("##data2"u8, 3, - ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, - new Vector2(-1, 20 * ImGui.GetTextLineHeightWithSpacing())); + using var table2 = Im.Table.Begin("##data2"u8, 3, + TableFlags.RowBackground | TableFlags.BordersOuter | TableFlags.ScrollY, + new Vector2(-1, 20 * Im.Style.TextHeightWithSpacing)); if (!table2) return; @@ -67,7 +68,7 @@ public sealed class ObjectManagerPanel(ActorObjectManager objectManager, ActorMa ImGui.SetScrollY(0); ImGui.TableNextColumn(); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeightWithSpacing()); + var skips = ImGuiClip.GetNecessarySkips(Im.Style.TextHeightWithSpacing); ImGui.TableNextRow(); var remainder = ImGuiClip.FilteredClippedDraw(objectManager, skips, @@ -78,6 +79,6 @@ public sealed class ObjectManagerPanel(ActorObjectManager objectManager, ActorMa ImUtf8.DrawTableColumn(p.Value.Label); ImUtf8.DrawTableColumn(string.Join(", ", p.Value.Objects.OrderBy(a => a.Index).Select(a => a.Index.ToString()))); }); - ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeightWithSpacing()); + ImGuiClip.DrawEndDummy(remainder, Im.Style.TextHeightWithSpacing); } } diff --git a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs index 44e775a..f4543ec 100644 --- a/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/PenumbraPanel.cs @@ -1,9 +1,5 @@ -using Dalamud.Interface.Utility; -using Glamourer.Interop.Penumbra; -using Dalamud.Bindings.ImGui; +using Glamourer.Interop.Penumbra; using ImSharp; -using OtterGui; -using OtterGui.Raii; using Penumbra.Api.Enums; using Penumbra.GameData.Enums; using Penumbra.GameData.Gui.Debug; @@ -25,80 +21,76 @@ public sealed class PenumbraPanel(PenumbraService penumbra, PenumbraChangedItemT public void Draw() { - using var table = ImRaii.Table("##PenumbraTable", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##PenumbraTable"u8, 3, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; - ImGuiUtil.DrawTableColumn("Available"); - ImGuiUtil.DrawTableColumn(penumbra.Available.ToString()); - ImGui.TableNextColumn(); - if (ImGui.SmallButton("Unattach")) + table.DrawDataPair("Available"u8, penumbra.Available); + table.NextColumn(); + if (Im.SmallButton("Unattach"u8)) penumbra.Unattach(); - Im.Line.Same(); - if (ImGui.SmallButton("Reattach")) + Im.Line.SameInner(); + if (Im.SmallButton("Reattach"u8)) penumbra.Reattach(); - ImGuiUtil.DrawTableColumn("Version"); - ImGuiUtil.DrawTableColumn($"{penumbra.CurrentMajor}.{penumbra.CurrentMinor}"); - ImGui.TableNextColumn(); + table.DrawDataPair("Version"u8, $"{penumbra.CurrentMajor}.{penumbra.CurrentMinor}"); + table.NextColumn(); - ImGuiUtil.DrawTableColumn("Attached When"); - ImGuiUtil.DrawTableColumn(penumbra.AttachTime.ToLocalTime().ToLongTimeString()); - ImGui.TableNextColumn(); + table.DrawDataPair("Attached When"u8, penumbra.AttachTime.ToLocalTime().ToLongTimeString()); + table.NextColumn(); - ImGuiUtil.DrawTableColumn("Draw Object"); - ImGui.TableNextColumn(); + table.DrawFrameColumn("Draw Object"u8); + table.NextColumn(); var address = _drawObject.Address; - ImGui.SetNextItemWidth(200 * Im.Style.GlobalScale); - if (ImGui.InputScalar("##drawObjectPtr", ImGuiDataType.U64, ref address, nint.Zero, nint.Zero, "%llx", - ImGuiInputTextFlags.CharsHexadecimal)) + Im.Item.SetNextWidthScaled(200); + if (Im.Input.Scalar("##drawObjectPtr"u8, ref address, "%llx"u8, flags: InputTextFlags.CharsHexadecimal)) _drawObject = address; - ImGuiUtil.DrawTableColumn(penumbra.Available - ? $"0x{penumbra.GameObjectFromDrawObject(_drawObject).Address:X}" - : "Penumbra Unavailable"); + table.NextColumn(); + if (penumbra.Available) + Glamourer.Dynamis.DrawPointer(penumbra.GameObjectFromDrawObject(_drawObject).Address); + else + Im.Text("Penumbra Unavailable"u8); - ImGuiUtil.DrawTableColumn("Cutscene Object"); - ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(200 * Im.Style.GlobalScale); - ImGui.InputInt("##CutsceneIndex", ref _gameObjectIndex, 0, 0); - ImGuiUtil.DrawTableColumn(penumbra.Available - ? penumbra.CutsceneParent((ushort)_gameObjectIndex).ToString() - : "Penumbra Unavailable"); + table.DrawFrameColumn("Cutscene Object"u8); + table.NextColumn(); + Im.Item.SetNextWidthScaled(200); + Im.Input.Scalar("##CutsceneIndex"u8, ref _gameObjectIndex); + table.DrawColumn(penumbra.Available ? $"{penumbra.CutsceneParent((ushort)_gameObjectIndex)}" : "Penumbra Unavailable"u8); - ImGuiUtil.DrawTableColumn("Redraw Object"); - ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(200 * Im.Style.GlobalScale); - ImGui.InputInt("##redrawObject", ref _gameObjectIndex, 0, 0); - ImGui.TableNextColumn(); - using (_ = ImRaii.Disabled(!penumbra.Available)) + table.DrawFrameColumn("Redraw Object"u8); + table.NextColumn(); + Im.Item.SetNextWidthScaled(200); + Im.Input.Scalar("##redrawObject"u8, ref _gameObjectIndex); + table.NextColumn(); + using (Im.Disabled(!penumbra.Available)) { - if (ImGui.SmallButton("Redraw")) + if (Im.Button("Redraw"u8)) penumbra.RedrawObject((ObjectIndex)_gameObjectIndex, RedrawType.Redraw); } - ImGuiUtil.DrawTableColumn("Last Tooltip Date"); - ImGuiUtil.DrawTableColumn(penumbraTooltip.LastTooltip > DateTime.MinValue + table.DrawColumn("Last Tooltip Date"u8); + table.DrawColumn(penumbraTooltip.LastTooltip > DateTime.MinValue ? $"{penumbraTooltip.LastTooltip.ToLongTimeString()} ({penumbraTooltip.LastType} {penumbraTooltip.LastId})" - : "Never"); - ImGui.TableNextColumn(); + : "Never"u8); + table.NextColumn(); - ImGuiUtil.DrawTableColumn("Last Click Date"); - ImGuiUtil.DrawTableColumn(penumbraTooltip.LastClick > DateTime.MinValue ? penumbraTooltip.LastClick.ToLongTimeString() : "Never"); - ImGui.TableNextColumn(); + table.DrawColumn("Last Click Date"u8); + table.DrawColumn(penumbraTooltip.LastClick > DateTime.MinValue ? penumbraTooltip.LastClick.ToLongTimeString() : "Never"u8); + table.NextColumn(); - ImGui.Separator(); - ImGui.Separator(); + Im.Separator(); + Im.Separator(); foreach (var (slot, item) in penumbraTooltip.LastItems) { switch (slot) { - case EquipSlot e: ImGuiUtil.DrawTableColumn($"{e.ToName()} Revert-Item"); break; - case BonusItemFlag f: ImGuiUtil.DrawTableColumn($"{f.ToName()} Revert-Item"); break; - default: ImGuiUtil.DrawTableColumn("Unk Revert-Item"); break; + case EquipSlot e: table.DrawColumn($"{e.ToNameU8()} Revert-Item"); break; + case BonusItemFlag f: table.DrawColumn($"{f.ToNameU8()} Revert-Item"); break; + default: table.DrawColumn("Unk Revert-Item"u8); break; } - ImGuiUtil.DrawTableColumn(item.Valid ? item.Name : "None"); - ImGui.TableNextColumn(); + table.DrawColumn(item.Valid ? item.Name : "None"u8); + table.NextColumn(); } } } diff --git a/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs b/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs index 711c3f6..fe641c7 100644 --- a/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/UnlockableItemsPanel.cs @@ -2,6 +2,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui; using OtterGui.Raii; using Penumbra.GameData.Enums; @@ -20,21 +21,21 @@ public sealed class UnlockableItemsPanel(ItemUnlockManager itemUnlocks, ItemMana public void Draw() { - using var table = ImRaii.Table("unlockableItem", 6, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersOuter, - new Vector2(ImGui.GetContentRegionAvail().X, 12 * ImGui.GetTextLineHeight())); + using var table = Im.Table.Begin("unlockableItem"u8, 6, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.ScrollY | TableFlags.BordersOuter, + Im.ContentRegion.Available with { Y = 12 * Im.Style.TextHeight }); if (!table) return; - ImGui.TableSetupColumn("ItemId", ImGuiTableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, 400 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Slot", ImGuiTableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Model", ImGuiTableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Unlock", ImGuiTableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("Criteria", ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("ItemId"u8, TableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); + table.SetupColumn("Name"u8, TableColumnFlags.WidthFixed, 400 * Im.Style.GlobalScale); + table.SetupColumn("Slot"u8, TableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); + table.SetupColumn("Model"u8, TableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); + table.SetupColumn("Unlock"u8, TableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); + table.SetupColumn("Criteria"u8, TableColumnFlags.WidthStretch); ImGui.TableNextColumn(); - var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeightWithSpacing()); + var skips = ImGuiClip.GetNecessarySkips(Im.Style.TextHeightWithSpacing); ImGui.TableNextRow(); var remainder = ImGuiClip.ClippedDraw(itemUnlocks.Unlockable, skips, t => { @@ -59,6 +60,6 @@ public sealed class UnlockableItemsPanel(ItemUnlockManager itemUnlocks, ItemMana : "Never"); ImGuiUtil.DrawTableColumn(t.Value.ToString()); }, itemUnlocks.Unlockable.Count); - ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight()); + ImGuiClip.DrawEndDummy(remainder, Im.Style.TextHeight); } } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 4955e61..3f5d984 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -52,23 +52,23 @@ public class DesignDetailTab DrawDesignInfoTable(); DrawDescription(); - ImGui.NewLine(); + Im.Line.New(); } private void DrawDesignInfoTable() { using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - using var table = ImUtf8.Table("Details"u8, 2); + using var table = Im.Table.Begin("Details"u8, 2); if (!table) return; - ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Reset Temporary Settings"u8).X); - ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Type"u8, TableColumnFlags.WidthFixed, Im.Font.CalculateSize("Reset Temporary Settings"u8).X); + table.SetupColumn("Data"u8, TableColumnFlags.WidthStretch); ImUtf8.DrawFrameColumn("Design Name"u8); ImGui.TableNextColumn(); - var width = new Vector2(ImGui.GetContentRegionAvail().X, 0); + var width = new Vector2(Im.ContentRegion.Available.X, 0); var name = _newName ?? _selector.Selected!.Name; ImGui.SetNextItemWidth(width.X); if (ImUtf8.InputText("##Name"u8, ref name)) @@ -88,7 +88,7 @@ public class DesignDetailTab ImUtf8.DrawFrameColumn("Unique Identifier"u8); ImGui.TableNextColumn(); var fileName = _saveService.FileNames.DesignFile(_selector.Selected!); - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { if (ImGui.Button(identifier, width)) try @@ -101,7 +101,7 @@ public class DesignDetailTab NotificationType.Warning); } - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + if (Im.Item.RightClicked()) ImGui.SetClipboardText(identifier); } @@ -172,14 +172,14 @@ public class DesignDetailTab 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 - Im.Style.ItemSpacing.X - Im.Style.FrameHeight, ImGui.GetTextLineHeight()) + width.X - Im.Style.ItemSpacing.X - Im.Style.FrameHeight, Im.Style.TextHeight) && _colorCombo.CurrentSelection != null) { colorName = _colorCombo.CurrentSelection is DesignColors.AutomaticName ? string.Empty : _colorCombo.CurrentSelection; _manager.ChangeColor(_selector.Selected!, colorName); } - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + if (Im.Item.RightClicked()) _manager.ChangeColor(_selector.Selected!, string.Empty); if (_colors.TryGetValue(_selector.Selected!.Color, out var currentColor)) @@ -230,7 +230,7 @@ public class DesignDetailTab private void DrawDescription() { var desc = _selector.Selected!.Description; - var size = new Vector2(ImGui.GetContentRegionAvail().X, 12 * ImGui.GetTextLineHeightWithSpacing()); + var size = new Vector2(Im.ContentRegion.Available.X, 12 * Im.Style.TextHeightWithSpacing); if (!_editDescriptionMode) { using (var textBox = ImUtf8.ListBox("##desc"u8, size)) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index ad79c4f..00b0723 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -49,10 +49,10 @@ public sealed class DesignFileSystemSelector : FileSystemSelector _config.Ephemeral.CurrentDesignSelectorWidth * ImUtf8.GlobalScale; + => _config.Ephemeral.CurrentDesignSelectorWidth * Im.Style.GlobalScale; protected override float MinimumAbsoluteRemainder - => 470 * ImUtf8.GlobalScale; + => 470 * Im.Style.GlobalScale; protected override float MinimumScaling => _config.Ephemeral.DesignSelectorMinimumScale; @@ -63,7 +63,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector _config.SortMode; protected override uint ExpandedFolderColor - => ColorId.FolderExpanded.Value(); + => ColorId.FolderExpanded.Value().Color; protected override uint CollapsedFolderColor - => ColorId.FolderCollapsed.Value(); + => ColorId.FolderCollapsed.Value().Color; protected override uint FolderLineColor - => ColorId.FolderLine.Value(); + => ColorId.FolderLine.Value().Color; protected override bool FoldersDefaultOpen => _config.OpenFoldersByDefault; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs index 68a2fba..f83e11d 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignLinkDrawer.cs @@ -74,13 +74,13 @@ public class DesignLinkDrawer( private void DrawList() { - using var table = ImRaii.Table("table", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter); + using var table = Im.Table.Begin("table"u8, 3, TableFlags.RowBackground | TableFlags.BordersOuter); if (!table) return; - ImGui.TableSetupColumn("Del", ImGuiTableColumnFlags.WidthFixed, Im.Style.FrameHeight); - ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("Detail", ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn("Del"u8, TableColumnFlags.WidthFixed, Im.Style.FrameHeight); + table.SetupColumn("Name"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("Detail"u8, TableColumnFlags.WidthFixed, 6 * Im.Style.FrameHeight + 5 * Im.Style.ItemInnerSpacing.X); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Im.Style.ItemInnerSpacing); @@ -93,7 +93,7 @@ public class DesignLinkDrawer( private void DrawSelf() { - using var id = ImRaii.PushId((int)LinkOrder.Self); + using var id = Im.Id.Push((int)LinkOrder.Self); ImGui.TableNextColumn(); var color = colorManager.GetColor(selector.Selected!); using (ImRaii.PushFont(UiBuilder.IconFont)) @@ -123,7 +123,7 @@ public class DesignLinkDrawer( private void DrawSubList(IReadOnlyList list, LinkOrder order) { - using var id = ImRaii.PushId((int)order); + using var id = Im.Id.Push((int)order); var buttonSize = new Vector2(Im.Style.FrameHeight); for (var i = 0; i < list.Count; ++i) @@ -157,7 +157,7 @@ public class DesignLinkDrawer( var buttonSize = new Vector2(Im.Style.FrameHeight); ImGui.TableNextColumn(); ImGui.TableNextColumn(); - combo.Draw(ImGui.GetContentRegionAvail().X); + combo.Draw(Im.ContentRegion.Available.X); ImGui.TableNextColumn(); string ttBefore, ttAfter; bool canAddBefore, canAddAfter; @@ -218,9 +218,8 @@ public class DesignLinkDrawer( { var newType = current; var newTypeInt = (uint)newType; - using (ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, Im.Style.GlobalScale)) + using (ImStyleBorder.Frame.Push(ColorId.FolderLine.Value())) { - using var _ = ImRaii.PushColor(ImGuiCol.Border, ColorId.FolderLine.Value()); if (ImGui.CheckboxFlags("##all", ref newTypeInt, (uint)ApplicationType.All)) newType = (ApplicationType)newTypeInt; } diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index 824611a..464dd19 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -96,7 +96,7 @@ public class DesignPanel } private void DrawHeader() - => HeaderDrawer.Draw(SelectionName, 0, ImGui.GetColorU32(ImGuiCol.FrameBg), _leftButtons, _rightButtons); + => HeaderDrawer.Draw(SelectionName, 0, ImGuiColor.FrameBackground.Get().Color, _leftButtons, _rightButtons); private string SelectionName => _selector.Selected == null ? "No Selection" : _selector.IncognitoMode ? _selector.Selected.Incognito : _selector.Selected.Name.Text; @@ -128,9 +128,9 @@ public class DesignPanel _equipmentDrawer.DrawBonusItem(data); } - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); DrawEquipmentMetaToggles(); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); _equipmentDrawer.DrawDragDropTooltip(); } @@ -168,17 +168,17 @@ public class DesignPanel if (_config.HideDesignPanel.HasFlag(DesignPanelFlag.Customization)) return; - var header = _selector.Selected!.DesignData.ModelId == 0 - ? "Customization" - : $"Customization (Model Id #{_selector.Selected!.DesignData.ModelId})###Customization"; - var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); - using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); + var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); + using var h = Im.Tree.HeaderId(_selector.Selected!.DesignData.ModelId is 0 + ? "Customization" + : $"Customization (Model Id #{_selector.Selected!.DesignData.ModelId})###Customization", + expand ? TreeNodeFlags.DefaultOpen : TreeNodeFlags.None); if (!h) return; if (_customizationDrawer.Draw(_selector.Selected!.DesignData.Customize, _selector.Selected.Application.Customize, _selector.Selected!.WriteProtected(), false)) - foreach (var idx in Enum.GetValues()) + foreach (var idx in CustomizeIndex.Values) { var flag = idx.ToFlag(); var newValue = _customizationDrawer.ChangeApply.HasFlag(flag); @@ -188,7 +188,7 @@ public class DesignPanel } EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(MetaIndex.Wetness, _manager, _selector.Selected!)); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); } private void DrawCustomizeParameters() @@ -226,11 +226,11 @@ public class DesignPanel } var applyClan = _selector.Selected!.DoApplyCustomize(CustomizeIndex.Clan); - if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Clan.ToDefaultName()}", ref applyClan)) + if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Clan.ToNameU8()}", ref applyClan)) _manager.ChangeApplyCustomize(_selector.Selected!, CustomizeIndex.Clan, applyClan); var applyGender = _selector.Selected!.DoApplyCustomize(CustomizeIndex.Gender); - if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Gender.ToDefaultName()}", ref applyGender)) + if (ImUtf8.Checkbox($"Apply {CustomizeIndex.Gender.ToNameU8()}", ref applyGender)) _manager.ChangeApplyCustomize(_selector.Selected!, CustomizeIndex.Gender, applyGender); @@ -261,7 +261,7 @@ public class DesignPanel if (!h) return; - using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected()); + using var disabled = Im.Disabled(_selector.Selected!.WriteProtected()); DrawAllButtons(); @@ -274,7 +274,7 @@ public class DesignPanel DrawMetaApplication(); } - ImGui.SameLine(210 * ImUtf8.GlobalScale + Im.Style.ItemSpacing.X); + ImGui.SameLine(210 * Im.Style.GlobalScale + Im.Style.ItemSpacing.X); using (var _ = ImRaii.Group()) { void ApplyEquip(string label, EquipFlag allFlags, bool stain, IEnumerable slots) @@ -327,7 +327,7 @@ public class DesignPanel var enabled = _config.DeleteDesignModifier.IsActive(); bool? equip = null; bool? customize = null; - var size = new Vector2(210 * ImUtf8.GlobalScale, 0); + var size = new Vector2(210 * Im.Style.GlobalScale, 0); if (ImUtf8.ButtonEx("Disable Everything"u8, "Disable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size, !enabled)) @@ -505,16 +505,16 @@ public class DesignPanel private void DrawPanel() { - using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); - if (!table || _selector.Selected == null) + using var table = Im.Table.Begin("##Panel"u8, 1, TableFlags.BordersOuter | TableFlags.ScrollY, Im.ContentRegion.Available); + if (!table || _selector.Selected is null) return; ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableNextColumn(); - if (_selector.Selected == null) + if (_selector.Selected is null) return; - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); DrawButtonRow(); ImGui.TableNextColumn(); diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 6891287..2d74e5d 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -43,7 +43,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect private void DrawCopyButtons() { - var size = new Vector2((ImGui.GetContentRegionAvail().X - 2 * Im.Style.ItemSpacing.X) / 3, 0); + var size = new Vector2((Im.ContentRegion.Available.X - 2 * Im.Style.ItemSpacing.X) / 3, 0); if (ImGui.Button("Copy All to Clipboard", size)) _copy = selector.Selected!.AssociatedMods.Select(kvp => (kvp.Key, kvp.Value)).ToArray(); @@ -76,7 +76,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (config.Ephemeral.IncognitoMode) name = id.ShortGuid(); if (ImGuiUtil.DrawDisabledButton($"Try Applying All Associated Mods to {name}##applyAll", - new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, id == Guid.Empty)) + new Vector2(Im.ContentRegion.Available.X, 0), string.Empty, id == Guid.Empty)) ApplyAll(); } @@ -97,26 +97,25 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect private void DrawTable() { - using var table = ImUtf8.Table("Mods"u8, config.UseTemporarySettings ? 7 : 6, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("Mods"u8, config.UseTemporarySettings ? 7 : 6, TableFlags.RowBackground); if (!table) return; - ImUtf8.TableSetupColumn("##Buttons"u8, ImGuiTableColumnFlags.WidthFixed, - Im.Style.FrameHeight * 3 + Im.Style.ItemInnerSpacing.X * 2); - ImUtf8.TableSetupColumn("Mod Name"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("##Buttons"u8, TableColumnFlags.WidthFixed, Im.Style.FrameHeight * 3 + Im.Style.ItemInnerSpacing.X * 2); + table.SetupColumn("Mod Name"u8, TableColumnFlags.WidthStretch); if (config.UseTemporarySettings) - ImUtf8.TableSetupColumn("Remove"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); - ImUtf8.TableSetupColumn("Inherit"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); - ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("State"u8).X); - ImUtf8.TableSetupColumn("Priority"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Priority"u8).X); - ImUtf8.TableSetupColumn("##Options"u8, ImGuiTableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Applym"u8).X); - ImGui.TableHeadersRow(); + table.SetupColumn("Remove"u8, TableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Remove"u8).X); + table.SetupColumn("Inherit"u8, TableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Inherit"u8).X); + table.SetupColumn("State"u8, TableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("State"u8).X); + table.SetupColumn("Priority"u8, TableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Priority"u8).X); + table.SetupColumn("##Options"u8, TableColumnFlags.WidthFixed, ImUtf8.CalcTextSize("Applym"u8).X); + table.HeaderRow(); Mod? removedMod = null; (Mod mod, ModSettings settings)? updatedMod = null; foreach (var ((mod, settings), idx) in selector.Selected!.AssociatedMods.WithIndex()) { - using var id = ImRaii.PushId(idx); + using var id = Im.Id.Push(idx); DrawAssociatedModRow(mod, settings, out var removedModTmp, out var updatedModTmp); if (removedModTmp.HasValue) removedMod = removedModTmp; @@ -150,11 +149,11 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect disabled: true); } - ImUtf8.SameLineInner(); + Im.Line.SameInner(); if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Copy this mod setting to clipboard."u8)) _copy = [(mod, settings)]; - ImUtf8.SameLineInner(); + Im.Line.SameInner(); ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8); if (ImGui.IsItemHovered()) { @@ -166,9 +165,9 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect using var tt = ImUtf8.Tooltip(); if (source.Length > 0) ImUtf8.Text($"Using temporary settings made by {source}."); - ImGui.Separator(); + Im.Separator(); var namesDifferent = mod.Name != mod.DirectoryName; - ImGui.Dummy(new Vector2(300 * Im.Style.GlobalScale, 0)); + Im.Dummy(new Vector2(300 * Im.Style.GlobalScale, 0)); using (ImRaii.Group()) { if (namesDifferent) @@ -220,11 +219,11 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImGui.TableNextColumn(); var priority = settings.Priority; - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); if (ImUtf8.InputScalarOnDeactivated("##Priority"u8, ref priority)) updatedMod = (mod, settings with { Priority = priority }); ImGui.TableNextColumn(); - if (ImGuiUtil.DrawDisabledButton("Apply", new Vector2(ImGui.GetContentRegionAvail().X, 0), string.Empty, + if (ImGuiUtil.DrawDisabledButton("Apply", new Vector2(Im.ContentRegion.Available.X, 0), string.Empty, !penumbra.Available)) { var text = penumbra.SetMod(mod, settings, StateSource.Manual, false); @@ -243,13 +242,13 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect using var t = ImRaii.Tooltip(); ImGui.TextUnformatted("This will also try to apply the following settings to the current collection:"); - ImGui.NewLine(); + Im.Line.New(); using (var _ = ImRaii.Group()) { ModCombo.DrawSettingsLeft(settings); } - ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2); + ImGui.SameLine(Im.ContentRegion.Available.X / 2); using (var _ = ImRaii.Group()) { ModCombo.DrawSettingsRight(settings); @@ -271,6 +270,6 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect manager.AddMod(selector.Selected!, _modCombo.CurrentSelection.Mod, _modCombo.CurrentSelection.Settings); ImGui.TableNextColumn(); _modCombo.Draw("##new", currentName.IsNullOrEmpty() ? "Select new Mod..." : currentName, string.Empty, - ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight()); + Im.ContentRegion.Available.X, Im.Style.TextHeight); } } diff --git a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs index a66d9cd..a0b805e 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModCombo.cs @@ -1,11 +1,13 @@ using Dalamud.Interface.Utility; using Glamourer.Interop.Penumbra; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui.Classes; using OtterGui.Log; using OtterGui.Raii; using OtterGui.Text; using OtterGui.Widgets; +using MouseWheelType = OtterGui.Widgets.MouseWheelType; namespace Glamourer.Gui.Tabs.DesignTab; @@ -29,11 +31,11 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings, var color = settings.Enabled ? count > 0 ? ColorId.ContainsItemsEnabled.Value() - : ImGui.GetColorU32(ImGuiCol.Text) + : ImGuiColor.Text.Get() : count > 0 ? ColorId.ContainsItemsDisabled.Value() - : ImGui.GetColorU32(ImGuiCol.TextDisabled); - using (ImRaii.PushColor(ImGuiCol.Text, color)) + : ImGuiColor.TextDisabled.Get(); + using (ImGuiColor.Text.Push(color)) { ret = ImUtf8.Selectable(mod.Name, selected); } @@ -43,7 +45,7 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings, using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * Im.Style.GlobalScale); using var tt = ImUtf8.Tooltip(); var namesDifferent = mod.Name != mod.DirectoryName; - ImGui.Dummy(new Vector2(300 * Im.Style.GlobalScale, 0)); + Im.Dummy(new Vector2(300 * Im.Style.GlobalScale, 0)); using (ImUtf8.Group()) { if (namesDifferent) @@ -75,7 +77,7 @@ public sealed class ModCombo : FilterComboCache<(Mod Mod, ModSettings Settings, { ImUtf8.Text(setting.Key); for (var i = 1; i < setting.Value.Count; ++i) - ImGui.NewLine(); + Im.Line.New(); } } diff --git a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs index 6fe2b7f..8ab07a6 100644 --- a/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/MultiDesignPanel.cs @@ -27,7 +27,7 @@ public class MultiDesignPanel( if (selector.SelectedPaths.Count == 0) return; - HeaderDrawer.Draw(string.Empty, 0, ImGui.GetColorU32(ImGuiCol.FrameBg), _leftButtons, _rightButtons); + HeaderDrawer.Draw(string.Empty, 0, ImGuiColor.FrameBackground.Get().Color, _leftButtons, _rightButtons); using var child = ImUtf8.Child("##MultiPanel"u8, default, true); if (!child) return; @@ -101,31 +101,31 @@ public class MultiDesignPanel( private int DrawDesignList() { ResetCounts(); - using var tree = ImUtf8.TreeNode("Currently Selected Objects"u8, ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.NoTreePushOnOpen); - ImGui.Separator(); + using var tree = Im.Tree.Node("Currently Selected Objects"u8, TreeNodeFlags.DefaultOpen | TreeNodeFlags.NoTreePushOnOpen); + Im.Separator(); if (!tree) return selector.SelectedPaths.Count(CountLeaves); var sizeType = new Vector2(Im.Style.FrameHeight); - var availableSizePercent = (ImGui.GetContentRegionAvail().X - sizeType.X - 4 * Im.Style.CellPadding.X) / 100; + var availableSizePercent = (Im.ContentRegion.Available.X - sizeType.X - 4 * Im.Style.CellPadding.X) / 100; var sizeMods = availableSizePercent * 35; var sizeFolders = availableSizePercent * 65; var numDesigns = 0; - using (var table = ImUtf8.Table("mods"u8, 3, ImGuiTableFlags.RowBg)) + using (var table = Im.Table.Begin("mods"u8, 3, TableFlags.RowBackground)) { if (!table) return selector.SelectedPaths.Count(l => l is DesignFileSystem.Leaf); - ImUtf8.TableSetupColumn("type"u8, ImGuiTableColumnFlags.WidthFixed, sizeType.X); - ImUtf8.TableSetupColumn("mod"u8, ImGuiTableColumnFlags.WidthFixed, sizeMods); - ImUtf8.TableSetupColumn("path"u8, ImGuiTableColumnFlags.WidthFixed, sizeFolders); + table.SetupColumn("type"u8, TableColumnFlags.WidthFixed, sizeType.X); + table.SetupColumn("mod"u8, TableColumnFlags.WidthFixed, sizeMods); + table.SetupColumn("path"u8, TableColumnFlags.WidthFixed, sizeFolders); var i = 0; foreach (var (fullName, path) in selector.SelectedPaths.Select(p => (p.FullName(), p)) .OrderBy(p => p.Item1, StringComparer.OrdinalIgnoreCase)) { - using var id = ImRaii.PushId(i++); + using var id = Im.Id.Push(i++); var (icon, text) = path is DesignFileSystem.Leaf l ? (FontAwesomeIcon.FileCircleMinus, l.Value.Name.Text) : (FontAwesomeIcon.FolderMinus, string.Empty); @@ -141,7 +141,7 @@ public class MultiDesignPanel( } } - ImGui.Separator(); + Im.Separator(); return numDesigns; } @@ -162,7 +162,7 @@ public class MultiDesignPanel( ImUtf8.TextFrameAligned("Multi Tagger:"u8); Im.Line.Same(); var offset = ImGui.GetItemRectSize().X + Im.Style.WindowPadding.X; - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - 2 * (width.X + Im.Style.ItemSpacing.X)); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X - 2 * (width.X + Im.Style.ItemSpacing.X)); ImUtf8.InputText("##tag"u8, ref _tag, "Tag Name..."u8); UpdateTagCache(); @@ -191,7 +191,7 @@ public class MultiDesignPanel( if (ImUtf8.ButtonEx(label, tooltip, width, _removeDesigns.Count == 0)) foreach (var (design, index) in _removeDesigns) editor.RemoveTag(design, index); - ImGui.Separator(); + Im.Separator(); return offset; } @@ -199,7 +199,7 @@ public class MultiDesignPanel( { ImUtf8.TextFrameAligned("Multi QDB:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var buttonWidth = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numQuickDesignEnabled; var tt = diff == 0 ? $"All {_numDesigns} selected designs are already displayed in the quick design bar." @@ -220,14 +220,14 @@ public class MultiDesignPanel( editor.SetQuickDesign(design.Value, false); } - ImGui.Separator(); + Im.Separator(); } private void DrawMultiLock(float offset) { ImUtf8.TextFrameAligned("Multi Lock:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var buttonWidth = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numDesignsLocked; var tt = diff == 0 ? $"All {_numDesigns} selected designs are already write protected." @@ -243,14 +243,14 @@ public class MultiDesignPanel( if (ImUtf8.ButtonEx("Remove Write-Protection"u8, tt, buttonWidth, _numDesignsLocked == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.SetWriteProtection(design.Value, false); - ImGui.Separator(); + Im.Separator(); } private void DrawMultiResetSettings(float offset) { ImUtf8.TextFrameAligned("Settings:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var buttonWidth = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numDesignsResetSettings; var tt = diff == 0 ? $"All {_numDesigns} selected designs already reset temporary settings." @@ -266,14 +266,14 @@ public class MultiDesignPanel( if (ImUtf8.ButtonEx("Remove Reset Temp. Settings"u8, tt, buttonWidth, _numDesignsResetSettings == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.ChangeResetTemporarySettings(design.Value, false); - ImGui.Separator(); + Im.Separator(); } private void DrawMultiResetDyes(float offset) { ImUtf8.TextFrameAligned("Adv. Dyes:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var buttonWidth = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numDesignsResetDyes; var tt = diff == 0 ? $"All {_numDesigns} selected designs already reset advanced dyes." @@ -289,14 +289,14 @@ public class MultiDesignPanel( if (ImUtf8.ButtonEx("Remove Reset Dyes"u8, tt, buttonWidth, _numDesignsResetDyes == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.ChangeResetAdvancedDyes(design.Value, false); - ImGui.Separator(); + Im.Separator(); } private void DrawMultiForceRedraw(float offset) { ImUtf8.TextFrameAligned("Redrawing:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var buttonWidth = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var buttonWidth = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var diff = _numDesigns - _numDesignsForcedRedraw; var tt = diff == 0 ? $"All {_numDesigns} selected designs already force redraws." @@ -312,7 +312,7 @@ public class MultiDesignPanel( if (ImUtf8.ButtonEx("Remove Forced Redraws"u8, tt, buttonWidth, _numDesignsForcedRedraw == 0)) foreach (var design in selector.SelectedPaths.OfType()) editor.ChangeForcedRedraw(design.Value, false); - ImGui.Separator(); + Im.Separator(); } private void DrawMultiColor(Vector2 width, float offset) @@ -320,7 +320,7 @@ public class MultiDesignPanel( ImUtf8.TextFrameAligned("Multi Colors:"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); _colorCombo.Draw("##color", _colorCombo.CurrentSelection ?? string.Empty, "Select a design color.", - ImGui.GetContentRegionAvail().X - 2 * (width.X + Im.Style.ItemSpacing.X), ImGui.GetTextLineHeight()); + Im.ContentRegion.Available.X - 2 * (width.X + Im.Style.ItemSpacing.X), Im.Style.TextHeight); UpdateColorCache(); var label = _addDesigns.Count > 0 @@ -354,7 +354,7 @@ public class MultiDesignPanel( editor.ChangeColor(design, string.Empty); } - ImGui.Separator(); + Im.Separator(); } private void DrawAdvancedButtons(float offset) @@ -365,7 +365,7 @@ public class MultiDesignPanel( var tt = _numDesignsWithAdvancedDyes is 0 ? "No selected designs contain any advanced dyes." : $"Delete {_numAdvancedDyes} advanced dyes from {_numDesignsWithAdvancedDyes} of the selected designs."; - if (ImUtf8.ButtonEx("Delete All Advanced Dyes"u8, tt, new Vector2(ImGui.GetContentRegionAvail().X, 0), + if (ImUtf8.ButtonEx("Delete All Advanced Dyes"u8, tt, new Vector2(Im.ContentRegion.Available.X, 0), !enabled || _numDesignsWithAdvancedDyes is 0)) foreach (var design in selector.SelectedPaths.OfType()) @@ -376,14 +376,14 @@ public class MultiDesignPanel( if (!enabled && _numDesignsWithAdvancedDyes is not 0) ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking to delete."); - ImGui.Separator(); + Im.Separator(); } private void DrawApplicationButtons(float offset) { ImUtf8.TextFrameAligned("Application"u8); ImGui.SameLine(offset, Im.Style.ItemSpacing.X); - var width = new Vector2((ImGui.GetContentRegionAvail().X - Im.Style.ItemSpacing.X) / 2, 0); + var width = new Vector2((Im.ContentRegion.Available.X - Im.Style.ItemSpacing.X) / 2, 0); var enabled = config.DeleteDesignModifier.IsActive(); bool? equip = null; bool? customize = null; @@ -462,7 +462,7 @@ public class MultiDesignPanel( ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {config.DeleteDesignModifier} while clicking."); group.Dispose(); - ImGui.Separator(); + Im.Separator(); if (equip is null && customize is null) return; diff --git a/Glamourer/Gui/Tabs/HeaderDrawer.cs b/Glamourer/Gui/Tabs/HeaderDrawer.cs index cdba40d..255f83e 100644 --- a/Glamourer/Gui/Tabs/HeaderDrawer.cs +++ b/Glamourer/Gui/Tabs/HeaderDrawer.cs @@ -1,5 +1,4 @@ using Dalamud.Interface; -using Dalamud.Interface.Utility; using Dalamud.Bindings.ImGui; using ImSharp; using OtterGui; @@ -16,10 +15,10 @@ public static class HeaderDrawer protected virtual string Description => string.Empty; - protected virtual uint BorderColor + protected virtual Rgba32 BorderColor => ColorId.HeaderButtons.Value(); - protected virtual uint TextColor + protected virtual Rgba32 TextColor => ColorId.HeaderButtons.Value(); protected virtual FontAwesomeIcon Icon @@ -36,8 +35,8 @@ public static class HeaderDrawer if (!Visible) return; - using var color = ImRaii.PushColor(ImGuiCol.Border, BorderColor) - .Push(ImGuiCol.Text, TextColor, TextColor != 0); + using var color = ImGuiColor.Border.Push(BorderColor) + .Push(ImGuiColor.Text, TextColor, TextColor.IsVisible); if (ImGuiUtil.DrawDisabledButton(Icon.ToIconString(), new Vector2(width, Im.Style.FrameHeight), string.Empty, Disabled, true)) OnClick(); color.Pop(); @@ -94,7 +93,7 @@ public static class HeaderDrawer } var rightButtonSize = rightButtons.Count(b => b.Visible) * width; - var midSize = ImGui.GetContentRegionAvail().X - rightButtonSize - Im.Style.GlobalScale; + var midSize = Im.ContentRegion.Available.X - rightButtonSize - Im.Style.GlobalScale; style.Pop(); style.Push(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.5f + (rightButtonSize - leftButtonSize) / midSize, 0.5f)); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index 16614b8..b88b441 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -1,4 +1,5 @@ -using Dalamud.Interface; +using Dalamud.Bindings.ImGui; +using Dalamud.Interface; using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.Game.Object; using Glamourer.Designs; @@ -6,11 +7,9 @@ using Glamourer.Gui.Customization; using Glamourer.Gui.Equipment; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.State; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; using OtterGui; -using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; @@ -80,8 +79,8 @@ public class NpcPanel private void DrawHeader() { - HeaderDrawer.Draw(_selector.HasSelection ? _selector.Selection.Name : "No Selection", ColorId.NormalDesign.Value(), - ImGui.GetColorU32(ImGuiCol.FrameBg), _leftButtons, _rightButtons); + HeaderDrawer.Draw(_selector.HasSelection ? _selector.Selection.Name : "No Selection", ColorId.NormalDesign.Value().Color, + ImGuiColor.FrameBackground.Get().Color, _leftButtons, _rightButtons); SaveDesignDrawPopup(); } @@ -92,7 +91,7 @@ public class NpcPanel ? "Remove this NPC appearance from your favorites." : "Add this NPC Appearance to your favorites."; - protected override uint TextColor + protected override Rgba32 TextColor => panel._favorites.IsFavorite(panel._selector.Selection) ? ColorId.FavoriteStarOn.Value() : 0x80000000; @@ -120,13 +119,13 @@ public class NpcPanel private void DrawPanel() { - using var table = ImUtf8.Table("##Panel", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail()); + using var table = Im.Table.Begin("##Panel"u8, 1, TableFlags.BordersOuter | TableFlags.ScrollY, Im.ContentRegion.Available); if (!table || !_selector.HasSelection) return; ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableNextColumn(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); DrawButtonRow(); ImGui.TableNextColumn(); @@ -147,16 +146,16 @@ public class NpcPanel if (_config.HideDesignPanel.HasFlag(DesignPanelFlag.Customization)) return; - var header = _selector.Selection.ModelId == 0 - ? "Customization" - : $"Customization (Model Id #{_selector.Selection.ModelId})###Customization"; - var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); - using var h = ImUtf8.CollapsingHeaderId(header, expand ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None); + var expand = _config.AutoExpandDesignPanel.HasFlag(DesignPanelFlag.Customization); + using var h = Im.Tree.HeaderId(_selector.Selection.ModelId is 0 + ? "Customization"u8 + : $"Customization (Model Id #{_selector.Selection.ModelId})###Customization", + expand ? TreeNodeFlags.DefaultOpen : TreeNodeFlags.None); if (!h) return; _customizeDrawer.Draw(_selector.Selection.Customize, true, true); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); } private void DrawEquipment() @@ -178,9 +177,9 @@ public class NpcPanel var offhandData = new EquipDrawData(EquipSlot.OffHand, designData) { Locked = true }; _equipDrawer.DrawWeapons(mainhandData, offhandData, false); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromValue(MetaIndex.VisorState, _selector.Selection.VisorToggled)); - ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2)); + Im.Dummy(new Vector2(Im.Style.TextHeight / 2)); } private DesignData ToDesignData() @@ -237,22 +236,22 @@ public class NpcPanel if (!h) return; - using var table = ImUtf8.Table("Details"u8, 2); + using var table = Im.Table.Begin("Details"u8, 2); if (!table) return; using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); - ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Last Update Datem").X); - ImUtf8.TableSetupColumn("Data"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Type"u8, TableColumnFlags.WidthFixed, Im.Font.CalculateSize("Last Update Datem"u8).X); + table.SetupColumn("Data"u8, TableColumnFlags.WidthStretch); var selection = _selector.Selection; CopyButton("NPC Name"u8, selection.Name); CopyButton("NPC ID"u8, selection.Id.Id.ToString()); ImGuiUtil.DrawFrameColumn("NPC Type"); ImGui.TableNextColumn(); - var width = ImGui.GetContentRegionAvail().X; - ImGuiUtil.DrawTextButton(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC" : "Event NPC", new Vector2(width, 0), - ImGui.GetColorU32(ImGuiCol.FrameBg)); + var width = Im.ContentRegion.Available.X; + ImEx.TextFramed(selection.Kind is ObjectKind.BattleNpc ? "Battle NPC"u8 : "Event NPC"u8, new Vector2(width, 0), + ImGuiColor.FrameBackground.Get()); ImUtf8.DrawFrameColumn("Color"u8); var color = _favorites.GetColor(selection); @@ -262,14 +261,14 @@ public class NpcPanel "Associate a color with this NPC appearance.\n" + "Right-Click to revert to automatic coloring.\n" + "Hold Control and scroll the mousewheel to scroll.", - width - Im.Style.ItemSpacing.X - Im.Style.FrameHeight, ImGui.GetTextLineHeight()) + width - Im.Style.ItemSpacing.X - Im.Style.FrameHeight, Im.Style.TextHeight) && _colorCombo.CurrentSelection != null) { color = _colorCombo.CurrentSelection is DesignColors.AutomaticName ? string.Empty : _colorCombo.CurrentSelection; _favorites.SetColor(selection, color); } - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + if (Im.Item.RightClicked()) { _favorites.SetColor(selection, string.Empty); color = string.Empty; @@ -296,7 +295,7 @@ public class NpcPanel { ImUtf8.DrawFrameColumn(label); ImGui.TableNextColumn(); - if (ImUtf8.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0))) + if (ImUtf8.Button(text, new Vector2(Im.ContentRegion.Available.X, 0))) ImUtf8.SetClipboardText(text); ImUtf8.HoverTooltip("Click to copy to clipboard."u8); } diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs index 36634f1..44134ee 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcSelector.cs @@ -74,17 +74,17 @@ public class NpcSelector : IDisposable private void DrawSelector() { - using var child = ImRaii.Child("##Selector", new Vector2(_width, ImGui.GetContentRegionAvail().Y), true); + using var child = ImRaii.Child("##Selector", new Vector2(_width, Im.ContentRegion.Available.Y), true); if (!child) return; using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _defaultItemSpacing); - ImGuiClip.ClippedDraw(_visibleOrdered, DrawSelectable, ImGui.GetTextLineHeight()); + ImGuiClip.ClippedDraw(_visibleOrdered, DrawSelectable, Im.Style.TextHeight); } private void DrawSelectable(int globalIndex) { - using var id = ImRaii.PushId(globalIndex); + using var id = Im.Id.Push(globalIndex); using var color = ImGuiColor.Text.Push(_favorites.GetData(_npcs[globalIndex]).Color); if (ImGui.Selectable(_npcs[globalIndex].Name, _selectedGlobalIndex == globalIndex, ImGuiSelectableFlags.AllowItemOverlap)) _selectedGlobalIndex = globalIndex; diff --git a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs index aa11715..de40e4d 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CodeDrawer.cs @@ -1,7 +1,6 @@ using Dalamud.Interface; using Glamourer.Services; using Glamourer.State; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; using OtterGui.Filesystem; @@ -27,7 +26,7 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule public void Draw() { - var show = ImGui.CollapsingHeader("Cheat Codes"); + var show = Im.Tree.Header("Cheat Codes"u8); DrawTooltip(); if (!show) @@ -42,22 +41,22 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule private void DrawCodeInput() { var color = codeService.CheckCode(_currentCode).Item2 is not 0 ? ColorId.ActorAvailable : ColorId.ActorUnavailable; - using var border = ImRaii.PushFrameBorder(ImUtf8.GlobalScale, color.Value(), _currentCode.Length > 0); - ImGui.SetNextItemWidth(500 * ImUtf8.GlobalScale + ImUtf8.ItemSpacing.X); - if (ImUtf8.InputText("##Code"u8, ref _currentCode, "Enter Cheat Code..."u8, ImGuiInputTextFlags.EnterReturnsTrue)) + using var border = ImRaii.PushFrameBorder(Im.Style.GlobalScale, color.Value().Color, _currentCode.Length > 0); + Im.Item.SetNextWidth(500 * Im.Style.GlobalScale + Im.Style.ItemSpacing.X); + if (Im.Input.Text("##Code"u8, ref _currentCode, "Enter Cheat Code..."u8, InputTextFlags.EnterReturnsTrue)) { codeService.AddCode(_currentCode); _currentCode = string.Empty; } Im.Line.Same(); - ImUtf8.Icon(FontAwesomeIcon.ExclamationCircle, ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImUtf8.Icon(FontAwesomeIcon.ExclamationCircle, ImGuiColor.TextDisabled.Get().Color); DrawTooltip(); } private void DrawCopyButtons() { - var buttonSize = new Vector2(250 * ImUtf8.GlobalScale, 0); + var buttonSize = new Vector2(250 * Im.Style.GlobalScale, 0); if (ImUtf8.Button("Who am I?!?"u8, buttonSize)) funModule.WhoAmI(); ImUtf8.HoverTooltip( @@ -95,17 +94,17 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule } knownFlags |= flag; - ImUtf8.SameLineInner(); + Im.Line.SameInner(); if (ImUtf8.Checkbox("\0"u8, ref state)) { action!(state); codeService.SaveState(); } - var hovered = ImGui.IsItemHovered(); + var hovered = Im.Item.Hovered(); Im.Line.Same(); - ImUtf8.Selectable(code, false); - hovered |= ImGui.IsItemHovered(); + ImUtf8.Selectable(code); + hovered |= Im.Item.Hovered(); DrawSource(i, code); DrawTarget(i); if (hovered) @@ -151,7 +150,7 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule if (!_showCodeHints) return; - foreach (var code in Enum.GetValues()) + foreach (var code in CodeService.CodeFlag.Values) { if (knownFlags.HasFlag(code)) continue; @@ -160,9 +159,9 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule if (!data.Display) continue; - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); ImUtf8.Text(data.Effect); using var indent = ImRaii.PushIndent(2); using (ImUtf8.Group()) @@ -171,10 +170,10 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule ImUtf8.Text("Punctuation: "u8); } - ImUtf8.SameLineInner(); + Im.Line.SameInner(); using (ImUtf8.Group()) { - using var mono = ImRaii.PushFont(UiBuilder.MonoFont); + using var mono = Im.Font.PushMono(); ImUtf8.Text($"{data.CapitalCount}"); ImUtf8.Text($"{data.Punctuation}"); } @@ -186,10 +185,10 @@ public class CodeDrawer(Configuration config, CodeService codeService, FunModule private static void DrawTooltip() { - if (!ImGui.IsItemHovered()) + if (!Im.Item.Hovered()) return; - ImGui.SetNextWindowSize(new Vector2(400, 0)); + Im.Window.SetNextSize(new Vector2(400, 0)); using var tt = ImUtf8.Tooltip(); ImUtf8.TextWrapped(Tooltip); } diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs index ef0e9b2..78987e2 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionCombo.cs @@ -1,10 +1,7 @@ using Dalamud.Interface; using Glamourer.Interop.Penumbra; -using Dalamud.Bindings.ImGui; using ImSharp; using Luna; -using OtterGui; -using OtterGui.Raii; using OtterGui.Widgets; using Logger = OtterGui.Log.Logger; using MouseWheelType = OtterGui.Widgets.MouseWheelType; @@ -20,17 +17,17 @@ public sealed class CollectionCombo(Configuration config, PenumbraService penumb { var (_, idShort, name) = Items[globalIdx]; if (config.Ephemeral.IncognitoMode) - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { - return ImGui.Selectable(idShort); + return Im.Selectable(idShort); } - var ret = ImGui.Selectable(name, selected); + var ret = Im.Selectable(name, selected); Im.Line.Same(); - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { - using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled)); - ImGuiUtil.RightAlign($"({idShort})"); + using var color = ImGuiColor.Text.Push(ImGuiColor.TextDisabled.Get()); + ImEx.TextRightAligned($"({idShort})"); } return ret; diff --git a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs index f0077e5..1a4e2c9 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/CollectionOverrideDrawer.cs @@ -1,7 +1,8 @@ -using Dalamud.Interface; +using Dalamud.Bindings.ImGui; +using Dalamud.Interface; using Glamourer.Interop.Penumbra; using Glamourer.Services; -using Dalamud.Bindings.ImGui; +using ImSharp; using Luna; using OtterGui; using OtterGui.Raii; @@ -32,15 +33,15 @@ public class CollectionOverrideDrawer( if (!header) return; - using var table = ImRaii.Table("table", 4, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("table"u8, 4, TableFlags.RowBackground); if (!table) return; var buttonSize = new Vector2(Im.Style.FrameHeight); - ImGui.TableSetupColumn("buttons", ImGuiTableColumnFlags.WidthFixed, buttonSize.X); - ImGui.TableSetupColumn("identifiers", ImGuiTableColumnFlags.WidthStretch, 0.35f); - ImGui.TableSetupColumn("collections", ImGuiTableColumnFlags.WidthStretch, 0.4f); - ImGui.TableSetupColumn("name", ImGuiTableColumnFlags.WidthStretch, 0.25f); + table.SetupColumn("buttons"u8, TableColumnFlags.WidthFixed, buttonSize.X); + table.SetupColumn("identifiers"u8, TableColumnFlags.WidthStretch, 0.35f); + table.SetupColumn("collections"u8, TableColumnFlags.WidthStretch, 0.4f); + table.SetupColumn("name"u8, TableColumnFlags.WidthStretch, 0.25f); for (var i = 0; i < collectionOverrides.Overrides.Count; ++i) DrawCollectionRow(ref i, buttonSize); @@ -50,7 +51,7 @@ public class CollectionOverrideDrawer( private void DrawCollectionRow(ref int idx, Vector2 buttonSize) { - using var id = ImRaii.PushId(idx); + using var id = Im.Id.Push(idx); var (exists, actor, collection, name) = collectionOverrides.Fetch(idx); ImGui.TableNextColumn(); @@ -61,8 +62,8 @@ public class CollectionOverrideDrawer( DrawActorIdentifier(idx, actor); ImGui.TableNextColumn(); - if (combo.Draw("##collection", name, $"Select the overriding collection. Current GUID:", ImGui.GetContentRegionAvail().X, - ImGui.GetTextLineHeight())) + if (combo.Draw("##collection", name, $"Select the overriding collection. Current GUID:", Im.ContentRegion.Available.X, + Im.Style.TextHeight)) { var (guid, _, newName) = combo.CurrentSelection; collectionOverrides.ChangeOverride(idx, guid, newName); @@ -71,7 +72,7 @@ public class CollectionOverrideDrawer( if (ImGui.IsItemHovered()) { using var tt = ImRaii.Tooltip(); - using var font = ImRaii.PushFont(UiBuilder.MonoFont); + using var font = Im.Font.PushMono(); ImGui.TextUnformatted($" {collection}"); } @@ -89,7 +90,7 @@ public class CollectionOverrideDrawer( using var tt1 = ImRaii.Tooltip(); ImGui.TextUnformatted($"The design {name} with the GUID"); - using (ImRaii.PushFont(UiBuilder.MonoFont)) + using (Im.Font.PushMono()) { ImGui.TextUnformatted($" {collection}"); } @@ -103,7 +104,7 @@ public class CollectionOverrideDrawer( return; using var tt2 = ImRaii.Tooltip(); - using var f = ImRaii.PushFont(UiBuilder.MonoFont); + using var f = Im.Font.PushMono(); ImGui.TextUnformatted(collection.ToString()); } @@ -139,7 +140,7 @@ public class CollectionOverrideDrawer( collectionOverrides.AddOverride([objects.PlayerData.Identifier], currentId, currentName); ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(Im.ContentRegion.Available.X); if (ImGui.InputTextWithHint("##newActor", "New Identifier...", ref _newIdentifier, 80)) try { @@ -164,7 +165,7 @@ public class CollectionOverrideDrawer( ImGui.SameLine(0, Im.Style.ItemInnerSpacing.X); using (ImRaii.PushFont(UiBuilder.IconFont)) { - using var color = ImRaii.PushColor(ImGuiCol.Text, ImGui.GetColorU32(ImGuiCol.TextDisabled)); + using var color = ImGuiColor.Text.Push(Im.Style[ImGuiColor.TextDisabled]); ImGui.TextUnformatted(FontAwesomeIcon.InfoCircle.ToIconString()); } diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 443c618..ee08fe9 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -57,10 +57,10 @@ public sealed class SettingsTab( config.EnableAutoDesigns = v; autoDesignApplier.OnEnableAutoDesignsChanged(v); }); - ImGui.NewLine(); - ImGui.NewLine(); - ImGui.NewLine(); - ImGui.NewLine(); + Im.Line.New(); + Im.Line.New(); + Im.Line.New(); + Im.Line.New(); using (ImUtf8.Child("SettingsChild"u8, default)) { @@ -110,7 +110,7 @@ public sealed class SettingsTab( Checkbox("Prevent Random Design Repeats"u8, "When using random designs, prevent the same design from being chosen twice in a row."u8, config.PreventRandomRepeats, v => config.PreventRandomRepeats = v); - ImGui.NewLine(); + Im.Line.New(); } private void DrawPenumbraIntegrationSettings1() @@ -164,7 +164,7 @@ public sealed class SettingsTab( config.DefaultDesignSettings.ResetTemporarySettings, v => config.DefaultDesignSettings.ResetTemporarySettings = v); var tmp = config.PcpFolder; - ImGui.SetNextItemWidth(0.4f * ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(0.4f * Im.ContentRegion.Available.X); if (ImUtf8.InputText("##pcpFolder"u8, ref tmp)) config.PcpFolder = tmp; @@ -175,7 +175,7 @@ public sealed class SettingsTab( "The folder any designs created due to penumbra character packs are moved to on creation.\nLeave blank to import into Root."); tmp = config.PcpColor; - ImGui.SetNextItemWidth(0.4f * ImGui.GetContentRegionAvail().X); + ImGui.SetNextItemWidth(0.4f * Im.ContentRegion.Available.X); if (ImUtf8.InputText("##pcpColor"u8, ref tmp)) config.PcpColor = tmp; @@ -207,9 +207,9 @@ public sealed class SettingsTab( config.ShowQuickBarInTabs, v => config.ShowQuickBarInTabs = v); DrawQuickDesignBoxes(); - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); Checkbox("Enable Game Context Menus"u8, "Whether to show a Try On via Glamourer button on context menus for equippable items."u8, config.EnableGameContextMenu, v => @@ -239,9 +239,9 @@ public sealed class SettingsTab( v => config.Ephemeral.LockMainWindow = v); Checkbox("Open Main Window at Game Start"u8, "Whether the main Glamourer window should be open or closed after launching the game."u8, config.OpenWindowAtStart, v => config.OpenWindowAtStart = v); - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); Checkbox("Smaller Equip Display"u8, "Use single-line display without icons and small dye buttons instead of double-line display."u8, config.SmallEquip, v => config.SmallEquip = v); @@ -263,9 +263,9 @@ public sealed class SettingsTab( v => config.OpenFoldersByDefault = v); DrawFolderSortType(); - ImGui.NewLine(); + Im.Line.New(); ImUtf8.Text("Show the following panels in their respective tabs:"u8); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); DesignPanelFlagExtensions.DrawTable("##panelTable"u8, config.HideDesignPanel, config.AutoExpandDesignPanel, v => { config.HideDesignPanel = v; @@ -277,9 +277,9 @@ public sealed class SettingsTab( }); - ImGui.Dummy(Vector2.Zero); - ImGui.Separator(); - ImGui.Dummy(Vector2.Zero); + Im.Dummy(Vector2.Zero); + Im.Separator(); + Im.Dummy(Vector2.Zero); Checkbox("Allow Double-Clicking Designs to Apply"u8, "Tries to apply a design to the current player character When double-clicking it in the design selector."u8, @@ -295,7 +295,7 @@ public sealed class SettingsTab( Checkbox("Show Palette+ Import Button"u8, "Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs."u8, config.ShowPalettePlusImport, v => config.ShowPalettePlusImport = v); - using (ImRaii.PushId(1)) + using (Im.Id.Push(1)) { PaletteImportButton(); } @@ -307,18 +307,17 @@ public sealed class SettingsTab( Checkbox("Debug Mode"u8, "Show the debug tab. Only useful for debugging or advanced use. Not recommended in general."u8, config.DebugMode, v => config.DebugMode = v); - ImGui.NewLine(); + Im.Line.New(); } private void DrawQuickDesignBoxes() { var showAuto = config.EnableAutoDesigns; var numColumns = 9 - (showAuto ? 0 : 2) - (config.UseTemporarySettings ? 0 : 1); - ImGui.NewLine(); + Im.Line.New(); ImUtf8.Text("Show the Following Buttons in the Quick Design Bar:"u8); - ImGui.Dummy(Vector2.Zero); - using var table = ImUtf8.Table("##tableQdb"u8, numColumns, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders | ImGuiTableFlags.NoHostExtendX); + Im.Dummy(Vector2.Zero); + using var table = Im.Table.Begin("##tableQdb"u8, numColumns, TableFlags.SizingFixedFit | TableFlags.Borders | TableFlags.NoHostExtendX); if (!table) return; @@ -352,7 +351,7 @@ public sealed class SettingsTab( var flag = columns[i].Item3; using var id = ImUtf8.PushId((int)flag); ImGui.TableNextColumn(); - var offset = (ImGui.GetContentRegionAvail().X - Im.Style.FrameHeight) / 2; + var offset = (Im.ContentRegion.Available.X - Im.Style.FrameHeight) / 2; ImGui.SetCursorPosX(ImGui.GetCursorPosX() + offset); var value = config.QdbButtons.HasFlag(flag); if (!ImUtf8.Checkbox(""u8, ref value)) @@ -394,7 +393,7 @@ public sealed class SettingsTab( using (var tree = ImUtf8.TreeNode("Color Settings"u8)) { if (tree) - foreach (var color in Enum.GetValues()) + foreach (var color in ColorId.Values) { var (defaultColor, name, description) = color.Data(); var currentColor = config.Colors.GetValueOrDefault(color, defaultColor); @@ -403,7 +402,7 @@ public sealed class SettingsTab( } } - ImGui.NewLine(); + Im.Line.New(); } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] @@ -466,7 +465,7 @@ public sealed class SettingsTab( using (var combo = ImUtf8.Combo("##renameSettings"u8, config.ShowRename.GetData().Name)) { if (combo) - foreach (var value in Enum.GetValues()) + foreach (var value in RenameField.Values) { var (name, desc) = value.GetData(); if (ImGui.Selectable(name, config.ShowRename == value)) @@ -495,7 +494,7 @@ public sealed class SettingsTab( using (var combo = ImUtf8.Combo("##heightUnit"u8, HeightDisplayTypeName(config.HeightDisplayType))) { if (combo) - foreach (var type in Enum.GetValues()) + foreach (var type in HeightDisplayType.Values) { if (ImUtf8.Selectable(HeightDisplayTypeName(type), type == config.HeightDisplayType) && type != config.HeightDisplayType) { diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index 5f3f546..7a61f9e 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -7,6 +7,7 @@ using Glamourer.Services; using Glamourer.Unlocks; using Dalamud.Bindings.ImGui; using ImSharp; +using Luna; using OtterGui.Raii; using OtterGui.Text; using Penumbra.GameData.Enums; @@ -34,8 +35,8 @@ public class UnlockOverview( private Gender _selected3 = Gender.Unknown; private BonusItemFlag _selected4 = BonusItemFlag.Unknown; - private uint _favoriteColor; - private uint _moddedColor; + private Rgba32 _favoriteColor; + private Rgba32 _moddedColor; private void DrawSelector() { @@ -43,7 +44,7 @@ public class UnlockOverview( if (!child) return; - foreach (var type in Enum.GetValues()) + foreach (var type in FullEquipType.Values) { if (type.IsOffhandType() || type.IsBonus() || !items.ItemData.ByType.TryGetValue(type, out var value) || value.Count == 0) continue; @@ -83,7 +84,7 @@ public class UnlockOverview( public void Draw() { - using var color = ImRaii.PushColor(ImGuiCol.Border, ImGui.GetColorU32(ImGuiCol.TableBorderStrong)); + using var color = ImGuiColor.Border.Push(Im.Style[ImGuiColor.TableBorderStrong]); DrawSelector(); Im.Line.Same(); DrawPanel(); @@ -128,8 +129,8 @@ public class UnlockOverview( unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(_selected3, _selected2, customize.Index, customize.Value)) - ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), _favoriteColor, - 12 * Im.Style.GlobalScale, ImDrawFlags.RoundCornersAll, 6 * Im.Style.GlobalScale); + Im.Window.DrawList.Shape.Rectangle(Im.Item.UpperLeftCorner, Im.Item.LowerRightCorner, _favoriteColor, 12 * Im.Style.GlobalScale, + ImDrawFlagsRectangle.RoundCornersAll, 6 * Im.Style.GlobalScale); if (hasIcon && ImGui.IsItemHovered()) { @@ -138,7 +139,7 @@ public class UnlockOverview( if (size.X >= iconSize.X && size.Y >= iconSize.Y) ImGui.Image(wrap.Handle, size); ImGui.TextUnformatted(unlockData.Name); - ImGui.TextUnformatted($"{customize.Index.ToDefaultName()} {customize.Value.Value}"); + ImGui.TextUnformatted($"{customize.Index.ToNameU8()} {customize.Value.Value}"); ImGui.TextUnformatted(unlocked ? $"Unlocked on {time:g}" : "Not unlocked."); } @@ -161,7 +162,7 @@ public class UnlockOverview( var iconSize = ImGuiHelpers.ScaledVector2(64); var iconsPerRow = IconsPerRow(iconSize.X, spacing.X); var numRows = (items.DictBonusItems.Count + iconsPerRow - 1) / iconsPerRow; - var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; + var numVisibleRows = (int)(Math.Ceiling(Im.ContentRegion.Available.Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; var skips = ImGuiClip.GetNecessarySkips(iconSize.Y + spacing.Y); var start = skips * iconsPerRow; @@ -183,7 +184,7 @@ public class UnlockOverview( } if (ImGui.GetCursorPosX() != 0) - ImGui.NewLine(); + Im.Line.New(); var remainder = numRows - numVisibleRows - skips; if (remainder > 0) ImGuiClip.DrawEndDummy(remainder, iconSize.Y + spacing.Y); @@ -200,8 +201,8 @@ public class UnlockOverview( ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(item)) - ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), _favoriteColor, - 2 * Im.Style.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * Im.Style.GlobalScale); + Im.Window.DrawList.Shape.Rectangle(Im.Item.UpperLeftCorner, Im.Item.LowerRightCorner, _favoriteColor, + 2 * Im.Style.GlobalScale, ImDrawFlagsRectangle.RoundCornersAll, 4 * Im.Style.GlobalScale); var mods = DrawModdedMarker(item, iconSize); @@ -234,7 +235,7 @@ public class UnlockOverview( var iconSize = ImGuiHelpers.ScaledVector2(64); var iconsPerRow = IconsPerRow(iconSize.X, spacing.X); var numRows = (value.Count + iconsPerRow - 1) / iconsPerRow; - var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; + var numVisibleRows = (int)(Math.Ceiling(Im.ContentRegion.Available.Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; var skips = ImGuiClip.GetNecessarySkips(iconSize.Y + spacing.Y); var end = Math.Min(numVisibleRows * iconsPerRow + skips * iconsPerRow, value.Count); @@ -254,7 +255,7 @@ public class UnlockOverview( } if (ImGui.GetCursorPosX() != 0) - ImGui.NewLine(); + Im.Line.New(); var remainder = numRows - numVisibleRows - skips; if (remainder > 0) ImGuiClip.DrawEndDummy(remainder, iconSize.Y + spacing.Y); @@ -271,15 +272,15 @@ public class UnlockOverview( ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked || codes.Enabled(CodeService.CodeFlag.Shirts) ? Vector4.One : UnavailableTint); if (favorites.Contains(item)) - ImGui.GetWindowDrawList().AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ColorId.FavoriteStarOn.Value(), - 2 * Im.Style.GlobalScale, ImDrawFlags.RoundCornersAll, 4 * Im.Style.GlobalScale); + Im.Window.DrawList.Shape.Rectangle(Im.Item.UpperLeftCorner, Im.Item.LowerRightCorner, ColorId.FavoriteStarOn.Value(), + 2 * Im.Style.GlobalScale, ImDrawFlagsRectangle.RoundCornersAll, 4 * Im.Style.GlobalScale); var mods = DrawModdedMarker(item, iconSize); if (ImGui.IsItemClicked()) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); - if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && tooltip.Player(out var state)) + if (Im.Item.RightClicked() && tooltip.Player(out var state)) tooltip.ApplyItem(state, item); if (ImGui.IsItemHovered()) @@ -329,18 +330,18 @@ public class UnlockOverview( => ImGuiHelpers.ScaledVector2(2); private static int IconsPerRow(float iconWidth, float iconSpacing) - => (int)(ImGui.GetContentRegionAvail().X / (iconWidth + iconSpacing)); + => (int)(Im.ContentRegion.Available.X / (iconWidth + iconSpacing)); [MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)] private (string ModDirectory, string ModName)[] DrawModdedMarker(in EquipItem item, Vector2 iconSize) { var mods = penumbra.CheckCurrentChangedItem(item.Name); - if (mods.Length == 0) + if (mods.Length is 0) return mods; var center = ImGui.GetItemRectMin() + new Vector2(iconSize.X * 0.85f, iconSize.Y * 0.15f); - ImGui.GetWindowDrawList().AddCircleFilled(center, iconSize.X * 0.1f, _moddedColor); - ImGui.GetWindowDrawList().AddCircle(center, iconSize.X * 0.1f, 0xFF000000); + Im.Window.DrawList.Shape.CircleFilled(center, iconSize.X * 0.1f, _moddedColor); + Im.Window.DrawList.Shape.Circle(center, iconSize.X * 0.1f, Rgba32.Black); return mods; } @@ -351,14 +352,14 @@ public class UnlockOverview( { case 0: return; case 1: - ImUtf8.Text("Modded by: "u8, _moddedColor); - ImGui.SameLine(0, 0); - ImUtf8.Text(mods[0].ModName); + Im.Text("Modded by: "u8, _moddedColor); + Im.Line.NoSpacing(); + Im.Text(mods[0].ModName); return; default: - ImUtf8.Text("Modded by:"u8, _moddedColor); + Im.Text("Modded by:"u8, _moddedColor); foreach (var (_, mod) in mods) - ImUtf8.BulletText(mod); + Im.BulletText(mod); return; } } diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index e55e21b..5aa09eb 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -136,7 +136,7 @@ public class UnlockTable : Table, IDisposable using (ImRaii.PushFont(UiBuilder.IconFont)) { - using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.ModdedItemMarker.Value()); + using var color = ImGuiColor.Text.Push(ColorId.ModdedItemMarker.Value()); ImGuiUtil.Center(FontAwesomeIcon.Circle.ToIconString()); } @@ -192,13 +192,13 @@ public class UnlockTable : Table, IDisposable if (_textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) ImGuiUtil.HoverIcon(iconHandle, new Vector2(Im.Style.FrameHeight)); else - ImGui.Dummy(new Vector2(Im.Style.FrameHeight)); + Im.Dummy(new Vector2(Im.Style.FrameHeight)); Im.Line.Same(); ImGui.AlignTextToFramePadding(); if (ImGui.Selectable(item.Name) && item.Id is { IsBonusItem: false, IsCustom: false }) Glamourer.Messager.Chat.Print(new SeStringBuilder().AddItemLink(item.ItemId.Id, false).BuiltString); - if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && _tooltip.Player(out var state)) + if (Im.Item.RightClicked() && _tooltip.Player(out var state)) _tooltip.ApplyItem(state, item); if (ImGui.IsItemHovered() && _tooltip.Player()) @@ -446,15 +446,15 @@ public class UnlockTable : Table, IDisposable Job.JobRole.Healer => 0xFFD0FFD0, Job.JobRole.Crafter => 0xFF808080, Job.JobRole.Gatherer => 0xFFD0D0D0, - _ => ImGui.GetColorU32(ImGuiCol.Text), + _ => ImGuiColor.Text.Get(), }; bool r; - using (ImRaii.PushColor(ImGuiCol.Text, color)) + using (ImGuiColor.Text.Push(color)) { r = base.DrawCheckbox(idx, out ret); } - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + if (Im.Item.RightClicked()) { _filterValue = job.Flag & _filterValue; ret = true; diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index 18840a2..989949e 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -1,11 +1,8 @@ -using Dalamud.Interface; using Glamourer.Services; using Glamourer.Unlocks; -using Dalamud.Bindings.ImGui; using ImSharp; using Lumina.Misc; -using OtterGui; -using OtterGui.Raii; +using Luna; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -16,26 +13,26 @@ public static class UiHelpers /// Open a combo popup with another method than the combo itself. public static void OpenCombo(string comboLabel) { - var windowId = ImGui.GetID(comboLabel); - var popupId = ~Crc32.Get("##ComboPopup", windowId); - ImGui.OpenPopup(popupId); + var windowId = Im.Id.Get(comboLabel); + var popupId = ~Crc32.Get("##ComboPopup", windowId.Id); + Im.Popup.Open(popupId); } public static void DrawIcon(this EquipItem item, TextureService textures, Vector2 size, EquipSlot slot) { - var isEmpty = item.PrimaryId.Id == 0; + var isEmpty = item.PrimaryId.Id is 0; var (ptr, textureSize, empty) = textures.GetIcon(item, slot); if (empty) { var (bgColor, tint) = isEmpty - ? (ImGui.GetColorU32(ImGuiCol.FrameBg), Vector4.One) - : (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 1f)); - var pos = ImGui.GetCursorScreenPos(); - ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size, bgColor, 5 * Im.Style.GlobalScale); + ? (ImGuiColor.FrameBackground.Get(), Vector4.One) + : (ImGuiColor.FrameBackgroundActive.Get(), new Vector4(0.3f, 0.3f, 0.3f, 1f)); + var pos = Im.Cursor.ScreenPosition; + Im.Window.DrawList.Shape.RectangleFilled(pos, pos + size, bgColor, 5 * Im.Style.GlobalScale); if (!ptr.IsNull) Im.Image.Draw(ptr, size, Vector2.Zero, Vector2.One, tint); else - ImGui.Dummy(size); + Im.Dummy(size); } else { @@ -50,14 +47,14 @@ public static class UiHelpers if (empty) { var (bgColor, tint) = isEmpty - ? (ImGui.GetColorU32(ImGuiCol.FrameBg), Vector4.One) - : (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 1f)); - var pos = ImGui.GetCursorScreenPos(); - ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size, bgColor, 5 * Im.Style.GlobalScale); + ? (ImGuiColor.FrameBackground.Get(), Vector4.One) + : (ImGuiColor.FrameBackgroundActive.Get(), new Vector4(0.3f, 0.3f, 0.3f, 1f)); + var pos = Im.Cursor.ScreenPosition; + Im.Window.DrawList.Shape.RectangleFilled(pos, pos + size, bgColor, 5 * Im.Style.GlobalScale); if (!ptr.IsNull) Im.Image.Draw(ptr, size, Vector2.Zero, Vector2.One, tint); else - ImGui.Dummy(size); + Im.Dummy(size); } else { @@ -65,41 +62,41 @@ public static class UiHelpers } } - public static bool DrawCheckbox(string label, string tooltip, bool value, out bool on, bool locked) + public static bool DrawCheckbox(ReadOnlySpan label, Utf8StringHandler tooltip, bool value, out bool on, bool locked) { - var startsWithHash = label.StartsWith("##"); bool ret; - using (_ = ImRaii.Disabled(locked)) + using (Im.Disabled(locked)) { - ret = ImGuiUtil.Checkbox(startsWithHash ? label : "##" + label, string.Empty, value, v => value = v); + using var id = Im.Id.Push(label); + ret = Im.Checkbox(StringU8.Empty, ref value); } - if (!startsWithHash) + if (!label.StartsWith("##"u8)) { - ImGui.SameLine(0, Im.Style.ItemInnerSpacing.X); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(label); + Im.Line.SameInner(); + ImEx.TextFrameAligned(label); } - ImGuiUtil.HoverTooltip(tooltip, ImGuiHoveredFlags.AllowWhenDisabled); + Im.Tooltip.OnHover(tooltip, HoveredFlags.AllowWhenDisabled); on = value; return ret; } - public static (bool, bool) DrawMetaToggle(string label, bool currentValue, bool currentApply, out bool newValue, + public static (bool, bool) DrawMetaToggle(ReadOnlySpan label, bool currentValue, bool currentApply, out bool newValue, out bool newApply, bool locked) { - var flags = (sbyte)(currentApply ? currentValue ? 1 : -1 : 0); - using (_ = ImRaii.Disabled(locked)) + bool? apply = currentApply ? currentValue : null; + using (Im.Disabled(locked)) { - if (ImEx.TriStateCheckbox(ColorId.TriStateCross.Value(), ColorId.TriStateCheck.Value(), ColorId.TriStateNeutral.Value()).Draw( - "##" + label, flags, out flags)) + using var id = Im.Id.Push(label); + if (ImEx.TriStateCheckbox(StringU8.Empty, ref apply, ColorId.TriStateCross.Value(), ColorId.TriStateCheck.Value(), + ColorId.TriStateNeutral.Value())) { - (newValue, newApply) = flags switch + (newValue, newApply) = apply switch { - -1 => (false, true), - 0 => (true, false), - _ => (true, true), + true => (true, true), + false => (false, true), + _ => (true, false), }; } else @@ -109,17 +106,17 @@ public static class UiHelpers } } - ImGuiUtil.HoverTooltip($"This attribute will be {(currentApply ? currentValue ? "enabled." : "disabled." : "kept as is.")}"); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, + $"This attribute will be {(currentApply ? currentValue ? "enabled." : "disabled." : "kept as is.")}"); - ImGui.SameLine(0, Im.Style.ItemInnerSpacing.X); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(label); + Im.Line.SameInner(); + ImEx.TextFrameAligned(label); return (currentValue != newValue, currentApply != newApply); } public static (bool, bool) ConvertKeysToBool() - => (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch + => (Im.Io.KeyControl, Im.Io.KeyShift) switch { (false, false) => (true, true), (true, true) => (true, true), @@ -130,14 +127,11 @@ public static class UiHelpers public static bool DrawFavoriteStar(FavoriteManager favorites, EquipItem item) { var favorite = favorites.Contains(item); - var hovering = ImGui.IsMouseHoveringRect(ImGui.GetCursorScreenPos(), - ImGui.GetCursorScreenPos() + new Vector2(ImGui.GetTextLineHeight())); + var hovering = Im.Mouse.IsHoveringRectangle(Rectangle.FromSize(Im.Cursor.ScreenPosition, new Vector2(Im.Style.TextHeight))); - using var font = ImRaii.PushFont(UiBuilder.IconFont); - using var c = ImRaii.PushColor(ImGuiCol.Text, + ImEx.Icon.DrawAligned(LunaStyle.FavoriteIcon, hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); - ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); - if (!ImGui.IsItemClicked()) + if (!Im.Item.Clicked()) return false; if (favorite) @@ -145,21 +139,16 @@ public static class UiHelpers else favorites.TryAdd(item); return true; - } public static bool DrawFavoriteStar(FavoriteManager favorites, StainId stain) { var favorite = favorites.Contains(stain); - var hovering = ImGui.IsMouseHoveringRect(ImGui.GetCursorScreenPos(), - ImGui.GetCursorScreenPos() + new Vector2(Im.Style.FrameHeight)); + var hovering = Im.Mouse.IsHoveringRectangle(Rectangle.FromSize(Im.Cursor.ScreenPosition, new Vector2(Im.Style.TextHeight))); - using var font = ImRaii.PushFont(UiBuilder.IconFont); - using var c = ImRaii.PushColor(ImGuiCol.Text, + ImEx.Icon.DrawAligned(LunaStyle.FavoriteIcon, hovering ? ColorId.FavoriteStarHovered.Value() : favorite ? ColorId.FavoriteStarOn.Value() : ColorId.FavoriteStarOff.Value()); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(FontAwesomeIcon.Star.ToIconString()); - if (!ImGui.IsItemClicked()) + if (!Im.Item.Clicked()) return false; if (favorite) @@ -167,6 +156,5 @@ public static class UiHelpers else favorites.TryAdd(stain); return true; - } -} \ No newline at end of file +} diff --git a/Glamourer/Services/CodeService.cs b/Glamourer/Services/CodeService.cs index 4a82f0e..783a03d 100644 --- a/Glamourer/Services/CodeService.cs +++ b/Glamourer/Services/CodeService.cs @@ -1,3 +1,5 @@ +using ImSharp; +using Luna; using Penumbra.GameData.Enums; namespace Glamourer.Services; @@ -36,7 +38,7 @@ public class CodeService } public static readonly CodeFlag AllHintCodes = - Enum.GetValues().Where(f => GetData(f).Display).Aggregate((CodeFlag)0, (f1, f2) => f1 | f2); + CodeFlag.Values.Where(f => GetData(f).Display).Aggregate((CodeFlag)0, (f1, f2) => f1 | f2); public const CodeFlag DyeCodes = CodeFlag.Clown | CodeFlag.World | CodeFlag.Elephants | CodeFlag.Dolphins; @@ -138,7 +140,7 @@ public class CodeService using var stream = new MemoryStream(Encoding.UTF8.GetBytes(name)); var sha = (ReadOnlySpan)_hasher.ComputeHash(stream); - foreach (var flag in Enum.GetValues()) + foreach (var flag in CodeFlag.Values) { if (sha.SequenceEqual(GetSha(flag))) return flag; diff --git a/Glamourer/Services/ConfigMigrationService.cs b/Glamourer/Services/ConfigMigrationService.cs index c3ee7ec..a0a3914 100644 --- a/Glamourer/Services/ConfigMigrationService.cs +++ b/Glamourer/Services/ConfigMigrationService.cs @@ -1,5 +1,7 @@ using Glamourer.Automation; using Glamourer.Gui; +using ImSharp; +using Luna; using Newtonsoft.Json.Linq; namespace Glamourer.Services; @@ -104,7 +106,7 @@ public class ConfigMigrationService(SaveService saveService, FixedDesignMigrator private static void AddColors(Configuration config, bool forceSave) { var save = false; - foreach (var color in Enum.GetValues()) + foreach (var color in ColorId.Values) save |= config.Colors.TryAdd(color, color.Data().DefaultColor); if (save || forceSave) diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 7f8f833..483355c 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -427,7 +427,7 @@ public unsafe class FunModule : IDisposable return; var set = _customizations.Manager.GetSet(customize.Clan, customize.Gender); - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) { if (index is CustomizeIndex.Face || !set.IsAvailable(index)) continue; diff --git a/Glamourer/State/InternalStateEditor.cs b/Glamourer/State/InternalStateEditor.cs index 69051c2..eb3403d 100644 --- a/Glamourer/State/InternalStateEditor.cs +++ b/Glamourer/State/InternalStateEditor.cs @@ -4,6 +4,7 @@ using Glamourer.Events; using Glamourer.GameData; using Glamourer.Interop.Material; using Glamourer.Services; +using ImSharp; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -64,7 +65,7 @@ public class InternalStateEditor( state.Sources[CustomizeIndex.Clan] = source; state.Sources[CustomizeIndex.Gender] = source; var set = customizations.Manager.GetSet(state.ModelData.Customize.Clan, state.ModelData.Customize.Gender); - foreach (var index in Enum.GetValues().Where(set.IsAvailable)) + foreach (var index in CustomizeIndex.Values.Where(set.IsAvailable)) state.Sources[index] = source; } else @@ -107,7 +108,7 @@ public class InternalStateEditor( state.ModelData.Customize = customize; applied |= changed; - foreach (var type in Enum.GetValues()) + foreach (var type in CustomizeIndex.Values) { if (applied.HasFlag(type.ToFlag())) state.Sources[type] = source(type); @@ -120,7 +121,7 @@ public class InternalStateEditor( public bool ChangeHumanCustomize(ActorState state, in CustomizeArray customizeInput, Func applyWhich, Func source, out CustomizeArray old, out CustomizeFlag changed, uint key = 0) { - var apply = Enum.GetValues().Where(applyWhich).Aggregate((CustomizeFlag)0, (current, type) => current | type.ToFlag()); + var apply = CustomizeIndex.Values.Where(applyWhich).Aggregate((CustomizeFlag)0, (current, type) => current | type.ToFlag()); return ChangeHumanCustomize(state, customizeInput, apply, source, out old, out changed, key); } diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 986bdc2..cbce7d5 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -56,7 +56,7 @@ public class StateEditor( var actors = Applier.ChangeCustomize(state, settings.Source.RequiresChange()); Glamourer.Log.Verbose( - $"Set {idx.ToDefaultName()} customizations in state {state.Identifier.Incognito(null)} from {old.Value} to {value.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); + $"Set {idx.ToName()} customizations in state {state.Identifier.Incognito(null)} from {old.Value} to {value.Value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Customize, settings.Source, state, actors, new CustomizeTransaction(idx, old, value)); } diff --git a/Glamourer/State/StateIndex.cs b/Glamourer/State/StateIndex.cs index 7526d52..bc1ea44 100644 --- a/Glamourer/State/StateIndex.cs +++ b/Glamourer/State/StateIndex.cs @@ -5,7 +5,6 @@ using ImSharp; using Luna; using Penumbra.GameData.Enums; using System.Collections.Frozen; -using static OtterGui.ItemSelector; namespace Glamourer.State; @@ -226,7 +225,7 @@ public readonly record struct StateIndex(int Value) : IEqualityOperators GetFlag() switch { EquipFlag e => GetName(e), - CustomizeFlag c => c.ToIndex().ToDefaultName(), + CustomizeFlag c => c.ToIndex().ToNameU8(), MetaFlag m => m.ToIndex().ToNameU8(), CrestFlag c => c.ToLabelU8(), CustomizeParameterFlag c => c.ToNameU8(), diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index e8926d6..633c444 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -9,6 +9,7 @@ using Glamourer.Interop.Material; using Glamourer.Interop.Penumbra; using Glamourer.Interop.Structs; using Glamourer.Services; +using ImSharp; using Penumbra.GameData.Actors; using Penumbra.GameData.DataContainers; using Penumbra.GameData.Enums; @@ -248,7 +249,7 @@ public sealed class StateManager( state.ModelData = state.BaseData; state.ModelData.SetIsWet(false); - foreach (var index in Enum.GetValues()) + foreach (var index in CustomizeIndex.Values) state.Sources[index] = StateSource.Game; foreach (var slot in EquipSlotExtensions.FullSlots) @@ -260,7 +261,7 @@ public sealed class StateManager( foreach (var slot in BonusExtensions.AllFlags) state.Sources[slot] = StateSource.Game; - foreach (var type in Enum.GetValues()) + foreach (var type in MetaIndex.Values) state.Sources[type] = StateSource.Game; foreach (var slot in CrestExtensions.AllRelevantSet) @@ -432,7 +433,7 @@ public sealed class StateManager( if (!state.Unlock(key)) return; - foreach (var index in Enum.GetValues().Where(i => state.Sources[i] is StateSource.Fixed)) + foreach (var index in CustomizeIndex.Values.Where(i => state.Sources[i] is StateSource.Fixed)) { state.Sources[index] = StateSource.Game; state.ModelData.Customize[index] = state.BaseData.Customize[index]; diff --git a/Glamourer/State/StateSource.cs b/Glamourer/State/StateSource.cs index 9a12214..e13bbf1 100644 --- a/Glamourer/State/StateSource.cs +++ b/Glamourer/State/StateSource.cs @@ -1,7 +1,9 @@ -using Penumbra.GameData.Enums; +using Luna.Generators; +using Penumbra.GameData.Enums; namespace Glamourer.State; +[NamedEnum(Utf16: false)] public enum StateSource : byte { Game, @@ -15,7 +17,7 @@ public enum StateSource : byte IpcPending, } -public static class StateSourceExtensions +public static partial class StateSourceExtensions { public static StateSource Base(this StateSource source) => source switch diff --git a/Luna b/Luna index 206221c..2cc9a03 160000 --- a/Luna +++ b/Luna @@ -1 +1 @@ -Subproject commit 206221cec8eb23f4291e9204c079b179a7051799 +Subproject commit 2cc9a03ba52a781f474d1b14d5b8c616fa719284