예제 #1
0
        // Display all registered call event nodes and event listener nodes
        public void DrawMap(GraphEditor _editor, EventBoard _eventBoard, Guid _event)
        {
                        #if FLOWREACTOR_DEBUG
            GUI.contentColor = Color.yellow;
            if (GUILayout.Button("clear"))
            {
                _eventBoard.events[_event].callEventNodes     = new List <FlowReactor.Nodes.Node>();
                _eventBoard.events[_event].listenerEventNodes = new List <FlowReactor.Nodes.Node>();
            }
            GUI.contentColor = Color.white;
                        #endif


            using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
            {
                //GUILayout.Label("Call event nodes:");

                if (_eventBoard.events[_event].callEventNodes != null)
                {
                    using (new GUILayout.VerticalScope())
                    {
                        for (int i = 0; i < _eventBoard.events[_event].callEventNodes.Count; i++)
                        {
                            if (_editor != null)
                            {
                                if (_editor.rootGraph == _eventBoard.events[_event].callEventNodes[i].node.rootGraph)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;

                                        if (GUILayout.Button(_eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name, FlowReactorEditorStyles.graphExplorerButton, GUILayout.ExpandWidth(true)))
                                        {
                                            _editor.GotoNode(_eventBoard.events[_event].callEventNodes[i].node);
                                        }

                                        GUI.contentColor = Color.white;
                                    }
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;
                                    GUILayout.Label(eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                            else
                            {
                                if (_eventBoard.events[_event].callEventNodes[i] == null)
                                {
                                    // graph doesn't exist
                                    _eventBoard.events[_event].callEventNodes.RemoveAt(i);
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                        }
                    }
                }

                //}

                //GUILayout.Space(5);

                //GUI.color = settings.GetColor("eventNodeColor");
                //using (new GUILayout.VerticalScope(editorSkin.GetStyle("FRVariable")))
                //{
                //GUI.color = Color.white;
                //GUILayout.Label("Event listener nodes:");
                if (_eventBoard.events[_event].listenerEventNodes != null)
                {
                    using (new GUILayout.VerticalScope())
                    {
                        for (int i = 0; i < _eventBoard.events[_event].listenerEventNodes.Count; i++)
                        {
                            if (_editor != null)
                            {
                                if (_editor.rootGraph == _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;

                                        if (GUILayout.Button(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name, FlowReactorEditorStyles.graphExplorerButton, GUILayout.ExpandWidth(true)))
                                        {
                                            _editor.GotoNode(_eventBoard.events[_event].listenerEventNodes[i].node);
                                        }
                                        GUI.contentColor = Color.white;
                                    }
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                            else
                            {
                                if (_eventBoard.events[_event].listenerEventNodes[i] == null)
                                {
                                    // graph doesn't exist
                                    _eventBoard.events[_event].listenerEventNodes.RemoveAt(i);
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                        }
                    }
                }
            }
        }
        void DrawListItems(Rect rect, int index, bool isActive, bool isFocused)
        {
            if (index >= reorderableList.count)
            {
                return;
            }



            SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index);             // The element in the list


            EditorGUI.BeginChangeCheck();

            var _width = rect.width - 68;

                        #if FLOWREACTOR_DATABOX
            if (data.useDatabox)
            {
                _width = rect.width - 150;
            }
                        #endif

            // Drag variable field size
            var splitterRect       = new Rect(rect.x + data.variableFieldWidth + 21, rect.y + 1, 10, 20);
            var splitterRectVisual = new Rect(rect.x + data.variableFieldWidth + 21, rect.y + 1, 3, 20);
            EditorGUIUtility.AddCursorRect(splitterRect, MouseCursor.ResizeHorizontal);
            if (GUI.RepeatButton(splitterRectVisual, "", "TextArea"))
            {
                data.dragVariableFieldSize = true;
            }

            if (splitterRect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown)
            {
                data.dragVariableFieldSize = true;
            }

            if (Event.current.type == EventType.MouseDrag && data.dragVariableFieldSize)
            {
                data.variableFieldWidth += Event.current.delta.x / data.variables.Count;

                if (data.variableFieldWidth < 10)
                {
                    data.variableFieldWidth = 10;
                }
                if (_width - data.variableFieldWidth <= 20)
                {
                    data.variableFieldWidth = _width - 50;
                }
            }

            if (Event.current.type == EventType.MouseUp)
            {
                data.dragVariableFieldSize = false;
            }



            var _id = Guid.Parse(data.tempVariablesList[index].id);


            if (data.variables.ContainsKey(_id))
            {
                Event _evt = Event.current;
                DragItem(index, rect, data.variables[_id], _id, _evt);

                //if (data.variables[_id].sceneReferenceOnly)
                //{
                //	GUI.Label(new Rect(rect.x + 20, rect.y, 20, 20), EditorGUIUtility.IconContent("toggle on act"));
                //}

                data.variables[_id].name = GUI.TextField(new Rect(rect.x + 20, rect.y, data.variableFieldWidth, EditorGUIUtility.singleLineHeight), data.variables[_id].name);

                if (!data.variables[_id].useDatabox)
                {
                    GUI.enabled = !FRVariableGUIUtility.sceneRefObjectDragging;
                    if (data.variables[_id].sceneReferenceOnly)
                    {
                        GUI.enabled = false;
                        GUI.Label(new Rect(rect.x + data.variableFieldWidth + 25, rect.y, _width - data.variableFieldWidth, EditorGUIUtility.singleLineHeight), new GUIContent("scene only", EditorGUIUtility.IconContent("d_SceneViewOrtho").image), "ObjectField");
                        GUI.enabled = true;
                    }
                    else
                    {
                        data.variables[_id].Draw(new Rect(rect.x + data.variableFieldWidth + 25, rect.y, _width - data.variableFieldWidth, EditorGUIUtility.singleLineHeight));                         //rect.height - 2)); //EditorGUIUtility.singleLineHeight));
                    }
                    GUI.enabled = true;

                                        #if FLOWREACTOR_DATABOX
                    if (data.useDatabox)
                    {
                        GUI.enabled = data.databoxObjectManager ? true : false;

                        var _rect = new Rect(rect.x + rect.width - 122, rect.y, 80, EditorGUIUtility.singleLineHeight);
                        if (GUI.Button(_rect, "Databox", "miniButton"))
                        {
                            PopupWindow.Show(_rect, new PopUps.PopupDataboxVariables(data.databoxObjectManager, data.variables[_id]));
                        }
                        GUI.enabled = true;
                    }
                                        #else
                    if (data.useDatabox)
                    {
                        GUILayout.Label("Databox not installed");
                    }
                                        #endif
                }
                else
                {
                    GUI.Label(new Rect(rect.x + 125, rect.y, rect.width - 230, EditorGUIUtility.singleLineHeight), data.variables[_id].databoxID + " | " + data.variables[_id].tableID + " | " + data.variables[_id].entryID + " | " + data.variables[_id].valueID);
                    if (GUI.Button(new Rect(rect.x + rect.width - 122, rect.y, 80, EditorGUIUtility.singleLineHeight), "Release", "miniButton"))
                    {
                        data.variables[_id].useDatabox = false;
                        data.variables[_id].databoxID  = "";
                        data.variables[_id].tableID    = "";
                        data.variables[_id].entryID    = "";
                        data.variables[_id].valueID    = "";
                    }
                }

                if (GUI.Button(new Rect(rect.x + rect.width - 41, rect.y, 22, EditorGUIUtility.singleLineHeight), linkIcon))
                {
                    data.variables[index].showConnectedNodes = !data.variables[index].showConnectedNodes;
                }

                if (GUI.Button(new Rect(rect.x + rect.width - 18, rect.y, 22, EditorGUIUtility.singleLineHeight), "x"))
                {
                    if (data.variables[index].connectedNodes != null && data.variables[index].connectedNodes.Count > 0)
                    {
                        if (EditorUtility.DisplayDialog("Remove blackboard variable?", "Do you really want to remove this variable? Warning: It is still being used by one or more nodes", "yes", "no"))
                        {
                            DoRemove(index);
                        }
                    }
                    else
                    {
                        DoRemove(index);
                    }
                }

                if (index >= data.variables.Count)
                {
                    return;
                }

                if (data.variables[index].showConnectedNodes)
                {
                    if (data.variables[_id].connectedNodes != null && data.variables[_id].connectedNodes.Count > 0)
                    {
                        GUI.Box(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight + (data.variables[_id].connectedNodes.Count * EditorGUIUtility.singleLineHeight)), "", editorSkin.GetStyle("BoxLine"));

                        for (int c = 0; c < data.variables[_id].connectedNodes.Count; c++)
                        {
                            if (data.variables[_id].connectedNodes[c] == null)
                            {
                                data.variables[_id].connectedNodes.RemoveAt(c);
                            }
                            else
                            {
                                if (data.variables[_id].connectedNodes[c].graphOwner != null)
                                {
                                    if (graphEditor != null)
                                    {
                                        if (GUI.Button(new Rect(rect.x + 10, rect.y + EditorGUIUtility.singleLineHeight + (c * EditorGUIUtility.singleLineHeight), rect.width, EditorGUIUtility.singleLineHeight), "", FlowReactorEditorStyles.graphExplorerButton))
                                        {
                                            graphEditor.GotoNode(data.variables[_id].connectedNodes[c]);
                                        }
                                    }

                                    GUI.contentColor = data.variables[_id].connectedNodes[c].color;
                                    GUI.Label(new Rect(rect.x + 10, rect.y + EditorGUIUtility.singleLineHeight + (c * EditorGUIUtility.singleLineHeight), rect.width, EditorGUIUtility.singleLineHeight), data.variables[_id].connectedNodes[c].name + " : " + data.variables[_id].connectedNodes[c].rootGraph.name + "/" + data.variables[_id].connectedNodes[c].graphOwner.name);

                                    GUI.contentColor = Color.white;
                                }
                                else
                                {
                                    data.variables[_id].connectedNodes.RemoveAt(c);
                                }
                            }
                        }
                    }
                    else
                    {
                        //GUI.Label(new Rect(rect.x, rect.y + 20, rect.width, EditorGUIUtility.singleLineHeight), "not connected to any nodes in any graph");
                    }
                }


                HighlightConnectedVariables(index, rect);
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(data);
            }
        }