Esempio n. 1
0
        private void PaintToolbar()
        {
            bool hasSelection   = this.dialogueTree.HasSelection();
            int  selectionCount = (hasSelection ? this.dialogueTree.GetSelection().Count : 0);

            System.Type selectionType = null;
            if (selectionCount == 1)
            {
                int    instanceID = this.dialogueTree.GetSelection()[0];
                Object instance   = this.InstanceIDToObject(instanceID);
                selectionType = (instance != null ? instance.GetType() : null);
            }

            DialogueToolbarUtils.ContentStyle contentStyle = DialogueToolbarUtils.ContentStyle.IconOnly;
            GUIContent gcText   = DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.Text, contentStyle);
            GUIContent gcGroup  = DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.ChoiceGroup, contentStyle);
            GUIContent gcChoice = DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.Choice, contentStyle);
            GUIContent gcDelete = DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.Delete, contentStyle);

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            EditorGUI.BeginDisabledGroup(!DialogueItemTextEditor.CanAddElement(selectionCount, selectionType));
            if (GUILayout.Button(gcText, EditorStyles.toolbarButton))
            {
                DialogueItemTextEditor.AddElement(this);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!DialogueItemChoiceGroupEditor.CanAddElement(selectionCount, selectionType));
            if (GUILayout.Button(gcGroup, EditorStyles.toolbarButton))
            {
                DialogueItemChoiceGroupEditor.AddElement(this);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!DialogueItemChoiceEditor.CanAddElement(selectionCount, selectionType));
            if (GUILayout.Button(gcChoice, EditorStyles.toolbarButton))
            {
                DialogueItemChoiceEditor.AddElement(this);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!hasSelection);
            if (GUILayout.Button(gcDelete, EditorStyles.toolbarButton) && this.dialogueTree.HasSelection())
            {
                List <int> items = new List <int>(this.dialogueTree.GetSelection());
                this.DeleteItems(items);
                this.dialogueTree.Reload();
            }
            EditorGUI.EndDisabledGroup();

            Rect searchRect = GUILayoutUtility.GetRect(
                0f, 10000f,
                EditorGUIUtility.singleLineHeight,
                EditorGUIUtility.singleLineHeight,
                EditorStyles.toolbarTextField
                );

            this.dialogueTree.searchString = this.searchField.OnToolbarGUI(
                searchRect,
                this.dialogueTree.searchString
                );
            GUILayout.FlexibleSpace();

            GUIStyle   flscrenStyle = (this.isMaximized ? this.btnToolbarOn : this.btnToolbarOff);
            GUIContent gcScreen     = (this.isMaximized
                ? DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.Minimize, contentStyle)
                : DialogueToolbarUtils.GetContent(DialogueToolbarUtils.ContentType.Maximize, contentStyle)
                                       );

            if (GUILayout.Button(gcScreen, flscrenStyle))
            {
                if (EditorWindow.mouseOverWindow != null)
                {
                    if (EditorWindow.mouseOverWindow.maximized)
                    {
                        EditorApplication.update += this.MinimizeWindow;
                    }
                    else
                    {
                        EditorApplication.update += this.MaximizeWindow;
                    }
                }
            }

            EditorGUILayout.EndHorizontal();

            UnityEngine.Event current = UnityEngine.Event.current;
            if (current.type != EventType.KeyDown)
            {
                return;
            }
            if (!current.command && !current.control)
            {
                return;
            }

            switch (current.keyCode)
            {
            case KeyCode.T:
                if (DialogueItemTextEditor.CanAddElement(selectionCount, selectionType))
                {
                    DialogueItemTextEditor.AddElement(this);
                    current.Use();
                }
                break;

            case KeyCode.G:
                if (DialogueItemChoiceGroupEditor.CanAddElement(selectionCount, selectionType))
                {
                    DialogueItemChoiceGroupEditor.AddElement(this);
                    current.Use();
                }
                break;

            case KeyCode.J:
                if (DialogueItemChoiceEditor.CanAddElement(selectionCount, selectionType))
                {
                    DialogueItemChoiceEditor.AddElement(this);
                    current.Use();
                }
                break;
            }
        }
Esempio n. 2
0
        // PUBLIC STATIC METHODS: -----------------------------------------------------------------

        public static GUIContent GetContent(ContentType type, ContentStyle style)
        {
            DialogueToolbarUtils.RequireDataSetup();
            return(DATA[(int)type].Get(style));
        }