Esempio n. 1
0
    public void addEdge(DialogEdge edge)
    {
        List <DialogEdge> temp = new List <DialogEdge>(_edges);

        temp.Add(edge);
        _edges = temp.ToArray();
    }
Esempio n. 2
0
 public void setEdge(DialogEdge edge, int index)
 {
     if (index < _edges.Length)
     {
         _edges[index] = edge;
     }
 }
Esempio n. 3
0
    internal void OnClicked(DialogButton dialogButton)
    {
        if (!node)
        {
            return;
        }
        DialogEdge de = node[dialogButton.index];

        de.invoke();
    }
Esempio n. 4
0
 public void load(DialogNode dnode)
 {
     node = dnode;
     box.gameObject.SetActive(true);
     text.text = dnode.text;
     hideButtons();
     for (int i = 0; i < dnode.Length; ++i)
     {
         if (i >= buttons.Length)
         {
             break;
         }
         Button b = buttons[i];
         b.gameObject.SetActive(true);
         DialogEdge de = dnode[i];
         b.GetComponentInChildren <Text>().text = de.label;
     }
 }
Esempio n. 5
0
 public void UpdateEdge(DialogOption o)
 {
     if (graph.EdgesList.Where(x => x.Key.DialogOption.ID == o.ID).Any())
     {
         graph.RemoveEdge(graph.EdgesList.First(x => x.Key.DialogOption.ID == o.ID).Key);
     }
     if (!o.TargetID.IsNullOrEmpty())
     {
         var de = new DialogEdge(graph.VertexList.First(x => x.Key.Dialog.ID == Story.FindParent(o).ID).Key, graph.VertexList.First(x => x.Key.Dialog.ID == o.TargetID).Key)
         {
             DialogOption = o
         };
         graph.AddEdge(de, new EdgeControl(graph.VertexList.First(x => x.Key.Dialog.ID == Story.FindParent(o).ID).Value, graph.VertexList.First(x => x.Key.Dialog.ID == o.TargetID).Value, de, false)
         {
             ShowArrows = true
         });
     }
     Relayout();
     //graph.GenerateAllEdges(updateLayout: false);
     //graph.UpdateParallelEdgesData();
     //graph.RelayoutGraph(true);
 }
Esempio n. 6
0
    private void displayDNode(DialogNode dn, int colorIndex)
    {
        EditorGUI.indentLevel = 1;
        GUIStyle   style = EditorStyles.helpBox;
        RectOffset ro    = new RectOffset();

        ro.left      = 22;
        style.margin = ro;

        GUI.backgroundColor = normalColor; // bgColors[colorIndex % bgColors.Length];
        GUI.contentColor    = bgColors[colorIndex % bgColors.Length];

        bool shouldFoldout = false;

        if (foldoutLookup.ContainsKey(dn))
        {
            shouldFoldout = foldoutLookup[dn];
        }
        foldoutLookup[dn] = EditorGUILayout.Foldout(shouldFoldout, dn.name);
        if (foldoutLookup[dn])
        {
            EditorGUILayout.BeginVertical(style);
            EditorGUILayout.LabelField(string.Format("NODE: {0}", dn.name));

            dn.setText = EditorGUILayout.TextArea(dn.text, GUILayout.MinHeight(60));

            List <DialogEdge> edges = new List <DialogEdge>(dn.getEdges());

            for (int i = 0; i < edges.Count; ++i)
            {
                DialogEdge edge = edges[i];
                EditorGUI.indentLevel = 1;

                GUI.backgroundColor = bgColors[colorIndex % bgColors.Length];
                GUI.contentColor    = bgColors[colorIndex % bgColors.Length];
                edge.label          = EditorGUILayout.TextField(string.Format("EDGE {0}:", i), edge.label);

                EditorGUI.indentLevel = 2;

                edge.updaterSet = (MLUpdaterSet)EditorGUILayout.ObjectField(
                    string.Format("UPDATER: {0}", edge.dialogNode ? "(unused)" : ""),
                    edge.updaterSet,
                    typeof(MLUpdaterSet),
                    true);

                edge.dialogNode = (DialogNode)EditorGUILayout.ObjectField(
                    string.Format("NODE:"),
                    edge.dialogNode,
                    typeof(DialogNode),
                    true);

                if (!edge.dialogNode)
                {
                    GUIStyle   buttonStyle = EditorStyles.miniButtonRight;
                    RectOffset bRo         = new RectOffset(); bRo.left = 33; buttonStyle.margin = bRo;

                    if (GUILayout.Button("Attach new sub-node", buttonStyle))
                    {
                        DialogNode.CreateSubNode(dn, i);
                    }
                }

                if (edge.dialogNode)
                {
                    displayDNode(edge.dialogNode, colorIndex + 1);
                }
                dn.setEdge(edge, i);
            }

            GUI.backgroundColor = bgColors[colorIndex % bgColors.Length];
            GUI.contentColor    = bgColors[colorIndex % bgColors.Length];
            if (GUILayout.Button("Add edge"))
            {
                dn.addEdge(new DialogEdge());
            }

            EditorGUILayout.EndVertical();
        }
    }