Пример #1
0
    private void DrawNode(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
        DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node.m_id);

        if ((data.questsToAdd.Count > 0) || (data.questsToComplete.Count > 0) || (data.itemsToGive.Count > 0))
        {
            style = m_actionNodeStyle;
        }


        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("Dialogue", EditorStyles.boldLabel);
        if (data != null)
        {
            List <string> errors = m_nodeGraphModel.GetErrorMesssages(node.m_id);
            if (errors.Count > 0)
            {
                GUIStyle error_label = new GUIStyle();
                error_label.fontStyle        = FontStyle.Bold;
                error_label.normal.textColor = new Color(171f / 255f, 19f / 255f, 0);
                Label("Errors!!", error_label);
            }

            Label(data.characterName);
            string tag_pattern = "<[^>]+>";
            string displayText = Regex.Replace(data.dialogueText, tag_pattern, "");
            Label(displayText, Height(node.m_dimension.y));
        }
        EndArea();
    }
Пример #2
0
    private void DrawNode(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);
        DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node.m_id);

        if (data != null)
        {
            Label(data.characterName);
            Label(data.dialogueText, Height(node.m_dimension.y));
        }
        EndArea();
    }