diff --git a/Luna b/Luna index e69b638e..c872e220 160000 --- a/Luna +++ b/Luna @@ -1 +1 @@ -Subproject commit e69b638efaf89468517fe3741a300c8d3a7c6860 +Subproject commit c872e220ebf7e8e53c6389be99a54827f0afd222 diff --git a/Penumbra/UI/AdvancedWindow/FileEditor.cs b/Penumbra/UI/AdvancedWindow/FileEditor.cs index ac8eb4f0..fac92cb8 100644 --- a/Penumbra/UI/AdvancedWindow/FileEditor.cs +++ b/Penumbra/UI/AdvancedWindow/FileEditor.cs @@ -303,12 +303,12 @@ public class FileEditor( ret = ImGui.Selectable(file.RelPath.ToString(), selected); } - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) { using var tt = ImRaii.Tooltip(); ImGui.TextUnformatted("All Game Paths"); ImGui.Separator(); - using var t = ImRaii.Table("##Tooltip", 2, ImGuiTableFlags.SizingFixedFit); + using var t = Im.Table.Begin("##Tooltip"u8, 2, TableFlags.SizingFixedFit); foreach (var (option, gamePath) in file.SubModUsage) { ImGui.TableNextColumn(); diff --git a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs index cee0e177..206e1f70 100644 --- a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs +++ b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs @@ -165,7 +165,7 @@ public class ItemSwapTab : IDisposable, ITab : null; var ret = base.DrawSelectable(globalIdx, selected); if (inCollection.Count > 0) - ImUtf8.HoverTooltip(string.Join('\n', inCollection.Select(m => m.Name))); + Im.Tooltip.OnHover(string.Join('\n', inCollection.Select(m => m.Name))); return ret; } @@ -506,8 +506,8 @@ public class ItemSwapTab : IDisposable, ITab if (!tab) return; - using var table = ImRaii.Table("##settings", 3, ImGuiTableFlags.SizingFixedFit); - ImGui.TableSetupColumn("##text", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("and put them on these").X); + using var table = Im.Table.Begin("##settings"u8, 3, TableFlags.SizingFixedFit); + table.SetupColumn("##text"u8, TableColumnFlags.WidthFixed, Im.Font.CalculateSize("and put them on these"u8).X); var (article1, article2, selector) = GetAccessorySelector(_slotFrom, true); ImGui.TableNextColumn(); @@ -566,7 +566,7 @@ public class ItemSwapTab : IDisposable, ITab Im.Line.Same(); ImGuiUtil.DrawTextButton($"which will also affect {_affectedItems.Count - 1} other Items.", Vector2.Zero, Colors.PressEnterWarningBg); - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) ImGui.SetTooltip(string.Join('\n', _affectedItems.Where(i => !ReferenceEquals(i.Name, selector.CurrentSelection.Item.Name)) .Select(i => i.Name))); } @@ -595,7 +595,7 @@ public class ItemSwapTab : IDisposable, ITab return; var (sourceSelector, targetSelector, text1, text2) = _selectors[type]; - using var table = ImRaii.Table("##settings", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##settings"u8, 2, TableFlags.SizingFixedFit); ImGui.TableNextColumn(); ImGui.AlignTextToFramePadding(); ImGui.TextUnformatted(text1); @@ -627,7 +627,7 @@ public class ItemSwapTab : IDisposable, ITab Im.Line.Same(); ImGuiUtil.DrawTextButton($"which will also affect {_affectedItems.Count - 1} other Items.", Vector2.Zero, Colors.PressEnterWarningBg); - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) ImGui.SetTooltip(string.Join('\n', _affectedItems.Where(i => !ReferenceEquals(i.Name, targetSelector.CurrentSelection.Item.Name)) .Select(i => i.Name))); } @@ -638,7 +638,7 @@ public class ItemSwapTab : IDisposable, ITab if (!tab) return; - using var table = ImRaii.Table("##settings", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##settings"u8, 2, TableFlags.SizingFixedFit); DrawTargetIdInput("Take this Hairstyle"); DrawSourceIdInput(); DrawGenderInput(); @@ -650,7 +650,7 @@ public class ItemSwapTab : IDisposable, ITab if (!tab) return; - using var table = ImRaii.Table("##settings", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##settings"u8, 2, TableFlags.SizingFixedFit); DrawTargetIdInput("Take this Tail Type"); DrawSourceIdInput(); DrawGenderInput("for all", 2); @@ -663,7 +663,7 @@ public class ItemSwapTab : IDisposable, ITab if (!tab) return; - using var table = ImRaii.Table("##settings", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##settings"u8, 2, TableFlags.SizingFixedFit); DrawTargetIdInput("Take this Ear Type"); DrawSourceIdInput(); DrawGenderInput("for all Viera", 0); diff --git a/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs b/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs index 4ad78398..21915a88 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MaterialTemplatePickers.cs @@ -117,7 +117,7 @@ public sealed unsafe class MaterialTemplatePickers : Luna.IUiService DrawTextureSlices(cbTextureRegionStart, cbMaxSize, itemSpacing.X, textureRHs, (byte)value); } - if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && (description.Length > 0 || compact && value != ushort.MaxValue)) + if (Im.Item.Hovered(HoveredFlags.AllowWhenDisabled) && (description.Length > 0 || compact && value != ushort.MaxValue)) { using var disabled = ImRaii.Enabled(); using var tt = ImUtf8.Tooltip(); diff --git a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.CommonColorTable.cs b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.CommonColorTable.cs index 31ee13f2..63349478 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.CommonColorTable.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.CommonColorTable.cs @@ -285,7 +285,7 @@ public partial class MtrlTab "Highlight this pair of rows on your character, if possible.\n\nHighlight colors can be configured in Penumbra's settings."u8, Im.Style.FrameHeight * Vector2.One, disabled || _colorTablePreviewers.Count == 0); - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) HighlightColorTablePair(pairIdx); else if (_highlightedColorTablePair == pairIdx) CancelColorTableHighlight(); @@ -297,7 +297,7 @@ public partial class MtrlTab "Highlight this row on your character, if possible.\n\nHighlight colors can be configured in Penumbra's settings."u8, Im.Style.FrameHeight * Vector2.One, disabled || _colorTablePreviewers.Count == 0); - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) HighlightColorTableRow(rowIdx); else if (_highlightedColorTableRow == rowIdx) CancelColorTableHighlight(); @@ -357,7 +357,7 @@ public partial class MtrlTab ImGui.GetWindowDrawList().AddText(letter, center, textColor); } - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); return ret; } @@ -387,7 +387,7 @@ public partial class MtrlTab ImGui.GetWindowDrawList().AddText(letter, center, 0x80000000u); } - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); } } @@ -395,7 +395,7 @@ public partial class MtrlTab { var tmp = current; var result = ApplyStainCheckbox.Draw(label, ref tmp); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); if (!result || tmp == current) return false; @@ -408,7 +408,7 @@ public partial class MtrlTab { var tmp = (float)value; var result = ImUtf8.DragScalar(label, ref tmp, format, min, max, speed); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); if (!result) return false; @@ -425,7 +425,7 @@ public partial class MtrlTab { var tmp = (float)value; var result = ImUtf8.DragScalar(label, ref tmp, format, min, max, speed); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); if (!result) return false; @@ -450,7 +450,7 @@ public partial class MtrlTab { var tmp = value; var result = ImUtf8.DragScalar(label, ref tmp, format, min, max, speed); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); if (!result || tmp == value) return false; @@ -463,7 +463,7 @@ public partial class MtrlTab { var tmp = value; var result = ImUtf8.DragScalar(label, ref tmp, format, min, max, speed); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, description); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, description); if (!result || tmp == value) return false; diff --git a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.LegacyColorTable.cs b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.LegacyColorTable.cs index 030d7c9c..747e661a 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.LegacyColorTable.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.LegacyColorTable.cs @@ -7,6 +7,7 @@ using OtterGui.Text; using Penumbra.GameData.Files.MaterialStructs; using Penumbra.GameData.Files.StainMapStructs; using Penumbra.Services; +using TableFlags = ImSharp.TableFlags; namespace Penumbra.UI.AdvancedWindow.Materials; @@ -19,12 +20,12 @@ public partial class MtrlTab private bool DrawLegacyColorTable(LegacyColorTable table, LegacyColorDyeTable? dyeTable, bool disabled) { - using var imTable = ImUtf8.Table("##ColorTable"u8, dyeTable != null ? 10 : 8, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV); + using var imTable = Im.Table.Begin("##ColorTable"u8, dyeTable is not null ? 10 : 8, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInnerVertical); if (!imTable) return false; - DrawLegacyColorTableHeader(dyeTable != null); + DrawLegacyColorTableHeader(dyeTable is not null); var ret = false; for (var i = 0; i < LegacyColorTable.NumRows; ++i) @@ -43,12 +44,12 @@ public partial class MtrlTab private bool DrawLegacyColorTable(ColorTable table, ColorDyeTable? dyeTable, bool disabled) { - using var imTable = ImUtf8.Table("##ColorTable"u8, dyeTable != null ? 10 : 8, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV); + using var imTable = Im.Table.Begin("##ColorTable"u8, dyeTable is not null ? 10 : 8, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInnerVertical); if (!imTable) return false; - DrawLegacyColorTableHeader(dyeTable != null); + DrawLegacyColorTableHeader(dyeTable is not null); var ret = false; for (var i = 0; i < ColorTable.NumRows; ++i) @@ -189,7 +190,7 @@ public partial class MtrlTab ret = true; } - ImGuiUtil.HoverTooltip("Dye Template", ImGuiHoveredFlags.AllowWhenDisabled); + Im.Tooltip.OnHover("Dye Template"u8, HoveredFlags.AllowWhenDisabled); ImGui.TableNextColumn(); ret |= DrawLegacyDyePreview(rowIdx, disabled, dye, floatSize); @@ -304,7 +305,7 @@ public partial class MtrlTab ret = true; } - ImGuiUtil.HoverTooltip("Dye Template", ImGuiHoveredFlags.AllowWhenDisabled); + Im.Tooltip.OnHover("Dye Template"u8, HoveredFlags.AllowWhenDisabled); ImGui.TableNextColumn(); ret |= DrawLegacyDyePreview(rowIdx, disabled, dye, floatSize); diff --git a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Textures.cs b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Textures.cs index 1869b714..10f93b02 100644 --- a/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Textures.cs +++ b/Penumbra/UI/AdvancedWindow/Materials/MtrlTab.Textures.cs @@ -128,11 +128,11 @@ public partial class MtrlTab var frameHeight = Im.Style.FrameHeight; var ret = false; - using var table = ImRaii.Table("##Textures", 3); + using var table = Im.Table.Begin("##Textures"u8, 3); - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, frameHeight); - ImGui.TableSetupColumn("Path", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, TextureLabelWidth * Im.Style.GlobalScale); + table.SetupColumn(StringU8.Empty, TableColumnFlags.WidthFixed, frameHeight); + table.SetupColumn("Path"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("Name"u8, TableColumnFlags.WidthFixed, TextureLabelWidth * Im.Style.GlobalScale); foreach (var (label, textureI, samplerI, description, monoFont) in Textures) { using var _ = ImRaii.PushId(samplerI); diff --git a/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs index 345315cc..f8641e55 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/AtchMetaDrawer.cs @@ -183,18 +183,18 @@ public sealed class AtchMetaDrawer : MetaDrawer { ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Race.ToName(), FrameColor); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); ImGui.TableNextColumn(); DrawGender(ref identifier, true); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Type.ToName(), FrameColor); - ImUtf8.HoverTooltip("Attachment Point Type"u8); + Im.Tooltip.OnHover("Attachment Point Type"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.EntryIndex.ToString(), FrameColor); - ImUtf8.HoverTooltip("State Entry Index"u8); + Im.Tooltip.OnHover("State Entry Index"u8); } private static bool DrawEntry(in AtchEntry defaultEntry, ref AtchEntry entry, bool disabled) @@ -205,42 +205,42 @@ public sealed class AtchMetaDrawer : MetaDrawer return false; ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(200 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(200 * Im.Style.GlobalScale); if (ImUtf8.InputText("##BoneName"u8, entry.FullSpan, out TerminatedByteString newBone)) { entry.SetBoneName(newBone); changes = true; } - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Bone Name"u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Bone Name"u8); - ImGui.SetNextItemWidth(200 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(200 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchScale"u8, ref entry.Scale); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Scale"u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Scale"u8); ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchOffsetX"u8, ref entry.OffsetX); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Offset X-Coordinate"u8); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Offset X-Coordinate"u8); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchRotationX"u8, ref entry.RotationX); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Rotation X-Axis"u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Rotation X-Axis"u8); ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchOffsetY"u8, ref entry.OffsetY); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Offset Y-Coordinate"u8); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Offset Y-Coordinate"u8); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchRotationY"u8, ref entry.RotationY); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Rotation Y-Axis"u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Rotation Y-Axis"u8); ImGui.TableNextColumn(); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchOffsetZ"u8, ref entry.OffsetZ); - ImUtf8.HoverTooltip("Offset Z-Coordinate"u8); - ImGui.SetNextItemWidth(120 * ImUtf8.GlobalScale); + Im.Tooltip.OnHover("Offset Z-Coordinate"u8); + ImGui.SetNextItemWidth(120 * Im.Style.GlobalScale); changes |= ImUtf8.InputScalar("##AtchRotationZ"u8, ref entry.RotationZ); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Rotation Z-Axis"u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Rotation Z-Axis"u8); return changes; } @@ -248,7 +248,7 @@ public sealed class AtchMetaDrawer : MetaDrawer private static bool DrawRace(ref AtchIdentifier identifier, float unscaledWidth = 100) { var ret = Combos.Race("##atchRace", identifier.Race, out var race, unscaledWidth); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; @@ -269,7 +269,7 @@ public sealed class AtchMetaDrawer : MetaDrawer private static bool DrawPointInput(ref AtchIdentifier identifier, AtchPointCombo combo) { - if (!combo.Draw("##AtchPoint", identifier.Type.ToName(), "Attachment Point Type", 160 * ImUtf8.GlobalScale, + if (!combo.Draw("##AtchPoint", identifier.Type.ToName(), "Attachment Point Type", 160 * Im.Style.GlobalScale, Im.Style.TextHeightWithSpacing)) return false; @@ -280,10 +280,10 @@ public sealed class AtchMetaDrawer : MetaDrawer private static bool DrawEntryIndexInput(ref AtchIdentifier identifier, AtchPoint currentAtchPoint) { var index = identifier.EntryIndex; - ImGui.SetNextItemWidth(40 * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(40 * Im.Style.GlobalScale); var ret = ImUtf8.DragScalar("##AtchEntry"u8, ref index, 0, (ushort)(currentAtchPoint.Entries.Length - 1), 0.05f, ImGuiSliderFlags.AlwaysClamp); - ImUtf8.HoverTooltip("State Entry Index"u8); + Im.Tooltip.OnHover("State Entry Index"u8); if (!ret) return false; diff --git a/Penumbra/UI/AdvancedWindow/Meta/AtrMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/AtrMetaDrawer.cs index 3ab74d71..9aa38013 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/AtrMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/AtrMetaDrawer.cs @@ -96,13 +96,13 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile ImGui.TableNextColumn(); ImUtf8.TextFramed(ShpMetaDrawer.SlotName(identifier.Slot), FrameColor); - ImUtf8.HoverTooltip("Model Slot"u8); + Im.Tooltip.OnHover("Model Slot"u8); ImGui.TableNextColumn(); if (identifier.GenderRaceCondition is not GenderRace.Unknown) { ImUtf8.TextFramed($"{identifier.GenderRaceCondition.ToName()} ({identifier.GenderRaceCondition.ToRaceCode()})", FrameColor); - ImUtf8.HoverTooltip("Gender & Race Code for this attribute to be set."); + Im.Tooltip.OnHover("Gender & Race Code for this attribute to be set."); } else { @@ -114,7 +114,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile ImUtf8.TextFramed($"{identifier.Id.Value.Id}", FrameColor); else ImUtf8.TextFramed("All IDs"u8, FrameColor); - ImUtf8.HoverTooltip("Primary ID"u8); + Im.Tooltip.OnHover("Primary ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Attribute.AsSpan, FrameColor); @@ -128,7 +128,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile var changes = ImUtf8.Checkbox("##atrEntry"u8, ref value); if (changes) entry = new AtrEntry(value); - ImUtf8.HoverTooltip("Whether to enable or disable this attribute for the selected items."); + Im.Tooltip.OnHover("Whether to enable or disable this attribute for the selected items."); return changes; } @@ -146,7 +146,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip(allSlots + Im.Tooltip.OnHover(allSlots ? "When using all slots, you also need to use all IDs."u8 : "Enable this attribute for all model IDs."u8); @@ -167,7 +167,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Primary ID - You can usually find this as the 'e####' part of an item path or similar for customizations."u8); + Im.Tooltip.OnHover("Primary ID - You can usually find this as the 'e####' part of an item path or similar for customizations."u8); return ret; } @@ -175,7 +175,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public bool DrawHumanSlot(ref AtrIdentifier identifier, float unscaledWidth = 150) { var ret = false; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using (var combo = ImUtf8.Combo("##atrSlot"u8, ShpMetaDrawer.SlotName(identifier.Slot))) { if (combo) @@ -208,14 +208,14 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Model Slot"u8); + Im.Tooltip.OnHover("Model Slot"u8); return ret; } private static bool DrawGenderRaceConditionInput(ref AtrIdentifier identifier, float unscaledWidth = 250) { var ret = false; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using (var combo = ImUtf8.Combo("##shpGenderRace"u8, identifier.GenderRaceCondition is GenderRace.Unknown @@ -243,7 +243,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Only activate this attribute for this gender & race code."u8); return ret; @@ -257,7 +257,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile var span = new Span(ptr, ShapeAttributeString.MaxLength + 1); using (ImStyleBorder.Frame.Push(Colors.RegexWarningBorder, Im.Style.GlobalScale, !valid)) { - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); if (ImUtf8.InputText("##atrAttribute"u8, span, out int newLength, "Attribute..."u8)) { buffer.ForceLength((byte)newLength); @@ -268,7 +268,7 @@ public sealed class AtrMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Supported attribute need to have the format `atrx_*` and a maximum length of 30 characters."u8); + Im.Tooltip.OnHover("Supported attribute need to have the format `atrx_*` and a maximum length of 30 characters."u8); return ret; } } diff --git a/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs index 50c8b2d5..0a774235 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EqdpMetaDrawer.cs @@ -90,19 +90,19 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil { ImGui.TableNextColumn(); ImUtf8.TextFramed($"{identifier.SetId.Id}", FrameColor); - ImUtf8.HoverTooltip("Model Set ID"u8); + Im.Tooltip.OnHover("Model Set ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Race.ToName(), FrameColor); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Gender.ToName(), FrameColor); - ImUtf8.HoverTooltip("Gender"u8); + Im.Tooltip.OnHover("Gender"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Slot.ToName(), FrameColor); - ImUtf8.HoverTooltip("Equip Slot"u8); + Im.Tooltip.OnHover("Equip Slot"u8); } private static bool DrawEntry(EqdpEntryInternal defaultEntry, ref EqdpEntryInternal entry, bool disabled) @@ -130,7 +130,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil { var ret = IdInput("##eqdpPrimaryId"u8, unscaledWidth, identifier.SetId.Id, out var setId, 0, ExpandedEqpGmpBase.Count - 1, identifier.SetId.Id <= 1); - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Model Set ID - You can usually find this as the 'e####' part of an item path.\nThis should generally not be left <= 1 unless you explicitly want that."u8); if (ret) identifier = identifier with { SetId = setId }; @@ -140,7 +140,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawRace(ref EqdpIdentifier identifier, float unscaledWidth = 100) { var ret = Combos.Race("##eqdpRace", identifier.Race, out var race, unscaledWidth); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; return ret; @@ -149,7 +149,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawGender(ref EqdpIdentifier identifier, float unscaledWidth = 120) { var ret = Combos.Gender("##eqdpGender", identifier.Gender, out var gender, unscaledWidth); - ImUtf8.HoverTooltip("Gender"u8); + Im.Tooltip.OnHover("Gender"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(gender, identifier.Race) }; return ret; @@ -158,7 +158,7 @@ public sealed class EqdpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFil public static bool DrawEquipSlot(ref EqdpIdentifier identifier, float unscaledWidth = 100) { var ret = Combos.EqdpEquipSlot("##eqdpSlot", identifier.Slot, out var slot, unscaledWidth); - ImUtf8.HoverTooltip("Equip Slot"u8); + Im.Tooltip.OnHover("Equip Slot"u8); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs index 3ecc90d9..6e0e07ef 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EqpMetaDrawer.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Bindings.ImGui; +using ImSharp; using Newtonsoft.Json.Linq; using OtterGui.Raii; using OtterGui.Text; @@ -81,11 +82,11 @@ public sealed class EqpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { ImGui.TableNextColumn(); ImUtf8.TextFramed($"{identifier.SetId.Id}", FrameColor); - ImUtf8.HoverTooltip("Model Set ID"u8); + Im.Tooltip.OnHover("Model Set ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Slot.ToName(), FrameColor); - ImUtf8.HoverTooltip("Equip Slot"u8); + Im.Tooltip.OnHover("Equip Slot"u8); } private static bool DrawEntry(EquipSlot slot, EqpEntryInternal defaultEntry, ref EqpEntryInternal entry, bool disabled) @@ -122,7 +123,7 @@ public sealed class EqpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { var ret = IdInput("##eqpPrimaryId"u8, unscaledWidth, identifier.SetId.Id, out var setId, 0, ExpandedEqpGmpBase.Count - 1, identifier.SetId.Id <= 1); - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Model Set ID - You can usually find this as the 'e####' part of an item path.\nThis should generally not be left <= 1 unless you explicitly want that."u8); if (ret) identifier = identifier with { SetId = setId }; @@ -132,7 +133,7 @@ public sealed class EqpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawEquipSlot(ref EqpIdentifier identifier, float unscaledWidth = 100) { var ret = Combos.EqpEquipSlot("##eqpSlot", identifier.Slot, out var slot, unscaledWidth); - ImUtf8.HoverTooltip("Equip Slot"u8); + Im.Tooltip.OnHover("Equip Slot"u8); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs index e7183a4d..9358dd44 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/EstMetaDrawer.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using Dalamud.Bindings.ImGui; +using ImSharp; using Newtonsoft.Json.Linq; using OtterGui.Text; using Penumbra.GameData.Enums; @@ -33,7 +34,8 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile protected override void DrawNew() { ImGui.TableNextColumn(); - CopyToClipboardButton("Copy all current EST manipulations to clipboard."u8, new Lazy(() => MetaDictionary.SerializeTo([], Editor.Est))); + CopyToClipboardButton("Copy all current EST manipulations to clipboard."u8, + new Lazy(() => MetaDictionary.SerializeTo([], Editor.Est))); ImGui.TableNextColumn(); var canAdd = !Editor.Contains(Identifier); @@ -88,26 +90,26 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { ImGui.TableNextColumn(); ImUtf8.TextFramed($"{identifier.SetId.Id}", FrameColor); - ImUtf8.HoverTooltip("Model Set ID"u8); + Im.Tooltip.OnHover("Model Set ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Race.ToName(), FrameColor); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Gender.ToName(), FrameColor); - ImUtf8.HoverTooltip("Gender"u8); + Im.Tooltip.OnHover("Gender"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Slot.ToString(), FrameColor); - ImUtf8.HoverTooltip("Extra Skeleton Type"u8); + Im.Tooltip.OnHover("Extra Skeleton Type"u8); } private static bool DrawEntry(EstEntry defaultEntry, ref EstEntry entry, bool disabled) { using var dis = ImRaii.Disabled(disabled); ImGui.TableNextColumn(); - var ret = DragInput("##estValue"u8, [], 100f * ImUtf8.GlobalScale, entry.Value, defaultEntry.Value, out var newValue, (ushort)0, + var ret = DragInput("##estValue"u8, [], 100f * Im.Style.GlobalScale, entry.Value, defaultEntry.Value, out var newValue, (ushort)0, ushort.MaxValue, 0.05f, !disabled); if (ret) entry = new EstEntry(newValue); @@ -118,7 +120,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { var ret = IdInput("##estPrimaryId"u8, unscaledWidth, identifier.SetId.Id, out var setId, 0, ExpandedEqpGmpBase.Count - 1, identifier.SetId.Id <= 1); - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Model Set ID - You can usually find this as the 'e####' part of an item path.\nThis should generally not be left <= 1 unless you explicitly want that."u8); if (ret) identifier = identifier with { SetId = setId }; @@ -128,7 +130,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawRace(ref EstIdentifier identifier, float unscaledWidth = 100) { var ret = Combos.Race("##estRace", identifier.Race, out var race, unscaledWidth); - ImUtf8.HoverTooltip("Model Race"u8); + Im.Tooltip.OnHover("Model Race"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(identifier.Gender, race) }; return ret; @@ -137,7 +139,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawGender(ref EstIdentifier identifier, float unscaledWidth = 120) { var ret = Combos.Gender("##estGender", identifier.Gender, out var gender, unscaledWidth); - ImUtf8.HoverTooltip("Gender"u8); + Im.Tooltip.OnHover("Gender"u8); if (ret) identifier = identifier with { GenderRace = Names.CombinedRace(gender, identifier.Race) }; return ret; @@ -146,7 +148,7 @@ public sealed class EstMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawSlot(ref EstIdentifier identifier, float unscaledWidth = 200) { var ret = Combos.EstSlot("##estSlot", identifier.Slot, out var slot, unscaledWidth); - ImUtf8.HoverTooltip("Extra Skeleton Type"u8); + Im.Tooltip.OnHover("Extra Skeleton Type"u8); if (ret) identifier = identifier with { Slot = slot }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/GlobalEqpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/GlobalEqpMetaDrawer.cs index 505450a5..e1c0a413 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/GlobalEqpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/GlobalEqpMetaDrawer.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Bindings.ImGui; +using ImSharp; using Newtonsoft.Json.Linq; using OtterGui.Text; using Penumbra.GameData.Structs; @@ -20,7 +21,7 @@ public sealed class GlobalEqpMetaDrawer(ModMetaEditor editor, MetaFileManager me protected override void Initialize() { - Identifier = new GlobalEqpManipulation() + Identifier = new GlobalEqpManipulation { Condition = 1, Type = GlobalEqpType.DoNotHideEarrings, @@ -30,7 +31,8 @@ public sealed class GlobalEqpMetaDrawer(ModMetaEditor editor, MetaFileManager me protected override void DrawNew() { ImGui.TableNextColumn(); - CopyToClipboardButton("Copy all current global EQP manipulations to clipboard."u8, new Lazy(() => MetaDictionary.SerializeTo([], Editor.GlobalEqp))); + CopyToClipboardButton("Copy all current global EQP manipulations to clipboard."u8, + new Lazy(() => MetaDictionary.SerializeTo([], Editor.GlobalEqp))); ImGui.TableNextColumn(); var canAdd = !Editor.Contains(Identifier); @@ -72,19 +74,19 @@ public sealed class GlobalEqpMetaDrawer(ModMetaEditor editor, MetaFileManager me { ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Type.ToName(), FrameColor); - ImUtf8.HoverTooltip("Global EQP Type"u8); + Im.Tooltip.OnHover("Global EQP Type"u8); ImGui.TableNextColumn(); if (identifier.Type.HasCondition()) { ImUtf8.TextFramed($"{identifier.Condition.Id}", FrameColor); - ImUtf8.HoverTooltip("Conditional Model ID"u8); + Im.Tooltip.OnHover("Conditional Model ID"u8); } } public static bool DrawType(ref GlobalEqpManipulation identifier, float unscaledWidth = 250) { - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using var combo = ImUtf8.Combo("##geqpType"u8, identifier.Type.ToName()); if (!combo) return false; @@ -102,7 +104,7 @@ public sealed class GlobalEqpMetaDrawer(ModMetaEditor editor, MetaFileManager me ret = true; } - ImUtf8.HoverTooltip(type.ToDescription()); + Im.Tooltip.OnHover(type.ToDescription()); } return ret; @@ -113,6 +115,6 @@ public sealed class GlobalEqpMetaDrawer(ModMetaEditor editor, MetaFileManager me if (IdInput("##geqpCond"u8, unscaledWidth, identifier.Condition.Id, out var newId, 1, ushort.MaxValue, identifier.Condition.Id <= 1)) identifier = identifier with { Condition = newId }; - ImUtf8.HoverTooltip("The Model ID for the item that should not be hidden."u8); + Im.Tooltip.OnHover("The Model ID for the item that should not be hidden."u8); } } diff --git a/Penumbra/UI/AdvancedWindow/Meta/GmpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/GmpMetaDrawer.cs index 81976324..a42156c3 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/GmpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/GmpMetaDrawer.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui.Text; using Penumbra.GameData.Structs; using Penumbra.Meta.Files; @@ -32,7 +33,8 @@ public sealed class GmpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile protected override void DrawNew() { ImGui.TableNextColumn(); - CopyToClipboardButton("Copy all current Gmp manipulations to clipboard."u8, new Lazy(() => MetaDictionary.SerializeTo([], Editor.Gmp))); + CopyToClipboardButton("Copy all current Gmp manipulations to clipboard."u8, + new Lazy(() => MetaDictionary.SerializeTo([], Editor.Gmp))); ImGui.TableNextColumn(); var canAdd = !Editor.Contains(Identifier); @@ -74,7 +76,7 @@ public sealed class GmpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { ImGui.TableNextColumn(); ImUtf8.TextFramed($"{identifier.SetId.Id}", FrameColor); - ImUtf8.HoverTooltip("Model Set ID"u8); + Im.Tooltip.OnHover("Model Set ID"u8); } private static bool DrawEntry(GmpEntry defaultEntry, ref GmpEntry entry, bool disabled) @@ -95,7 +97,7 @@ public sealed class GmpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile changes = true; } - var rotationWidth = 75 * ImUtf8.GlobalScale; + var rotationWidth = 75 * Im.Style.GlobalScale; ImGui.TableNextColumn(); if (DragInput("##gmpRotationA"u8, "Rotation A in Degrees"u8, rotationWidth, entry.RotationA, defaultEntry.RotationA, out var rotationA, (ushort)0, (ushort)360, 0.05f, !disabled)) @@ -120,7 +122,7 @@ public sealed class GmpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile changes = true; } - var unkWidth = 50 * ImUtf8.GlobalScale; + var unkWidth = 50 * Im.Style.GlobalScale; ImGui.TableNextColumn(); if (DragInput("##gmpUnkA"u8, "Animation Type A?"u8, unkWidth, entry.UnknownA, defaultEntry.UnknownA, out var unknownA, (byte)0, (byte)15, 0.01f, !disabled)) @@ -144,7 +146,7 @@ public sealed class GmpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { var ret = IdInput("##gmpPrimaryId"u8, unscaledWidth, identifier.SetId.Id, out var setId, 1, ExpandedEqpGmpBase.Count - 1, identifier.SetId.Id <= 1); - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Model Set ID - You can usually find this as the 'e####' part of an item path.\nThis should generally not be left <= 1 unless you explicitly want that."u8); if (ret) identifier = new GmpIdentifier(setId); diff --git a/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs index 8b84a11a..33841100 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/ImcMetaDrawer.cs @@ -1,302 +1,304 @@ -using Dalamud.Interface; -using Dalamud.Bindings.ImGui; -using Newtonsoft.Json.Linq; -using OtterGui.Raii; -using OtterGui.Text; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Structs; -using Penumbra.Meta; -using Penumbra.Meta.Manipulations; -using Penumbra.Mods.Editor; -using Penumbra.UI.Classes; - -namespace Penumbra.UI.AdvancedWindow.Meta; - -public sealed class ImcMetaDrawer(ModMetaEditor editor, MetaFileManager metaFiles) - : MetaDrawer(editor, metaFiles) -{ - public override ReadOnlySpan Label - => "Variant Edits (IMC)###IMC"u8; - - public override int NumColumns - => 10; - - private bool _fileExists; - - protected override void Initialize() - { - Identifier = ImcIdentifier.Default; - UpdateEntry(); - } - - private void UpdateEntry() - => (Entry, _fileExists, _) = ImcChecker.GetDefaultEntry(Identifier, true); - - protected override void DrawNew() - { - ImGui.TableNextColumn(); - CopyToClipboardButton("Copy all current IMC manipulations to clipboard."u8, - new Lazy(() => MetaDictionary.SerializeTo([], Editor.Imc))); - ImGui.TableNextColumn(); - var canAdd = _fileExists && !Editor.Contains(Identifier); - var tt = canAdd ? "Stage this edit."u8 : !_fileExists ? "This IMC file does not exist."u8 : "This entry is already edited."u8; - if (ImUtf8.IconButton(FontAwesomeIcon.Plus, tt, disabled: !canAdd)) - Editor.Changes |= Editor.TryAdd(Identifier, Entry); - - if (DrawIdentifierInput(ref Identifier)) - UpdateEntry(); - - using var disabled = ImRaii.Disabled(); - DrawEntry(Entry, ref Entry, false); - } - - protected override void DrawEntry(ImcIdentifier identifier, ImcEntry entry) - { - DrawMetaButtons(identifier, entry); - DrawIdentifier(identifier); - - var defaultEntry = ImcChecker.GetDefaultEntry(identifier, true).Entry; - if (DrawEntry(defaultEntry, ref entry, true)) - Editor.Changes |= Editor.Update(identifier, entry); - } - - private static bool DrawIdentifierInput(ref ImcIdentifier identifier) - { - ImGui.TableNextColumn(); - var change = DrawObjectType(ref identifier); - - ImGui.TableNextColumn(); - change |= DrawPrimaryId(ref identifier); - - ImGui.TableNextColumn(); - if (identifier.ObjectType is ObjectType.Equipment or ObjectType.Accessory) - change |= DrawSlot(ref identifier); - else - change |= DrawSecondaryId(ref identifier); - - ImGui.TableNextColumn(); - change |= DrawVariant(ref identifier); - - ImGui.TableNextColumn(); - if (identifier.ObjectType is ObjectType.DemiHuman) - change |= DrawSlot(ref identifier, 70f); - else - ImUtf8.ScaledDummy(70f); - return change; - } - - private static void DrawIdentifier(ImcIdentifier identifier) - { - ImGui.TableNextColumn(); - ImUtf8.TextFramed(identifier.ObjectType.ToName(), FrameColor); - ImUtf8.HoverTooltip("Object Type"u8); - - ImGui.TableNextColumn(); - ImUtf8.TextFramed($"{identifier.PrimaryId.Id}", FrameColor); - ImUtf8.HoverTooltip("Primary ID"); - - ImGui.TableNextColumn(); - if (identifier.ObjectType is ObjectType.Equipment or ObjectType.Accessory) - { - ImUtf8.TextFramed(identifier.EquipSlot.ToName(), FrameColor); - ImUtf8.HoverTooltip("Equip Slot"u8); - } - else - { - ImUtf8.TextFramed($"{identifier.SecondaryId.Id}", FrameColor); - ImUtf8.HoverTooltip("Secondary ID"u8); - } - - ImGui.TableNextColumn(); - ImUtf8.TextFramed($"{identifier.Variant.Id}", FrameColor); - ImUtf8.HoverTooltip("Variant"u8); - - ImGui.TableNextColumn(); - if (identifier.ObjectType is ObjectType.DemiHuman) - { - ImUtf8.TextFramed(identifier.EquipSlot.ToName(), FrameColor); - ImUtf8.HoverTooltip("Equip Slot"u8); - } - } - - private static bool DrawEntry(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault) - { - ImGui.TableNextColumn(); - var change = DrawMaterialId(defaultEntry, ref entry, addDefault); - ImUtf8.SameLineInner(); - change |= DrawMaterialAnimationId(defaultEntry, ref entry, addDefault); - - ImGui.TableNextColumn(); - change |= DrawDecalId(defaultEntry, ref entry, addDefault); - ImUtf8.SameLineInner(); - change |= DrawVfxId(defaultEntry, ref entry, addDefault); - ImUtf8.SameLineInner(); - change |= DrawSoundId(defaultEntry, ref entry, addDefault); - - ImGui.TableNextColumn(); - change |= DrawAttributes(defaultEntry, ref entry); - return change; - } - - - protected override IEnumerable<(ImcIdentifier, ImcEntry)> Enumerate() - => Editor.Imc - .OrderBy(kvp => kvp.Key.ObjectType) - .ThenBy(kvp => kvp.Key.PrimaryId.Id) - .ThenBy(kvp => kvp.Key.EquipSlot) - .ThenBy(kvp => kvp.Key.BodySlot) - .ThenBy(kvp => kvp.Key.SecondaryId.Id) - .ThenBy(kvp => kvp.Key.Variant.Id) - .Select(kvp => (kvp.Key, kvp.Value)); - - protected override int Count - => Editor.Imc.Count; - - public static bool DrawObjectType(ref ImcIdentifier identifier, float width = 110) - { - var ret = Combos.ImcType("##imcType", identifier.ObjectType, out var type, width); - ImUtf8.HoverTooltip("Object Type"u8); - - if (ret) - { - var (equipSlot, secondaryId) = type switch - { - ObjectType.Equipment => (identifier.EquipSlot.IsEquipment() ? identifier.EquipSlot : EquipSlot.Head, SecondaryId.Zero), - ObjectType.DemiHuman => (identifier.EquipSlot.IsEquipment() ? identifier.EquipSlot : EquipSlot.Head, - identifier.SecondaryId == 0 ? (SecondaryId)1 : identifier.SecondaryId), - ObjectType.Accessory => (identifier.EquipSlot.IsAccessory() ? identifier.EquipSlot : EquipSlot.Ears, SecondaryId.Zero), - _ => (EquipSlot.Unknown, identifier.SecondaryId == 0 ? (SecondaryId)1 : identifier.SecondaryId), - }; - identifier = identifier with - { - ObjectType = type, - EquipSlot = equipSlot, - SecondaryId = secondaryId, - }; - } - - return ret; - } - - public static bool DrawPrimaryId(ref ImcIdentifier identifier, float unscaledWidth = 80) - { - var ret = IdInput("##imcPrimaryId"u8, unscaledWidth, identifier.PrimaryId.Id, out var newId, 0, ushort.MaxValue, - identifier.PrimaryId.Id <= 1); - ImUtf8.HoverTooltip("Primary ID - You can usually find this as the 'x####' part of an item path.\n"u8 - + "This should generally not be left <= 1 unless you explicitly want that."u8); - if (ret) - identifier = identifier with { PrimaryId = newId }; - return ret; - } - - public static bool DrawSecondaryId(ref ImcIdentifier identifier, float unscaledWidth = 100) - { - var ret = IdInput("##imcSecondaryId"u8, unscaledWidth, identifier.SecondaryId.Id, out var newId, 0, ushort.MaxValue, false); - ImUtf8.HoverTooltip("Secondary ID"u8); - if (ret) - identifier = identifier with { SecondaryId = newId }; - return ret; - } - - public static bool DrawVariant(ref ImcIdentifier identifier, float unscaledWidth = 45) - { - var ret = IdInput("##imcVariant"u8, unscaledWidth, identifier.Variant.Id, out var newId, 0, byte.MaxValue, false); - ImUtf8.HoverTooltip("Variant ID"u8); - if (ret) - identifier = identifier with { Variant = (byte)newId }; - return ret; - } - - public static bool DrawSlot(ref ImcIdentifier identifier, float unscaledWidth = 100) - { - bool ret; - EquipSlot slot; - switch (identifier.ObjectType) - { - case ObjectType.Equipment: - case ObjectType.DemiHuman: - ret = Combos.EqpEquipSlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); - break; - case ObjectType.Accessory: ret = Combos.AccessorySlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); break; - default: return false; - } - - ImUtf8.HoverTooltip("Equip Slot"u8); - if (ret) - identifier = identifier with { EquipSlot = slot }; - return ret; - } - - public static bool DrawMaterialId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) - { - if (!DragInput("##materialId"u8, "Material ID"u8, unscaledWidth * ImUtf8.GlobalScale, entry.MaterialId, defaultEntry.MaterialId, - out var newValue, (byte)1, byte.MaxValue, 0.01f, addDefault)) - return false; - - entry = entry with { MaterialId = newValue }; - return true; - } - - public static bool DrawMaterialAnimationId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) - { - if (!DragInput("##mAnimId"u8, "Material Animation ID"u8, unscaledWidth * ImUtf8.GlobalScale, entry.MaterialAnimationId, - defaultEntry.MaterialAnimationId, out var newValue, (byte)0, byte.MaxValue, 0.01f, addDefault)) - return false; - - entry = entry with { MaterialAnimationId = newValue }; - return true; - } - - public static bool DrawDecalId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) - { - if (!DragInput("##decalId"u8, "Decal ID"u8, unscaledWidth * ImUtf8.GlobalScale, entry.DecalId, defaultEntry.DecalId, out var newValue, - (byte)0, byte.MaxValue, 0.01f, addDefault)) - return false; - - entry = entry with { DecalId = newValue }; - return true; - } - - public static bool DrawVfxId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) - { - if (!DragInput("##vfxId"u8, "VFX ID"u8, unscaledWidth * ImUtf8.GlobalScale, entry.VfxId, defaultEntry.VfxId, out var newValue, (byte)0, - byte.MaxValue, 0.01f, addDefault)) - return false; - - entry = entry with { VfxId = newValue }; - return true; - } - - public static bool DrawSoundId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) - { - if (!DragInput("##soundId"u8, "Sound ID"u8, unscaledWidth * ImUtf8.GlobalScale, entry.SoundId, defaultEntry.SoundId, out var newValue, - (byte)0, byte.MaxValue, 0.01f, addDefault)) - return false; - - entry = entry with { SoundId = newValue }; - return true; - } - - private static bool DrawAttributes(ImcEntry defaultEntry, ref ImcEntry entry) - { - var changes = false; - for (var i = 0; i < ImcEntry.NumAttributes; ++i) - { - using var id = ImRaii.PushId(i); - var flag = 1 << i; - var value = (entry.AttributeMask & flag) != 0; - var def = (defaultEntry.AttributeMask & flag) != 0; - if (Checkmark("##attribute"u8, "ABCDEFGHIJ"u8.Slice(i, 1), value, def, out var newValue)) - { - var newMask = (ushort)(newValue ? entry.AttributeMask | flag : entry.AttributeMask & ~flag); - entry = entry with { AttributeMask = newMask }; - changes = true; - } - - if (i < ImcEntry.NumAttributes - 1) - ImUtf8.SameLineInner(); - } - - return changes; - } -} +using Dalamud.Interface; +using Dalamud.Bindings.ImGui; +using ImSharp; +using Newtonsoft.Json.Linq; +using OtterGui.Raii; +using OtterGui.Text; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; +using Penumbra.Meta; +using Penumbra.Meta.Manipulations; +using Penumbra.Mods.Editor; +using Penumbra.UI.Classes; + +namespace Penumbra.UI.AdvancedWindow.Meta; + +public sealed class ImcMetaDrawer(ModMetaEditor editor, MetaFileManager metaFiles) + : MetaDrawer(editor, metaFiles) +{ + public override ReadOnlySpan Label + => "Variant Edits (IMC)###IMC"u8; + + public override int NumColumns + => 10; + + private bool _fileExists; + + protected override void Initialize() + { + Identifier = ImcIdentifier.Default; + UpdateEntry(); + } + + private void UpdateEntry() + => (Entry, _fileExists, _) = ImcChecker.GetDefaultEntry(Identifier, true); + + protected override void DrawNew() + { + ImGui.TableNextColumn(); + CopyToClipboardButton("Copy all current IMC manipulations to clipboard."u8, + new Lazy(() => MetaDictionary.SerializeTo([], Editor.Imc))); + ImGui.TableNextColumn(); + var canAdd = _fileExists && !Editor.Contains(Identifier); + var tt = canAdd ? "Stage this edit."u8 : !_fileExists ? "This IMC file does not exist."u8 : "This entry is already edited."u8; + if (ImUtf8.IconButton(FontAwesomeIcon.Plus, tt, disabled: !canAdd)) + Editor.Changes |= Editor.TryAdd(Identifier, Entry); + + if (DrawIdentifierInput(ref Identifier)) + UpdateEntry(); + + using var disabled = ImRaii.Disabled(); + DrawEntry(Entry, ref Entry, false); + } + + protected override void DrawEntry(ImcIdentifier identifier, ImcEntry entry) + { + DrawMetaButtons(identifier, entry); + DrawIdentifier(identifier); + + var defaultEntry = ImcChecker.GetDefaultEntry(identifier, true).Entry; + if (DrawEntry(defaultEntry, ref entry, true)) + Editor.Changes |= Editor.Update(identifier, entry); + } + + private static bool DrawIdentifierInput(ref ImcIdentifier identifier) + { + ImGui.TableNextColumn(); + var change = DrawObjectType(ref identifier); + + ImGui.TableNextColumn(); + change |= DrawPrimaryId(ref identifier); + + ImGui.TableNextColumn(); + if (identifier.ObjectType is ObjectType.Equipment or ObjectType.Accessory) + change |= DrawSlot(ref identifier); + else + change |= DrawSecondaryId(ref identifier); + + ImGui.TableNextColumn(); + change |= DrawVariant(ref identifier); + + ImGui.TableNextColumn(); + if (identifier.ObjectType is ObjectType.DemiHuman) + change |= DrawSlot(ref identifier, 70f); + else + ImUtf8.ScaledDummy(70f); + return change; + } + + private static void DrawIdentifier(ImcIdentifier identifier) + { + ImGui.TableNextColumn(); + ImUtf8.TextFramed(identifier.ObjectType.ToName(), FrameColor); + Im.Tooltip.OnHover("Object Type"u8); + + ImGui.TableNextColumn(); + ImUtf8.TextFramed($"{identifier.PrimaryId.Id}", FrameColor); + Im.Tooltip.OnHover("Primary ID"); + + ImGui.TableNextColumn(); + if (identifier.ObjectType is ObjectType.Equipment or ObjectType.Accessory) + { + ImUtf8.TextFramed(identifier.EquipSlot.ToName(), FrameColor); + Im.Tooltip.OnHover("Equip Slot"u8); + } + else + { + ImUtf8.TextFramed($"{identifier.SecondaryId.Id}", FrameColor); + Im.Tooltip.OnHover("Secondary ID"u8); + } + + ImGui.TableNextColumn(); + ImUtf8.TextFramed($"{identifier.Variant.Id}", FrameColor); + Im.Tooltip.OnHover("Variant"u8); + + ImGui.TableNextColumn(); + if (identifier.ObjectType is ObjectType.DemiHuman) + { + ImUtf8.TextFramed(identifier.EquipSlot.ToName(), FrameColor); + Im.Tooltip.OnHover("Equip Slot"u8); + } + } + + private static bool DrawEntry(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault) + { + ImGui.TableNextColumn(); + var change = DrawMaterialId(defaultEntry, ref entry, addDefault); + ImUtf8.SameLineInner(); + change |= DrawMaterialAnimationId(defaultEntry, ref entry, addDefault); + + ImGui.TableNextColumn(); + change |= DrawDecalId(defaultEntry, ref entry, addDefault); + ImUtf8.SameLineInner(); + change |= DrawVfxId(defaultEntry, ref entry, addDefault); + ImUtf8.SameLineInner(); + change |= DrawSoundId(defaultEntry, ref entry, addDefault); + + ImGui.TableNextColumn(); + change |= DrawAttributes(defaultEntry, ref entry); + return change; + } + + + protected override IEnumerable<(ImcIdentifier, ImcEntry)> Enumerate() + => Editor.Imc + .OrderBy(kvp => kvp.Key.ObjectType) + .ThenBy(kvp => kvp.Key.PrimaryId.Id) + .ThenBy(kvp => kvp.Key.EquipSlot) + .ThenBy(kvp => kvp.Key.BodySlot) + .ThenBy(kvp => kvp.Key.SecondaryId.Id) + .ThenBy(kvp => kvp.Key.Variant.Id) + .Select(kvp => (kvp.Key, kvp.Value)); + + protected override int Count + => Editor.Imc.Count; + + public static bool DrawObjectType(ref ImcIdentifier identifier, float width = 110) + { + var ret = Combos.ImcType("##imcType", identifier.ObjectType, out var type, width); + Im.Tooltip.OnHover("Object Type"u8); + + if (ret) + { + var (equipSlot, secondaryId) = type switch + { + ObjectType.Equipment => (identifier.EquipSlot.IsEquipment() ? identifier.EquipSlot : EquipSlot.Head, SecondaryId.Zero), + ObjectType.DemiHuman => (identifier.EquipSlot.IsEquipment() ? identifier.EquipSlot : EquipSlot.Head, + identifier.SecondaryId == 0 ? (SecondaryId)1 : identifier.SecondaryId), + ObjectType.Accessory => (identifier.EquipSlot.IsAccessory() ? identifier.EquipSlot : EquipSlot.Ears, SecondaryId.Zero), + _ => (EquipSlot.Unknown, identifier.SecondaryId == 0 ? (SecondaryId)1 : identifier.SecondaryId), + }; + identifier = identifier with + { + ObjectType = type, + EquipSlot = equipSlot, + SecondaryId = secondaryId, + }; + } + + return ret; + } + + public static bool DrawPrimaryId(ref ImcIdentifier identifier, float unscaledWidth = 80) + { + var ret = IdInput("##imcPrimaryId"u8, unscaledWidth, identifier.PrimaryId.Id, out var newId, 0, ushort.MaxValue, + identifier.PrimaryId.Id <= 1); + Im.Tooltip.OnHover("Primary ID - You can usually find this as the 'x####' part of an item path.\n"u8 + + "This should generally not be left <= 1 unless you explicitly want that."u8); + if (ret) + identifier = identifier with { PrimaryId = newId }; + return ret; + } + + public static bool DrawSecondaryId(ref ImcIdentifier identifier, float unscaledWidth = 100) + { + var ret = IdInput("##imcSecondaryId"u8, unscaledWidth, identifier.SecondaryId.Id, out var newId, 0, ushort.MaxValue, false); + Im.Tooltip.OnHover("Secondary ID"u8); + if (ret) + identifier = identifier with { SecondaryId = newId }; + return ret; + } + + public static bool DrawVariant(ref ImcIdentifier identifier, float unscaledWidth = 45) + { + var ret = IdInput("##imcVariant"u8, unscaledWidth, identifier.Variant.Id, out var newId, 0, byte.MaxValue, false); + Im.Tooltip.OnHover("Variant ID"u8); + if (ret) + identifier = identifier with { Variant = (byte)newId }; + return ret; + } + + public static bool DrawSlot(ref ImcIdentifier identifier, float unscaledWidth = 100) + { + bool ret; + EquipSlot slot; + switch (identifier.ObjectType) + { + case ObjectType.Equipment: + case ObjectType.DemiHuman: + ret = Combos.EqpEquipSlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); + break; + case ObjectType.Accessory: ret = Combos.AccessorySlot("##slot", identifier.EquipSlot, out slot, unscaledWidth); break; + default: return false; + } + + Im.Tooltip.OnHover("Equip Slot"u8); + if (ret) + identifier = identifier with { EquipSlot = slot }; + return ret; + } + + public static bool DrawMaterialId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) + { + if (!DragInput("##materialId"u8, "Material ID"u8, unscaledWidth * Im.Style.GlobalScale, entry.MaterialId, defaultEntry.MaterialId, + out var newValue, (byte)1, byte.MaxValue, 0.01f, addDefault)) + return false; + + entry = entry with { MaterialId = newValue }; + return true; + } + + public static bool DrawMaterialAnimationId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) + { + if (!DragInput("##mAnimId"u8, "Material Animation ID"u8, unscaledWidth * Im.Style.GlobalScale, entry.MaterialAnimationId, + defaultEntry.MaterialAnimationId, out var newValue, (byte)0, byte.MaxValue, 0.01f, addDefault)) + return false; + + entry = entry with { MaterialAnimationId = newValue }; + return true; + } + + public static bool DrawDecalId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) + { + if (!DragInput("##decalId"u8, "Decal ID"u8, unscaledWidth * Im.Style.GlobalScale, entry.DecalId, defaultEntry.DecalId, out var newValue, + (byte)0, byte.MaxValue, 0.01f, addDefault)) + return false; + + entry = entry with { DecalId = newValue }; + return true; + } + + public static bool DrawVfxId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) + { + if (!DragInput("##vfxId"u8, "VFX ID"u8, unscaledWidth * Im.Style.GlobalScale, entry.VfxId, defaultEntry.VfxId, out var newValue, + (byte)0, + byte.MaxValue, 0.01f, addDefault)) + return false; + + entry = entry with { VfxId = newValue }; + return true; + } + + public static bool DrawSoundId(ImcEntry defaultEntry, ref ImcEntry entry, bool addDefault, float unscaledWidth = 45) + { + if (!DragInput("##soundId"u8, "Sound ID"u8, unscaledWidth * Im.Style.GlobalScale, entry.SoundId, defaultEntry.SoundId, out var newValue, + (byte)0, byte.MaxValue, 0.01f, addDefault)) + return false; + + entry = entry with { SoundId = newValue }; + return true; + } + + private static bool DrawAttributes(ImcEntry defaultEntry, ref ImcEntry entry) + { + var changes = false; + for (var i = 0; i < ImcEntry.NumAttributes; ++i) + { + using var id = ImRaii.PushId(i); + var flag = 1 << i; + var value = (entry.AttributeMask & flag) != 0; + var def = (defaultEntry.AttributeMask & flag) != 0; + if (Checkmark("##attribute"u8, "ABCDEFGHIJ"u8.Slice(i, 1), value, def, out var newValue)) + { + var newMask = (ushort)(newValue ? entry.AttributeMask | flag : entry.AttributeMask & ~flag); + entry = entry with { AttributeMask = newMask }; + changes = true; + } + + if (i < ImcEntry.NumAttributes - 1) + ImUtf8.SameLineInner(); + } + + return changes; + } +} diff --git a/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs index 4a6b1331..4618404e 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/MetaDrawer.cs @@ -79,7 +79,7 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta bool border) { int tmp = currentId; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using var style = ImStyleBorder.Frame.Push(Colors.RegexWarningBorder, Im.Style.GlobalScale, border); if (ImUtf8.InputScalar(label, ref tmp)) tmp = Math.Clamp(tmp, minId, maxId); @@ -103,9 +103,9 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta newValue = newValue <= minValue ? minValue : newValue >= maxValue ? maxValue : newValue; if (addDefault) - ImUtf8.HoverTooltip($"{tooltip}\nDefault Value: {defaultValue}"); + Im.Tooltip.OnHover($"{tooltip}\nDefault Value: {defaultValue}"); else - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, tooltip); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, tooltip); return newValue != currentValue; } @@ -121,7 +121,7 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta using var color = ImGuiColor.FrameBackground.Push(c, defaultValue != currentValue); newValue = currentValue; ImUtf8.Checkbox(label, ref newValue); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, tooltip); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, tooltip); return newValue != currentValue; } @@ -136,7 +136,7 @@ public abstract class MetaDrawer(ModMetaEditor editor, Meta using var color = ImGuiColor.FrameBackground.Push(c, defaultValue != currentValue); newValue = currentValue; ImUtf8.Checkbox(label, ref newValue); - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, tooltip); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, tooltip); return newValue != currentValue; } diff --git a/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs index 44b6d5ed..cbefecda 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/RspMetaDrawer.cs @@ -1,6 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using Dalamud.Bindings.ImGui; +using ImSharp; using Newtonsoft.Json.Linq; using OtterGui.Text; using Penumbra.GameData.Enums; @@ -33,7 +34,8 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile protected override void DrawNew() { ImGui.TableNextColumn(); - CopyToClipboardButton("Copy all current RSP manipulations to clipboard."u8, new Lazy(() => MetaDictionary.SerializeTo([], Editor.Rsp))); + CopyToClipboardButton("Copy all current RSP manipulations to clipboard."u8, + new Lazy(() => MetaDictionary.SerializeTo([], Editor.Rsp))); ImGui.TableNextColumn(); var canAdd = !Editor.Contains(Identifier); @@ -80,19 +82,19 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile { ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.SubRace.ToName(), FrameColor); - ImUtf8.HoverTooltip("Model Set ID"u8); + Im.Tooltip.OnHover("Model Set ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Attribute.ToFullString(), FrameColor); - ImUtf8.HoverTooltip("Equip Slot"u8); + Im.Tooltip.OnHover("Equip Slot"u8); } private static bool DrawEntry(RspEntry defaultEntry, ref RspEntry entry, bool disabled) { using var dis = ImRaii.Disabled(disabled); ImGui.TableNextColumn(); - var ret = DragInput("##rspValue"u8, [], ImUtf8.GlobalScale * 150, entry.Value, defaultEntry.Value, out var newValue, - RspEntry.MinValue, RspEntry.MaxValue, 0.001f, !disabled); + var ret = DragInput("##rspValue"u8, [], Im.Style.GlobalScale * 150, entry.Value, defaultEntry.Value, out var newValue, + RspEntry.MinValue, RspEntry.MaxValue, 0.001f, !disabled); if (ret) entry = new RspEntry(newValue); return ret; @@ -101,7 +103,7 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawSubRace(ref RspIdentifier identifier, float unscaledWidth = 150) { var ret = Combos.SubRace("##rspSubRace", identifier.SubRace, out var subRace, unscaledWidth); - ImUtf8.HoverTooltip("Racial Clan"u8); + Im.Tooltip.OnHover("Racial Clan"u8); if (ret) identifier = identifier with { SubRace = subRace }; return ret; @@ -110,7 +112,7 @@ public sealed class RspMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public static bool DrawAttribute(ref RspIdentifier identifier, float unscaledWidth = 200) { var ret = Combos.RspAttribute("##rspAttribute", identifier.Attribute, out var attribute, unscaledWidth); - ImUtf8.HoverTooltip("Scaling Attribute"u8); + Im.Tooltip.OnHover("Scaling Attribute"u8); if (ret) identifier = identifier with { Attribute = attribute }; return ret; diff --git a/Penumbra/UI/AdvancedWindow/Meta/ShpMetaDrawer.cs b/Penumbra/UI/AdvancedWindow/Meta/ShpMetaDrawer.cs index ea0e2cc9..0c115b15 100644 --- a/Penumbra/UI/AdvancedWindow/Meta/ShpMetaDrawer.cs +++ b/Penumbra/UI/AdvancedWindow/Meta/ShpMetaDrawer.cs @@ -99,13 +99,13 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile ImGui.TableNextColumn(); ImUtf8.TextFramed(SlotName(identifier.Slot), FrameColor); - ImUtf8.HoverTooltip("Model Slot"u8); + Im.Tooltip.OnHover("Model Slot"u8); ImGui.TableNextColumn(); if (identifier.GenderRaceCondition is not GenderRace.Unknown) { ImUtf8.TextFramed($"{identifier.GenderRaceCondition.ToName()} ({identifier.GenderRaceCondition.ToRaceCode()})", FrameColor); - ImUtf8.HoverTooltip("Gender & Race Code for this shape key to be set."); + Im.Tooltip.OnHover("Gender & Race Code for this shape key to be set."); } else { @@ -117,7 +117,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile ImUtf8.TextFramed($"{identifier.Id.Value.Id}", FrameColor); else ImUtf8.TextFramed("All IDs"u8, FrameColor); - ImUtf8.HoverTooltip("Primary ID"u8); + Im.Tooltip.OnHover("Primary ID"u8); ImGui.TableNextColumn(); ImUtf8.TextFramed(identifier.Shape.AsSpan, FrameColor); @@ -126,7 +126,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile if (identifier.ConnectorCondition is not ShapeConnectorCondition.None) { ImUtf8.TextFramed($"{identifier.ConnectorCondition}", FrameColor); - ImUtf8.HoverTooltip("Connector condition for this shape to be activated."); + Im.Tooltip.OnHover("Connector condition for this shape to be activated."); } } @@ -138,7 +138,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile var changes = ImUtf8.Checkbox("##shpEntry"u8, ref value); if (changes) entry = new ShpEntry(value); - ImUtf8.HoverTooltip("Whether to enable or disable this shape key for the selected items."); + Im.Tooltip.OnHover("Whether to enable or disable this shape key for the selected items."); return changes; } @@ -156,7 +156,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip(allSlots ? "When using all slots, you also need to use all IDs."u8 : "Enable this shape key for all model IDs."u8); + Im.Tooltip.OnHover(allSlots ? "When using all slots, you also need to use all IDs."u8 : "Enable this shape key for all model IDs."u8); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); if (all) @@ -175,7 +175,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Primary ID - You can usually find this as the 'e####' part of an item path or similar for customizations."u8); + Im.Tooltip.OnHover("Primary ID - You can usually find this as the 'e####' part of an item path or similar for customizations."u8); return ret; } @@ -183,7 +183,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile public bool DrawHumanSlot(ref ShpIdentifier identifier, float unscaledWidth = 170) { var ret = false; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using (var combo = ImUtf8.Combo("##shpSlot"u8, SlotName(identifier.Slot))) { if (combo) @@ -223,7 +223,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Model Slot"u8); + Im.Tooltip.OnHover("Model Slot"u8); return ret; } @@ -235,7 +235,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile var span = new Span(ptr, ShapeAttributeString.MaxLength + 1); using (ImStyleBorder.Frame.Push(Colors.RegexWarningBorder, Im.Style.GlobalScale, !valid)) { - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); if (ImUtf8.InputText("##shpShape"u8, span, out int newLength, "Shape Key..."u8)) { buffer.ForceLength((byte)newLength); @@ -246,14 +246,14 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip("Supported shape keys need to have the format `shpx_*` and a maximum length of 30 characters."u8); + Im.Tooltip.OnHover("Supported shape keys need to have the format `shpx_*` and a maximum length of 30 characters."u8); return ret; } private static bool DrawConnectorConditionInput(ref ShpIdentifier identifier, float unscaledWidth = 80) { var ret = false; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); var (showWrists, showWaist, showAnkles, disable) = identifier.Slot switch { HumanSlot.Unknown => (true, true, true, false), @@ -282,7 +282,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Only activate this shape key if any custom connector shape keys (shpx_[wr|wa|an]_*) are also enabled through matching attributes."u8); return ret; } @@ -290,7 +290,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile private static bool DrawGenderRaceConditionInput(ref ShpIdentifier identifier, float unscaledWidth = 250) { var ret = false; - ImGui.SetNextItemWidth(unscaledWidth * ImUtf8.GlobalScale); + ImGui.SetNextItemWidth(unscaledWidth * Im.Style.GlobalScale); using (var combo = ImUtf8.Combo("##shpGenderRace"u8, identifier.GenderRaceCondition is GenderRace.Unknown ? "Any Gender & Race" @@ -317,7 +317,7 @@ public sealed class ShpMetaDrawer(ModMetaEditor editor, MetaFileManager metaFile } } - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Only activate this shape key for this gender & race code."u8); return ret; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Deformers.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Deformers.cs index d039b460..487a26f8 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Deformers.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Deformers.cs @@ -69,7 +69,7 @@ public partial class ModEditWindow private void DrawBoneSelector() { using var group = ImUtf8.Group(); - var width = 200 * ImUtf8.GlobalScale; + var width = 200 * Im.Style.GlobalScale; using (ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 0) .Push(ImGuiStyleVar.ItemSpacing, Vector2.Zero)) { diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Files.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Files.cs index 266d515b..dd5b0a8f 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Files.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Files.cs @@ -62,16 +62,16 @@ public partial class ModEditWindow var height = Im.Style.TextHeightWithSpacing + 2 * ImGui.GetStyle().CellPadding.Y; var skips = ImGuiClip.GetNecessarySkips(height); - using var list = ImRaii.Table("##table", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV, -Vector2.One); + using var table = Im.Table.Begin("##table"u8, 3, TableFlags.RowBackground | TableFlags.BordersInnerVertical, -Vector2.One); - if (!list) + if (!table) return; var width = Im.ContentRegion.Available.X / 8; - ImGui.TableSetupColumn("##file", ImGuiTableColumnFlags.WidthFixed, width * 3); - ImGui.TableSetupColumn("##path", ImGuiTableColumnFlags.WidthFixed, width * 3 + ImGui.GetStyle().FrameBorderSize); - ImGui.TableSetupColumn("##option", ImGuiTableColumnFlags.WidthFixed, width * 2); + table.SetupColumn("##file"u8, TableColumnFlags.WidthFixed, width * 3); + table.SetupColumn("##path"u8, TableColumnFlags.WidthFixed, width * 3 + ImGui.GetStyle().FrameBorderSize); + table.SetupColumn("##option"u8, TableColumnFlags.WidthFixed, width * 2); var idx = 0; @@ -115,7 +115,7 @@ public partial class ModEditWindow private void DrawFilesNormalMode() { - using var list = ImRaii.Table("##table", 1); + using var list = Im.Table.Begin("##table"u8, 1); if (!list) return; @@ -154,7 +154,7 @@ public partial class ModEditWindow _ => (null, 0), }; - if (text != null && ImGui.IsItemHovered()) + if (text != null && Im.Item.Hovered()) { using var tt = ImUtf8.Tooltip(); using var c = ImRaii.DefaultColors(); @@ -295,7 +295,7 @@ public partial class ModEditWindow ImGuiUtil.TextColored(0xFF00B0B0, FontAwesomeIcon.ExclamationCircle.ToIconString()); } - ImUtf8.HoverTooltip("The game path and the file do not have the same extension."u8); + Im.Tooltip.OnHover("The game path and the file do not have the same extension."u8); } } @@ -338,7 +338,7 @@ public partial class ModEditWindow ImGuiUtil.TextColored(0xFF00B0B0, FontAwesomeIcon.ExclamationCircle.ToIconString()); } - ImUtf8.HoverTooltip("The game path and the file do not have the same extension."u8); + Im.Tooltip.OnHover("The game path and the file do not have the same extension."u8); } } diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.cs index 83200ccc..28c9b4e3 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.cs @@ -36,7 +36,7 @@ public partial class ModEditWindow if (!child) return; - using var table = ImUtf8.Table("##files"u8, 4, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, -Vector2.One); + using var table = Im.Table.Begin("##files"u8, 4, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.One); if (!table) return; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Meta.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Meta.cs index 3b797413..6ef9e8b6 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Meta.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Meta.cs @@ -97,7 +97,7 @@ public partial class ModEditWindow if (!hasAtch) { - ImGui.CloseCurrentPopup(); + Im.Popup.CloseCurrent(); return; } @@ -125,8 +125,8 @@ public partial class ModEditWindow private static void DrawTable(IMetaDrawer drawer) { - const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.BordersInnerV; - using var table = ImUtf8.Table(drawer.Label, drawer.NumColumns, flags); + const TableFlags flags = TableFlags.RowBackground | TableFlags.SizingFixedFit | TableFlags.BordersInnerVertical; + using var table = Im.Table.Begin(drawer.Label, drawer.NumColumns, flags); if (!table) return; @@ -144,7 +144,7 @@ public partial class ModEditWindow var size = ImGui.CalcTextSize(text).X; ImGui.SetCursorPos(new Vector2(Im.ContentRegion.Available.X - size, oldPos + ImGui.GetStyle().FramePadding.Y)); Im.Text(text, ColorId.RedundantAssignment.Value().FullAlpha()); - if (ImGui.IsItemHovered()) + if (Im.Item.Hovered()) { using var tt = ImUtf8.Tooltip(); foreach (var name in otherOptionData) @@ -177,7 +177,7 @@ public partial class ModEditWindow } } - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Try to add meta manipulations currently stored in the clipboard to the current manipulations.\nOverwrites already existing manipulations."u8); } @@ -193,7 +193,7 @@ public partial class ModEditWindow } } - ImUtf8.HoverTooltip( + Im.Tooltip.OnHover( "Try to set the current meta manipulations to the set currently stored in the clipboard.\nRemoves all other manipulations."u8); } } diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs index fc3e0368..9f534f53 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs @@ -299,7 +299,7 @@ public partial class ModEditWindow if (Im.Item.RightClicked()) ImGui.SetClipboardText(preview); - ImGuiUtil.HoverTooltip("Right-Click to copy to clipboard.", ImGuiHoveredFlags.AllowWhenDisabled); + Im.Tooltip.OnHover("Right-Click to copy to clipboard."u8, HoveredFlags.AllowWhenDisabled); } private void DrawDocumentationLink(string address) @@ -339,19 +339,19 @@ public partial class ModEditWindow if (!header) return false; - using var table = ImRaii.Table(string.Empty, disabled ? 2 : 4, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin(StringU8.Empty, disabled ? 2 : 4, TableFlags.SizingFixedFit); if (!table) return false; var ret = false; var materials = tab.Mdl.Materials; - ImGui.TableSetupColumn("index", ImGuiTableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("path", ImGuiTableColumnFlags.WidthStretch, 1); + table.SetupColumn("index"u8, TableColumnFlags.WidthFixed, 80 * Im.Style.GlobalScale); + table.SetupColumn("path"u8, TableColumnFlags.WidthStretch, 1); if (!disabled) { - ImGui.TableSetupColumn("actions", ImGuiTableColumnFlags.WidthFixed, UiHelpers.IconButtonSize.X); - ImGui.TableSetupColumn("help", ImGuiTableColumnFlags.WidthFixed, UiHelpers.IconButtonSize.X); + table.SetupColumn("actions"u8, TableColumnFlags.WidthFixed, UiHelpers.IconButtonSize.X); + table.SetupColumn("help"u8, TableColumnFlags.WidthFixed, UiHelpers.IconButtonSize.X); } var inputFlags = disabled ? ImGuiInputTextFlags.ReadOnly : ImGuiInputTextFlags.None; @@ -464,12 +464,12 @@ public partial class ModEditWindow return false; using var id = ImRaii.PushId(meshIndex); - using var table = ImRaii.Table(string.Empty, 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin(StringU8.Empty, 2, TableFlags.SizingFixedFit); if (!table) return false; - ImGui.TableSetupColumn("name", ImGuiTableColumnFlags.WidthFixed, 100 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("field", ImGuiTableColumnFlags.WidthStretch, 1); + table.SetupColumn("name"u8, TableColumnFlags.WidthFixed, 100 * Im.Style.GlobalScale); + table.SetupColumn("field"u8, TableColumnFlags.WidthStretch, 1); var file = tab.Mdl; var mesh = file.Meshes[meshIndex]; @@ -503,18 +503,18 @@ public partial class ModEditWindow if (!node) return; - var flags = ImGuiTableFlags.SizingFixedFit - | ImGuiTableFlags.RowBg - | ImGuiTableFlags.Borders - | ImGuiTableFlags.NoHostExtendX; - using var table = ImRaii.Table(string.Empty, 4, flags); + var flags = TableFlags.SizingFixedFit + | TableFlags.RowBackground + | TableFlags.Borders + | TableFlags.NoHostExtendX; + using var table = Im.Table.Begin(StringU8.Empty, 4, flags); if (!table) return; - ImGui.TableSetupColumn("Usage"); - ImGui.TableSetupColumn("Type"); - ImGui.TableSetupColumn("Stream"); - ImGui.TableSetupColumn("Offset"); + table.SetupColumn("Usage"u8); + table.SetupColumn("Type"u8); + table.SetupColumn("Stream"u8); + table.SetupColumn("Offset"u8); ImGui.TableHeadersRow(); @@ -595,7 +595,7 @@ public partial class ModEditWindow return false; var ret = false; - using (var table = ImRaii.Table("##data", 2, ImGuiTableFlags.SizingFixedFit)) + using (var table = Im.Table.Begin("##data"u8, 2, TableFlags.SizingFixedFit)) { if (table) { diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs index a7668a2a..cf960d67 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs @@ -391,16 +391,16 @@ public partial class ModEditWindow ? "Parameter positions (continuations are grayed out, globally unused values are red, unused values within filters are yellow):" : "Parameter positions (continuations are grayed out):"); - using var table = ImRaii.Table("##MaterialParamLayout", 5, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##MaterialParamLayout"u8, 5, + TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return false; - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, 40 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("x", ImGuiTableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("y", ImGuiTableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("z", ImGuiTableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("w", ImGuiTableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); + table.SetupColumn(StringU8.Empty, TableColumnFlags.WidthFixed, 40 * Im.Style.GlobalScale); + table.SetupColumn("x"u8, TableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); + table.SetupColumn("y"u8, TableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); + table.SetupColumn("z"u8, TableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); + table.SetupColumn("w"u8, TableColumnFlags.WidthFixed, 250 * Im.Style.GlobalScale); ImGui.TableHeadersRow(); var textColorStart = ImGuiColor.Text.Get().Color; @@ -436,11 +436,11 @@ public partial class ModEditWindow } } - ImUtf8.HoverTooltip(tooltip); + Im.Tooltip.OnHover(tooltip); } if (deletable) - ImUtf8.HoverTooltip("\nControl + Right-Click to remove."u8); + Im.Tooltip.OnHover("\nControl + Right-Click to remove."u8); } } diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs index 6366efdf..068de89d 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs @@ -280,7 +280,7 @@ public partial class ModEditWindow private Vector2 GetChildWidth() { - var windowWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - Im.Style.TextHeight; + var windowWidth = Im.Window.MaximumContentRegion.X - Im.Window.MinimumContentRegion.X - Im.Style.TextHeight; if (_overlayCollapsed) { var width = windowWidth - ImGui.GetStyle().FramePadding.X * 3; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs index c3d60411..cab847a0 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs @@ -199,8 +199,8 @@ public partial class ModEditWindow : IndexedWindow, IDisposable if (IsLoading) { - var radius = 100 * ImUtf8.GlobalScale; - var thickness = (int)(20 * ImUtf8.GlobalScale); + var radius = 100 * Im.Style.GlobalScale; + var thickness = (int)(20 * Im.Style.GlobalScale); var offsetX = Im.ContentRegion.Available.X / 2 - radius; var offsetY = Im.ContentRegion.Available.Y / 2 - radius; ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(offsetX, offsetY)); @@ -327,7 +327,7 @@ public partial class ModEditWindow : IndexedWindow, IDisposable if (!child) return; - using var table = ImRaii.Table("##missingFiles", 1, ImGuiTableFlags.RowBg, -Vector2.One); + using var table = Im.Table.Begin("##missingFiles"u8, 1, TableFlags.RowBackground, -Vector2.One); if (!table) return; @@ -401,14 +401,14 @@ public partial class ModEditWindow : IndexedWindow, IDisposable if (!child) return; - using var table = ImRaii.Table("##duplicates", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, -Vector2.One); + using var table = Im.Table.Begin("##duplicates"u8, 3, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.One); if (!table) return; var width = ImGui.CalcTextSize("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN ").X; - ImGui.TableSetupColumn("file", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("size", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("NNN.NNN ").X); - ImGui.TableSetupColumn("hash", ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn("file"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("size", TableColumnFlags.WidthFixed, ImGui.CalcTextSize("NNN.NNN "u8).X); + table.SetupColumn("hash"u8, TableColumnFlags.WidthFixed, ImGui.GetWindowWidth() > 2 * width ? width : ImGui.CalcTextSize("NNNNNNNN... ").X); foreach (var (set, size, hash) in _editor.Duplicates.Duplicates.Where(s => s.Paths.Length > 1)) { @@ -507,16 +507,16 @@ public partial class ModEditWindow : IndexedWindow, IDisposable if (!child) return; - using var list = ImRaii.Table("##table", 3, ImGuiTableFlags.RowBg, -Vector2.One); - if (!list) + using var table = Im.Table.Begin("##table"u8, 3, TableFlags.RowBackground, -Vector2.One); + if (!table) return; var idx = 0; var iconSize = Im.Style.FrameHeight * Vector2.One; var pathSize = Im.ContentRegion.Available.X / 2 - iconSize.X; - ImGui.TableSetupColumn("button", ImGuiTableColumnFlags.WidthFixed, iconSize.X); - ImGui.TableSetupColumn("source", ImGuiTableColumnFlags.WidthFixed, pathSize); - ImGui.TableSetupColumn("value", ImGuiTableColumnFlags.WidthFixed, pathSize); + table.SetupColumn("button"u8, TableColumnFlags.WidthFixed, iconSize.X); + table.SetupColumn("source"u8, TableColumnFlags.WidthFixed, pathSize); + table.SetupColumn("value"u8, TableColumnFlags.WidthFixed, pathSize); foreach (var (gamePath, file) in _editor.SwapEditor.Swaps.ToList()) { diff --git a/Penumbra/UI/AdvancedWindow/ModMergeTab.cs b/Penumbra/UI/AdvancedWindow/ModMergeTab.cs index bbae5fda..09d15f84 100644 --- a/Penumbra/UI/AdvancedWindow/ModMergeTab.cs +++ b/Penumbra/UI/AdvancedWindow/ModMergeTab.cs @@ -58,7 +58,7 @@ public class ModMergeTab(ModMerger modMerger, ModComboWithoutCurrent combo) : Lu if (size - textSize < minComboSize) { Im.Text("selected mod"u8, ColorId.FolderLine.Value()); - ImUtf8.HoverTooltip(modMerger.MergeFromMod!.Name); + Im.Tooltip.OnHover(modMerger.MergeFromMod!.Name); } else { @@ -104,8 +104,8 @@ public class ModMergeTab(ModMerger modMerger, ModComboWithoutCurrent combo) : Lu } if (modMerger.MergeFromMod.HasOptions) - ImGuiUtil.HoverTooltip("You can only specify a target option if the source mod has no true options itself.", - ImGuiHoveredFlags.AllowWhenDisabled); + Im.Tooltip.OnHover("You can only specify a target option if the source mod has no true options itself."u8, + HoveredFlags.AllowWhenDisabled); if (ImGuiUtil.DrawDisabledButton("Merge", new Vector2(size, 0), modMerger.CanMerge ? string.Empty : "Please select a target mod different from the current mod.", !modMerger.CanMerge)) @@ -171,22 +171,22 @@ public class ModMergeTab(ModMerger modMerger, ModComboWithoutCurrent combo) : Lu : 8 * Im.Style.FrameHeightWithSpacing; height = Math.Min(height, (options.Count + 1) * Im.Style.FrameHeightWithSpacing); var tableSize = new Vector2(size, height); - using var table = ImRaii.Table("##options", 6, - ImGuiTableFlags.RowBg - | ImGuiTableFlags.SizingFixedFit - | ImGuiTableFlags.ScrollY - | ImGuiTableFlags.BordersOuterV - | ImGuiTableFlags.BordersOuterH, + using var table = Im.Table.Begin("##options"u8, 6, + TableFlags.RowBackground + | TableFlags.SizingFixedFit + | TableFlags.ScrollY + | TableFlags.BordersOuterVertical + | TableFlags.BordersOuterHorizontal, tableSize); if (!table) return; - ImGui.TableSetupColumn("##Selected", ImGuiTableColumnFlags.WidthFixed, Im.Style.FrameHeight); - ImGui.TableSetupColumn("Option", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("Option Group", ImGuiTableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("#Files", ImGuiTableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("#Swaps", ImGuiTableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); - ImGui.TableSetupColumn("#Manips", ImGuiTableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); + table.SetupColumn("##Selected"u8, TableColumnFlags.WidthFixed, Im.Style.FrameHeight); + table.SetupColumn("Option"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("Option Group"u8, TableColumnFlags.WidthFixed, 120 * Im.Style.GlobalScale); + table.SetupColumn("#Files"u8, TableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); + table.SetupColumn("#Swaps"u8, TableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); + table.SetupColumn("#Manips"u8, TableColumnFlags.WidthFixed, 50 * Im.Style.GlobalScale); ImGui.TableHeadersRow(); foreach (var (idx, option) in options.Index()) { diff --git a/Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs b/Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs index 8ed1b587..1b988fd8 100644 --- a/Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs +++ b/Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs @@ -142,15 +142,15 @@ public class ResourceTreeViewer( ImUtf8.InputText("##note"u8, ref _note, "Export note..."u8); - using var table = ImRaii.Table("##ResourceTree", 4, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##ResourceTree"u8, 4, + TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) continue; - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthStretch, 0.2f); - ImGui.TableSetupColumn("Game Path", ImGuiTableColumnFlags.WidthStretch, 0.3f); - ImGui.TableSetupColumn("Actual Path", ImGuiTableColumnFlags.WidthStretch, 0.5f); - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, + table.SetupColumn(StringU8.Empty, TableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("Game Path"u8, TableColumnFlags.WidthStretch, 0.3f); + table.SetupColumn("Actual Path"u8, TableColumnFlags.WidthStretch, 0.5f); + table.SetupColumn(StringU8.Empty, TableColumnFlags.WidthFixed, actionCapacity * 3 * Im.Style.GlobalScale + (actionCapacity + 1) * Im.Style.FrameHeight); ImGui.TableHeadersRow(); diff --git a/Penumbra/UI/ModsTab/DescriptionEditPopup.cs b/Penumbra/UI/ModsTab/DescriptionEditPopup.cs index 1ea273ac..0a189fa0 100644 --- a/Penumbra/UI/ModsTab/DescriptionEditPopup.cs +++ b/Penumbra/UI/ModsTab/DescriptionEditPopup.cs @@ -1,114 +1,105 @@ -using Dalamud.Interface.Utility; -using Dalamud.Bindings.ImGui; -using ImSharp; -using OtterGui.Text; -using Penumbra.Mods; -using Penumbra.Mods.Groups; -using Penumbra.Mods.Manager; -using Penumbra.Mods.SubMods; - -namespace Penumbra.UI.ModsTab; - -public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService -{ - private static ReadOnlySpan PopupId - => "PenumbraEditDescription"u8; - - private bool _hasBeenEdited; - private string _description = string.Empty; - - private object? _current; - private bool _opened; - - public void Open(Mod mod) - { - _current = mod; - _opened = true; - _hasBeenEdited = false; - _description = mod.Description; - } - - public void Open(IModGroup group) - { - _current = group; - _opened = true; - _hasBeenEdited = false; - _description = group.Description; - } - - public void Open(IModOption option) - { - _current = option; - _opened = true; - _hasBeenEdited = false; - _description = option.Description; - } - - public void Draw() - { - if (_current == null) - return; - - if (_opened) - { - _opened = false; - ImUtf8.OpenPopup(PopupId); - } - - var inputSize = ImEx.ScaledVector(800); - using var popup = ImUtf8.Popup(PopupId); - if (!popup) - return; - - if (ImGui.IsWindowAppearing()) - ImGui.SetKeyboardFocusHere(); - - ImUtf8.InputMultiLineOnDeactivated("##editDescription"u8, ref _description, inputSize); - _hasBeenEdited |= ImGui.IsItemEdited(); - UiHelpers.DefaultLineSpace(); - - var buttonSize = new Vector2(ImUtf8.GlobalScale * 100, 0); - - var width = 2 * buttonSize.X - + 4 * ImUtf8.FramePadding.X - + ImUtf8.ItemSpacing.X; - - ImGui.SetCursorPosX((inputSize.X - width) / 2); - DrawSaveButton(buttonSize); - Im.Line.Same(); - DrawCancelButton(buttonSize); - } - - private void DrawSaveButton(Vector2 buttonSize) - { - if (!ImUtf8.ButtonEx("Save"u8, _hasBeenEdited ? [] : "No changes made yet."u8, buttonSize, !_hasBeenEdited)) - return; - - switch (_current) - { - case Mod mod: - modManager.DataEditor.ChangeModDescription(mod, _description); - break; - case IModGroup group: - modManager.OptionEditor.ChangeGroupDescription(group, _description); - break; - case IModOption option: - modManager.OptionEditor.ChangeOptionDescription(option, _description); - break; - } - - _description = string.Empty; - _hasBeenEdited = false; - ImGui.CloseCurrentPopup(); - } - - private void DrawCancelButton(Vector2 buttonSize) - { - if (!ImUtf8.Button("Cancel"u8, buttonSize) && !ImGui.IsKeyPressed(ImGuiKey.Escape)) - return; - - _description = string.Empty; - _hasBeenEdited = false; - ImGui.CloseCurrentPopup(); - } -} +using ImSharp; +using Penumbra.Mods; +using Penumbra.Mods.Groups; +using Penumbra.Mods.Manager; +using Penumbra.Mods.SubMods; + +namespace Penumbra.UI.ModsTab; + +public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService +{ + private static ReadOnlySpan PopupId + => "EditDesc"u8; + + private bool _hasBeenEdited; + private string _description = string.Empty; + + private object? _current; + private bool _opened; + + public void Open(Mod mod) + { + _current = mod; + _opened = true; + _hasBeenEdited = false; + _description = mod.Description; + } + + public void Open(IModGroup group) + { + _current = group; + _opened = true; + _hasBeenEdited = false; + _description = group.Description; + } + + public void Open(IModOption option) + { + _current = option; + _opened = true; + _hasBeenEdited = false; + _description = option.Description; + } + + public void Draw() + { + if (_current == null) + return; + + if (_opened) + { + _opened = false; + Im.Popup.Open(PopupId); + } + + var inputSize = ImEx.ScaledVector(800); + using var popup = Im.Popup.Begin(PopupId); + if (!popup) + return; + + if (Im.Window.Appearing) + Im.Keyboard.SetFocusHere(); + + ImEx.InputOnDeactivation.MultiLine("##editDescription"u8, _description, out _description, inputSize); + _hasBeenEdited |= Im.Item.Edited; + UiHelpers.DefaultLineSpace(); + + var buttonSize = new Vector2(Im.Style.GlobalScale * 100, 0); + + var width = 2 * buttonSize.X + + 4 * Im.Style.FramePadding.X + + Im.Style.ItemSpacing.X; + + Im.Cursor.X = (inputSize.X - width) / 2; + DrawSaveButton(buttonSize); + Im.Line.Same(); + DrawCancelButton(buttonSize); + } + + private void DrawSaveButton(Vector2 buttonSize) + { + if (!ImEx.Button("Save"u8, buttonSize, _hasBeenEdited ? StringU8.Empty : "No changes made yet."u8, !_hasBeenEdited)) + return; + + switch (_current) + { + case Mod mod: modManager.DataEditor.ChangeModDescription(mod, _description); break; + case IModGroup group: modManager.OptionEditor.ChangeGroupDescription(group, _description); break; + case IModOption option: modManager.OptionEditor.ChangeOptionDescription(option, _description); break; + } + + _description = string.Empty; + _hasBeenEdited = false; + Im.Popup.CloseCurrent(); + } + + private void DrawCancelButton(Vector2 buttonSize) + { + if (!Im.Button("Cancel"u8, buttonSize) && !Im.Keyboard.IsPressed(Key.Escape)) + return; + + _description = string.Empty; + _hasBeenEdited = false; + Im.Popup.CloseCurrent(); + } +} diff --git a/Penumbra/UI/ModsTab/Groups/AddGroupDrawer.cs b/Penumbra/UI/ModsTab/Groups/AddGroupDrawer.cs index 81681346..5695cbe2 100644 --- a/Penumbra/UI/ModsTab/Groups/AddGroupDrawer.cs +++ b/Penumbra/UI/ModsTab/Groups/AddGroupDrawer.cs @@ -1,158 +1,160 @@ -using Dalamud.Bindings.ImGui; -using OtterGui.Text; -using Penumbra.Api.Enums; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Structs; -using Penumbra.Meta; -using Penumbra.Meta.Manipulations; -using Penumbra.Mods; -using Penumbra.Mods.Manager; -using Penumbra.Mods.Manager.OptionEditor; -using Penumbra.UI.AdvancedWindow.Meta; -using Penumbra.UI.Classes; - -namespace Penumbra.UI.ModsTab.Groups; - -public class AddGroupDrawer : Luna.IUiService -{ - private string _groupName = string.Empty; - private bool _groupNameValid; - - private ImcIdentifier _imcIdentifier = ImcIdentifier.Default; - private ImcEntry _defaultEntry; - private bool _imcFileExists; - private bool _entryExists; - private bool _entryInvalid; - private readonly ModManager _modManager; - - public AddGroupDrawer(ModManager modManager) - { - _modManager = modManager; - UpdateEntry(); - } - - public void Draw(Mod mod, float width) - { - var buttonWidth = new Vector2((width - ImUtf8.ItemInnerSpacing.X) / 2, 0); - DrawBasicGroups(mod, width, buttonWidth); - DrawImcData(mod, buttonWidth); - } - - private void DrawBasicGroups(Mod mod, float width, Vector2 buttonWidth) - { - ImGui.SetNextItemWidth(width); - if (ImUtf8.InputText("##name"u8, ref _groupName, "Enter New Name..."u8)) - _groupNameValid = ModGroupEditor.VerifyFileName(mod, null, _groupName, false); - - DrawSingleGroupButton(mod, buttonWidth); - ImUtf8.SameLineInner(); - DrawMultiGroupButton(mod, buttonWidth); - DrawCombiningGroupButton(mod, buttonWidth); - } - - private void DrawSingleGroupButton(Mod mod, Vector2 width) - { - if (!ImUtf8.ButtonEx("Add Single Group"u8, _groupNameValid - ? "Add a new single selection option group to this mod."u8 - : "Can not add a new group of this name."u8, - width, !_groupNameValid)) - return; - - _modManager.OptionEditor.AddModGroup(mod, GroupType.Single, _groupName); - _groupName = string.Empty; - _groupNameValid = false; - } - - private void DrawMultiGroupButton(Mod mod, Vector2 width) - { - if (!ImUtf8.ButtonEx("Add Multi Group"u8, _groupNameValid - ? "Add a new multi selection option group to this mod."u8 - : "Can not add a new group of this name."u8, - width, !_groupNameValid)) - return; - - _modManager.OptionEditor.AddModGroup(mod, GroupType.Multi, _groupName); - _groupName = string.Empty; - _groupNameValid = false; - } - - private void DrawCombiningGroupButton(Mod mod, Vector2 width) - { - if (!ImUtf8.ButtonEx("Add Combining Group"u8, _groupNameValid - ? "Add a new combining option group to this mod."u8 - : "Can not add a new group of this name."u8, - width, !_groupNameValid)) - return; - - _modManager.OptionEditor.AddModGroup(mod, GroupType.Combining, _groupName); - _groupName = string.Empty; - _groupNameValid = false; - } - private void DrawImcInput(float width) - { - var change = ImcMetaDrawer.DrawObjectType(ref _imcIdentifier, width); - ImUtf8.SameLineInner(); - change |= ImcMetaDrawer.DrawPrimaryId(ref _imcIdentifier, width); - if (_imcIdentifier.ObjectType is ObjectType.Weapon or ObjectType.Monster) - { - change |= ImcMetaDrawer.DrawSecondaryId(ref _imcIdentifier, width); - ImUtf8.SameLineInner(); - change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, width); - } - else if (_imcIdentifier.ObjectType is ObjectType.DemiHuman) - { - var quarterWidth = (width - ImUtf8.ItemInnerSpacing.X / ImUtf8.GlobalScale) / 2; - change |= ImcMetaDrawer.DrawSecondaryId(ref _imcIdentifier, width); - ImUtf8.SameLineInner(); - change |= ImcMetaDrawer.DrawSlot(ref _imcIdentifier, quarterWidth); - ImUtf8.SameLineInner(); - change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, quarterWidth); - } - else - { - change |= ImcMetaDrawer.DrawSlot(ref _imcIdentifier, width); - ImUtf8.SameLineInner(); - change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, width); - } - - if (change) - UpdateEntry(); - } - - private void DrawImcData(Mod mod, Vector2 width) - { - var halfWidth = width.X / ImUtf8.GlobalScale; - DrawImcInput(halfWidth); - DrawImcButton(mod, width); - } - - private void DrawImcButton(Mod mod, Vector2 width) - { - if (ImUtf8.ButtonEx("Add IMC Group"u8, !_groupNameValid - ? "Can not add a new group of this name."u8 - : _entryInvalid - ? "The associated IMC entry is invalid."u8 - : "Add a new multi selection option group to this mod."u8, - width, !_groupNameValid || _entryInvalid)) - { - _modManager.OptionEditor.ImcEditor.AddModGroup(mod, _groupName, _imcIdentifier, _defaultEntry); - _groupName = string.Empty; - _groupNameValid = false; - } - - if (_entryInvalid) - { - ImUtf8.SameLineInner(); - var text = _imcFileExists - ? "IMC Entry Does Not Exist"u8 - : "IMC File Does Not Exist"u8; - ImUtf8.TextFramed(text, Colors.PressEnterWarningBg, width); - } - } - - private void UpdateEntry() - { - (_defaultEntry, _imcFileExists, _entryExists) = ImcChecker.GetDefaultEntry(_imcIdentifier, false); - _entryInvalid = !_imcIdentifier.Validate() || _defaultEntry.MaterialId == 0 || !_entryExists; - } -} +using Dalamud.Bindings.ImGui; +using ImSharp; +using OtterGui.Text; +using Penumbra.Api.Enums; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; +using Penumbra.Meta; +using Penumbra.Meta.Manipulations; +using Penumbra.Mods; +using Penumbra.Mods.Manager; +using Penumbra.Mods.Manager.OptionEditor; +using Penumbra.UI.AdvancedWindow.Meta; +using Penumbra.UI.Classes; + +namespace Penumbra.UI.ModsTab.Groups; + +public class AddGroupDrawer : Luna.IUiService +{ + private string _groupName = string.Empty; + private bool _groupNameValid; + + private ImcIdentifier _imcIdentifier = ImcIdentifier.Default; + private ImcEntry _defaultEntry; + private bool _imcFileExists; + private bool _entryExists; + private bool _entryInvalid; + private readonly ModManager _modManager; + + public AddGroupDrawer(ModManager modManager) + { + _modManager = modManager; + UpdateEntry(); + } + + public void Draw(Mod mod, float width) + { + var buttonWidth = new Vector2((width - ImUtf8.ItemInnerSpacing.X) / 2, 0); + DrawBasicGroups(mod, width, buttonWidth); + DrawImcData(mod, buttonWidth); + } + + private void DrawBasicGroups(Mod mod, float width, Vector2 buttonWidth) + { + ImGui.SetNextItemWidth(width); + if (ImUtf8.InputText("##name"u8, ref _groupName, "Enter New Name..."u8)) + _groupNameValid = ModGroupEditor.VerifyFileName(mod, null, _groupName, false); + + DrawSingleGroupButton(mod, buttonWidth); + ImUtf8.SameLineInner(); + DrawMultiGroupButton(mod, buttonWidth); + DrawCombiningGroupButton(mod, buttonWidth); + } + + private void DrawSingleGroupButton(Mod mod, Vector2 width) + { + if (!ImUtf8.ButtonEx("Add Single Group"u8, _groupNameValid + ? "Add a new single selection option group to this mod."u8 + : "Can not add a new group of this name."u8, + width, !_groupNameValid)) + return; + + _modManager.OptionEditor.AddModGroup(mod, GroupType.Single, _groupName); + _groupName = string.Empty; + _groupNameValid = false; + } + + private void DrawMultiGroupButton(Mod mod, Vector2 width) + { + if (!ImUtf8.ButtonEx("Add Multi Group"u8, _groupNameValid + ? "Add a new multi selection option group to this mod."u8 + : "Can not add a new group of this name."u8, + width, !_groupNameValid)) + return; + + _modManager.OptionEditor.AddModGroup(mod, GroupType.Multi, _groupName); + _groupName = string.Empty; + _groupNameValid = false; + } + + private void DrawCombiningGroupButton(Mod mod, Vector2 width) + { + if (!ImUtf8.ButtonEx("Add Combining Group"u8, _groupNameValid + ? "Add a new combining option group to this mod."u8 + : "Can not add a new group of this name."u8, + width, !_groupNameValid)) + return; + + _modManager.OptionEditor.AddModGroup(mod, GroupType.Combining, _groupName); + _groupName = string.Empty; + _groupNameValid = false; + } + + private void DrawImcInput(float width) + { + var change = ImcMetaDrawer.DrawObjectType(ref _imcIdentifier, width); + ImUtf8.SameLineInner(); + change |= ImcMetaDrawer.DrawPrimaryId(ref _imcIdentifier, width); + if (_imcIdentifier.ObjectType is ObjectType.Weapon or ObjectType.Monster) + { + change |= ImcMetaDrawer.DrawSecondaryId(ref _imcIdentifier, width); + ImUtf8.SameLineInner(); + change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, width); + } + else if (_imcIdentifier.ObjectType is ObjectType.DemiHuman) + { + var quarterWidth = (width - ImUtf8.ItemInnerSpacing.X / Im.Style.GlobalScale) / 2; + change |= ImcMetaDrawer.DrawSecondaryId(ref _imcIdentifier, width); + ImUtf8.SameLineInner(); + change |= ImcMetaDrawer.DrawSlot(ref _imcIdentifier, quarterWidth); + ImUtf8.SameLineInner(); + change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, quarterWidth); + } + else + { + change |= ImcMetaDrawer.DrawSlot(ref _imcIdentifier, width); + ImUtf8.SameLineInner(); + change |= ImcMetaDrawer.DrawVariant(ref _imcIdentifier, width); + } + + if (change) + UpdateEntry(); + } + + private void DrawImcData(Mod mod, Vector2 width) + { + var halfWidth = width.X / Im.Style.GlobalScale; + DrawImcInput(halfWidth); + DrawImcButton(mod, width); + } + + private void DrawImcButton(Mod mod, Vector2 width) + { + if (ImUtf8.ButtonEx("Add IMC Group"u8, !_groupNameValid + ? "Can not add a new group of this name."u8 + : _entryInvalid + ? "The associated IMC entry is invalid."u8 + : "Add a new multi selection option group to this mod."u8, + width, !_groupNameValid || _entryInvalid)) + { + _modManager.OptionEditor.ImcEditor.AddModGroup(mod, _groupName, _imcIdentifier, _defaultEntry); + _groupName = string.Empty; + _groupNameValid = false; + } + + if (_entryInvalid) + { + ImUtf8.SameLineInner(); + var text = _imcFileExists + ? "IMC Entry Does Not Exist"u8 + : "IMC File Does Not Exist"u8; + ImUtf8.TextFramed(text, Colors.PressEnterWarningBg, width); + } + } + + private void UpdateEntry() + { + (_defaultEntry, _imcFileExists, _entryExists) = ImcChecker.GetDefaultEntry(_imcIdentifier, false); + _entryInvalid = !_imcIdentifier.Validate() || _defaultEntry.MaterialId == 0 || !_entryExists; + } +} diff --git a/Penumbra/UI/ModsTab/Groups/CombiningModGroupEditDrawer.cs b/Penumbra/UI/ModsTab/Groups/CombiningModGroupEditDrawer.cs index 59b0e54e..a275ebb2 100644 --- a/Penumbra/UI/ModsTab/Groups/CombiningModGroupEditDrawer.cs +++ b/Penumbra/UI/ModsTab/Groups/CombiningModGroupEditDrawer.cs @@ -57,11 +57,11 @@ public readonly struct CombiningModGroupEditDrawer(ModGroupEditDrawer editor, Co { if (ImUtf8.ButtonEx("Edit Container Names"u8, "Add optional names to separate data containers of the combining group.\nThose are just for easier identification while editing the mod, and are not generally displayed to the user."u8, - new Vector2(400 * ImUtf8.GlobalScale, 0))) + new Vector2(400 * Im.Style.GlobalScale, 0))) ImUtf8.OpenPopup("DataContainerNames"u8); - var sizeX = group.OptionData.Count * (ImGui.GetStyle().ItemInnerSpacing.X + Im.Style.FrameHeight) + 300 * ImUtf8.GlobalScale; - ImGui.SetNextWindowSize(new Vector2(sizeX, Im.Style.FrameHeightWithSpacing * Math.Min(16, group.Data.Count) + 200 * ImUtf8.GlobalScale)); + var sizeX = group.OptionData.Count * (ImGui.GetStyle().ItemInnerSpacing.X + Im.Style.FrameHeight) + 300 * Im.Style.GlobalScale; + ImGui.SetNextWindowSize(new Vector2(sizeX, Im.Style.FrameHeightWithSpacing * Math.Min(16, group.Data.Count) + 200 * Im.Style.GlobalScale)); using var popup = ImUtf8.Popup("DataContainerNames"u8); if (!popup) return; diff --git a/Penumbra/UI/ModsTab/Groups/ImcModGroupEditDrawer.cs b/Penumbra/UI/ModsTab/Groups/ImcModGroupEditDrawer.cs index c542295a..a86d95e4 100644 --- a/Penumbra/UI/ModsTab/Groups/ImcModGroupEditDrawer.cs +++ b/Penumbra/UI/ModsTab/Groups/ImcModGroupEditDrawer.cs @@ -22,20 +22,20 @@ public readonly struct ImcModGroupEditDrawer(ModGroupEditDrawer editor, ImcModGr var entry = group.DefaultEntry; var changes = false; - var width = editor.AvailableWidth.X - 3 * ImUtf8.ItemInnerSpacing.X - ImUtf8.ItemSpacing.X - ImUtf8.CalcTextSize("All Variants"u8).X - ImUtf8.CalcTextSize("Only Attributes"u8).X - 2 * ImUtf8.FrameHeight; + var width = editor.AvailableWidth.X - 3 * ImUtf8.ItemInnerSpacing.X - Im.Style.ItemSpacing.X - ImUtf8.CalcTextSize("All Variants"u8).X - ImUtf8.CalcTextSize("Only Attributes"u8).X - 2 * ImUtf8.FrameHeight; ImEx.TextFramed(identifier.ToString(), new Vector2(width, 0), Rgba32.Transparent); ImUtf8.SameLineInner(); var allVariants = group.AllVariants; if (ImUtf8.Checkbox("All Variants"u8, ref allVariants)) editor.ModManager.OptionEditor.ImcEditor.ChangeAllVariants(group, allVariants); - ImUtf8.HoverTooltip("Make this group overwrite all corresponding variants for this identifier, not just the one specified."u8); + Im.Tooltip.OnHover("Make this group overwrite all corresponding variants for this identifier, not just the one specified."u8); Im.Line.Same(); var onlyAttributes = group.OnlyAttributes; if (ImUtf8.Checkbox("Only Attributes"u8, ref onlyAttributes)) editor.ModManager.OptionEditor.ImcEditor.ChangeOnlyAttributes(group, onlyAttributes); - ImUtf8.HoverTooltip("Only overwrite the attribute flags and take all the other values from the game's default entry instead of the one configured here.\n\nMainly useful if used with All Variants to keep the material IDs for each variant."u8); + Im.Tooltip.OnHover("Only overwrite the attribute flags and take all the other values from the game's default entry instead of the one configured here.\n\nMainly useful if used with All Variants to keep the material IDs for each variant."u8); using (ImUtf8.Group()) { @@ -162,7 +162,7 @@ public readonly struct ImcModGroupEditDrawer(ModGroupEditDrawer editor, ImcModGr } } - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "ABCDEFGHIJ"u8.Slice(i, 1)); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "ABCDEFGHIJ"u8.Slice(i, 1)); if (i != 9) ImUtf8.SameLineInner(); } diff --git a/Penumbra/UI/ModsTab/Groups/ModGroupEditDrawer.cs b/Penumbra/UI/ModsTab/Groups/ModGroupEditDrawer.cs index 34f944c9..b3711f7d 100644 --- a/Penumbra/UI/ModsTab/Groups/ModGroupEditDrawer.cs +++ b/Penumbra/UI/ModsTab/Groups/ModGroupEditDrawer.cs @@ -120,7 +120,7 @@ public sealed class ModGroupEditDrawer( var tt = _isGroupNameValid ? "Change the Group name."u8 : "Current name can not be used for this group."u8; - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, tt); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, tt); } private void DrawGroupDelete(IModGroup group) @@ -129,9 +129,9 @@ public sealed class ModGroupEditDrawer( ActionQueue.Enqueue(() => ModManager.OptionEditor.DeleteModGroup(group)); if (_deleteEnabled) - ImUtf8.HoverTooltip("Delete this option group."u8); + Im.Tooltip.OnHover("Delete this option group."u8); else - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Delete this option group.\nHold {config.DeleteModModifier} while clicking to delete."); } @@ -172,9 +172,9 @@ public sealed class ModGroupEditDrawer( ActionQueue.Enqueue(() => ModManager.OptionEditor.MoveModGroup(group, idx - 1)); if (isFirst) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Can not move this group further upwards."u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Can not move this group further upwards."u8); else - ImUtf8.HoverTooltip($"Move this group up to group {idx}."); + Im.Tooltip.OnHover($"Move this group up to group {idx}."); ImUtf8.SameLineInner(); @@ -183,9 +183,9 @@ public sealed class ModGroupEditDrawer( ActionQueue.Enqueue(() => ModManager.OptionEditor.MoveModGroup(group, idx + 1)); if (isLast) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "Can not move this group further downwards."u8); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Can not move this group further downwards."u8); else - ImUtf8.HoverTooltip($"Move this group down to group {idx + 2}."); + Im.Tooltip.OnHover($"Move this group down to group {idx + 2}."); } private void DrawGroupOpenFile(IModGroup group, int idx) @@ -203,9 +203,9 @@ public sealed class ModGroupEditDrawer( } if (fileExists) - ImUtf8.HoverTooltip($"Open the {group.Name} json file in the text editor of your choice."); + Im.Tooltip.OnHover($"Open the {group.Name} json file in the text editor of your choice."); else - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"The {group.Name} json file does not exist."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"The {group.Name} json file does not exist."); } @@ -224,7 +224,7 @@ public sealed class ModGroupEditDrawer( var isDefaultOption = group.DefaultSettings.AsIndex == optionIdx; if (ImUtf8.RadioButton("##default"u8, isDefaultOption)) ModManager.OptionEditor.ChangeModGroupDefaultOption(group, Setting.Single(optionIdx)); - ImUtf8.HoverTooltip($"Set {option.Name} as the default choice for this group."); + Im.Tooltip.OnHover($"Set {option.Name} as the default choice for this group."); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -233,7 +233,7 @@ public sealed class ModGroupEditDrawer( var isDefaultOption = group.DefaultSettings.HasFlag(optionIdx); if (ImUtf8.Checkbox("##default"u8, ref isDefaultOption)) ModManager.OptionEditor.ChangeModGroupDefaultOption(group, group.DefaultSettings.SetBit(optionIdx, isDefaultOption)); - ImUtf8.HoverTooltip($"{(isDefaultOption ? "Disable"u8 : "Enable"u8)} {option.Name} per default in this group."); + Im.Tooltip.OnHover($"{(isDefaultOption ? "Disable"u8 : "Enable"u8)} {option.Name} per default in this group."); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -250,7 +250,7 @@ public sealed class ModGroupEditDrawer( ImGui.SetNextItemWidth(PriorityWidth); if (ImUtf8.InputScalarOnDeactivated("##Priority"u8, ref priority)) ModManager.OptionEditor.MultiEditor.ChangeOptionPriority(option, new ModPriority(priority)); - ImUtf8.HoverTooltip("Option priority inside the mod."u8); + Im.Tooltip.OnHover("Option priority inside the mod."u8); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -269,9 +269,9 @@ public sealed class ModGroupEditDrawer( ActionQueue.Enqueue(() => ModManager.OptionEditor.DeleteOption(option)); if (_deleteEnabled) - ImUtf8.HoverTooltip("Delete this option."u8); + Im.Tooltip.OnHover("Delete this option."u8); else - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Delete this option.\nHold {config.DeleteModModifier} while clicking to delete."); } @@ -357,9 +357,9 @@ public sealed class ModGroupEditDrawer( [MethodImpl(MethodImplOptions.AggressiveInlining)] private void PrepareStyle() { - var totalWidth = 400f * ImUtf8.GlobalScale; + var totalWidth = 400f * Im.Style.GlobalScale; _buttonSize = new Vector2(ImUtf8.FrameHeight); - PriorityWidth = 50 * ImUtf8.GlobalScale; + PriorityWidth = 50 * Im.Style.GlobalScale; AvailableWidth = new Vector2(totalWidth + 3 * _spacing + 2 * _buttonSize.X + PriorityWidth, 0); _groupNameWidth = totalWidth - 3 * (_buttonSize.X + _spacing); _spacing = ImGui.GetStyle().ItemInnerSpacing.X; diff --git a/Penumbra/UI/ModsTab/Groups/SingleModGroupEditDrawer.cs b/Penumbra/UI/ModsTab/Groups/SingleModGroupEditDrawer.cs index 210f4aca..1a0eff1a 100644 --- a/Penumbra/UI/ModsTab/Groups/SingleModGroupEditDrawer.cs +++ b/Penumbra/UI/ModsTab/Groups/SingleModGroupEditDrawer.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Bindings.ImGui; +using ImSharp; using OtterGui.Raii; using OtterGui.Text; using Penumbra.Mods.Groups; @@ -43,7 +44,7 @@ public readonly struct SingleModGroupEditDrawer(ModGroupEditDrawer editor, Singl if (ImUtf8.ButtonEx("Convert to Multi Group", editor.AvailableWidth, !convertible)) editor.ActionQueue.Enqueue(() => e.ChangeToMulti(g)); if (!convertible) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, "Can not convert to multi group since maximum number of options is exceeded."u8); } diff --git a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs index 862bcbb3..91809401 100644 --- a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs +++ b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs @@ -144,10 +144,10 @@ public sealed class ModFileSystemSelector : FileSystemSelector _config.Ephemeral.CurrentModSelectorWidth * ImUtf8.GlobalScale; + => _config.Ephemeral.CurrentModSelectorWidth * Im.Style.GlobalScale; protected override float MinimumAbsoluteRemainder - => 550 * ImUtf8.GlobalScale; + => 550 * Im.Style.GlobalScale; protected override float MinimumScaling => _config.Ephemeral.ModSelectorMinimumScale; @@ -158,7 +158,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector Label => "Conflicts"u8; @@ -39,22 +33,22 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy public void DrawContent() { - using var table = ImRaii.Table("conflicts", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY, Im.ContentRegion.Available); + using var table = Im.Table.Begin("conflicts"u8, 3, TableFlags.RowBackground | TableFlags.ScrollY, Im.ContentRegion.Available); if (!table) return; var buttonSize = new Vector2(Im.Style.FrameHeight); - var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; - var priorityRowWidth = ImGui.CalcTextSize("Priority").X + 20 * Im.Style.GlobalScale + 2 * buttonSize.X; + var spacing = Im.Style.ItemInnerSpacing with { Y = Im.Style.ItemSpacing.Y }; + var priorityRowWidth = Im.Font.CalculateSize("Priority"u8).X + 20 * Im.Style.GlobalScale + 2 * buttonSize.X; var priorityWidth = priorityRowWidth - 2 * (buttonSize.X + spacing.X); - using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing); - ImGui.TableSetupColumn("Conflicting Mod", ImGuiTableColumnFlags.WidthStretch); - ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, priorityRowWidth); - ImGui.TableSetupColumn("Files", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("Files").X + spacing.X); + using var style = ImStyleDouble.ItemSpacing.Push(spacing); + table.SetupColumn("Conflicting Mod"u8, TableColumnFlags.WidthStretch); + table.SetupColumn("Priority"u8, TableColumnFlags.WidthFixed, priorityRowWidth); + table.SetupColumn("Files"u8, TableColumnFlags.WidthFixed, Im.Font.CalculateSize("Files"u8).X + spacing.X); - ImGui.TableSetupScrollFreeze(2, 2); - ImGui.TableHeadersRow(); - DrawCurrentRow(priorityWidth); + table.SetupScrollFreeze(2, 2); + table.HeaderRow(); + DrawCurrentRow(table, priorityWidth); // Can not be null because otherwise the tab bar is never drawn. var mod = selector.Selected!; @@ -62,56 +56,42 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy .OrderByDescending(GetPriority) .ThenBy(c => c.Mod2.Name, StringComparer.OrdinalIgnoreCase).Index()) { - using var id = ImRaii.PushId(index); - DrawConflictRow(conflict, priorityWidth, buttonSize); + using var id = Im.Id.Push(index); + DrawConflictRow(table, conflict, priorityWidth, buttonSize); } } - private void DrawCurrentRow(float priorityWidth) + private void DrawCurrentRow(in Im.TableDisposable table, float priorityWidth) { - ImGui.TableNextColumn(); using var c = ImGuiColor.Text.Push(ColorId.FolderLine.Value()); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(selector.Selected!.Name); - ImGui.TableNextColumn(); + table.DrawFrameColumn(selector.Selected!.Name); + table.NextColumn(); var actualSettings = collectionManager.Active.Current.GetActualSettings(selector.Selected!.Index).Settings!; var priority = actualSettings.Priority.Value; // TODO - using (ImRaii.Disabled(actualSettings is TemporaryModSettings)) + using (Im.Disabled(actualSettings is TemporaryModSettings)) { - ImGui.SetNextItemWidth(priorityWidth); - if (ImGui.InputInt("##priority", ref priority, 0, 0, flags: ImGuiInputTextFlags.EnterReturnsTrue)) - _currentPriority = priority; - - if (ImGui.IsItemDeactivatedAfterEdit() && _currentPriority.HasValue) - { - if (_currentPriority != actualSettings.Priority.Value) + if (ImEx.InputOnDeactivation.Scalar("##priority"u8, ref priority)) + if (priority != actualSettings.Priority.Value) collectionManager.Editor.SetModPriority(collectionManager.Active.Current, selector.Selected!, - new ModPriority(_currentPriority.Value)); - - _currentPriority = null; - } - else if (ImGui.IsItemDeactivated()) - { - _currentPriority = null; - } + new ModPriority(priority)); } - ImGui.TableNextColumn(); + table.NextColumn(); } private void DrawConflictSelectable(ModConflicts conflict) { - ImGui.AlignTextToFramePadding(); - if (ImGui.Selectable(conflict.Mod2.Name) && conflict.Mod2 is Mod otherMod) + Im.Cursor.FrameAlign(); + if (Im.Selectable(conflict.Mod2.Name) && conflict.Mod2 is Mod otherMod) selector.SelectByValue(otherMod); - var hovered = ImGui.IsItemHovered(); + var hovered = Im.Item.Hovered(); var rightClicked = Im.Item.RightClicked(); if (conflict.Mod2 is Mod otherMod2) { if (hovered) - ImGui.SetTooltip("Click to jump to mod, Control + Right-Click to disable mod."); - if (rightClicked && ImGui.GetIO().KeyCtrl) + Im.Tooltip.Set("Click to jump to mod, Control + Right-Click to disable mod."u8); + if (rightClicked && Im.Io.KeyControl) collectionManager.Editor.SetModState(collectionManager.Active.Current, otherMod2, false); } } @@ -121,13 +101,13 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy if (!_expandedMods.TryGetValue(conflict.Mod2, out _)) return false; - using var indent = ImRaii.PushIndent(30f); + using var indent = Im.Indent(30f); foreach (var data in conflict.Conflicts) { _ = data switch { - Utf8GamePath p => ImUtf8.Selectable(p.Path.Span, false), - IMetaIdentifier m => ImUtf8.Selectable(m.ToString(), false), + Utf8GamePath p => Im.Selectable(p.Path.Span), + IMetaIdentifier m => Im.Selectable($"{m}"), _ => false, }; } @@ -135,26 +115,26 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy return true; } - private void DrawConflictRow(ModConflicts conflict, float priorityWidth, Vector2 buttonSize) + private void DrawConflictRow(in Im.TableDisposable table, ModConflicts conflict, float priorityWidth, Vector2 buttonSize) { - ImGui.TableNextColumn(); + table.NextColumn(); DrawConflictSelectable(conflict); var expanded = DrawExpandedFiles(conflict); - ImGui.TableNextColumn(); + table.NextColumn(); var conflictPriority = DrawPriorityInput(conflict, priorityWidth); Im.Line.Same(); var selectedPriority = collectionManager.Active.Current.GetActualSettings(selector.Selected!.Index).Settings!.Priority.Value; DrawPriorityButtons(conflict.Mod2 as Mod, conflictPriority, selectedPriority, buttonSize); - ImGui.TableNextColumn(); + table.NextColumn(); DrawExpandButton(conflict.Mod2, expanded, buttonSize); } private void DrawExpandButton(IMod mod, bool expanded, Vector2 buttonSize) { var (icon, tt) = expanded - ? (FontAwesomeIcon.CaretUp.ToIconString(), "Hide the conflicting files for this mod.") - : (FontAwesomeIcon.CaretDown.ToIconString(), "Show the conflicting files for this mod."); - if (ImGuiUtil.DrawDisabledButton(icon, buttonSize, tt, false, true)) + ? RefTuple.Create(LunaStyle.CollapseUpIcon, "Hide the conflicting files for this mod."u8) + : RefTuple.Create(LunaStyle.ExpandDownIcon, "Show the conflicting files for this mod."u8); + if (ImEx.Icon.Button(icon, tt, buttonSize)) { if (expanded) _expandedMods.Remove(mod); @@ -165,41 +145,29 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy private int DrawPriorityInput(ModConflicts conflict, float priorityWidth) { - using var color = ImGuiColor.Text.Push(conflict.HasPriority ? ColorId.HandledConflictMod.Value() : ColorId.ConflictingMod.Value()); - using var disabled = ImRaii.Disabled(conflict.Mod2.Index < 0); - var priority = _currentPriority ?? GetPriority(conflict).Value; - - ImGui.SetNextItemWidth(priorityWidth); - if (ImGui.InputInt("##priority", ref priority, 0, 0, flags: ImGuiInputTextFlags.EnterReturnsTrue)) - _currentPriority = priority; - - if (ImGui.IsItemDeactivatedAfterEdit() && _currentPriority.HasValue) - { - if (_currentPriority != GetPriority(conflict).Value) - collectionManager.Editor.SetModPriority(collectionManager.Active.Current, (Mod)conflict.Mod2, - new ModPriority(_currentPriority.Value)); - - _currentPriority = null; - } - else if (ImGui.IsItemDeactivated()) - { - _currentPriority = null; - } + using var color = ImGuiColor.Text.Push(conflict.HasPriority ? ColorId.HandledConflictMod.Value() : ColorId.ConflictingMod.Value()); + using var disabled = Im.Disabled(conflict.Mod2.Index < 0); + var priority = GetPriority(conflict).Value; + var originalPriority = priority; + Im.Item.SetNextWidth(priorityWidth); + if (ImEx.InputOnDeactivation.Scalar("##priority"u8, ref priority) && priority != originalPriority) + collectionManager.Editor.SetModPriority(collectionManager.Active.Current, (Mod)conflict.Mod2, + new ModPriority(priority)); return priority; } private void DrawPriorityButtons(Mod? conflict, int conflictPriority, int selectedPriority, Vector2 buttonSize) { - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.SortNumericUpAlt.ToIconString(), buttonSize, + if (ImEx.Icon.Button(FontAwesomeIcon.SortNumericUpAlt.Icon(), $"Set the priority of the currently selected mod to this mods priority plus one. ({selectedPriority} -> {conflictPriority + 1})", - selectedPriority > conflictPriority, true)) + selectedPriority > conflictPriority, buttonSize)) collectionManager.Editor.SetModPriority(collectionManager.Active.Current, selector.Selected!, new ModPriority(conflictPriority + 1)); Im.Line.Same(); - if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.SortNumericDownAlt.ToIconString(), buttonSize, + if (ImEx.Icon.Button(FontAwesomeIcon.SortNumericDownAlt.Icon(), $"Set the priority of this mod to the currently selected mods priority minus one. ({conflictPriority} -> {selectedPriority - 1})", - selectedPriority > conflictPriority || conflict == null, true)) + selectedPriority > conflictPriority || conflict == null, buttonSize)) collectionManager.Editor.SetModPriority(collectionManager.Active.Current, conflict!, new ModPriority(selectedPriority - 1)); } } diff --git a/Penumbra/UI/ModsTab/ModPanelEditTab.cs b/Penumbra/UI/ModsTab/ModPanelEditTab.cs index 1facc0b0..9de9b25c 100644 --- a/Penumbra/UI/ModsTab/ModPanelEditTab.cs +++ b/Penumbra/UI/ModsTab/ModPanelEditTab.cs @@ -153,7 +153,7 @@ public class ModPanelEditTab( ImUtf8.Text(FontAwesomeIcon.CheckCircle.ToIconString()); } - ImUtf8.HoverTooltip($"Export exists in \"{backup.Name}\"."); + Im.Tooltip.OnHover($"Export exists in \"{backup.Name}\"."); } using var context = ImUtf8.Popup("context"u8); @@ -210,7 +210,7 @@ public class ModPanelEditTab( { ImEx.TextFramed($"{DateTimeOffset.FromUnixTimeMilliseconds(_mod.ImportDate).ToLocalTime():yyyy/MM/dd HH:mm}", new Vector2(UiHelpers.InputTextMinusButton3, 0), ImGuiColor.FrameBackground.Get(0.5f)); - ImGui.SameLine(0, 3 * ImUtf8.GlobalScale); + ImGui.SameLine(0, 3 * Im.Style.GlobalScale); var canRefresh = config.DeleteModModifier.IsActive(); var tt = canRefresh diff --git a/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs b/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs index 666b9038..ab940d76 100644 --- a/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs +++ b/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs @@ -40,7 +40,7 @@ public class ModPanelSettingsTab( public void DrawContent() { - using var table = ImUtf8.Table("##settings"u8, 1, ImGuiTableFlags.ScrollY, Im.ContentRegion.Available); + using var table = Im.Table.Begin("##settings"u8, 1, TableFlags.ScrollY, Im.ContentRegion.Available); if (!table) return; @@ -82,7 +82,7 @@ public class ModPanelSettingsTab( _locked)) collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!, null); - ImUtf8.HoverTooltip("Changing settings in temporary settings will not save them across sessions.\n"u8 + Im.Tooltip.OnHover("Changing settings in temporary settings will not save them across sessions.\n"u8 + "You can click this button to remove the temporary settings and return to your normal settings."u8); } @@ -107,7 +107,7 @@ public class ModPanelSettingsTab( } } - ImUtf8.HoverTooltip("You can click this button to copy the current settings to the current selection.\n"u8 + Im.Tooltip.OnHover("You can click this button to copy the current settings to the current selection.\n"u8 + "You can also just change any setting, which will copy the settings with the single setting changed to the current selection."u8); } @@ -147,7 +147,7 @@ public class ModPanelSettingsTab( if (ImUtf8.InputScalar("##Priority"u8, ref priority)) _currentPriority = priority; if (new ModPriority(priority).IsHidden) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"This priority is special-cased to hide this mod in conflict tabs ({ModPriority.HiddenMin}, {ModPriority.HiddenMax})."); diff --git a/Penumbra/UI/ModsTab/ModPanelTabBar.cs b/Penumbra/UI/ModsTab/ModPanelTabBar.cs index 97e87648..bceb1c52 100644 --- a/Penumbra/UI/ModsTab/ModPanelTabBar.cs +++ b/Penumbra/UI/ModsTab/ModPanelTabBar.cs @@ -147,7 +147,7 @@ public class ModPanelTabBar : IUiService if (ImEx.Icon.Button(LunaStyle.FavoriteIcon)) _modManager.DataEditor.ChangeModFavorite(mod, !mod.Favorite); - var hovered = ImGui.IsItemHovered(); + var hovered = Im.Item.Hovered(); _tutorial.OpenTutorial(BasicTutorialSteps.Favorites); if (hovered) diff --git a/Penumbra/UI/ModsTab/MultiModPanel.cs b/Penumbra/UI/ModsTab/MultiModPanel.cs index f8d0605b..3fb38484 100644 --- a/Penumbra/UI/ModsTab/MultiModPanel.cs +++ b/Penumbra/UI/ModsTab/MultiModPanel.cs @@ -56,14 +56,14 @@ public class MultiModPanel(ModFileSystemSelector selector, ModDataEditor editor, var sizeFolders = availableSizePercent * 65; var leaves = 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 ModFileSystem.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)) diff --git a/Penumbra/UI/ResourceWatcher/ResourceWatcher.cs b/Penumbra/UI/ResourceWatcher/ResourceWatcher.cs index 4106f75d..eede4474 100644 --- a/Penumbra/UI/ResourceWatcher/ResourceWatcher.cs +++ b/Penumbra/UI/ResourceWatcher/ResourceWatcher.cs @@ -189,7 +189,7 @@ public sealed class ResourceWatcher : IDisposable, ITab, Luna.IUiService } var maxEntries = _config.MaxResourceWatcherRecords; - if (maxEntries != DefaultMaxEntries && ImGui.IsItemHovered()) + if (maxEntries != DefaultMaxEntries && Im.Item.Hovered()) ImGui.SetTooltip($"CTRL + Right-Click to reset to default {DefaultMaxEntries}."); if (!change) diff --git a/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs b/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs index 81e0490f..5be065bb 100644 --- a/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs +++ b/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs @@ -86,7 +86,7 @@ internal sealed class ResourceWatcherTable : Table clicked |= ImUtf8.Selectable(shortPath.Span, false, ImGuiSelectableFlags.AllowItemOverlap); } - ImUtf8.HoverTooltip(path.Span); + Im.Tooltip.OnHover(path.Span); } if (clicked) diff --git a/Penumbra/UI/Tabs/ChangedItemsTab.cs b/Penumbra/UI/Tabs/ChangedItemsTab.cs index 50eb6172..1f9b12ba 100644 --- a/Penumbra/UI/Tabs/ChangedItemsTab.cs +++ b/Penumbra/UI/Tabs/ChangedItemsTab.cs @@ -45,14 +45,14 @@ public class ChangedItemsTab( .Push(ImGuiStyleVar.SelectableTextAlign, new Vector2(0.01f, 0.5f)); var skips = ImGuiClip.GetNecessarySkips(_buttonSize.Y); - using var list = ImUtf8.Table("##changedItems"u8, 3, ImGuiTableFlags.RowBg, -Vector2.One); - if (!list) + using var table = Im.Table.Begin("##changedItems"u8, 3, TableFlags.RowBackground, -Vector2.One); + if (!table) return; - const ImGuiTableColumnFlags flags = ImGuiTableColumnFlags.NoResize | ImGuiTableColumnFlags.WidthFixed; - ImUtf8.TableSetupColumn("items"u8, flags, 450 * Im.Style.GlobalScale); - ImUtf8.TableSetupColumn("mods"u8, flags, varWidth - 140 * Im.Style.GlobalScale); - ImUtf8.TableSetupColumn("id"u8, flags, 140 * Im.Style.GlobalScale); + const TableColumnFlags flags = TableColumnFlags.NoResize | TableColumnFlags.WidthFixed; + table.SetupColumn("items"u8, flags, 450 * Im.Style.GlobalScale); + table.SetupColumn("mods"u8, flags, varWidth - 140 * Im.Style.GlobalScale); + table.SetupColumn("id"u8, flags, 140 * Im.Style.GlobalScale); var items = collectionManager.Active.Current.ChangedItems; var rest = ImGuiClip.FilteredClippedDraw(items, skips, FilterChangedItem, DrawChangedItemColumn); @@ -106,7 +106,7 @@ public class ChangedItemsTab( && first is Mod mod) communicator.SelectTab.Invoke(new SelectTab.Arguments(TabType.Mods, mod)); - if (!ImGui.IsItemHovered()) + if (!Im.Item.Hovered()) return; using var _ = ImRaii.Tooltip(); diff --git a/Penumbra/UI/Tabs/Debug/CrashDataExtensions.cs b/Penumbra/UI/Tabs/Debug/CrashDataExtensions.cs index 4972ed88..509388b1 100644 --- a/Penumbra/UI/Tabs/Debug/CrashDataExtensions.cs +++ b/Penumbra/UI/Tabs/Debug/CrashDataExtensions.cs @@ -46,8 +46,8 @@ public static class CrashDataExtensions if (!tree) return; - using var table = ImRaii.Table("##characterTable", 6, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInner); + using var table = Im.Table.Begin("##characterTable"u8, 6, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInner); if (!table) return; @@ -68,8 +68,8 @@ public static class CrashDataExtensions if (!tree) return; - using var table = ImRaii.Table("##filesTable", 8, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInner); + using var table = Im.Table.Begin("##filesTable"u8, 8, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInner); if (!table) return; @@ -92,8 +92,8 @@ public static class CrashDataExtensions if (!tree) return; - using var table = ImRaii.Table("##vfxTable", 7, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInner); + using var table = Im.Table.Begin("##vfxTable"u8, 7, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInner); if (!table) return; diff --git a/Penumbra/UI/Tabs/Debug/CrashHandlerPanel.cs b/Penumbra/UI/Tabs/Debug/CrashHandlerPanel.cs index ea5c008e..247bbbe2 100644 --- a/Penumbra/UI/Tabs/Debug/CrashHandlerPanel.cs +++ b/Penumbra/UI/Tabs/Debug/CrashHandlerPanel.cs @@ -39,7 +39,7 @@ public class CrashHandlerPanel(CrashHandlerService service, Configuration config private void DrawMainData() { - using var table = ImRaii.Table("##CrashHandlerTable", 2, ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##CrashHandlerTable"u8, 2, TableFlags.SizingFixedFit); if (!table) return; diff --git a/Penumbra/UI/Tabs/Debug/DebugTab.cs b/Penumbra/UI/Tabs/Debug/DebugTab.cs index 48fac942..a9cd2374 100644 --- a/Penumbra/UI/Tabs/Debug/DebugTab.cs +++ b/Penumbra/UI/Tabs/Debug/DebugTab.cs @@ -51,7 +51,7 @@ public class Diagnostics(ServiceManager provider) : IUiService if (!ImGui.CollapsingHeader("Diagnostics")) return; - using var table = ImRaii.Table("##data", 4, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##data"u8, 4, TableFlags.RowBackground); if (!table) return; @@ -230,8 +230,8 @@ public class DebugTab : Window, ITab { if (inheritanceNode) { - using var table = ImUtf8.Table("table"u8, 3, - ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV); + using var table = Im.Table.Begin("table"u8, 3, + TableFlags.SizingFixedFit | TableFlags.RowBackground | TableFlags.BordersInnerVertical); if (table) { var max = Math.Max( @@ -243,17 +243,17 @@ public class DebugTab : Window, ITab if (i < collection.Inheritance.DirectlyInheritsFrom.Count) ImUtf8.Text(collection.Inheritance.DirectlyInheritsFrom[i].Identity.Name); else - ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, Im.Style.TextHeight)); + ImGui.Dummy(new Vector2(200 * Im.Style.GlobalScale, Im.Style.TextHeight)); ImGui.TableNextColumn(); if (i < collection.Inheritance.DirectlyInheritedBy.Count) ImUtf8.Text(collection.Inheritance.DirectlyInheritedBy[i].Identity.Name); else - ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, Im.Style.TextHeight)); + ImGui.Dummy(new Vector2(200 * Im.Style.GlobalScale, Im.Style.TextHeight)); ImGui.TableNextColumn(); if (i < collection.Inheritance.FlatHierarchy.Count) ImUtf8.Text(collection.Inheritance.FlatHierarchy[i].Identity.Name); else - ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, Im.Style.TextHeight)); + ImGui.Dummy(new Vector2(200 * Im.Style.GlobalScale, Im.Style.TextHeight)); } } } @@ -984,9 +984,9 @@ public class DebugTab : Window, ITab var slowPathCallDeltas = _shaderReplacementFixer.GetAndResetSlowPathCallDeltas(); - ImGui.TableSetupColumn("Shader Package Name", ImGuiTableColumnFlags.WidthStretch, 0.6f); - ImGui.TableSetupColumn("Materials with Modded ShPk", ImGuiTableColumnFlags.WidthStretch, 0.2f); - ImGui.TableSetupColumn("\u0394 Slow-Path Calls", ImGuiTableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("Shader Package Name"u8, TableColumnFlags.WidthStretch, 0.6f); + table.SetupColumn("Materials with Modded ShPk"u8, TableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("\u0394 Slow-Path Calls"u8, TableColumnFlags.WidthStretch, 0.2f); ImGui.TableHeadersRow(); ImGui.TableNextColumn(); @@ -1137,12 +1137,12 @@ public class DebugTab : Window, ITab ImUtf8.Text($"CI CRC32: {_crcPath.InternalName.Crc32:X8}"); ImUtf8.Text($" CRC64: {_crcPath.Crc64:X16}"); - using var table = ImUtf8.Table("table"u8, 2); + using var table = Im.Table.Begin("table"u8, 2); if (!table) return; - ImUtf8.TableSetupColumn("Hash"u8, ImGuiTableColumnFlags.WidthFixed, 18 * UiBuilder.MonoFont.GetCharAdvance('0')); - ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, 5 * UiBuilder.MonoFont.GetCharAdvance('0')); + table.SetupColumn("Hash"u8, TableColumnFlags.WidthFixed, 18 * UiBuilder.MonoFont.GetCharAdvance('0')); + table.SetupColumn("Type"u8, TableColumnFlags.WidthFixed, 5 * UiBuilder.MonoFont.GetCharAdvance('0')); ImGui.TableHeadersRow(); foreach (var (hash, type) in _rsfService.CustomCache) @@ -1166,13 +1166,13 @@ public class DebugTab : Window, ITab if (ongoingLoadCount == 0) return; - using var table = ImUtf8.Table("ongoingLoadTable"u8, 3); + using var table = Im.Table.Begin("ongoingLoadTable"u8, 3); if (!table) return; - ImUtf8.TableSetupColumn("Resource Handle"u8, ImGuiTableColumnFlags.WidthStretch, 0.2f); - ImUtf8.TableSetupColumn("Actual Path"u8, ImGuiTableColumnFlags.WidthStretch, 0.4f); - ImUtf8.TableSetupColumn("Original Path"u8, ImGuiTableColumnFlags.WidthStretch, 0.4f); + table.SetupColumn("Resource Handle"u8, TableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("Actual Path"u8, TableColumnFlags.WidthStretch, 0.4f); + table.SetupColumn("Original Path"u8, TableColumnFlags.WidthStretch, 0.4f); ImGui.TableHeadersRow(); foreach (var (handle, original) in ongoingLoads) diff --git a/Penumbra/UI/Tabs/Debug/GlobalVariablesDrawer.cs b/Penumbra/UI/Tabs/Debug/GlobalVariablesDrawer.cs index a1958c02..ad00c156 100644 --- a/Penumbra/UI/Tabs/Debug/GlobalVariablesDrawer.cs +++ b/Penumbra/UI/Tabs/Debug/GlobalVariablesDrawer.cs @@ -21,7 +21,7 @@ public unsafe class GlobalVariablesDrawer( public void Draw() { var header = ImUtf8.CollapsingHeader("Global Variables"u8); - ImUtf8.HoverTooltip("Draw information about global variables. Can provide useful starting points for a memory viewer."u8); + Im.Tooltip.OnHover("Draw information about global variables. Can provide useful starting points for a memory viewer."u8); if (!header) return; @@ -68,8 +68,7 @@ public unsafe class GlobalVariablesDrawer( if (!tree) return; - using var table = ImUtf8.Table("##CharacterUtility"u8, 7, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, - -Vector2.UnitX); + using var table = Im.Table.Begin("##CharacterUtility"u8, 7, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.UnitX); if (!table) return; @@ -115,7 +114,7 @@ public unsafe class GlobalVariablesDrawer( if (residentResources.Address == null || residentResources.Address->NumResources == 0) return; - using var table = ImUtf8.Table("##ResidentResources"u8, 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, + using var table = Im.Table.Begin("##ResidentResources"u8, 5, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.UnitX); if (!table) return; @@ -162,7 +161,7 @@ public unsafe class GlobalVariablesDrawer( ? t : CiByteString.Empty; ImUtf8.Text($"{_shownResourcesMap} / {scheduler.Scheduler->Resources.LongCount}"); - using var table = ImUtf8.Table("##SchedulerMapResources"u8, 10, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, + using var table = Im.Table.Begin("##SchedulerMapResources"u8, 10, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.UnitX); if (!table) return; @@ -213,7 +212,7 @@ public unsafe class GlobalVariablesDrawer( ? t : CiByteString.Empty; ImUtf8.Text($"{_shownResourcesList} / {scheduler.Scheduler->Resources.LongCount}"); - using var table = ImUtf8.Table("##SchedulerListResources"u8, 10, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit, + using var table = Im.Table.Begin("##SchedulerListResources"u8, 10, TableFlags.RowBackground | TableFlags.SizingFixedFit, -Vector2.UnitX); if (!table) return; diff --git a/Penumbra/UI/Tabs/Debug/RenderTargetDrawer.cs b/Penumbra/UI/Tabs/Debug/RenderTargetDrawer.cs index c9fbcbe5..c67ad43d 100644 --- a/Penumbra/UI/Tabs/Debug/RenderTargetDrawer.cs +++ b/Penumbra/UI/Tabs/Debug/RenderTargetDrawer.cs @@ -63,15 +63,15 @@ public class RenderTargetDrawer(RenderTargetHdrEnabler renderTargetHdrEnabler, D return; } - using var table = ImUtf8.Table("##RenderTargetTable"u8, 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit); + using var table = Im.Table.Begin("##RenderTargetTable"u8, 5, TableFlags.RowBackground | TableFlags.SizingFixedFit); if (!table) return; - ImUtf8.TableSetupColumn("Offset"u8, ImGuiTableColumnFlags.WidthStretch, 0.15f); - ImUtf8.TableSetupColumn("Creation Order"u8, ImGuiTableColumnFlags.WidthStretch, 0.15f); - ImUtf8.TableSetupColumn("Original Texture Format"u8, ImGuiTableColumnFlags.WidthStretch, 0.2f); - ImUtf8.TableSetupColumn("Current Texture Format"u8, ImGuiTableColumnFlags.WidthStretch, 0.2f); - ImUtf8.TableSetupColumn("Comment"u8, ImGuiTableColumnFlags.WidthStretch, 0.3f); + table.SetupColumn("Offset"u8, TableColumnFlags.WidthStretch, 0.15f); + table.SetupColumn("Creation Order"u8, TableColumnFlags.WidthStretch, 0.15f); + table.SetupColumn("Original Texture Format"u8, TableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("Current Texture Format"u8, TableColumnFlags.WidthStretch, 0.2f); + table.SetupColumn("Comment"u8, TableColumnFlags.WidthStretch, 0.3f); ImGui.TableHeadersRow(); foreach (var record in report) diff --git a/Penumbra/UI/Tabs/Debug/ShapeInspector.cs b/Penumbra/UI/Tabs/Debug/ShapeInspector.cs index 513ea517..b6c9f9e4 100644 --- a/Penumbra/UI/Tabs/Debug/ShapeInspector.cs +++ b/Penumbra/UI/Tabs/Debug/ShapeInspector.cs @@ -46,12 +46,12 @@ public class ShapeInspector(ObjectManager objects, CollectionResolver resolver) if (!treeNode1.Success || !data.ModCollection.HasCache) return; - using var table = ImUtf8.Table("##aCache"u8, 2, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##aCache"u8, 2, TableFlags.RowBackground); if (!table) return; - ImUtf8.TableSetupColumn("Attribute"u8, ImGuiTableColumnFlags.WidthFixed, 150 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Attribute"u8, TableColumnFlags.WidthFixed, 150 * Im.Style.GlobalScale); + table.SetupColumn("State"u8, TableColumnFlags.WidthStretch); ImGui.TableHeadersRow(); foreach (var (attribute, set) in data.ModCollection.MetaCache!.Atr.Data.OrderBy(a => a.Key)) @@ -68,13 +68,13 @@ public class ShapeInspector(ObjectManager objects, CollectionResolver resolver) if (!treeNode1.Success || !data.ModCollection.HasCache) return; - using var table = ImUtf8.Table("##sCache"u8, 3, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##sCache"u8, 3, TableFlags.RowBackground); if (!table) return; - ImUtf8.TableSetupColumn("Condition"u8, ImGuiTableColumnFlags.WidthFixed, 150 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Shape"u8, ImGuiTableColumnFlags.WidthFixed, 150 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("State"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("Condition"u8, TableColumnFlags.WidthFixed, 150 * Im.Style.GlobalScale); + table.SetupColumn("Shape"u8, TableColumnFlags.WidthFixed, 150 * Im.Style.GlobalScale); + table.SetupColumn("State"u8, TableColumnFlags.WidthStretch); ImGui.TableHeadersRow(); foreach (var condition in Enum.GetValues()) @@ -173,17 +173,17 @@ public class ShapeInspector(ObjectManager objects, CollectionResolver resolver) if (!treeNode2) return; - using var table = ImUtf8.Table("##shapes"u8, 7, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##shapes"u8, 7, TableFlags.RowBackground); if (!table) return; - ImUtf8.TableSetupColumn("#"u8, ImGuiTableColumnFlags.WidthFixed, 25 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Slot"u8, ImGuiTableColumnFlags.WidthFixed, 150 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Address"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 14); - ImUtf8.TableSetupColumn("Mask"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 8); - ImUtf8.TableSetupColumn("ID"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 4); - ImUtf8.TableSetupColumn("Count"u8, ImGuiTableColumnFlags.WidthFixed, 30 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Shapes"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("#"u8, TableColumnFlags.WidthFixed, 25 * Im.Style.GlobalScale); + table.SetupColumn("Slot"u8, TableColumnFlags.WidthFixed, 150 * Im.Style.GlobalScale); + table.SetupColumn("Address"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 14); + table.SetupColumn("Mask"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 8); + table.SetupColumn("ID"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 4); + table.SetupColumn("Count"u8, TableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); + table.SetupColumn("Shapes"u8, TableColumnFlags.WidthStretch); ImGui.TableHeadersRow(); @@ -230,17 +230,17 @@ public class ShapeInspector(ObjectManager objects, CollectionResolver resolver) if (!treeNode2) return; - using var table = ImUtf8.Table("##attributes"u8, 7, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##attributes"u8, 7, TableFlags.RowBackground); if (!table) return; - ImUtf8.TableSetupColumn("#"u8, ImGuiTableColumnFlags.WidthFixed, 25 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Slot"u8, ImGuiTableColumnFlags.WidthFixed, 150 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Address"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 14); - ImUtf8.TableSetupColumn("Mask"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 8); - ImUtf8.TableSetupColumn("ID"u8, ImGuiTableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 4); - ImUtf8.TableSetupColumn("Count"u8, ImGuiTableColumnFlags.WidthFixed, 30 * ImUtf8.GlobalScale); - ImUtf8.TableSetupColumn("Attributes"u8, ImGuiTableColumnFlags.WidthStretch); + table.SetupColumn("#"u8, TableColumnFlags.WidthFixed, 25 * Im.Style.GlobalScale); + table.SetupColumn("Slot"u8, TableColumnFlags.WidthFixed, 150 * Im.Style.GlobalScale); + table.SetupColumn("Address"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 14); + table.SetupColumn("Mask"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 8); + table.SetupColumn("ID"u8, TableColumnFlags.WidthFixed, UiBuilder.MonoFont.GetCharAdvance('0') * 4); + table.SetupColumn("Count"u8, TableColumnFlags.WidthFixed, 30 * Im.Style.GlobalScale); + table.SetupColumn("Attributes"u8, TableColumnFlags.WidthStretch); ImGui.TableHeadersRow(); diff --git a/Penumbra/UI/Tabs/Debug/TexHeaderDrawer.cs b/Penumbra/UI/Tabs/Debug/TexHeaderDrawer.cs index aeb8ed0a..642a2f15 100644 --- a/Penumbra/UI/Tabs/Debug/TexHeaderDrawer.cs +++ b/Penumbra/UI/Tabs/Debug/TexHeaderDrawer.cs @@ -53,7 +53,7 @@ public class TexHeaderDrawer(IDragDropManager dragDrop) : Luna.IUiService } else if (_tex != null) { - using var table = ImRaii.Table("table", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("table"u8, 2, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; diff --git a/Penumbra/UI/Tabs/EffectiveTab.cs b/Penumbra/UI/Tabs/EffectiveTab.cs index 68fe8144..7648b7a1 100644 --- a/Penumbra/UI/Tabs/EffectiveTab.cs +++ b/Penumbra/UI/Tabs/EffectiveTab.cs @@ -32,13 +32,13 @@ public class EffectiveTab(CollectionManager collectionManager, CollectionSelectH var height = Im.Style.TextHeightWithSpacing + 2 * ImGui.GetStyle().CellPadding.Y; var skips = ImGuiClip.GetNecessarySkips(height); - using var table = ImRaii.Table("##EffectiveChangesTable", 3, ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##EffectiveChangesTable"u8, 3, TableFlags.RowBackground); if (!table) return; - ImGui.TableSetupColumn("##gamePath", ImGuiTableColumnFlags.WidthFixed, _effectiveLeftTextLength); - ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, _effectiveArrowLength); - ImGui.TableSetupColumn("##file", ImGuiTableColumnFlags.WidthFixed, _effectiveRightTextLength); + table.SetupColumn("##gamePath"u8, TableColumnFlags.WidthFixed, _effectiveLeftTextLength); + table.SetupColumn(StringU8.Empty, TableColumnFlags.WidthFixed, _effectiveArrowLength); + table.SetupColumn("##file"u8, TableColumnFlags.WidthFixed, _effectiveRightTextLength); DrawEffectiveRows(collectionManager.Active.Current, skips, height, _effectiveFilePathFilter.Length > 0 || _effectiveGamePathFilter.Length > 0); diff --git a/Penumbra/UI/Tabs/ModsTab.cs b/Penumbra/UI/Tabs/ModsTab.cs index 1d6bcb2e..57b4675d 100644 --- a/Penumbra/UI/Tabs/ModsTab.cs +++ b/Penumbra/UI/Tabs/ModsTab.cs @@ -107,7 +107,7 @@ public class ModsTab( ImGuiUtil.DrawTextButton("Redraw: ", frameHeight, frameColor); } - var hovered = ImGui.IsItemHovered(); + var hovered = Im.Item.Hovered(); tutorial.OpenTutorial(BasicTutorialSteps.Redrawing); if (hovered) ImGui.SetTooltip($"The supported modifiers for '/penumbra redraw' are:\n{TutorialService.SupportedRedrawModifiers}"); @@ -155,9 +155,9 @@ public class ModsTab( } } - ImGuiUtil.HoverTooltip(lower.Length > 0 + Im.Tooltip.OnHover(lower.Length > 0 ? $"Execute '/penumbra redraw {lower}'.{additionalTooltip}" - : $"Execute '/penumbra redraw'.{additionalTooltip}", ImGuiHoveredFlags.AllowWhenDisabled); + : $"Execute '/penumbra redraw'.{additionalTooltip}", HoveredFlags.AllowWhenDisabled); } } diff --git a/Penumbra/UI/Tabs/ResourceTab.cs b/Penumbra/UI/Tabs/ResourceTab.cs index 842040b3..d36004cd 100644 --- a/Penumbra/UI/Tabs/ResourceTab.cs +++ b/Penumbra/UI/Tabs/ResourceTab.cs @@ -62,14 +62,14 @@ public class ResourceTab(Configuration config, ResourceManagerService resourceMa if (!tree || map->Count == 0) return; - using var table = ImRaii.Table("##table", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); + using var table = Im.Table.Begin("##table"u8, 4, TableFlags.SizingFixedFit | TableFlags.RowBackground); if (!table) return; - ImGui.TableSetupColumn("Hash", ImGuiTableColumnFlags.WidthFixed, _hashColumnWidth); - ImGui.TableSetupColumn("Ptr", ImGuiTableColumnFlags.WidthFixed, _hashColumnWidth); - ImGui.TableSetupColumn("Path", ImGuiTableColumnFlags.WidthFixed, _pathColumnWidth); - ImGui.TableSetupColumn("Refs", ImGuiTableColumnFlags.WidthFixed, _refsColumnWidth); + table.SetupColumn("Hash"u8, TableColumnFlags.WidthFixed, _hashColumnWidth); + table.SetupColumn("Ptr"u8, TableColumnFlags.WidthFixed, _hashColumnWidth); + table.SetupColumn("Path"u8, TableColumnFlags.WidthFixed, _pathColumnWidth); + table.SetupColumn("Refs"u8, TableColumnFlags.WidthFixed, _refsColumnWidth); ImGui.TableHeadersRow(); resourceManager.IterateResourceMap(map, (hash, r) => @@ -132,7 +132,7 @@ public class ResourceTab(Configuration config, ResourceManagerService resourceMa private void SetTableWidths() { _hashColumnWidth = 100 * Im.Style.GlobalScale; - _pathColumnWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - 300 * Im.Style.GlobalScale; + _pathColumnWidth = Im.Window.MaximumContentRegion.X - Im.Window.MinimumContentRegion.X - 300 * Im.Style.GlobalScale; _refsColumnWidth = 30 * Im.Style.GlobalScale; } } diff --git a/Penumbra/UI/Tabs/SettingsTab.cs b/Penumbra/UI/Tabs/SettingsTab.cs index af11ac9a..fbfeda24 100644 --- a/Penumbra/UI/Tabs/SettingsTab.cs +++ b/Penumbra/UI/Tabs/SettingsTab.cs @@ -611,7 +611,7 @@ public class SettingsTab : ITab, IUiService _config.Save(); } - ImUtf8.HoverTooltip(val.Description); + Im.Tooltip.OnHover(val.Description); } } @@ -699,14 +699,14 @@ public class SettingsTab : ITab, IUiService if (ImUtf8.ButtonEx("Delete all PCP Mods"u8, "Deletes all mods tagged with 'PCP' from the mod list."u8, disabled: !active)) _pcpService.CleanPcpMods(); if (!active) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking."); Im.Line.Same(); if (ImUtf8.ButtonEx("Delete all PCP Collections"u8, "Deletes all collections whose name starts with 'PCP/' from the collection list."u8, disabled: !active)) _pcpService.CleanPcpCollections(); if (!active) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking."); Checkbox("Allow Other Plugins Access to PCP Handling", "When creating or importing PCP files, other plugins can add and interpret their own data to the character.json file.", @@ -1176,7 +1176,7 @@ public class SettingsTab : ITab, IUiService var enabled = _config.DeleteModModifier.IsActive(); if (_cleanupService.Progress is not 0.0 and not 1.0) { - ImUtf8.ProgressBar((float)_cleanupService.Progress, new Vector2(200 * ImUtf8.GlobalScale, Im.Style.FrameHeight), + ImUtf8.ProgressBar((float)_cleanupService.Progress, new Vector2(200 * Im.Style.GlobalScale, Im.Style.FrameHeight), $"{_cleanupService.Progress * 100}%"); Im.Line.Same(); if (ImUtf8.Button("Cancel##FileCleanup"u8)) @@ -1192,21 +1192,21 @@ public class SettingsTab : ITab, IUiService !enabled || _cleanupService.IsRunning)) _cleanupService.CleanUnusedLocalData(); if (!enabled) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to delete files."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to delete files."); if (ImUtf8.ButtonEx("Clear Backup Files"u8, "Delete all backups of .json configuration files in your configuration folder and all backups of mod group files in your mod directory."u8, default, !enabled || _cleanupService.IsRunning)) _cleanupService.CleanBackupFiles(); if (!enabled) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to delete files."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to delete files."); if (ImUtf8.ButtonEx("Clear All Unused Settings"u8, "Remove all mod settings in all of your collections that do not correspond to currently installed mods."u8, default, !enabled || _cleanupService.IsRunning)) _cleanupService.CleanupAllUnusedSettings(); if (!enabled) - ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to remove settings."); + Im.Tooltip.OnHover(HoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to remove settings."); } /// Draw a checkbox that toggles the dalamud setting to wait for plugins on open.