public static Vec3F GetVec3(this DomNodeAdapter node, AttributeInfo attributeInfo) { return(LevelEditorCore.DomNodeUtil.GetVector(node.DomNode, attributeInfo)); // object value = node.DomNode.GetAttribute(attributeInfo); // // // if value is not null, attempt the cast; an invalid type will then cause // // an IllegalCastException; all value type attributes have a default // // value, so will return here // if (value != null) // return new Vec3F((float[])value); // // return default(Vec3F); }
public static Matrix4F GetMatrix4x4(this DomNodeAdapter node, AttributeInfo attributeInfo) { object value = node.DomNode.GetAttribute(attributeInfo); // if value is not null, attempt the cast; an invalid type will then cause // an IllegalCastException; all value type attributes have a default // value, so will return here if (value != null) { return(new Matrix4F((float[])value)); } return(default(Matrix4F)); }
public static void SetMatrix4x4(this DomNodeAdapter node, AttributeInfo attributeInfo, Matrix4F mat) { node.DomNode.SetAttribute(attributeInfo, mat.ToArray()); }
public static void SetVec3(this DomNodeAdapter node, AttributeInfo attributeInfo, Vec3F v) { LevelEditorCore.DomNodeUtil.SetVector(node.DomNode, attributeInfo, v); }
/// <summary> /// Searches ancestors of the given node to check for visibility status. /// This is how nodes inherit the hidden status from their parent. /// </summary> public static bool AncestorIsVisible(this DomNodeAdapter adapter) { var visible = adapter.DomNode.Ancestry.AsIEnumerable <IVisible>().FirstOrDefault(); return((visible != null)?visible.Visible:true); }
/// <summary> /// Searches ancestors of the given node to look for one that is locked. /// This is how nodes inherit the locked status from their parents. /// </summary> public static bool AncestorIsLocked(this DomNodeAdapter adapter) { var lockable = adapter.DomNode.Ancestry.AsIEnumerable <ILockable>().FirstOrDefault(); return((lockable != null)?lockable.IsLocked:false); }
/// <summary> /// Helper method for setting a string value on a DOM attribute from a given value /// </summary> /// <typeparam name="T">Type of value</typeparam> /// <param name="adapter">Adapter to use</param> /// <param name="attribute">Attribute to set</param> /// <param name="value">New value to set on attribute</param> public static void SetEnumValue <T>(this DomNodeAdapter adapter, AttributeInfo attribute, T value) { var stringValue = Enum.GetName(typeof(T), value); adapter.DomNode.SetAttribute(attribute, stringValue); }
/// <summary> /// Helper method for getting an enum value from a DOM attribute /// </summary> /// <typeparam name="T">Type to return enum as</typeparam> /// <param name="adapter">Adapter to use</param> /// <param name="attribute">Attribute to obtain enum for</param> /// <returns>Enum value</returns> public static T GetEnumValue <T>(this DomNodeAdapter adapter, AttributeInfo attribute) { var stringValue = (string)adapter.DomNode.GetAttribute(attribute); return((T)Enum.Parse(typeof(T), stringValue)); }