/// <summary> /// Make sure our list of PortViews and editables sync up with our NodePorts /// </summary> protected void UpdatePorts() { foreach (var port in target.ports) { if (port.isInput) { AddInputPort(port); } else { AddOutputPort(port); } } var reflectionData = NodeReflection.GetNodeType(target.GetType()); if (reflectionData != null) { foreach (var editable in reflectionData.editables) { AddEditableField(m_SerializedNode.FindPropertyRelative(editable.fieldName)); } } // Toggle visibility of the extension container RefreshExpandedState(); // Update state classes EnableInClassList("hasInputs", inputs.Count > 0); EnableInClassList("hasOutputs", outputs.Count > 0); }
/// <summary> /// Make sure our list of PortViews and editables sync up with our NodePorts /// </summary> protected void UpdatePorts() { foreach (var port in target.ports) { if (port.isInput) { AddInputPort(port); } else { AddOutputPort(port); } } // TODO: Support FuncNode since GetNodeType won't work for those // as they're registered under a different type. var reflectionData = NodeReflection.GetNodeType(target.GetType()); if (reflectionData != null) { foreach (var editable in reflectionData.editables) { AddEditableField(m_SerializedNode.FindProperty(editable.fieldName)); } } // Toggle visibility of the extension container RefreshExpandedState(); // Update state classes EnableInClassList("hasInputs", inputs.Count > 0); EnableInClassList("hasOutputs", outputs.Count > 0); }
private void RegistState(AbstractNode node) { if (typeof(SkillPhaseState).IsAssignableFrom(node.GetType())) { SkillPhaseState skillPhaseState = (SkillPhaseState)node; skillPhaseState.SetSkill(_skill); AbstractNode parentNode = _hsmStateMachine.GetNode(node.ParentId); int configIndex = (null != parentNode) ? ((SubMachineSkill)parentNode).SkillConfigIndex : -1; int nodeUid = NodeUid(configIndex, skillPhaseState.PhaseType); _stateDic[nodeUid] = skillPhaseState; } else if (typeof(SkillHoldSkillState).IsAssignableFrom(node.GetType())) { SkillHoldSkillState skillHoldSkillState = (SkillHoldSkillState)node; skillHoldSkillState.SetSkill(_skill); } else if (typeof(SkillHoldFishState).IsAssignableFrom(node.GetType())) { SkillHoldFishState skillHoldFishState = (SkillHoldFishState)node; skillHoldFishState.SetSkill(_skill); } else if (typeof(SkillNextStage).IsAssignableFrom(node.GetType())) { SkillNextStage skillNextStage = (SkillNextStage)node; skillNextStage.SetEnterCallBack(EnterNextStage); } else if (typeof(SkillExitState).IsAssignableFrom(node.GetType())) { SkillExitState skillExitState = (SkillExitState)node; skillExitState.SetEnterCallBack(EixtSkill); } }
public virtual void Apply(AbstractNode abstractNode, SemanticDocument doc) { var type = abstractNode.GetType().GetTypeInfo(); var markedUpProps = type.DeclaredProperties .Select(propertyInfo => new { propertyInfo = propertyInfo, att = CustomAttributeExtensions.GetCustomAttribute <ExposeAttribute>((MemberInfo)propertyInfo), propertyUri = UriHelper.Combine(abstractNode.Uri, propertyInfo.Name) }).Where(x => x.att != null); foreach (var x in markedUpProps) { if (typeof(AbstractNode).GetTypeInfo().IsAssignableFrom(x.propertyInfo.PropertyType.GetTypeInfo())) { var childNode = (AbstractNode)x.propertyInfo.GetValue(abstractNode); doc.AddLink(Links.CreateLink(childNode.Title, childNode.Uri, childNode.Term)); } else { doc.Value.Add(SemanticProperty.CreateValue(TermFactory.From(x.propertyInfo), JToken.FromObject(x.propertyInfo.GetValue(abstractNode)))); } } }
private AbstractNode AddParms(AbstractNode invocation, IList <object> parameters) { if (invocation == null) { throw new ArgumentNullException("invocation"); } var m = invocation as Statement; if (m != null) { invocation = m.DeepCopy(); } else { var q = invocation as Expression; if (q != null) { invocation = q.DeepCopy(); } else { throw new Exception("Found a " + invocation.GetType()); } } InvocationExpression ie = FirstInvocationExpression(invocation); foreach (var o in parameters) { ie.AddArg(o); } return(invocation); }
private void RegistSubMachine(AbstractNode node) { if (typeof(SubMachineSkill).IsAssignableFrom(node.GetType())) { SubMachineSkill subMachine = (SubMachineSkill)node; subMachine.SetSkill(_skill); } }
public virtual void Apply(AbstractNode abstractNode, SemanticDocument doc) { var operations = GetOperations(abstractNode.GetType().GetTypeInfo(), abstractNode); foreach (var linkedActionResource in operations) { doc.Value.Add(linkedActionResource); } }
public static SerializedNode SerializeNode(AbstractNode node) { node.OnNodeSerialized(); return(new SerializedNode { GUID = node.GUID, NodeType = node.GetType().Name, Position = node.GetPosition().position, GroupGUID = node.GroupGuid.ToString(), NodeData = node.GetNodeData() }); }
// TODO: It makes sense just to add this behavior to the base node view // and let the developer define templates to use for icons. public override void Initialize(AbstractNode node, EdgeConnectorListener connectorListener) { base.Initialize(node, connectorListener); styleSheets.Add(Resources.Load <StyleSheet>("Styles/IconNodeView")); AddToClassList("iconNodeView"); VisualElement iconContainer = new VisualElement { name = "icon" }; string iconName = null; bool showTitle = true; foreach (var attr in node.GetType().GetCustomAttributes(false)) { if (attr is NodeIconAttribute iconAttr) { iconName = iconAttr.iconName; showTitle = iconAttr.showTitle; break; } } if (showTitle) { var titleLabel = new Label(); titleLabel.text = title; titleLabel.AddToClassList("iconNodeTitle"); iconContainer.Add(titleLabel); } if (iconName != null) { var icon = Resources.Load <Texture2D>(iconName); iconContainer.style.backgroundImage = icon; } inputContainer.parent.Add(iconContainer); iconContainer.PlaceInFront(inputContainer); }
public ExposedReferenceControlView(AbstractNode node, ReflectionProperty property) { var nodeType = node.GetType(); if (nodeType.IsGenericType) { var genericNodeType = nodeType.GetGenericTypeDefinition(); if (typeof(ExposedReferenceNode <>) == genericNodeType) { var referenceType = nodeType.GenericTypeArguments[0]; Guid guid = (Guid)property.GetValue(node); #if UNITY_EDITOR var objectField = new ObjectField(); var propertyTable = node.owner.owner as IReferenceTable; var graphUnityObject = node.owner.owner as UnityEngine.Object; bool isValid; objectField.objectType = referenceType; objectField.value = propertyTable != null?propertyTable.GetReferenceValue(guid, out isValid) : null; objectField.OnValueChanged(e => { if (propertyTable != null) { propertyTable.SetReferenceValue(guid, e.newValue); } else { objectField.value = null; } if (graphUnityObject != null) { EditorUtility.SetDirty(graphUnityObject); } }); Add(objectField); #endif } } }
string GetContentNodeName(AbstractNode source) { if (source is ThisNode) { return("this"); } if (source is NonPublicMembersNode) { return(StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicMembers}")); } if (source is RawViewNode) { return("Raw View"); } var sourceBaseClassNode = source as BaseClassNode; if (sourceBaseClassNode != null) { string baseClassString = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"); return(string.Format("{0} ({1})", sourceBaseClassNode.TypeName, baseClassString)); } throw new ApplicationException("Unknown AbstractNode: " + source.GetType()); }
public void Initialize(AbstractNode inNode, IEdgeConnectorListener connectorListener) { AddStyleSheetPath("Styles/NodeView"); AddToClassList("Node"); if (inNode == null) { return; } var contents = this.Q("contents"); m_ConnectorListener = connectorListener; node = inNode; persistenceKey = node.guid.ToString(); var priorityField = new IntegerField() { value = node.priority, name = "priority-field", visible = CalculatePriorityVisibility(node) }; priorityField.OnValueChanged(e => node.priority = e.newValue); titleContainer.Insert(1, priorityField); m_PriorityField = priorityField; m_TitleLabel = titleContainer.First(e => e.name == "title-label"); m_TitleLabel.RegisterCallback <MouseDownEvent>(OnTitleLabelMouseDown); m_TitleField = new TextField { name = "title-field", value = inNode.name, visible = false }; m_TitleField.style.positionType = PositionType.Absolute; m_TitleField.RegisterCallback <FocusOutEvent>(e => { OnEditTitleTextFinished(); }); m_TitleField.RegisterCallback <KeyDownEvent>(OnTitleTextFieldKeyPressed); titleContainer.shadow.Add(m_TitleField); UpdateTitle(); // Add controls container var controlsContainer = new VisualElement { name = "controls" }; { m_ControlsDivider = new VisualElement { name = "divider" }; m_ControlsDivider.AddToClassList("horizontal"); controlsContainer.Add(m_ControlsDivider); m_ControlItems = new VisualElement { name = "items" }; controlsContainer.Add(m_ControlItems); // Instantiate control views from node foreach (var propertyInfo in node.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { foreach (IControlAttribute attribute in propertyInfo.GetCustomAttributes(typeof(IControlAttribute), false)) { var control = attribute.InstantiateControl(node, new ReflectionProperty(propertyInfo)); if (control != null) { m_ControlItems.Add(control); } } } foreach (var fieldInfo in node.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { foreach (IControlAttribute attribute in fieldInfo.GetCustomAttributes(typeof(IControlAttribute), false)) { var control = attribute.InstantiateControl(node, new ReflectionProperty(fieldInfo)); if (control != null) { m_ControlItems.Add(control); } } } } if (m_ControlItems.childCount > 0) { contents.Add(controlsContainer); } // Add port input container, which acts as a pixel cache for all port inputs m_PortInputContainer = new VisualElement { name = "portInputContainer", clippingOptions = ClippingOptions.ClipAndCacheContents, pickingMode = PickingMode.Ignore }; Add(m_PortInputContainer); AddSlots(node.GetSlots <NodeSlot>()); UpdatePortInputs(); base.expanded = node.drawState.expanded; RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here UpdatePortInputVisibilities(); SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0)); /*if (node is SubGraphNode) * { * RegisterCallback<MouseDownEvent>(OnSubGraphDoubleClick); * }*/ m_PortInputContainer.SendToBack(); // Remove this after updated to the correct API call has landed in trunk. ------------ VisualElement m_TitleContainer; VisualElement m_ButtonContainer; m_TitleContainer = this.Q("title"); // ----------------------------------------------------------------------------------- var settings = node as IHasSettings; if (settings != null) { m_NodeSettingsView = new NodeSettingsView(); m_NodeSettingsView.visible = false; Add(m_NodeSettingsView); m_SettingsButton = new VisualElement { name = "settings-button" }; m_SettingsButton.Add(new VisualElement { name = "icon" }); m_Settings = settings.CreateSettingsElement(); m_SettingsButton.AddManipulator(new Clickable(() => { UpdateSettingsExpandedState(); })); // Remove this after updated to the correct API call has landed in trunk. ------------ m_ButtonContainer = new VisualElement { name = "button-container" }; m_ButtonContainer.style.flexDirection = StyleValue <FlexDirection> .Create(FlexDirection.Row); m_ButtonContainer.Add(m_SettingsButton); m_ButtonContainer.Add(m_CollapseButton); m_TitleContainer.Add(m_ButtonContainer); // ----------------------------------------------------------------------------------- //titleButtonContainer.Add(m_SettingsButton); //titleButtonContainer.Add(m_CollapseButton); RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); } }
public override VisualElement InstantiateControl(AbstractNode node, PropertyInfo property) { return(new AutoCompleteView(label, node, node.GetType().GetMethod(autoCompleteMethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance), property)); }