Example #1
0
 private static void DrawNodes(UTNodeEditorModel editorModel, NodeDrawingPhase phase)
 {
     foreach (UTNode node in editorModel.GetNodes())
     {
         DrawNode(editorModel, node, phase);
     }
 }
Example #2
0
    private static void DrawNode(UTNodeEditorModel editorModel, UTNode node, NodeDrawingPhase phase)
    {
        if (phase == NodeDrawingPhase.DrawNodes)
        {
            var style = UTEditorResources.GraphNodeStyle;
            if (node.Data is UTAutomationPlanNoteEntry)
            {
                style = UTEditorResources.GraphCommentStyle;
                if (editorModel.SelectedNodes.Contains(node))
                {
                    style = UTEditorResources.GraphCommentSelectedStyle;
                }
            }
            else
            {
                if (editorModel.SelectedNodes.Contains(node))
                {
                    style = UTEditorResources.GraphNodeSelectedStyle;
                }
                if (node == editorModel.HighlightedNode)
                {
                    style = UTEditorResources.GraphNodeHighlightStyle;
                }
            }

            GUI.Box(node.Bounds, "", style);
            if (editorModel.IsFirstNode(node))
            {
                GUI.DrawTexture(node.IndicatorBounds, UTEditorResources.FirstNodeTexture);
            }
            if (node.Data is UTAutomationPlanPlanEntry)
            {
                GUI.DrawTexture(node.SecondaryIndicatorBounds, UTEditorResources.ExecutePlanTexture);
            }
        }

        foreach (var connector in node.Connectors)
        {
            if (phase == NodeDrawingPhase.DrawNodes)
            {
                GUI.Label(connector.labelPosition, connector.label, connector.labelStyle);
                GUI.Box(connector.connectorPosition, "",
                        connector.isConnected ? UTEditorResources.GraphNodeConnectorStyle :
                        UTEditorResources.GraphNodeConnectorStyleEmpty);
            }
            if (phase == NodeDrawingPhase.DrawLines)
            {
                var targetNode = editorModel.GetReferencedNode(node, connector.property);
                if (targetNode != null)
                {
                    UTLineUtils.DrawLine(connector.connectorPosition.center, targetNode.Bounds.center);
                }
            }
        }


        if (phase == NodeDrawingPhase.DrawNodes)
        {
            GUI.Label(node.Bounds, node.Label, UTEditorResources.GraphNodeHeaderStyle);
            if (!string.IsNullOrEmpty(node.Text))
            {
                GUI.Label(node.TextBounds, node.Text, UTEditorResources.GraphNodeTextStyle);
            }
        }
    }
 private static void DrawNodes(UTNodeEditorModel editorModel, NodeDrawingPhase phase)
 {
     foreach (UTNode node in editorModel.GetNodes()) {
         DrawNode (editorModel, node, phase);
     }
 }
    private static void DrawNode(UTNodeEditorModel editorModel, UTNode node, NodeDrawingPhase phase)
    {
        if (phase == NodeDrawingPhase.DrawNodes) {
            var style = UTEditorResources.GraphNodeStyle;
            if (node.Data is UTAutomationPlanNoteEntry) {
                style = UTEditorResources.GraphCommentStyle;
                if (editorModel.SelectedNodes.Contains (node)) {
                    style = UTEditorResources.GraphCommentSelectedStyle;
                }
            } else {
                if (editorModel.SelectedNodes.Contains (node)) {
                    style = UTEditorResources.GraphNodeSelectedStyle;
                }
                if (node == editorModel.HighlightedNode) {
                    style = UTEditorResources.GraphNodeHighlightStyle;
                }
            }

            GUI.Box (node.Bounds, "", style);
            if (editorModel.IsFirstNode (node)) {
                GUI.DrawTexture (node.IndicatorBounds, UTEditorResources.FirstNodeTexture);
            }
            if (node.Data is UTAutomationPlanPlanEntry) {
                GUI.DrawTexture( node.SecondaryIndicatorBounds, UTEditorResources.ExecutePlanTexture);
            }
        }

        foreach (var connector in node.Connectors) {
            if (phase == NodeDrawingPhase.DrawNodes) {
                GUI.Label (connector.labelPosition, connector.label, connector.labelStyle);
                GUI.Box (connector.connectorPosition, "",
                    connector.isConnected ? UTEditorResources.GraphNodeConnectorStyle :
                    UTEditorResources.GraphNodeConnectorStyleEmpty);
            }
            if (phase == NodeDrawingPhase.DrawLines) {
                var targetNode = editorModel.GetReferencedNode (node, connector.property);
                if (targetNode != null) {
                    UTLineUtils.DrawLine (connector.connectorPosition.center, targetNode.Bounds.center);
                }
            }
        }

        if (phase == NodeDrawingPhase.DrawNodes) {
            GUI.Label (node.Bounds, node.Label, UTEditorResources.GraphNodeHeaderStyle);
            if (!string.IsNullOrEmpty(node.Text)) {
                GUI.Label(node.TextBounds, node.Text, UTEditorResources.GraphNodeTextStyle);
            }
        }
    }