Ejemplo n.º 1
0
 public override void ConstructLinkInfo(NodesContainer container, List <Guid> includeIdList = null)
 {
     for (int i = 0; i < mLinkPairs.Count; ++i)
     {
         var from = mLinkPairs[i].LoadedLinkFrom;
         var to   = mLinkPairs[i].LoadedLinkTo;
         if (from == Guid.Empty || to == Guid.Empty)
         {
             return;
         }
         if (includeIdList != null && !includeIdList.Contains(from))
         {
             return;
         }
         if (includeIdList != null && !includeIdList.Contains(to))
         {
             return;
         }
         var startObj = container.GetLinkObjectWithGUID(ref from);
         var endObj   = container.GetLinkObjectWithGUID(ref to);
         if (startObj != null && endObj != null)
         {
             var linkInfo = new ClickableLinkInfo(MainDrawCanvas, startObj, endObj);
         }
     }
 }
Ejemplo n.º 2
0
        public static DomDocument Create(IServiceModel serviceModel, params Node <DomNodeType>[] domNodes)
        {
            Contract.Requires(serviceModel != null);

            var domDocument = NodesContainer <DomNodeType> .CreateRoot(() => new DomDocument(serviceModel), domNodes);

            return(domDocument);
        }
Ejemplo n.º 3
0
    protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
    {
        nodesContainer = (NodesContainer)e.NameScope.Find("PART_ElementItemsControl");
        nodesContainer.SelectionChanged += OnNodesContainerSelectChanged;

        connectionsContainer = (ConnectionsContainer)e.NameScope.Find("PART_ConnectionItemsControl");
        connectionsContainer.SelectionChanged += OnConnectionsContainerSelectChanged;

        base.OnApplyTemplate(e);
    }
Ejemplo n.º 4
0
        void listItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ErrorListItem item = sender as ErrorListItem;

            if (item != null)
            {
                OnListSelectionChanged?.Invoke(item.Node);
                NodesContainer.FocusNode(item.Node);
            }
        }
    public void LoadGraph(string fileName)
    {
        containerCache = Resources.Load <NodesContainer>($"Dialogues/{fileName}");

        if (containerCache == null)
        {
            EditorUtility.DisplayDialog("File not found!", "Target dialogue graph file does not exist.", "OK");
            return;
        }

        ClearGraph();
        CreateExposedProperties();
        CreateNodes();
        ConnectNodes();
    }
Ejemplo n.º 6
0
        public static DomDocument Parse(Document apiDocument, IServiceModel serviceModel)
        {
            Contract.Requires(serviceModel != null);

            var domDocument = NodesContainer <DomNodeType> .CreateRoot(() => new DomDocument(serviceModel));

            ParseDocumentType(domDocument, apiDocument);
            ParseDocumentJsonApi(domDocument, apiDocument);
            ParseDocumentMeta(domDocument, apiDocument);
            ParseDocumentLinks(domDocument, apiDocument);
            ParseDocumentData(domDocument, apiDocument);
            ParseDocumentIncluded(domDocument, apiDocument);
            ParseDocumentErrors(domDocument, apiDocument);

            return(domDocument);
        }
    private void SaveExposedProperties(NodesContainer nodesContainer)
    {
        var exposedPropertiesData = new List <ExposedPropertyData>();

        foreach (var property in targetGraphView.exposedProperties)
        {
            exposedPropertiesData.Add(new ExposedPropertyData()
            {
                propertyType  = property.propertyType,
                propertyName  = property.PropertyName,
                propertyValue = property.PropertyValue,
            });
        }

        nodesContainer.exposedProperties = exposedPropertiesData;
    }
    public bool BuildNodesContainer(NodesContainer nodesContainer)
    {
        var connectedPorts = edges.Where(x => x.input.node != null).OrderByDescending(x => ((BaseNode)(x.output.node)).inputPoint).ToArray();

        for (int i = 0; i < connectedPorts.Length; i++)
        {
            var outputNode = connectedPorts[i].output.node as BaseNode;
            var inputNode  = connectedPorts[i].input.node as BaseNode;

            nodesContainer.nodeLinks.Add(new NodeLinkData
            {
                thisNodeGuid = outputNode.guid,
                portName     = connectedPorts[i].output.portName,
                nextNodeGuid = inputNode.guid
            });
        }

        foreach (var node in nodes)
        {
            var baseNode = node as BaseNode;
            nodesContainer.baseNodesData.Add(baseNode.CopyData(true));

            switch (baseNode.nodeType)
            {
            case NodeType.DialogueNode:
                var dialogueNode = node as DialogueNode;
                nodesContainer.dialogueNodesData.Add(dialogueNode.CopyData(true));
                break;

            case NodeType.ChoiceNode:
                var choiceNode = node as ChoiceNode;
                nodesContainer.choiceNodesData.Add(choiceNode.CopyData(true));
                break;
            }
        }

        return(true);
    }
Ejemplo n.º 9
0
 public override void ContainerLoadComplete(NodesContainer container)
 {
 }
Ejemplo n.º 10
0
 public abstract VisitResult Visit(NodesContainer <TNodeType> nodesContainer, int depth);
Ejemplo n.º 11
0
 public override void ContainerLoadComplete(NodesContainer container)
 {
     ReCalculatePriority();
 }
Ejemplo n.º 12
0
            public static DocumentNode Create(params Node <TestNodeType>[] nodes)
            {
                var documentNode = NodesContainer.CreateRoot(() => new DocumentNode(), nodes);

                return(documentNode);
            }
Ejemplo n.º 13
0
        public void EndPreviewLine(LinkPinControl objInfo, NodesContainer nodesContainer)
        {
            if (nodesContainer.ContainerDrawCanvas == null)
            {
                return;
            }

            if (objInfo == null)
            {
                if (nodesContainer.StartLinkObj != null && nodesContainer.PreviewLinkCurve.Visibility == System.Windows.Visibility.Visible)
                {
                    nodesContainer.IsOpenContextMenu = true;
                }
            }
            else if (nodesContainer.StartLinkObj != null && objInfo != null)
            {
                nodesContainer.PreviewLinkCurve.Visibility = System.Windows.Visibility.Hidden;
                nodesContainer.enPreviewBezierType         = CodeGenerateSystem.Base.enBezierType.None;

                if (nodesContainer.StartLinkObj.LinkOpType == objInfo.LinkOpType && objInfo.LinkOpType != enLinkOpType.Both) // 只有start和end能连 或者其中之一 和 Both
                {
                    return;
                }
                if (CodeGenerateSystem.Base.LinkInfo.CanLinkWith(nodesContainer.StartLinkObj, objInfo))
                {
                    objInfo.MouseAssistVisible = System.Windows.Visibility.Hidden;

                    var container = new NodesContainer.LinkInfoContainer();
                    if (nodesContainer.StartLinkObj.LinkOpType == enLinkOpType.Start)
                    {
                        container.Start = nodesContainer.StartLinkObj;
                        container.End   = objInfo;
                    }
                    else if (objInfo.LinkOpType == enLinkOpType.Start)
                    {
                        container.Start = objInfo;
                        container.End   = nodesContainer.StartLinkObj;
                    }
                    else
                    {
                        container.Start = nodesContainer.StartLinkObj;
                        container.End   = objInfo;
                    }

                    if (nodesContainer.StartLinkObj.LinkCurveType == enLinkCurveType.Line)
                    {
                        NodesContainer.TransitionStaeBaseNodeForUndoRedo transCtrl = new NodesContainer.TransitionStaeBaseNodeForUndoRedo();
                        var redoAction = new Action <object>((obj) =>
                        {
                            var linkInfo = new AnimStateLinkInfo(nodesContainer.ContainerDrawCanvas, container.Start, container.End);
                            transCtrl.TransitionStateNode = linkInfo.AddTransition();
                        });
                        redoAction.Invoke(null);
                        EditorCommon.UndoRedo.UndoRedoManager.Instance.AddCommand(nodesContainer.HostControl.UndoRedoKey, null, redoAction, null,
                                                                                  (obj) =>
                        {
                            for (int i = 0; i < container.End.GetLinkInfosCount(); i++)
                            {
                                var info = container.End.GetLinkInfo(i);
                                if (info.m_linkFromObjectInfo == container.Start)
                                {
                                    var transitionInfo = info as AnimStateLinkInfo;
                                    transitionInfo.RemoveTransition(transCtrl.TransitionStateNode);
                                    break;
                                }
                            }
                        }, "Create Link");
                    }
                    else
                    {
                        var redoAction = new Action <Object>((obj) =>
                        {
                            var linkInfo = new CodeGenerateSystem.Base.LinkInfo(nodesContainer.ContainerDrawCanvas, container.Start, container.End);
                        });
                        redoAction.Invoke(null);
                        EditorCommon.UndoRedo.UndoRedoManager.Instance.AddCommand(nodesContainer.HostControl.UndoRedoKey, null, redoAction, null,
                                                                                  (obj) =>
                        {
                            for (int i = 0; i < container.End.GetLinkInfosCount(); i++)
                            {
                                var info = container.End.GetLinkInfo(i);
                                if (info.m_linkFromObjectInfo == container.Start)
                                {
                                    info.Clear();
                                    break;
                                }
                            }
                        }, "Create Link");
                    }

                    IsDirty = true;
                }
                else
                {
                    nodesContainer.OnLinkFailure(nodesContainer.StartLinkObj, objInfo);
                }
            }
        }