public void UpdateLayout(DialogPlayable graph)
    {
        if (m_Layout == null)
            m_Layout = new ReingoldTilford();

        m_Layout.Layout(graph);
        Repaint();
    }
 public void OnPlayModeChanged()
 {
     if (!EditorApplication.isPaused && !EditorApplication.isPlaying)
     {
         m_CurrentGraph = null;
         m_Graphs.Clear();
         Repaint();
     }
 }
    public static void OnGUI( Rect position, DialogPlayable p )
    {
        string style_string = "flow node 6";

        GUIStyle nodeStyle = new GUIStyle( style_string );
        string title = "";

        if ( p != null ) {
            title = p.name ?? "Node";

            if ( p.content != null ) {
                style_string = "flow node 3";
            }

            if ( DialogRenderer.selected_node == p ) {
                style_string += " on";
            }

            nodeStyle = new GUIStyle( style_string );

            GUILayout.BeginArea( position, title, nodeStyle );

            GUILayout.BeginVertical();

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label( DialogRenderer.dialog_bubble, GUILayout.Width( 64f ) );
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.EndVertical();

            GUILayout.EndArea();

        } else {
            GUI.Label( position, "", nodeStyle );
        }
    }
Пример #4
0
    public void InitGraph()
    {
        dialogs.Clear();
        root = new DialogPlayable( "Root", null );
        dialogs.Add( root );

        DialogPlayable child = new DialogPlayable( "Hey!", "Hello,I'm a dialog node!" );
        Playable.Connect( child, root );
        dialogs.Add( child );

        child = new DialogPlayable( "Go away!", "Go away,you are not welcome!" );
        Playable.Connect( child, root );
        dialogs.Add( child );
    }
    public void OnUpdateGraph(DialogPlayable p, string title)
    {
        if (!m_Graphs.ContainsKey(p))
        {
            m_Graphs.Add(p, title);
            m_CurrentGraph = p;
        }
        // Update titles if necessary
        else if (m_Graphs.ContainsKey(p) && m_Graphs[p] != title)
        {
            m_Graphs[p] = title;
        }

        if (m_CurrentGraph == p)
        {
            UpdateLayout(p);
        }
    }
    private void DoToolbar()
    {
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Width(position.width));
        GUIStyle onStyle = "ToolbarButton";
        const string graphTitle = "Graph: ";
        if (m_Graphs.Count == 1)
        {
            GUILayout.Label(graphTitle + m_Graphs[m_CurrentGraph]);
        }
        if (m_Graphs.Count > 1)
        {
            var options = m_Graphs.Values.ToArray();
            var playables = m_Graphs.Keys.ToArray();

            // Can buttons be used to select the multiple graphs, or do we need a drop down menu?
            float totalWidth = 0;
            foreach (var o in options)
            {
                totalWidth += onStyle.CalcSize(new GUIContent(o)).x;
            }

            if (totalWidth > position.width)
            {
                int initialIndex = Array.IndexOf(playables, m_CurrentGraph);
                int index = EditorGUILayout.Popup(graphTitle, initialIndex, options, GUILayout.Width(position.width));

                if (index !=  initialIndex)
                {
                    m_CurrentGraph = playables[index];
                    UpdateLayout(m_CurrentGraph);
                }
            }
            else
            {
                GUILayout.Label(graphTitle);
                for (int i = 0; i < m_Graphs.Count; i++)
                {
                    bool isCurrent = m_CurrentGraph == playables[i];
                    bool value = GUILayout.Toggle(isCurrent, options[i], onStyle);
                    if (value && value != isCurrent)
                    {
                        m_CurrentGraph = playables[i];
                        UpdateLayout(m_CurrentGraph);
                    }
                }
            }
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
    }
Пример #7
0
 public DialogRenderer()
 {
     InitializeStyles();
     FindCustomDrawingFunctions();
     DialogRenderer.selected_node = null;
 }
Пример #8
0
    void DrawNode(Vertex v, Vector2 nodeCenter, Vector2 nodeSize, string name)
    {
        var nodeType = v.payload.GetType();
        var nodeRect = new Rect(nodeCenter.x, nodeCenter.y, nodeSize.x, nodeSize.y);

        if (m_UseCustomDrawingMethods && m_CustomDrawingMethodForType.ContainsKey(nodeType))
        {
            if( e != null ) {
                if( e.isMouse && nodeRect.Contains( e.mousePosition ) ) {
                    if ( (e.type == EventType.MouseDown) ) {
                        //Debug.Log( "Mouse down" );
                        //Debug.Log( ((DialogPlayable)v.payload).name ?? "" );
                        DialogRenderer.selected_node = (DialogPlayable)v.payload;
                    } else {
                        //Debug.Log( "Mouse up" );
                    }
                    e.Use();
                }
            }
            m_CustomDrawingMethodForType[nodeType].Invoke(null, new object[] {nodeRect, v.payload});
        }
        else
        {
            GUI.Label(nodeRect, "", m_LegendForType[nodeType].style);
        }
    }
 public static void Show(DialogPlayable p, string title)
 {
     if (instance.updateGraph != null)
         instance.updateGraph(p, title);
 }