457 lines
No EOL
14 KiB
C#
457 lines
No EOL
14 KiB
C#
using System.Collections.Generic;
|
|
using System.Xml;
|
|
using System;
|
|
using System.Drawing.Design;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms.Design;
|
|
using System.Windows.Forms;
|
|
using System.Globalization;
|
|
|
|
namespace JD.Serialization
|
|
{
|
|
public class EditorContext
|
|
{
|
|
public static object CurrentActiveObject { get; set; }
|
|
}
|
|
|
|
public class BoneNameEditor : UITypeEditor, IDisposable
|
|
{
|
|
private ComboBox cb;
|
|
|
|
public BoneNameEditor()
|
|
{
|
|
|
|
}
|
|
|
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
|
{
|
|
return UITypeEditorEditStyle.DropDown;
|
|
}
|
|
|
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
|
{
|
|
if ((context != null) && (provider != null))
|
|
{
|
|
IWindowsFormsEditorService editorService =
|
|
(IWindowsFormsEditorService)
|
|
provider.GetService(typeof(IWindowsFormsEditorService));
|
|
if (editorService != null && EditorContext.CurrentActiveObject != null)
|
|
{
|
|
|
|
cb = new ComboBox();
|
|
|
|
Actor_Template template = (Actor_Template)EditorContext.CurrentActiveObject;
|
|
if (template != null)
|
|
{
|
|
AnimLightComponent_Template animComponent = (AnimLightComponent_Template)template.getComponent(typeof(AnimLightComponent_Template));
|
|
if (animComponent == null)
|
|
{
|
|
animComponent = (AnimLightComponent_Template)template.getComponent(typeof(AnimatedComponent_Template));
|
|
}
|
|
if (animComponent != null)
|
|
{
|
|
List<string> names = animComponent.getBoneNames();
|
|
|
|
string curValue = value.ToString();
|
|
|
|
int selectedindex = 0;
|
|
|
|
int index = names.FindIndex(delegate(string s) { return s.ToLower() == curValue.ToLower(); });
|
|
if (index >= 0 )
|
|
{
|
|
selectedindex = index;
|
|
}
|
|
|
|
cb.Items.AddRange(names.ToArray());
|
|
|
|
cb.SelectedIndex = selectedindex;
|
|
|
|
Type t = context.GetType();
|
|
object instance = context.Instance;
|
|
IContainer c = context.Container;
|
|
|
|
editorService.DropDownControl(cb);
|
|
|
|
return cb.SelectedItem;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return base.EditValue(context, provider, value);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
cb?.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
public partial class AnimLightComponent_Template : GraphicComponent_Template
|
|
{
|
|
[Browsable(false)]
|
|
public SkeletonFile SkeletonFile { get; set; }
|
|
|
|
public AnimLightComponent_Template()
|
|
{
|
|
}
|
|
|
|
public List<string> getBoneNames()
|
|
{
|
|
if (SkeletonFile == null)
|
|
{
|
|
SkeletonFile = new SkeletonFile(AnimSet.AnimPackage.Skeleton);
|
|
}
|
|
|
|
if (SkeletonFile != null)
|
|
return SkeletonFile.GetBoneNames();
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public partial class AnimMarkerEvent
|
|
{
|
|
public Vec3d Pos { get; set; }
|
|
public string UID { get; set; }
|
|
public AnimMarkerEvent(XmlNode node)
|
|
{
|
|
Pos = new Vec3d();
|
|
UID = string.Empty;
|
|
|
|
string name = Name.ToString();
|
|
Name = XMLHelper.getNodeValue("Name", node, name);
|
|
|
|
Pos = XMLHelper.getNodeValue("Pos", node, Pos);
|
|
|
|
Vec3d PosLocalVec = new Vec3d(PosLocal.X, PosLocal.Y, 0.0f);
|
|
XMLHelper.getNodeValue("PosLocal", node, PosLocalVec);
|
|
PosLocal = new Vec2d(PosLocalVec.X, PosLocalVec.Y);
|
|
|
|
UID = XMLHelper.getNodeValue("UID", node, UID);
|
|
}
|
|
uint Frame { get; set; }
|
|
}
|
|
|
|
public partial class AnimFXEvent : AnimMarkerEvent
|
|
{
|
|
public AnimFXEvent(XmlNode node)
|
|
: base(node)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public partial class AnimAnimationEvent : AnimMarkerEvent
|
|
{
|
|
public AnimAnimationEvent(XmlNode node)
|
|
: base(node)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public partial class AnimGameplayEvent : AnimMarkerEvent
|
|
{
|
|
public AnimGameplayEvent(XmlNode node)
|
|
: base(node)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public partial class AnimPolylineEvent : AnimMarkerEvent
|
|
{
|
|
public AnimPolylineEvent(XmlNode node)
|
|
: base(node)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#region BlendTreeNodeAddBranch_Template Anim
|
|
public class BlendTreeNodeAddBranch_Template_Anim_Converter : UAFObjectConverter
|
|
{
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(BlendTreeNodeAddBranch_Template<AnimTreeResult>))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is BlendTreeNodeAddBranch_Template<AnimTreeResult>)
|
|
{
|
|
|
|
BlendTreeNodeAddBranch_Template<AnimTreeResult> desc = (BlendTreeNodeAddBranch_Template<AnimTreeResult>)value;
|
|
|
|
return desc.NodeName.ToString();// +" " + GetTableInfo(value);
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
|
|
[TypeConverter(typeof(BlendTreeNodeAddBranch_Template_Anim_Converter))]
|
|
public partial class BlendTreeNodeAddBranch_Template<T>
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region BlendTreeNodeChooseBranch_Template Anim
|
|
public class BlendTreeNodeChooseBranch_Template_Anim_Converter : UAFObjectConverter
|
|
{
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(BlendTreeNodeChooseBranch_Template<AnimTreeResult>))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is BlendTreeNodeChooseBranch_Template<AnimTreeResult>)
|
|
{
|
|
|
|
BlendTreeNodeChooseBranch_Template<AnimTreeResult> desc = (BlendTreeNodeChooseBranch_Template<AnimTreeResult>)value;
|
|
|
|
return desc.NodeName.ToString();// +" " + GetTableInfo(value);
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
[TypeConverter(typeof(BlendTreeNodeChooseBranch_Template_Anim_Converter))]
|
|
public partial class BlendTreeNodeChooseBranch_Template<T>
|
|
{
|
|
[TypeConverter(typeof(BlendTreeNodeChooseBranch_Template_BlendLeaf_Anim_Converter))]
|
|
public partial class BlendLeaf
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public class BlendTreeNodeChooseBranch_Template_BlendLeaf_Anim_Converter : UAFObjectConverter
|
|
{
|
|
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(BlendTreeNodeChooseBranch_Template<AnimTreeResult>.BlendLeaf))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is BlendTreeNodeChooseBranch_Template<AnimTreeResult>.BlendLeaf)
|
|
{
|
|
|
|
BlendTreeNodeChooseBranch_Template<AnimTreeResult>.BlendLeaf desc = (BlendTreeNodeChooseBranch_Template<AnimTreeResult>.BlendLeaf)value;
|
|
string result = "";
|
|
|
|
foreach (var v in desc.Criterias)
|
|
{
|
|
result += TypeDescriptor.GetConverter(v.GetType()).ConvertToString(null, culture, v) +" ";
|
|
}
|
|
return result;
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region AnimTreeNodePlayAnim_Template
|
|
public class AnimTreeNodePlayAnim_Template_Converter : UAFObjectConverter
|
|
{
|
|
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(AnimTreeNodePlayAnim_Template))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is AnimTreeNodePlayAnim_Template)
|
|
{
|
|
|
|
AnimTreeNodePlayAnim_Template desc = (AnimTreeNodePlayAnim_Template)value;
|
|
|
|
return desc.NodeName.ToString() + " (" + desc.AnimationName + ")";// +" " + GetTableInfo(value);
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
|
|
[TypeConverter(typeof(AnimTreeNodePlayAnim_Template_Converter))]
|
|
public partial class AnimTreeNodePlayAnim_Template
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region AnimTreeNodeSequence_Template
|
|
public class AnimTreeNodeSequence_Template_Converter : UAFObjectConverter
|
|
{
|
|
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(AnimTreeNodeSequence_Template))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is AnimTreeNodeSequence_Template)
|
|
{
|
|
|
|
AnimTreeNodeSequence_Template desc = (AnimTreeNodeSequence_Template)value;
|
|
|
|
return desc.NodeName.ToString();// +" " + GetTableInfo(value);
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
|
|
[TypeConverter(typeof(AnimTreeNodeSequence_Template_Converter))]
|
|
public partial class AnimTreeNodeSequence_Template
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region CriteriaDesc
|
|
public class CriteriaDesc_Converter : UAFObjectConverter
|
|
{
|
|
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(CriteriaDesc))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is CriteriaDesc)
|
|
{
|
|
|
|
CriteriaDesc desc = (CriteriaDesc)value;
|
|
|
|
return desc.Name.ToString() + " " + desc.Eval.ToString() + " " + desc.Value.ToString() + (desc.IsOR > 0 ? " OR" : string.Empty);
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
[TypeConverter(typeof(CriteriaDesc_Converter))]
|
|
public partial class CriteriaDesc
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region BlendTreeTransition_Template
|
|
public class BlendTreeTransition_Template_Anim_Converter : UAFObjectConverter
|
|
{
|
|
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(BlendTreeTransition_Template<AnimTreeResult>))
|
|
return true;
|
|
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
public override object ConvertTo(ITypeDescriptorContext context,
|
|
CultureInfo culture,
|
|
object value,
|
|
System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) &&
|
|
value is BlendTreeTransition_Template<AnimTreeResult>)
|
|
{
|
|
|
|
BlendTreeTransition_Template<AnimTreeResult> desc = (BlendTreeTransition_Template<AnimTreeResult>)value;
|
|
|
|
string result = "";
|
|
|
|
if (desc.From.Count > 0)
|
|
{
|
|
foreach (var v in desc.From)
|
|
{
|
|
result += v.ToString() + ",";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = "*";
|
|
}
|
|
|
|
result += " -> ";
|
|
|
|
foreach (var v in desc.To)
|
|
{
|
|
result += v.ToString() + ",";
|
|
}
|
|
|
|
return result;
|
|
}
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
|
|
[TypeConverter(typeof(BlendTreeTransition_Template_Anim_Converter))]
|
|
public partial class BlendTreeTransition_Template<T>
|
|
{
|
|
}
|
|
#endregion
|
|
} |