Update some things for Luna.
Some checks are pending
.NET Build / build (push) Waiting to run

This commit is contained in:
Ottermandias 2025-11-01 20:56:46 +01:00
parent 5c736576fa
commit 019b9533bf
7 changed files with 297 additions and 281 deletions

2
Luna

@ -1 +1 @@
Subproject commit c872e220ebf7e8e53c6389be99a54827f0afd222 Subproject commit c8f90e537ae2b5ab1a9db53eafe3f7f5b2e68f38

@ -1 +1 @@
Subproject commit a63f6735cf4bed4f7502a022a10378607082b770 Subproject commit 18e62ab2d8b9ac7028a33707eb35f8f9c61f245a

View file

@ -1,7 +1,5 @@
using Dalamud.Bindings.ImGui;
using ImSharp; using ImSharp;
using OtterGui; using OtterGui;
using OtterGui.Raii;
using Penumbra.Collections; using Penumbra.Collections;
using Penumbra.Collections.Manager; using Penumbra.Collections.Manager;
using Penumbra.Communication; using Penumbra.Communication;
@ -77,8 +75,8 @@ public sealed class CollectionSelector : ItemSelector<ModCollection>, IDisposabl
protected override bool OnDraw(int idx) protected override bool OnDraw(int idx)
{ {
using var color = ImGuiColor.Header.Push(ColorId.SelectedCollection.Value()); using var color = ImGuiColor.Header.Push(ColorId.SelectedCollection.Value());
var ret = ImGui.Selectable(Name(Items[idx]), idx == CurrentIdx); var ret = Im.Selectable(Name(Items[idx]), idx == CurrentIdx);
using var source = ImRaii.DragDropSource(); using var source = Im.DragDrop.Source();
if (idx == CurrentIdx) if (idx == CurrentIdx)
_tutorial.OpenTutorial(BasicTutorialSteps.CurrentCollection); _tutorial.OpenTutorial(BasicTutorialSteps.CurrentCollection);
@ -86,8 +84,8 @@ public sealed class CollectionSelector : ItemSelector<ModCollection>, IDisposabl
if (source) if (source)
{ {
_dragging = Items[idx]; _dragging = Items[idx];
ImGui.SetDragDropPayload(PayloadString, null); source.SetPayload(PayloadString);
ImGui.TextUnformatted($"Assigning {Name(_dragging)} to..."); Im.Text($"Assigning {Name(_dragging)} to...");
} }
if (ret) if (ret)
@ -98,8 +96,8 @@ public sealed class CollectionSelector : ItemSelector<ModCollection>, IDisposabl
public void DragTargetAssignment(CollectionType type, ActorIdentifier identifier) public void DragTargetAssignment(CollectionType type, ActorIdentifier identifier)
{ {
using var target = ImRaii.DragDropTarget(); using var target = Im.DragDrop.Target();
if (!target.Success || _dragging == null || !ImGuiUtil.IsDropping(PayloadString)) if (!target.Success || _dragging is null || !target.IsDropping(PayloadString))
return; return;
_active.SetCollection(_dragging, type, _active.Individuals.GetGroup(identifier)); _active.SetCollection(_dragging, type, _active.Individuals.GetGroup(identifier));

View file

@ -1,8 +1,5 @@
using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Bindings.ImGui;
using ImSharp; using ImSharp;
using OtterGui.Custom;
using Penumbra.Collections;
using Penumbra.Collections.Manager; using Penumbra.Collections.Manager;
using Penumbra.Communication; using Penumbra.Communication;
using Penumbra.GameData.Actors; using Penumbra.GameData.Actors;
@ -18,6 +15,13 @@ public class IndividualAssignmentUi : IDisposable
private readonly ActorManager _actors; private readonly ActorManager _actors;
private readonly CollectionManager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly ObjectKindCombo _objectKindCombo = new(
ObjectKind.BattleNpc,
ObjectKind.EventNpc,
ObjectKind.Companion,
ObjectKind.MountType,
ObjectKind.Ornament);
private WorldCombo _worldCombo = null!; private WorldCombo _worldCombo = null!;
private NpcCombo _mountCombo = null!; private NpcCombo _mountCombo = null!;
private NpcCombo _companionCombo = null!; private NpcCombo _companionCombo = null!;
@ -61,7 +65,7 @@ public class IndividualAssignmentUi : IDisposable
public void DrawObjectKindCombo(float width) public void DrawObjectKindCombo(float width)
{ {
if (_ready && IndividualHelpers.DrawObjectKindCombo(width, _newKind, out _newKind, ObjectKinds)) if (_ready && _objectKindCombo.Draw("##objectKind"u8, ref _newKind, StringU8.Empty, width))
UpdateIdentifiersInternal(); UpdateIdentifiersInternal();
} }
@ -70,8 +74,8 @@ public class IndividualAssignmentUi : IDisposable
if (!_ready) if (!_ready)
return; return;
ImGui.SetNextItemWidth(width); Im.Item.SetNextWidth(width);
if (ImGui.InputTextWithHint("##NewCharacter", "Character Name...", ref _newCharacterName, 32)) if (Im.Input.Text("##NewCharacter"u8, ref _newCharacterName, "Character Name..."u8))
UpdateIdentifiersInternal(); UpdateIdentifiersInternal();
} }
@ -103,15 +107,6 @@ public class IndividualAssignmentUi : IDisposable
private const string AlreadyAssigned = "The Individual you specified has already been assigned a collection."; private const string AlreadyAssigned = "The Individual you specified has already been assigned a collection.";
private const string NewNpcTooltipEmpty = "Please select a valid NPC from the drop down menu first."; private const string NewNpcTooltipEmpty = "Please select a valid NPC from the drop down menu first.";
private static readonly IReadOnlyList<ObjectKind> ObjectKinds = new[]
{
ObjectKind.BattleNpc,
ObjectKind.EventNpc,
ObjectKind.Companion,
ObjectKind.MountType,
ObjectKind.Ornament,
};
private NpcCombo GetNpcCombo(ObjectKind kind) private NpcCombo GetNpcCombo(ObjectKind kind)
=> kind switch => kind switch
{ {
@ -127,11 +122,11 @@ public class IndividualAssignmentUi : IDisposable
private void SetupCombos() private void SetupCombos()
{ {
_worldCombo = new WorldCombo(_actors.Data.Worlds); _worldCombo = new WorldCombo(_actors.Data.Worlds);
_mountCombo = new NpcCombo(new StringU8("##mounts"u8), _actors.Data.Mounts); _mountCombo = new NpcCombo(new StringU8("##mounts"u8), _actors.Data.Mounts);
_companionCombo = new NpcCombo(new StringU8("##companions"u8), _actors.Data.Companions); _companionCombo = new NpcCombo(new StringU8("##companions"u8), _actors.Data.Companions);
_ornamentCombo = new NpcCombo(new StringU8("##ornaments"u8), _actors.Data.Ornaments); _ornamentCombo = new NpcCombo(new StringU8("##ornaments"u8), _actors.Data.Ornaments);
_bnpcCombo = new NpcCombo(new StringU8("##bnpc"u8), _actors.Data.BNpcs); _bnpcCombo = new NpcCombo(new StringU8("##bnpc"u8), _actors.Data.BNpcs);
_enpcCombo = new NpcCombo(new StringU8("##enpc"u8), _actors.Data.ENpcs); _enpcCombo = new NpcCombo(new StringU8("##enpc"u8), _actors.Data.ENpcs);
_ready = true; _ready = true;
} }

View file

@ -1,19 +1,17 @@
using Dalamud.Interface;
using Dalamud.Bindings.ImGui;
using ImSharp; using ImSharp;
using Luna; using Luna;
using OtterGui;
using OtterGui.Raii;
using Penumbra.Collections; using Penumbra.Collections;
using Penumbra.Collections.Manager; using Penumbra.Collections.Manager;
using Penumbra.UI.Classes; using Penumbra.UI.Classes;
namespace Penumbra.UI.CollectionTab; namespace Penumbra.UI.CollectionTab;
public class InheritanceUi(CollectionManager collectionManager, IncognitoService incognito) : Luna.IUiService public class InheritanceUi(CollectionManager collectionManager, IncognitoService incognito) : IUiService
{ {
private const int InheritedCollectionHeight = 9; private const int InheritedCollectionHeight = 9;
private const string InheritanceDragDropLabel = "##InheritanceMove";
private static ReadOnlySpan<byte> InheritanceDragDropLabel
=> "##InheritanceMove"u8;
private readonly CollectionStorage _collections = collectionManager.Storage; private readonly CollectionStorage _collections = collectionManager.Storage;
private readonly ActiveCollections _active = collectionManager.Active; private readonly ActiveCollections _active = collectionManager.Active;
@ -22,10 +20,12 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// <summary> Draw the whole inheritance block. </summary> /// <summary> Draw the whole inheritance block. </summary>
public void Draw() public void Draw()
{ {
using var id = ImRaii.PushId("##Inheritance"); using var id = Im.Id.Push("##Inheritance"u8);
ImGuiUtil.DrawColoredText(($"The {TutorialService.SelectedCollection} ", 0), ImEx.TextMultiColored("The Selected Collection "u8)
(Name(_active.Current), ColorId.SelectedCollection.Value().FullAlpha().Color), (" inherits from:", 0)); .Then(Name(_active.Current), ColorId.SelectedCollection.Value().FullAlpha().Color)
ImGui.Dummy(Vector2.One); .Then(" inherits from:"u8)
.End();
Im.Dummy(Vector2.One);
DrawCurrentCollectionInheritance(); DrawCurrentCollectionInheritance();
Im.Line.Same(); Im.Line.Same();
@ -35,8 +35,8 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
DrawNewInheritanceSelection(); DrawNewInheritanceSelection();
Im.Line.Same(); Im.Line.Same();
if (ImGui.Button("More Information about Inheritance", new Vector2(Im.ContentRegion.Available.X, 0))) if (Im.Button("More Information about Inheritance"u8, Im.ContentRegion.Available with { Y = 0 }))
ImGui.OpenPopup("InheritanceHelp"); Im.Popup.Open("InheritanceHelp"u8);
DrawHelpPopup(); DrawHelpPopup();
DelayedActions(); DelayedActions();
@ -53,38 +53,38 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
private static void DrawRightText() private static void DrawRightText()
{ {
using var group = ImRaii.Group(); using var group = Im.Group();
ImGuiUtil.TextWrapped( Im.TextWrapped(
"Inheritance is a way to use a baseline of mods across multiple collections, without needing to change all those collections if you want to add a single mod."); "Inheritance is a way to use a baseline of mods across multiple collections, without needing to change all those collections if you want to add a single mod."u8);
ImGuiUtil.TextWrapped( Im.TextWrapped(
"You can select inheritances from the combo below to add them.\nSince the order of inheritances is important, you can reorder them here via drag and drop.\nYou can also delete inheritances by dragging them onto the trash can."); "You can select inheritances from the combo below to add them.\nSince the order of inheritances is important, you can reorder them here via drag and drop.\nYou can also delete inheritances by dragging them onto the trash can."u8);
} }
private static void DrawHelpPopup() private static void DrawHelpPopup()
=> ImGuiUtil.HelpPopup("InheritanceHelp", new Vector2(1000 * Im.Style.GlobalScale, 20 * Im.Style.TextHeightWithSpacing), () => => ImEx.HelpPopup("InheritanceHelp"u8, new Vector2(1000 * Im.Style.GlobalScale, 20 * Im.Style.TextHeightWithSpacing), () =>
{ {
Im.Line.New(); Im.Line.New();
ImGui.TextUnformatted("Every mod in a collection can have three basic states: 'Enabled', 'Disabled' and 'Unconfigured'."); Im.Text("Every mod in a collection can have three basic states: 'Enabled', 'Disabled' and 'Unconfigured'."u8);
ImGui.BulletText("If the mod is 'Enabled' or 'Disabled', it does not matter if the collection inherits from other collections."); Im.BulletText("If the mod is 'Enabled' or 'Disabled', it does not matter if the collection inherits from other collections."u8);
ImGui.BulletText( Im.BulletText(
"If the mod is unconfigured, those inherited-from collections are checked in the order displayed here, including sub-inheritances."); "If the mod is unconfigured, those inherited-from collections are checked in the order displayed here, including sub-inheritances."u8);
ImGui.BulletText( Im.BulletText(
"If a collection is found in which the mod is either 'Enabled' or 'Disabled', the settings from this collection will be used."); "If a collection is found in which the mod is either 'Enabled' or 'Disabled', the settings from this collection will be used."u8);
ImGui.BulletText("If no such collection is found, the mod will be treated as disabled."); Im.BulletText("If no such collection is found, the mod will be treated as disabled."u8);
ImGui.BulletText( Im.BulletText(
"Highlighted collections in the left box are never reached because they are already checked in a sub-inheritance before."); "Highlighted collections in the left box are never reached because they are already checked in a sub-inheritance before."u8);
Im.Line.New(); Im.Line.New();
ImGui.TextUnformatted("Example"); Im.Text("Example"u8);
ImGui.BulletText("Collection A has the Bibo+ body and a Hempen Camise mod enabled."); Im.BulletText("Collection A has the Bibo+ body and a Hempen Camise mod enabled."u8);
ImGui.BulletText( Im.BulletText(
"Collection B inherits from A, leaves Bibo+ unconfigured, but has the Hempen Camise enabled with different settings than A."); "Collection B inherits from A, leaves Bibo+ unconfigured, but has the Hempen Camise enabled with different settings than A."u8);
ImGui.BulletText("Collection C also inherits from A, has Bibo+ explicitly disabled and the Hempen Camise unconfigured."); Im.BulletText("Collection C also inherits from A, has Bibo+ explicitly disabled and the Hempen Camise unconfigured."u8);
ImGui.BulletText("Collection D inherits from C and then B and leaves everything unconfigured."); Im.BulletText("Collection D inherits from C and then B and leaves everything unconfigured."u8);
using var indent = ImRaii.PushIndent(); using var indent = Im.Indent();
ImGui.BulletText("B uses Bibo+ settings from A and its own Hempen Camise settings."); Im.BulletText("B uses Bibo+ settings from A and its own Hempen Camise settings."u8);
ImGui.BulletText("C has Bibo+ disabled and uses A's Hempen Camise settings."); Im.BulletText("C has Bibo+ disabled and uses A's Hempen Camise settings."u8);
ImGui.BulletText( Im.BulletText(
"D has Bibo+ disabled and uses A's Hempen Camise settings, not B's. It traversed the collections in Order D -> (C -> A) -> (B -> A)."); "D has Bibo+ disabled and uses A's Hempen Camise settings, not B's. It traversed the collections in Order D -> (C -> A) -> (B -> A)."u8);
}); });
@ -94,15 +94,15 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// </summary> /// </summary>
private void DrawInheritedChildren(ModCollection collection) private void DrawInheritedChildren(ModCollection collection)
{ {
using var id = ImRaii.PushId(collection.Identity.Index); using var id = Im.Id.Push(collection.Identity.Index);
using var indent = ImRaii.PushIndent(); using var indent = Im.Indent();
// Get start point for the lines (top of the selector). // Get start point for the lines (top of the selector).
// Tree line stuff. // Tree line stuff.
var lineStart = ImGui.GetCursorScreenPos(); var lineStart = Im.Cursor.ScreenPosition;
var offsetX = -ImGui.GetStyle().IndentSpacing + ImGui.GetTreeNodeToLabelSpacing() / 2; var offsetX = -Im.Style.IndentSpacing + Im.Style.TreeNodeToLabelSpacing / 2;
var drawList = ImGui.GetWindowDrawList(); var drawList = Im.Window.DrawList.Shape;
var lineSize = Math.Max(0, ImGui.GetStyle().IndentSpacing - 9 * Im.Style.GlobalScale); var lineSize = Math.Max(0, Im.Style.IndentSpacing - 9 * Im.Style.GlobalScale);
lineStart.X += offsetX; lineStart.X += offsetX;
lineStart.Y -= 2 * Im.Style.GlobalScale; lineStart.Y -= 2 * Im.Style.GlobalScale;
var lineEnd = lineStart; var lineEnd = lineStart;
@ -115,9 +115,9 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
_seenInheritedCollections.Contains(inheritance)); _seenInheritedCollections.Contains(inheritance));
_seenInheritedCollections.Add(inheritance); _seenInheritedCollections.Add(inheritance);
ImRaii.TreeNode($"{Name(inheritance)}###{inheritance.Identity.Id}", Im.Tree.Node($"{Name(inheritance)}###{inheritance.Identity.Id}",
ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.Bullet); TreeNodeFlags.NoTreePushOnOpen | TreeNodeFlags.Leaf | TreeNodeFlags.Bullet).Dispose();
var (minRect, maxRect) = (ImGui.GetItemRectMin(), ImGui.GetItemRectMax()); var (minRect, maxRect) = (Im.Item.UpperLeftCorner, Im.Item.LowerRightCorner);
DrawInheritanceTreeClicks(inheritance, false); DrawInheritanceTreeClicks(inheritance, false);
// Tree line stuff. // Tree line stuff.
@ -126,13 +126,13 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
// Draw the notch and increase the line length. // Draw the notch and increase the line length.
var midPoint = (minRect.Y + maxRect.Y) / 2f - 1f; var midPoint = (minRect.Y + maxRect.Y) / 2f - 1f;
drawList.AddLine(lineStart with { Y = midPoint }, new Vector2(lineStart.X + lineSize, midPoint), Colors.MetaInfoText, drawList.Line(lineStart with { Y = midPoint }, new Vector2(lineStart.X + lineSize, midPoint), Colors.MetaInfoText,
Im.Style.GlobalScale); Im.Style.GlobalScale);
lineEnd.Y = midPoint; lineEnd.Y = midPoint;
} }
// Finally, draw the folder line. // Finally, draw the folder line.
drawList.AddLine(lineStart, lineEnd, Colors.MetaInfoText, Im.Style.GlobalScale); drawList.Line(lineStart, lineEnd, Colors.MetaInfoText, Im.Style.GlobalScale);
} }
/// <summary> Draw a single primary inherited collection. </summary> /// <summary> Draw a single primary inherited collection. </summary>
@ -141,7 +141,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
using var color = ImGuiColor.Text.Push(ColorId.HandledConflictMod.Value(), using var color = ImGuiColor.Text.Push(ColorId.HandledConflictMod.Value(),
_seenInheritedCollections.Contains(collection)); _seenInheritedCollections.Contains(collection));
_seenInheritedCollections.Add(collection); _seenInheritedCollections.Add(collection);
using var tree = ImRaii.TreeNode($"{Name(collection)}###{collection.Identity.Name}", ImGuiTreeNodeFlags.NoTreePushOnOpen); using var tree = Im.Tree.Node($"{Name(collection)}###{collection.Identity.Name}", TreeNodeFlags.NoTreePushOnOpen);
color.Pop(); color.Pop();
DrawInheritanceTreeClicks(collection, true); DrawInheritanceTreeClicks(collection, true);
DrawInheritanceDropSource(collection); DrawInheritanceDropSource(collection);
@ -157,7 +157,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// <summary> Draw the list box containing the current inheritance information. </summary> /// <summary> Draw the list box containing the current inheritance information. </summary>
private void DrawCurrentCollectionInheritance() private void DrawCurrentCollectionInheritance()
{ {
using var list = ImRaii.ListBox("##inheritanceList", using var list = Im.ListBox.Begin("##inheritanceList"u8,
new Vector2(UiHelpers.InputTextMinusButton, Im.Style.TextHeightWithSpacing * InheritedCollectionHeight)); new Vector2(UiHelpers.InputTextMinusButton, Im.Style.TextHeightWithSpacing * InheritedCollectionHeight));
if (!list) if (!list)
return; return;
@ -176,11 +176,10 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
// Prevent hovering from highlighting the button. // Prevent hovering from highlighting the button.
using var color = ImGuiColor.ButtonActive.Push(buttonColor) using var color = ImGuiColor.ButtonActive.Push(buttonColor)
.Push(ImGuiColor.ButtonHovered, buttonColor); .Push(ImGuiColor.ButtonHovered, buttonColor);
ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), size, ImEx.Icon.Button(LunaStyle.DeleteIcon, "Drag primary inheritance here to remove it from the list."u8, size);
"Drag primary inheritance here to remove it from the list.", false, true);
using var target = ImRaii.DragDropTarget(); using var target = Im.DragDrop.Target();
if (target.Success && ImGuiUtil.IsDropping(InheritanceDragDropLabel)) if (target.Success && target.IsDropping(InheritanceDragDropLabel))
_inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(_movedInheritance!), -1); _inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(_movedInheritance!), -1);
} }
@ -228,8 +227,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
InheritanceManager.ValidInheritance.Circle => "Inheriting from this collection would lead to cyclic inheritance.", InheritanceManager.ValidInheritance.Circle => "Inheriting from this collection would lead to cyclic inheritance.",
_ => string.Empty, _ => string.Empty,
}; };
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Plus.ToIconString(), UiHelpers.IconButtonSize, tt, if (ImEx.Icon.Button(LunaStyle.AddObjectIcon, tt, inheritance is not InheritanceManager.ValidInheritance.Valid)
inheritance != InheritanceManager.ValidInheritance.Valid, true)
&& _inheritance.AddInheritance(_active.Current, _newInheritance!)) && _inheritance.AddInheritance(_active.Current, _newInheritance!))
_newInheritance = null; _newInheritance = null;
@ -243,11 +241,11 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// </summary> /// </summary>
private void DrawNewInheritanceCombo() private void DrawNewInheritanceCombo()
{ {
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton); Im.Item.SetNextWidth(UiHelpers.InputTextMinusButton);
_newInheritance ??= _collections.FirstOrDefault(c _newInheritance ??= _collections.FirstOrDefault(c
=> c != _active.Current && !_active.Current.Inheritance.DirectlyInheritsFrom.Contains(c)) => c != _active.Current && !_active.Current.Inheritance.DirectlyInheritsFrom.Contains(c))
?? ModCollection.Empty; ?? ModCollection.Empty;
using var combo = ImRaii.Combo("##newInheritance", Name(_newInheritance)); using var combo = Im.Combo.Begin("##newInheritance"u8, Name(_newInheritance));
if (!combo) if (!combo)
return; return;
@ -255,7 +253,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
.Where(c => InheritanceManager.CheckValidInheritance(_active.Current, c) == InheritanceManager.ValidInheritance.Valid) .Where(c => InheritanceManager.CheckValidInheritance(_active.Current, c) == InheritanceManager.ValidInheritance.Valid)
.OrderBy(c => c.Identity.Name)) .OrderBy(c => c.Identity.Name))
{ {
if (ImGui.Selectable(Name(collection), _newInheritance == collection)) if (Im.Selectable(Name(collection), _newInheritance == collection))
_newInheritance = collection; _newInheritance = collection;
} }
} }
@ -266,8 +264,8 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// </summary> /// </summary>
private void DrawInheritanceDropTarget(ModCollection collection) private void DrawInheritanceDropTarget(ModCollection collection)
{ {
using var target = ImRaii.DragDropTarget(); using var target = Im.DragDrop.Target();
if (!target.Success || !ImGuiUtil.IsDropping(InheritanceDragDropLabel)) if (!target.Success || !target.IsDropping(InheritanceDragDropLabel))
return; return;
if (_movedInheritance != null) if (_movedInheritance != null)
@ -284,13 +282,13 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// <summary> Move an inherited collection. </summary> /// <summary> Move an inherited collection. </summary>
private void DrawInheritanceDropSource(ModCollection collection) private void DrawInheritanceDropSource(ModCollection collection)
{ {
using var source = ImRaii.DragDropSource(); using var source = Im.DragDrop.Source();
if (!source) if (!source)
return; return;
ImGui.SetDragDropPayload(InheritanceDragDropLabel, null); source.SetPayload(InheritanceDragDropLabel);
_movedInheritance = collection; _movedInheritance = collection;
ImGui.TextUnformatted($"Moving {(_movedInheritance != null ? Name(_movedInheritance) : "Unknown")}..."); Im.Text($"Moving {(_movedInheritance != null ? Name(_movedInheritance) : "Unknown")}...");
} }
/// <summary> /// <summary>
@ -300,16 +298,16 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
/// </summary> /// </summary>
private void DrawInheritanceTreeClicks(ModCollection collection, bool withDelete) private void DrawInheritanceTreeClicks(ModCollection collection, bool withDelete)
{ {
if (ImGui.GetIO().KeyCtrl && Im.Item.RightClicked()) if (Im.Io.KeyControl && Im.Item.RightClicked())
{ {
if (withDelete && ImGui.GetIO().KeyShift) if (withDelete && Im.Io.KeyShift)
_inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(collection), -1); _inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(collection), -1);
else else
_newCurrentCollection = collection; _newCurrentCollection = collection;
} }
ImGuiUtil.HoverTooltip($"Control + Right-Click to switch the {TutorialService.SelectedCollection} to this one." Im.Tooltip.OnHover(
+ (withDelete ? "\nControl + Shift + Right-Click to remove this inheritance." : string.Empty)); $"Control + Right-Click to switch the {TutorialService.SelectedCollection} to this one.{(withDelete ? "\nControl + Shift + Right-Click to remove this inheritance."u8 : StringU8.Empty)}");
} }
private string Name(ModCollection collection) private string Name(ModCollection collection)

View file

@ -0,0 +1,25 @@
using Dalamud.Game.ClientState.Objects.Enums;
using ImSharp;
namespace Penumbra.UI.CollectionTab;
public sealed class ObjectKindCombo(params IReadOnlyList<ObjectKind> kinds) : SimpleFilterCombo<ObjectKind>(SimpleFilterType.None)
{
public override StringU8 DisplayString(in ObjectKind value)
=> value switch
{
ObjectKind.None => new StringU8("Unknown"u8),
ObjectKind.BattleNpc => new StringU8("Battle NPC"u8),
ObjectKind.EventNpc => new StringU8("Event NPC"u8),
ObjectKind.MountType => new StringU8("Mount"u8),
ObjectKind.Companion => new StringU8("Companion"u8),
ObjectKind.Ornament => new StringU8("Accessory"u8),
_ => new StringU8($"{value}"),
};
public override string FilterString(in ObjectKind value)
=> string.Empty;
public override IEnumerable<ObjectKind> GetBaseItems()
=> kinds;
}

View file

@ -12,7 +12,7 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
=> "EditDesc"u8; => "EditDesc"u8;
private bool _hasBeenEdited; private bool _hasBeenEdited;
private string _description = string.Empty; private StringU8 _description = StringU8.Empty;
private object? _current; private object? _current;
private bool _opened; private bool _opened;
@ -22,7 +22,7 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
_current = mod; _current = mod;
_opened = true; _opened = true;
_hasBeenEdited = false; _hasBeenEdited = false;
_description = mod.Description; _description = new StringU8(mod.Description);
} }
public void Open(IModGroup group) public void Open(IModGroup group)
@ -30,7 +30,7 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
_current = group; _current = group;
_opened = true; _opened = true;
_hasBeenEdited = false; _hasBeenEdited = false;
_description = group.Description; _description = new StringU8(group.Description);
} }
public void Open(IModOption option) public void Open(IModOption option)
@ -38,7 +38,7 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
_current = option; _current = option;
_opened = true; _opened = true;
_hasBeenEdited = false; _hasBeenEdited = false;
_description = option.Description; _description = new StringU8(option.Description);
} }
public void Draw() public void Draw()
@ -60,8 +60,8 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
if (Im.Window.Appearing) if (Im.Window.Appearing)
Im.Keyboard.SetFocusHere(); Im.Keyboard.SetFocusHere();
ImEx.InputOnDeactivation.MultiLine("##editDescription"u8, _description, out _description, inputSize); if (Im.Input.MultiLine("##editDescription"u8, ref _description, inputSize))
_hasBeenEdited |= Im.Item.Edited; _hasBeenEdited = true;
UiHelpers.DefaultLineSpace(); UiHelpers.DefaultLineSpace();
var buttonSize = new Vector2(Im.Style.GlobalScale * 100, 0); var buttonSize = new Vector2(Im.Style.GlobalScale * 100, 0);
@ -83,12 +83,12 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
switch (_current) switch (_current)
{ {
case Mod mod: modManager.DataEditor.ChangeModDescription(mod, _description); break; case Mod mod: modManager.DataEditor.ChangeModDescription(mod, _description.ToString()); break;
case IModGroup group: modManager.OptionEditor.ChangeGroupDescription(group, _description); break; case IModGroup group: modManager.OptionEditor.ChangeGroupDescription(group, _description.ToString()); break;
case IModOption option: modManager.OptionEditor.ChangeOptionDescription(option, _description); break; case IModOption option: modManager.OptionEditor.ChangeOptionDescription(option, _description.ToString()); break;
} }
_description = string.Empty; _description = StringU8.Empty;
_hasBeenEdited = false; _hasBeenEdited = false;
Im.Popup.CloseCurrent(); Im.Popup.CloseCurrent();
} }
@ -98,7 +98,7 @@ public class DescriptionEditPopup(ModManager modManager) : Luna.IUiService
if (!Im.Button("Cancel"u8, buttonSize) && !Im.Keyboard.IsPressed(Key.Escape)) if (!Im.Button("Cancel"u8, buttonSize) && !Im.Keyboard.IsPressed(Key.Escape))
return; return;
_description = string.Empty; _description = StringU8.Empty;
_hasBeenEdited = false; _hasBeenEdited = false;
Im.Popup.CloseCurrent(); Im.Popup.CloseCurrent();
} }