Esempio n. 1
0
        public override void Execute(Rect editorRect, Rect precentageRect, Event e, EngineGraph currentGraph)
        {
            _textStyle = new GUIStyle(GUI.skin.label)
            {
                fontSize  = 12,
                alignment = TextAnchor.UpperCenter,
                onNormal  = new GUIStyleState()
                {
                    textColor = Color.white
                }
            };

            base.Execute(editorRect, precentageRect, e, currentGraph);
            _style = new GUIStyle(GUI.skin.box);

            ShowCreatePanelGUI();
            GUILayout.BeginHorizontal(_toolbar);

            if (GUILayout.Button("File", _dropdown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Create Graph"), false, () => showDialogue = true);
                menu.AddItem(new GUIContent("Load Graph"), false, EngineGraphEditorUtilities.LoadGraph);

                menu.AddSeparator("");

                if (currentGraph == null)
                {
                    menu.AddDisabledItem(new GUIContent("Unload Graph"));
                    menu.AddDisabledItem(new GUIContent("Delete Graph"));
                }

                else
                {
                    currentGraph.selectedNode = null;

                    menu.AddItem(new GUIContent("Delete Graph/Confirm"), false, EngineGraphEditorUtilities.DeleteGraph);
                    menu.AddItem(new GUIContent("Unload Graph"), false, EngineGraphEditorUtilities.UnloadGraph);
                }

                menu.Show(new Vector2(5, 17));
            }

            GUILayout.Space(10);

            if (GUILayout.Button("Insert", _dropdown, GUILayout.Width(100)))
            {
                GenericMenu menu = new GenericMenu();

                if (currentGraph != null)
                {
                    currentGraph.selectedNode = null;

                    menu.AddItem(new GUIContent("Story State/Add Text State", "Write dialogues and narrative text in the text container."), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Text, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Story State/Add Clear Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Clear, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Story State/Add Change Flow Chart State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Flow_Chart, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Character State/Add Show Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Character, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Character State/Add Hide Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Character, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Character State/Add Change Character Sprite State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Character_Sprite, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Character State/Add Character Move State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Move_Character, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Image State/Add Change Background State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Background, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Effect State/Add Delay State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Delay, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Effect State/Add Show Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Text_Container, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Effect State/Add Hide Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Text_Container, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Music/Add Play Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Music, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Music/Add Stop Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Music, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Sound FX/Add Play Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Sound, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Sound FX/Add Stop SouSoundnd State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Sound, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Voice/Add Play Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Voice, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Sound State/Voice/Add Stop Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Voice, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Branch State/Add Question Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Question, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Branch State/Add Conditional Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Condition, new Vector2(50, 50)));
                    menu.AddSeparator("Branch State/");
                    menu.AddItem(new GUIContent("Branch State/Add Answer State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Answer, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("Branch State/Add Condition State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Condition, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("System State/Add Set Parameter State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, new Vector2(50, 50)));
                    menu.AddItem(new GUIContent("System State/Add Trigger Event State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, new Vector2(50, 50)));
                }

                else
                {
                    menu.AddDisabledItem(new GUIContent("Story State/Add Text State"));
                    menu.AddDisabledItem(new GUIContent("Story State/Add Clear Text State"));
                    menu.AddDisabledItem(new GUIContent("Story State/Add Change Flow Chart State"));
                    menu.AddDisabledItem(new GUIContent("Character State/Add Show Character State"));
                    menu.AddDisabledItem(new GUIContent("Character State/Add Hide Character State"));
                    menu.AddDisabledItem(new GUIContent("Character State/Add Change Character Sprite State"));
                    menu.AddDisabledItem(new GUIContent("Character State/Add Character Move State"));
                    menu.AddDisabledItem(new GUIContent("Image State/Add Change Background State"));
                    menu.AddDisabledItem(new GUIContent("Effect State/Add Delay State"));
                    menu.AddDisabledItem(new GUIContent("Effect State/Add Show Text Container"));
                    menu.AddDisabledItem(new GUIContent("Effect State/Add Hide Text Container"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Music/Add Play Music State"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Music/Add Stop Music State"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Sound FX/Add Play Sound State"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Sound FX/Add Stop Sound State"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Voice/Add Play Voice State"));
                    menu.AddDisabledItem(new GUIContent("Sound State/Voice/Add Stop Voice State"));
                    menu.AddDisabledItem(new GUIContent("Branch State/Add Question Branch State"));
                    menu.AddDisabledItem(new GUIContent("Branch State/Add Conditional Brach State"));
                    menu.AddSeparator("Branch State/");
                    menu.AddDisabledItem(new GUIContent("Branch State/Add Answer State"));
                    menu.AddDisabledItem(new GUIContent("Branch State/Add Condition State"));
                    menu.AddDisabledItem(new GUIContent("System State/Add Set Parameter State"));
                    menu.AddDisabledItem(new GUIContent("System State/Add Trigger Event State"));
                }

                menu.Show(new Vector2(65, 17));
            }

            if (GUILayout.Button("Tools", _dropdown, GUILayout.Width(80)))
            {
                GenericMenu menu = new GenericMenu();

                //menu.AddDisabledItem(new GUIContent("Import/XML"));
                //menu.AddDisabledItem(new GUIContent("Import/TXT"));
                //menu.AddDisabledItem(new GUIContent("Export/XML"));
                //menu.AddDisabledItem(new GUIContent("Export/TXT"));
                menu.AddItem(new GUIContent("Clear cache", "Clear the cache information of the last session."), false, EngineGraphCacheUtilities.ClearSessionCache);

                menu.Show(new Vector2(135, 17));
            }

            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();

            if (showDialogue)
            {
                CreateGraphDialogueGUI();
            }
        }
Esempio n. 2
0
        void ProcessContextMenu(Event e, int contextID)
        {
            GenericMenu menu = new GenericMenu();

            if (contextID == 0)
            {
                menu.AddItem(new GUIContent("Create Graph"), false, EngineGraphEditorUtilities.OpenNewGraphPanel);
                menu.AddItem(new GUIContent("Load Graph"), false, EngineGraphEditorUtilities.LoadGraph);

                if (currentGraph != null)
                {
                    menu.AddSeparator("");
                    menu.AddItem(new GUIContent("Unload Graph"), false, EngineGraphEditorUtilities.UnloadGraph);
                    menu.AddSeparator("");
                    menu.AddItem(new GUIContent("Story State/Add Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Text, mousePos));
                    menu.AddItem(new GUIContent("Story State/Add Clear Text State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Clear, mousePos));
                    menu.AddItem(new GUIContent("Story State/Add Change Flow Chart State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Flow_Chart, mousePos));
                    menu.AddItem(new GUIContent("Character State/Add Show Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Character, mousePos));
                    menu.AddItem(new GUIContent("Character State/Add Hide Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Character, mousePos));
                    menu.AddItem(new GUIContent("Character State/Add Change Character Sprite State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Character_Sprite, mousePos));
                    menu.AddItem(new GUIContent("Character State/Add Move Character State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Move_Character, mousePos));
                    menu.AddItem(new GUIContent("Image State/Add Change Background State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Change_Background, mousePos));
                    menu.AddItem(new GUIContent("Effect State/Add Delay State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Delay, mousePos));
                    menu.AddItem(new GUIContent("Effect State/Add Show Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Show_Text_Container, mousePos));
                    menu.AddItem(new GUIContent("Effect State/Add Hide Text Container"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Hide_Text_Container, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Music/Add Play Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Music, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Music/Add Stop Music State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Music, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Sound FX/Add Play Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Sound, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Sound FX/Add Stop Sound State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Sound, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Voice/Add Play Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Play_Voice, mousePos));
                    menu.AddItem(new GUIContent("Sound State/Voice/Add Stop Voice State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Stop_Voice, mousePos));
                    menu.AddItem(new GUIContent("Branch State/Add Question Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Question, mousePos));
                    menu.AddItem(new GUIContent("Branch State/Add Conditional Branch State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Branch_Condition, mousePos));
                    menu.AddSeparator("Branch State/");
                    menu.AddItem(new GUIContent("Branch State/Add Answer State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Answer, mousePos));
                    menu.AddItem(new GUIContent("Branch State/Add Condition State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Condition, mousePos));
                    menu.AddItem(new GUIContent("System State/Add Set Parameter State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Set_Param, mousePos));
                    menu.AddItem(new GUIContent("System State/Add Trigger Event State"), false, () => EngineGraphEditorUtilities.CreateNode(currentGraph, EnumNodeType.Trigger_Event, mousePos));
                }
            }

            if (contextID == 1)
            {
                if (currentGraph != null)
                {
                    menu.AddItem(new GUIContent("Delete State"), false, () => EngineGraphEditorUtilities.DeleteNode(currentGraph, overNodeID));
                    menu.AddItem(new GUIContent("Disconnect/Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID));
                    menu.AddItem(new GUIContent("Disconnect/Disconnect Output"), false, () => EngineGraphEditorUtilities.DisconnectOutput(currentGraph, overNodeID));
                    menu.AddItem(new GUIContent("Disconnect/Disconnect All"), false, () => EngineGraphEditorUtilities.DisconnectAll(currentGraph, overNodeID));
                }
            }
            if (contextID == 2)
            {
                if (currentGraph != null)
                {
                    menu.AddItem(new GUIContent("Disconnect Output"), false, () => EngineGraphEditorUtilities.DisconnectOutput(currentGraph, overNodeID));
                }
            }
            if (contextID == 3)
            {
                if (currentGraph != null)
                {
                    menu.AddItem(new GUIContent("Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID));
                }
            }
            if (contextID == 4)
            {
                if (currentGraph != null)
                {
                    menu.AddItem(new GUIContent("Delete State"), false, () => EngineGraphEditorUtilities.DeleteNode(currentGraph, overNodeID));
                    menu.AddItem(new GUIContent("Disconnect Input"), false, () => EngineGraphEditorUtilities.DisconnectInput(currentGraph, overNodeID));
                }
            }

            OnShowMenu += () =>
            {
                menu.Show(_fixedMousePose);
                e.Use();
            };
        }