修复问题

This commit is contained in:
ww-rm
2025-04-19 01:32:19 +08:00
parent 16739c39d6
commit cd86155878
12 changed files with 27 additions and 35 deletions

View File

@@ -194,7 +194,7 @@
tabPage_Slot.Name = "tabPage_Slot"; tabPage_Slot.Name = "tabPage_Slot";
tabPage_Slot.Size = new Size(364, 370); tabPage_Slot.Size = new Size(364, 370);
tabPage_Slot.TabIndex = 6; tabPage_Slot.TabIndex = 6;
tabPage_Slot.Text = "槽"; tabPage_Slot.Text = "槽";
// //
// propertyGrid_Slot // propertyGrid_Slot
// //

View File

@@ -64,7 +64,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
//private SkeletonClipping clipping = new(); //private SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -63,7 +63,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -60,7 +60,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -67,7 +67,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -62,7 +62,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -62,7 +62,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -62,7 +62,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
private readonly SkeletonClipping clipping = new(); private readonly SkeletonClipping clipping = new();
/// <summary> /// <summary>
/// 所有槽在所有皮肤中可用的附件集合 /// 所有槽在所有皮肤中可用的附件集合
/// </summary> /// </summary>
private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = []; private readonly Dictionary<string, Dictionary<string, Attachment>> slotAttachments = [];

View File

@@ -325,7 +325,7 @@ namespace SpineViewer.Spine
protected bool debugClippings = false; protected bool debugClippings = false;
/// <summary> /// <summary>
/// 所有槽下可用的附件名 /// 所有槽下可用的附件名
/// </summary> /// </summary>
public FrozenDictionary<string, ImmutableArray<string>> SlotAttachmentNames { get; protected set; } public FrozenDictionary<string, ImmutableArray<string>> SlotAttachmentNames { get; protected set; }
@@ -340,13 +340,13 @@ namespace SpineViewer.Spine
public ImmutableArray<string> AnimationNames { get; protected set; } public ImmutableArray<string> AnimationNames { get; protected set; }
/// <summary> /// <summary>
/// 获取某个槽当前加载的附件 /// 获取某个槽当前加载的附件
/// </summary> /// </summary>
public string GetSlotAttachment(string slot) { lock (_lock) return getSlotAttachment(slot); } public string GetSlotAttachment(string slot) { lock (_lock) return getSlotAttachment(slot); }
protected abstract string getSlotAttachment(string slot); protected abstract string getSlotAttachment(string slot);
/// <summary> /// <summary>
/// 设置某个槽当前加载的附件 /// 设置某个槽当前加载的附件
/// </summary> /// </summary>
public void SetSlotAttachment(string slot, string name) { lock (_lock) setSlotAttachment(slot, name); } public void SetSlotAttachment(string slot, string name) { lock (_lock) setSlotAttachment(slot, name); }
protected abstract void setSlotAttachment(string slot, string name); protected abstract void setSlotAttachment(string slot, string name);

View File

@@ -186,16 +186,12 @@ namespace SpineViewer.Spine.SpineView
{ {
return new StandardValuesCollection(tracks.Spine.AnimationNames); return new StandardValuesCollection(tracks.Spine.AnimationNames);
} }
else if (context?.Instance is SpineAnimationProperty[] animTracks) else if (context?.Instance is object[] instances)
{ {
// XXX: 莫名其妙好了, 不是 object[] 类型是具体的类型了 IEnumerable<string> common = [];
if (animTracks.Length > 0) foreach (SpineAnimationProperty prop in instances.Where(inst => inst is SpineAnimationProperty))
{ common = common.Union(prop.Spine.AnimationNames);
IEnumerable<string> common = animTracks[0].Spine.AnimationNames; return new StandardValuesCollection(common.ToArray());
foreach (var t in animTracks.Skip(1))
common = common.Union(t.Spine.AnimationNames);
return new StandardValuesCollection(common.ToArray());
}
} }
return base.GetStandardValues(context); return base.GetStandardValues(context);
} }

View File

@@ -28,7 +28,7 @@ namespace SpineViewer.Spine.SpineView
public SpineSkinProperty Skin { get; } = new(spine); public SpineSkinProperty Skin { get; } = new(spine);
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
[DisplayName("皮肤")] [DisplayName("插槽")]
public SpineSlotProperty Slot { get; } = new(spine); public SpineSlotProperty Slot { get; } = new(spine);
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]

View File

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace SpineViewer.Spine.SpineView namespace SpineViewer.Spine.SpineView
{ {
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示槽附件加载情况包装类 /// 用于在 PropertyGrid 上显示槽附件加载情况包装类
/// </summary> /// </summary>
public class SpineSlotProperty(SpineObject spine) : ICustomTypeDescriptor public class SpineSlotProperty(SpineObject spine) : ICustomTypeDescriptor
{ {
@@ -18,7 +18,7 @@ namespace SpineViewer.Spine.SpineView
public SpineObject Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 显示所有槽集合 /// 显示所有槽集合
/// </summary> /// </summary>
public override string ToString() => $"[{string.Join(", ", Spine.SlotAttachmentNames.Keys)}]"; public override string ToString() => $"[{string.Join(", ", Spine.SlotAttachmentNames.Keys)}]";
@@ -56,14 +56,14 @@ namespace SpineViewer.Spine.SpineView
foreach (var slotName in Spine.SlotAttachmentNames.Keys) foreach (var slotName in Spine.SlotAttachmentNames.Keys)
{ {
if (!pdCache.TryGetValue(slotName, out var pd)) if (!pdCache.TryGetValue(slotName, out var pd))
pdCache[slotName] = pd =new SlotPropertyDescriptor(slotName, [new DisplayNameAttribute($"{slotName}")]); pdCache[slotName] = pd = new SlotPropertyDescriptor(slotName, [new DisplayNameAttribute($"{slotName}")]);
props.Add(pd); props.Add(pd);
} }
return props; return props;
} }
/// <summary> /// <summary>
/// 槽属性描述符, 实现对属性的读取和赋值 /// 槽属性描述符, 实现对属性的读取和赋值
/// </summary> /// </summary>
internal class SlotPropertyDescriptor(string name, Attribute[]? attributes) : PropertyDescriptor(name, attributes) internal class SlotPropertyDescriptor(string name, Attribute[]? attributes) : PropertyDescriptor(name, attributes)
{ {
@@ -153,19 +153,15 @@ namespace SpineViewer.Spine.SpineView
if (slots.Spine.SlotAttachmentNames.TryGetValue(pd.Name, out var names)) if (slots.Spine.SlotAttachmentNames.TryGetValue(pd.Name, out var names))
return new StandardValuesCollection(names); return new StandardValuesCollection(names);
} }
else if (context?.Instance is SpineSlotProperty[] spinesSlots) else if (context?.Instance is object[] instances)
{ {
// XXX: 莫名其妙好了, 不是 object[] 类型是具体的类型了 IEnumerable<string> common = [];
if (spinesSlots.Length > 0) foreach (SpineSlotProperty prop in instances.Where(inst => inst is SpineSlotProperty))
{ {
IEnumerable<string> common = []; if (prop.Spine.SlotAttachmentNames.TryGetValue(pd.Name, out var names))
foreach (var t in spinesSlots) common = common.Union(names);
{
if (t.Spine.SlotAttachmentNames.TryGetValue(pd.Name, out var names))
common = common.Union(names);
}
return new StandardValuesCollection(common.ToArray());
} }
return new StandardValuesCollection(common.ToArray());
} }
} }
return base.GetStandardValues(context); return base.GetStandardValues(context);