示例#1
0
    private void DrawOptionNode(Node node, GUIStyle style)
    {
        Rect nodeRect = new Rect(node.m_position.x, node.m_position.y, node.m_dimension.x, node.m_dimension.y);

        // draw plugs on specific node
        DrawPlug(node.m_inputPlug, nodeRect, m_inputPlugStyle, 1, 1);
        int  plug_count  = 1;
        Plug delete_plug = null;

        foreach (KeyValuePair <int, Plug> output_plug in node.m_outputPlugs)
        {
            if (delete_plug == null)
            {
                delete_plug = DrawPlug(output_plug.Value, nodeRect, m_outputPlugStyle, plug_count, node.m_outputPlugs.Count);
            }
            else
            {
                DrawPlug(output_plug.Value, nodeRect, m_outputPlugStyle, plug_count, node.m_outputPlugs.Count);
            }
            ++plug_count;
        }
        if (delete_plug != null)
        {
            m_nodeGraphModel.RemoveOutputPlugFromNode(delete_plug.m_plugId, delete_plug.m_nodeId);
        }


        // drawing the node itself with the contents in it
        GUI.Box(nodeRect, "", style);
        float padding         = 7f;
        Rect  nodeContentRect = new Rect(node.m_position.x + padding, node.m_position.y + padding, node.m_dimension.x - (2 * padding), node.m_dimension.y - (2 * padding));

        BeginArea(nodeContentRect);
        Label("Option", EditorStyles.boldLabel);

        int currIndex = 0;
        OutputPlugToNode outputdata;

        foreach (var outplug in node.m_outputPlugs)
        {
            outputdata = m_nodeGraphModel.GetOutputPlugToNode(node.m_id, currIndex);
            if (outputdata != null)
            {
                DialogueData inputNodeData = m_nodeGraphModel.GetDataFromNodeID(outputdata.inputNodeID);
                if (inputNodeData != null)
                {
                    inputNodeData.branchingIndex = currIndex;
                }
            }
            ++currIndex;
        }

        DialogueData data        = m_nodeGraphModel.GetDataFromNodeID(node.m_id);
        string       tag_pattern = "<[^>]+>";

        if (data.m_nextDialogueData != null)
        {
            foreach (var nodeId in data.m_nextDialogueData)
            {
                DialogueData nextData = m_nodeGraphModel.GetDataFromNodeID(nodeId);
                if (nextData != null)
                {
                    string previewData = Regex.Replace(nextData.previewDialogueText, tag_pattern, "");
                    Label(previewData);
                    Label("");
                }
            }
        }
        EndArea();
    }