Example #1
0
 public EditorLink(EditorPinIdentifier LHSPin, EditorPinIdentifier RHSPin)
 {
     FromNodeID = LHSPin.NodeID;
     FromPinID  = LHSPin.PinID;
     ToNodeID   = RHSPin.NodeID;
     ToPinID    = RHSPin.PinID;
 }
Example #2
0
    public EditorPinIdentifier GetPinIdentifier(int ID)
    {
        EditorPinIdentifier Identifier = new EditorPinIdentifier();

        Identifier.NodeID = _ID;
        Identifier.PinID  = ID;
        return(Identifier);
    }
    public void LinkPins(EditorPinIdentifier LHSPin, EditorPinIdentifier RHSPin)
    {
        if (Links == null)
        {
            Links = new List <EditorLink>();
        }

        EditorLink NewLink = new EditorLink(LHSPin, RHSPin);

        Links.Add(NewLink);
        NotifyGraphChange();
    }
    public bool LinkPins(EditorPinIdentifier pinA, EditorPinIdentifier pinB)
    {
        EditorPin pinAData = GraphToEdit.GetPinFromID(pinA);
        EditorPin pinBData = GraphToEdit.GetPinFromID(pinB);

        if (!pinBData.CanLinkTo(pinAData))
        {
            Debug.LogWarning("Failed to link pin " + pinA + " to " + pinB + ".");
            return(false);
        }

        GraphToEdit.LinkPins(pinA, pinB);
        return(true);
    }
    public void OnMouseUp(int button, Vector2 mousePos)
    {
        if (button == 0)
        {
            if (GraphToEdit == null)
            {
                return;
            }

            bool bMouseOverNode = false;
            foreach (EditorNode _Node in NodeList)
            {
                Rect NodeRect = _Node.GetNodeRect();
                if (HitTestPointToRect(mousePos, NodeRect))
                {
                    bMouseOverNode = true;
                    int NumPins = _Node.PinCount;
                    for (int PinIndex = 0; PinIndex < NumPins; ++PinIndex)
                    {
                        Rect PinRect = _Node.GetPinRect(PinIndex);
                        if (HitTestPointToRect(mousePos, PinRect))
                        {
                            if (GraphToEdit.IsPinSelected())
                            {
                                EditorPinIdentifier SelectedPinIdentifier = GraphToEdit.GetSelectedElementID();
                                LinkPins(SelectedPinIdentifier, _Node.GetPinIdentifier(PinIndex));
                                UpdateGraphCache();
                                break;
                            }
                        }
                    }
                }
            }

            if (!bMouseOverNode || GraphToEdit.IsPinSelected())
            {
                GraphToEdit.Deselect();
            }
        }
        else if (button == 1)
        {
            ProcessContextMenu(mousePos);
        }

        Repaint();
    }
    public EditorPin GetPinFromID(EditorPinIdentifier PinIdentifier)
    {
        if (PinMap == null)
        {
            PinMap = new Dictionary <EditorPinIdentifier, EditorPin>();
        }
        else if (PinMap.ContainsKey(PinIdentifier))
        {
            return(PinMap[PinIdentifier]);
        }

        EditorNode _Node = GetNodeFromID(PinIdentifier.NodeID);

        if (_Node != null)
        {
            EditorPin Pin = _Node.GetPin(PinIdentifier.PinID);
            PinMap[PinIdentifier] = Pin;
            return(Pin);
        }

        return(null);
    }
 public void SelectPin(EditorPinIdentifier PinIdentifier)
 {
     SelectedElement = PinIdentifier;
 }