Added gesture support

Added flag to indicate item is a link (this is for a special exception for "nostrip")
This commit is contained in:
nooperation
2025-08-27 01:02:54 -04:00
parent 24d65d3c50
commit aa76dcbeff
6 changed files with 34 additions and 15 deletions

View File

@@ -426,7 +426,7 @@ namespace LibreMetaverse.RLV
{
foreach (var item in kvp.Value)
{
if (item.WornOn != null || item.AttachedTo != null)
if (item.WornOn != null || item.AttachedTo != null || item.GestureState == RlvGestureState.Active)
{
foundItems.Add(item);
}
@@ -435,7 +435,7 @@ namespace LibreMetaverse.RLV
foreach (var kvp in ExternalItems)
{
if (kvp.Value.WornOn != null || kvp.Value.AttachedTo != null)
if (kvp.Value.WornOn != null || kvp.Value.AttachedTo != null || kvp.Value.GestureState == RlvGestureState.Active)
{
foundItems.Add(kvp.Value);
}

View File

@@ -151,7 +151,7 @@ namespace LibreMetaverse.RLV
private bool CanRemAttachItem(RlvInventoryItem item, bool enforceNostrip, bool enforceRestrictions)
{
if (item.WornOn == null && item.AttachedTo == null)
if (item.WornOn == null && item.AttachedTo == null && item.GestureState != RlvGestureState.Active)
{
return false;
}
@@ -161,7 +161,9 @@ namespace LibreMetaverse.RLV
return false;
}
if (enforceNostrip && item.Folder != null && item.Folder.Name.ToLowerInvariant().Contains("nostrip"))
// Special exception: If a folder with (nostrip) contains inventory links to other items, those linked items can still
// be removed. Only the objects actual parent folder or the actual item itself counts.
if (enforceNostrip && !item.IsLink && item.Folder != null && item.Folder.Name.ToLowerInvariant().Contains("nostrip"))
{
return false;
}
@@ -199,7 +201,7 @@ namespace LibreMetaverse.RLV
foreach (var item in folder.Items)
{
if (item.AttachedTo != null || item.WornOn != null)
if (item.AttachedTo != null || item.WornOn != null || item.GestureState == RlvGestureState.Active)
{
continue;
}
@@ -263,7 +265,7 @@ namespace LibreMetaverse.RLV
{
foreach (var item in items)
{
if (item.AttachedTo == null && item.WornOn == null)
if (item.AttachedTo == null && item.WornOn == null && item.GestureState != RlvGestureState.Active)
{
continue;
}

View File

@@ -0,0 +1,8 @@
namespace LibreMetaverse.RLV
{
public enum RlvGestureState
{
Inactive,
Active
}
}

View File

@@ -168,7 +168,6 @@ namespace LibreMetaverse.RLV
}
}
if (specificType.HasValue)
{
if (attachedTypes.Contains(specificType.Value))
@@ -440,7 +439,7 @@ namespace LibreMetaverse.RLV
}
private static void GetInvWornInfo_Internal(RlvSharedFolder folder, bool recursive, ref int totalItems, ref int totalItemsWorn)
{
totalItemsWorn += folder.Items.Count(n => n.AttachedTo != null || n.WornOn != null);
totalItemsWorn += folder.Items.Count(n => n.AttachedTo != null || n.WornOn != null || n.GestureState == RlvGestureState.Active);
totalItems += folder.Items.Count;
if (recursive)

View File

@@ -8,20 +8,24 @@ namespace LibreMetaverse.RLV
public RlvSharedFolder? Folder { get; }
public Guid? FolderId { get; }
public string Name { get; set; }
public bool IsLink { get; set; }
public RlvWearableType? WornOn { get; set; }
public RlvAttachmentPoint? AttachedTo { get; set; }
public Guid? AttachedPrimId { get; set; }
public RlvGestureState? GestureState { get; set; }
/// <summary>
/// Creates an inventory item associated with an external folder
/// </summary>
/// <param name="id">Item ID</param>
/// <param name="name">Item Name</param>
/// <param name="isLink">Item is an item link</param>
/// <param name="externalFolderId">ID of the external folder containing this item</param>
/// <param name="attachedTo">Attachment point if the item is attached</param>
/// <param name="attachedPrimId">ID of the attached prim</param>
/// <param name="wornOn">Wearable type if the item is worn</param>
public RlvInventoryItem(Guid id, string name, Guid? externalFolderId, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn)
/// <param name="gestureState">Gesture state if item is a gesture, otherwise null</param>
public RlvInventoryItem(Guid id, string name, bool isLink, Guid? externalFolderId, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn, RlvGestureState? gestureState)
{
if (string.IsNullOrEmpty(name))
{
@@ -29,15 +33,17 @@ namespace LibreMetaverse.RLV
}
Name = name;
IsLink = isLink;
AttachedTo = attachedTo;
WornOn = wornOn;
Id = id;
Folder = null;
FolderId = externalFolderId;
AttachedPrimId = attachedPrimId;
GestureState = gestureState;
}
internal RlvInventoryItem(Guid id, string name, RlvSharedFolder folder, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn)
internal RlvInventoryItem(Guid id, string name, bool isLink, RlvSharedFolder folder, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn, RlvGestureState? gestureState)
{
if (string.IsNullOrEmpty(name))
{
@@ -49,12 +55,14 @@ namespace LibreMetaverse.RLV
}
Name = name;
IsLink = isLink;
AttachedTo = attachedTo;
WornOn = wornOn;
Id = id;
Folder = folder ?? throw new ArgumentException("Folder cannot be null", nameof(folder));
FolderId = folder.Id;
AttachedPrimId = attachedPrimId;
GestureState = gestureState;
}
public override string ToString()

View File

@@ -50,18 +50,20 @@ namespace LibreMetaverse.RLV
/// </summary>
/// <param name="id">Item ID</param>
/// <param name="name">Item Name</param>
/// <param name="attachedTo">Item attachment point if attached</param>
/// <param name="attachedPrimId">ID of the attached prim</param>
/// <param name="wornOn">Item wearable type if worn</param>
/// <param name="isLink">Item is an item link</param>
/// <param name="attachedTo">Item attachment point if attached, null if not attached</param>
/// <param name="attachedPrimId">ID of the attached prim, null if not attached</param>
/// <param name="wornOn">Item wearable type if worn, null if not a wearable</param>
/// <param name="gestureState">Gesture state, or null if this is not a gesture</param>
/// <returns>Newly added item</returns>
public RlvInventoryItem AddItem(Guid id, string name, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn)
public RlvInventoryItem AddItem(Guid id, string name, bool isLink, RlvAttachmentPoint? attachedTo, Guid? attachedPrimId, RlvWearableType? wornOn, RlvGestureState? gestureState)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Name cannot be null or empty", nameof(name));
}
var newItem = new RlvInventoryItem(id, name, this, attachedTo, attachedPrimId, wornOn);
var newItem = new RlvInventoryItem(id, name, isLink, this, attachedTo, attachedPrimId, wornOn, gestureState);
_items.Add(newItem);
return newItem;