修复问题

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.Size = new Size(364, 370);
tabPage_Slot.TabIndex = 6;
tabPage_Slot.Text = "槽";
tabPage_Slot.Text = "槽";
//
// propertyGrid_Slot
//

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -325,7 +325,7 @@ namespace SpineViewer.Spine
protected bool debugClippings = false;
/// <summary>
/// 所有槽下可用的附件名
/// 所有槽下可用的附件名
/// </summary>
public FrozenDictionary<string, ImmutableArray<string>> SlotAttachmentNames { get; protected set; }
@@ -340,13 +340,13 @@ namespace SpineViewer.Spine
public ImmutableArray<string> AnimationNames { get; protected set; }
/// <summary>
/// 获取某个槽当前加载的附件
/// 获取某个槽当前加载的附件
/// </summary>
public string GetSlotAttachment(string slot) { lock (_lock) return getSlotAttachment(slot); }
protected abstract string getSlotAttachment(string slot);
/// <summary>
/// 设置某个槽当前加载的附件
/// 设置某个槽当前加载的附件
/// </summary>
public void SetSlotAttachment(string slot, string name) { lock (_lock) setSlotAttachment(slot, 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);
}
else if (context?.Instance is SpineAnimationProperty[] animTracks)
else if (context?.Instance is object[] instances)
{
// XXX: 莫名其妙好了, 不是 object[] 类型是具体的类型了
if (animTracks.Length > 0)
{
IEnumerable<string> common = animTracks[0].Spine.AnimationNames;
foreach (var t in animTracks.Skip(1))
common = common.Union(t.Spine.AnimationNames);
return new StandardValuesCollection(common.ToArray());
}
IEnumerable<string> common = [];
foreach (SpineAnimationProperty prop in instances.Where(inst => inst is SpineAnimationProperty))
common = common.Union(prop.Spine.AnimationNames);
return new StandardValuesCollection(common.ToArray());
}
return base.GetStandardValues(context);
}

View File

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

View File

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