Ejemplo n.º 1
0
        private void DrawCameraStage()
        {
            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            Camera playerCamera = pcObject.GetComponentInChildren <Camera>() ?? Camera.main;
            SmoothCameraWithBumper smoothCamera = (playerCamera != null) ? playerCamera.GetComponent <SmoothCameraWithBumper>() : null;

            EditorGUILayout.BeginHorizontal();
            bool useSmoothCamera = EditorGUILayout.Toggle((smoothCamera != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("Use Smooth Follow Camera", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (useSmoothCamera)
            {
                if (playerCamera == null)
                {
                    GameObject playerCameraObject = new GameObject("Player Camera");
                    playerCameraObject.transform.parent = pcObject.transform;
                    playerCamera     = playerCameraObject.AddComponent <Camera>();
                    playerCamera.tag = "MainCamera";
                }
                smoothCamera = playerCamera.GetComponentInChildren <SmoothCameraWithBumper>() ?? playerCamera.gameObject.AddComponent <SmoothCameraWithBumper>();
                EditorWindowTools.StartIndentedSection();
                if (smoothCamera.target == null)
                {
                    EditorGUILayout.HelpBox("Specify the transform (usually the head) that the camera should follow.", MessageType.Info);
                }
                smoothCamera.target = EditorGUILayout.ObjectField("Target", smoothCamera.target, typeof(Transform), true) as Transform;
                EditorWindowTools.EndIndentedSection();
            }
            else
            {
                DestroyImmediate(smoothCamera);
            }
            if (GUILayout.Button("Select Camera", GUILayout.Width(100)))
            {
                Selection.activeObject = playerCamera;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 2
0
        private void DrawLocalizedVersions(List <Field> fields, string titleFormat, bool alwaysAdd, FieldType fieldType, List <Field> alreadyDrawn, bool useSequenceEditor = false)
        {
            bool indented = false;

            foreach (var language in languages)
            {
                string localizedTitle = string.Format(titleFormat, language);
                Field  field          = Field.Lookup(fields, localizedTitle);
                if ((field == null) && (alwaysAdd || (Field.FieldExists(template.dialogueEntryFields, localizedTitle))))
                {
                    field = new Field(localizedTitle, string.Empty, fieldType);
                    fields.Add(field);
                }
                if (field != null)
                {
                    if (!indented)
                    {
                        indented = true;
                        EditorWindowTools.StartIndentedSection();
                    }
                    //[TODO] Resolve menu callback issue.
                    //if (useSequenceEditor)
                    //{
                    //    field.value = SequenceEditorTools.DrawLayout(new GUIContent(localizedTitle), field.value, ref sequenceRect, ref sequenceSyntaxState);
                    //}
                    //else
                    {
                        EditorGUILayout.LabelField(localizedTitle);
                        field.value = EditorGUILayout.TextArea(field.value);
                    }
                    if (alreadyDrawn != null)
                    {
                        alreadyDrawn.Add(field);
                    }
                }
            }
            if (indented)
            {
                EditorWindowTools.EndIndentedSection();
            }
        }
        private void DrawEditorSettings()
        {
            EditorWindowTools.StartIndentedSection();

            EditorGUI.BeginChangeCheck();
            var newFreq = EditorGUILayout.FloatField(new GUIContent("Auto Backup Frequency", "Seconds between auto backups. Set to zero for no auto backups."), autoBackupFrequency);

            if (newFreq != autoBackupFrequency)
            {
                autoBackupFrequency   = newFreq;
                timeForNextAutoBackup = Time.realtimeSinceStartup + autoBackupFrequency;
            }
            EditorGUILayout.BeginHorizontal();
            autoBackupFolder = EditorGUILayout.TextField(new GUIContent("Auto Backup Folder", "Location to write auto backups."), autoBackupFolder);
            if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                var newAutoBackupFolder = EditorUtility.OpenFolderPanel("Auto Backup Folder", autoBackupFolder, string.Empty);
                if (!string.IsNullOrEmpty(newAutoBackupFolder))
                {
                    if (!newAutoBackupFolder.Contains(Application.dataPath))
                    {
                        EditorUtility.DisplayDialog("Auto Backup Folder", "Destination for backups must be in your Assets folder or a subfolder.", "OK");
                    }
                    else
                    {
                        autoBackupFolder = "Assets" + newAutoBackupFolder.Replace(Application.dataPath, string.Empty);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            showDatabaseName           = EditorGUILayout.ToggleLeft(new GUIContent("Show Database Name", "Show the database name in the lower left of the editor window."), showDatabaseName);
            registerCompleteObjectUndo = EditorGUILayout.ToggleLeft(new GUIContent("Fast Undo for Large Databases", "Use Undo.RegisterCompleteObjectUndo instead of Undo.RegisterUndo. Tick if operations such as deleting a conversation become slow in very large databases."), registerCompleteObjectUndo);
            debug = EditorGUILayout.ToggleLeft(new GUIContent("Debug", "For internal debugging of the dialogue editor."), debug);

            if (EditorGUI.EndChangeCheck())
            {
                SaveEditorSettings();
            }

            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 4
0
        private void DrawReviewStage()
        {
            EditorGUILayout.LabelField("Review", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("Your NPC is ready! Below is a summary of your NPC's configuration.", MessageType.Info);
            ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>();

            if (conversationTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Conversation: '{0}'{1} {2}", conversationTrigger.conversation, conversationTrigger.once ? " (once)" : string.Empty, conversationTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Conversation: None");
            }
            BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>();

            if (barkTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Triggered Bark: '{0}' ({1}) {2}", barkTrigger.conversation, barkTrigger.barkOrder, barkTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Triggered Bark: None");
            }
            BarkOnIdle barkOnIdle = npcObject.GetComponentInChildren <BarkOnIdle>();

            if (barkOnIdle != null)
            {
                EditorGUILayout.LabelField(string.Format("Timed Bark: '{0}' ({1}) every {2}-{3} seconds", barkOnIdle.conversation, barkOnIdle.barkOrder, barkOnIdle.minSeconds, barkOnIdle.maxSeconds));
            }
            else
            {
                EditorGUILayout.LabelField("Timed Bark: No");
            }
            PersistentPositionData persistentPositionData = npcObject.GetComponentInChildren <PersistentPositionData>();

            EditorGUILayout.LabelField(string.Format("Save Position: {0}", (persistentPositionData != null) ? "Yes" : "No"));
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, true);
        }
Ejemplo n.º 5
0
        private void DrawLocalizationSection()
        {
            EditorWindowTools.StartIndentedSection();
            if (exportLanguageList == null)
            {
                exportLanguageList = new ReorderableList(localizationLanguages.languages, typeof(string), true, true, true, true);
                exportLanguageList.drawHeaderCallback += OnDrawExportLanguageListHeader;
                exportLanguageList.drawElementCallback = OnDrawExportLanguageListElement;
                exportLanguageList.onAddCallback      += OnAddExportLanguageListElement;
            }
            exportLanguageList.DoLayoutList();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Checkbox also imports updated main text from file.");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Find Languages", GUILayout.Width(120)))
            {
                FindLanguagesForLocalizationExportImport();
            }
            if (GUILayout.Button("Export...", GUILayout.Width(100)))
            {
                var newOutputFolder = EditorUtility.OpenFolderPanel("Export Localization Files", localizationLanguages.outputFolder, string.Empty);
                if (!string.IsNullOrEmpty(newOutputFolder))
                {
                    localizationLanguages.outputFolder = newOutputFolder;
                    ExportLocalizationFiles();
                }
            }
            if (GUILayout.Button("Import...", GUILayout.Width(100)))
            {
                var newOutputFolder = EditorUtility.OpenFolderPanel("Import Localization Files", localizationLanguages.outputFolder, string.Empty);
                if (!string.IsNullOrEmpty(newOutputFolder))
                {
                    localizationLanguages.outputFolder = newOutputFolder;
                    ImportLocalizationFiles();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorWindowTools.EndIndentedSection();
        }
            public void Draw(bool drawFoldout, bool draggable)
            {
                if (database == null)
                {
                    return;
                }

                if (drawFoldout)
                {
                    var foldout    = variableGroupFoldouts.Contains(group);
                    var newFoldout = EditorGUILayout.Foldout(foldout, group);
                    if (newFoldout != foldout)
                    {
                        foldout = newFoldout;
                        if (foldout)
                        {
                            variableGroupFoldouts.Add(group);
                        }
                        else
                        {
                            variableGroupFoldouts.Remove(group);
                        }
                    }
                    if (!foldout)
                    {
                        return;
                    }
                }
                if (reorderableList == null)
                {
                    reorderableList = new ReorderableList(variableList, typeof(Variable), draggable, false, true, true);
                    reorderableList.drawHeaderCallback    = OnDrawVariableHeader;
                    reorderableList.drawElementCallback   = OnDrawVariableElement;
                    reorderableList.onAddDropdownCallback = OnAddVariableDropdown;
                    reorderableList.onRemoveCallback      = OnRemoveVariable;
                }
                EditorWindowTools.StartIndentedSection();
                reorderableList.DoLayoutList();
                EditorWindowTools.EndIndentedSection();
            }
Ejemplo n.º 7
0
        private void DrawPersistenceStage()
        {
            EditorGUILayout.LabelField("Persistence", EditorStyles.boldLabel);
            PersistentPositionData persistentPositionData = npcObject.GetComponent <PersistentPositionData>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("The NPC can be configured to record its position in the Dialogue System's Lua environment so it will be preserved when saving and loading games.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasPersistentPosition = EditorGUILayout.Toggle((persistentPositionData != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("NPC records position for saved games", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasPersistentPosition)
            {
                if (persistentPositionData == null)
                {
                    persistentPositionData = npcObject.AddComponent <PersistentPositionData>();
                }
                if (string.IsNullOrEmpty(persistentPositionData.overrideActorName))
                {
                    EditorGUILayout.HelpBox(string.Format("Position data will be saved to the Actor['{0}'] (the name of the NPC GameObject) or the Override Actor Name if defined. You can override the name below.", npcObject.name), MessageType.None);
                }
                else
                {
                    EditorGUILayout.HelpBox(string.Format("Position data will be saved to the Actor['{0}']. To use the name of the NPC GameObject instead, clear the field below.", persistentPositionData.overrideActorName), MessageType.None);
                }
                persistentPositionData.overrideActorName = EditorGUILayout.TextField("Actor Name", persistentPositionData.overrideActorName);
            }
            else
            {
                DestroyImmediate(persistentPositionData);
            }
            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 8
0
        private void DrawDisableControlsSection()
        {
            EditorWindowTools.StartIndentedSection();
            SetEnabledOnDialogueEvent enabler = FindConversationEnabler();

            if (setEnabledFlag)
            {
                if (enabler == null)
                {
                    enabler = pcObject.AddComponent <SetEnabledOnDialogueEvent>();
                }
                enabler.trigger = DialogueEvent.OnConversation;
                enabler.onStart = GetPlayerControls(enabler.onStart, Toggle.False);
                enabler.onEnd   = GetPlayerControls(enabler.onEnd, Toggle.True);
                ShowDisabledComponents(enabler.onStart);
            }
            else
            {
                DestroyImmediate(enabler);
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 9
0
        private void DrawControlStage()
        {
            EditorGUILayout.LabelField("Control", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SimpleController     simpleController     = pcObject.GetComponent <SimpleController>();
            NavigateOnMouseClick navigateOnMouseClick = pcObject.GetComponent <NavigateOnMouseClick>();
            ControlStyle         controlStyle         = (simpleController != null)
                                ? ControlStyle.ThirdPersonShooter
                                : (navigateOnMouseClick != null)
                                        ? ControlStyle.FollowMouseClicks
                                        : ControlStyle.Custom;

            EditorGUILayout.HelpBox("How will the player control movement? (Select Custom to provide your own control components instead of using the Dialogue System's.)", MessageType.Info);
            controlStyle = (ControlStyle)EditorGUILayout.EnumPopup("Control", controlStyle);
            switch (controlStyle)
            {
            case ControlStyle.ThirdPersonShooter:
                DestroyImmediate(navigateOnMouseClick);
                DrawSimpleControllerSection(simpleController ?? pcObject.AddComponent <SimpleController>());
                break;

            case ControlStyle.FollowMouseClicks:
                DestroyImmediate(simpleController);
                DrawNavigateOnMouseClickSection(navigateOnMouseClick ?? pcObject.AddComponent <NavigateOnMouseClick>());
                break;

            default:
                DestroyImmediate(simpleController);
                DestroyImmediate(navigateOnMouseClick);
                break;
            }
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 10
0
        private void DrawVariable(Variable asset, int index, AssetFoldouts foldouts)
        {
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.BeginVertical("button");
            List <Field> fields = asset.fields;

            for (int i = 0; i < fields.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (IsTextAreaField(fields[i]))
                {
                    DrawTextAreaFirstPart(fields[i], false);
                    DrawTextAreaSecondPart(fields[i]);
                }
                else
                {
                    DrawField(fields[i], false);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 11
0
        private void DrawBarkStage()
        {
            EditorGUILayout.LabelField("Bark", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("If the NPC barks (says one-off lines during gameplay), tick either or both of the checkboxs below.", MessageType.Info);
            bool hasBarkTrigger = DrawBarkTriggerSection();

            EditorWindowTools.DrawHorizontalLine();
            bool hasBarkOnIdle    = DrawBarkOnIdleSection();
            bool hasBarkComponent = hasBarkTrigger || hasBarkOnIdle;
            bool hasBarkUI        = false;

            if (hasBarkComponent)
            {
                hasBarkUI = DrawBarkUISection();
            }
            if (hasBarkComponent && GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, (hasBarkUI || !hasBarkComponent), false);
        }
Ejemplo n.º 12
0
        private void DrawSelector(SelectorType selectorType)
        {
            DestroyImmediate(pcObject.GetComponent <ProximitySelector>());
            Selector selector = pcObject.GetComponent <Selector>() ?? pcObject.AddComponent <Selector>();

            EditorWindowTools.StartIndentedSection();
            switch (selectorType)
            {
            case SelectorType.CenterOfScreen:
                EditorGUILayout.HelpBox("Usable objects in the center of the screen will be targeted.", MessageType.None);
                selector.selectAt = Selector.SelectAt.CenterOfScreen;
                break;

            case SelectorType.MousePosition:
                EditorGUILayout.HelpBox("Usable objects under the mouse cursor will be targeted. Specify which mouse button activates the targeted object.", MessageType.None);
                selector.selectAt = Selector.SelectAt.MousePosition;
                MouseButtonChoice mouseButtonChoice = string.Equals(selector.useButton, "Fire2") ? MouseButtonChoice.RightMouseButton : MouseButtonChoice.LeftMouseButton;
                mouseButtonChoice  = (MouseButtonChoice)EditorGUILayout.EnumPopup("Select With", mouseButtonChoice);
                selector.useButton = (mouseButtonChoice == MouseButtonChoice.RightMouseButton) ? "Fire2" : "Fire1";
                break;

            default:
            case SelectorType.CustomPosition:
                EditorGUILayout.HelpBox("Usable objects will be targeted at a custom screen position. You are responsible for setting the Selector component's CustomPosition property.", MessageType.None);
                selector.selectAt = Selector.SelectAt.CustomPosition;
                break;
            }
            if (selector.reticle != null)
            {
                selector.reticle.inRange    = EditorGUILayout.ObjectField("In-Range Reticle", selector.reticle.inRange, typeof(Texture2D), false) as Texture2D;
                selector.reticle.outOfRange = EditorGUILayout.ObjectField("Out-of-Range Reticle", selector.reticle.outOfRange, typeof(Texture2D), false) as Texture2D;
            }
            selector.useKey    = (KeyCode)EditorGUILayout.EnumPopup("'Use' Key", selector.useKey);
            selector.useButton = EditorGUILayout.TextField("'Use' Button", selector.useButton);
            EditorGUILayout.HelpBox("Click Select Player Inspect to customize the Selector.", MessageType.None);
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 13
0
        private void DrawConversationStage()
        {
            EditorGUILayout.LabelField("Conversation", EditorStyles.boldLabel);
            ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("If the NPC has an interactive conversation (for example, with the player), tick the checkbox below.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasConversation = EditorGUILayout.Toggle((conversationTrigger != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("NPC has an interactive conversation", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasConversation)
            {
                EditorWindowTools.StartIndentedSection();
                if (conversationTrigger == null)
                {
                    conversationTrigger = npcObject.AddComponent <ConversationTrigger>();
                }
                EditorGUILayout.HelpBox("Select the NPC's conversation and what event will trigger it. If the NPC will only engage in this conversation once, tick Once Only. Click Select NPC to further customize the Conversation Trigger in the inspector, such as setting conditions on when the conversation can occur.",
                                        string.IsNullOrEmpty(conversationTrigger.conversation) ? MessageType.Info : MessageType.None);
                conversationTrigger.conversation = DrawConversationPopup(conversationTrigger.conversation);
                conversationTrigger.once         = EditorGUILayout.Toggle("Once Only", conversationTrigger.once);
                conversationTrigger.trigger      = DrawTriggerPopup(conversationTrigger.trigger);
                if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
                {
                    Selection.activeGameObject = npcObject;
                }
                EditorWindowTools.EndIndentedSection();
            }
            else
            {
                DestroyImmediate(conversationTrigger);
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 14
0
        private void DrawVariables()
        {
            List <Variable> assets   = database.variables;
            AssetFoldouts   foldouts = variableFoldouts;

            EditorWindowTools.StartIndentedSection();
            Variable assetToRemove = null;

            for (int index = 0; index < assets.Count; index++)
            {
                Variable asset = assets[index];
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawVariable(asset, index, foldouts);
                }
            }
            if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 15
0
        private void DrawTargetingStage()
        {
            EditorGUILayout.LabelField("Targeting", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SelectorType selectorType = GetSelectorType();

            if (selectorType == SelectorType.None)
            {
                EditorGUILayout.HelpBox("Specify how the player will target NPCs to trigger conversations and barks.", MessageType.Info);
            }
            selectorType = (SelectorType)EditorGUILayout.EnumPopup("Target NPCs By", selectorType);
            switch (selectorType)
            {
            case SelectorType.Proximity:
                DrawProximitySelector();
                break;

            case SelectorType.CenterOfScreen:
            case SelectorType.MousePosition:
            case SelectorType.CustomPosition:
                DrawSelector(selectorType);
                break;

            default:
                DrawNoSelector();
                break;
            }
            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.DrawHorizontalLine();
            DrawOverrideNameSubsection();
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 16
0
        private void DrawTransitionStage()
        {
            EditorGUILayout.LabelField("Gameplay/Conversation Transition", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SetEnabledOnDialogueEvent setEnabled = pcObject.GetComponent <SetEnabledOnDialogueEvent>();

            setEnabledFlag = setEnabledFlag || (setEnabled != null);
            if (!setEnabledFlag)
            {
                EditorGUILayout.HelpBox("Gameplay components, such as movement and camera control, will interfere with conversations. If you want to disable gameplay components during conversations, tick the checkbox below.", MessageType.None);
            }
            EditorGUILayout.BeginHorizontal();
            setEnabledFlag = EditorGUILayout.Toggle(setEnabledFlag, GUILayout.Width(ToggleWidth));
            EditorGUILayout.LabelField("Disable gameplay components during conversations", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            DrawDisableControlsSection();
            DrawShowCursorSection();
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Ejemplo n.º 17
0
        private void DrawAssets <T>(string label, List <T> assets, AssetFoldouts foldouts, string filter) where T : Asset
        {
            EditorWindowTools.StartIndentedSection();
            showStateFieldAsQuest = false;
            DrawAssetSpecificFoldoutProperties <T>(assets);
            T   assetToRemove   = null;
            int indexToMoveUp   = -1;
            int indexToMoveDown = -1;

            for (int index = 0; index < assets.Count; index++)
            {
                T asset = assets[index];
                if (!IsAssetInFilter(asset, filter))
                {
                    continue;
                }
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                EditorGUI.BeginDisabledGroup(index >= (assets.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawAsset <T>(asset, index, foldouts);
                }
            }
            if (indexToMoveDown >= 0)
            {
                T asset = assets[indexToMoveDown];
                assets.RemoveAt(indexToMoveDown);
                assets.Insert(indexToMoveDown + 1, asset);
                SetDatabaseDirty("Move Down");
            }
            else if (indexToMoveUp >= 0)
            {
                T asset = assets[indexToMoveUp];
                assets.RemoveAt(indexToMoveUp);
                assets.Insert(indexToMoveUp - 1, asset);
                SetDatabaseDirty("Move Up");
            }
            else if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                    SetDatabaseDirty("Delete");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 18
0
        private void DrawVariablesTraditional()
        {
            List <Variable> assets   = database.variables;
            AssetFoldouts   foldouts = variableFoldouts;

            EditorWindowTools.StartIndentedSection();
            Variable assetToRemove   = null;
            int      indexToMoveUp   = -1;
            int      indexToMoveDown = -1;

            for (int index = 0; index < assets.Count; index++)
            {
                Variable asset = assets[index];
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                EditorGUI.BeginDisabledGroup(index >= (assets.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawVariable(asset, index, foldouts);
                }
            }
            if (indexToMoveDown >= 0)
            {
                Variable asset = assets[indexToMoveDown];
                assets.RemoveAt(indexToMoveDown);
                assets.Insert(indexToMoveDown + 1, asset);
                SetDatabaseDirty("Move Variable Down");
            }
            else if (indexToMoveUp >= 0)
            {
                Variable asset = assets[indexToMoveUp];
                assets.RemoveAt(indexToMoveUp);
                assets.Insert(indexToMoveUp - 1, asset);
                SetDatabaseDirty("Move Variable Up");
            }
            else if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                    SetDatabaseDirty("Delete Variable");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 19
0
        private void DrawConversations()
        {
            EditorWindowTools.StartIndentedSection();
            showStateFieldAsQuest = false;
            Conversation conversationToRemove = null;
            int          indexToMoveUp        = -1;
            int          indexToMoveDown      = -1;

            for (int index = 0; index < database.conversations.Count; index++)
            {
                Conversation conversation = database.conversations[index];
                EditorGUILayout.BeginHorizontal();
                bool isCurrentConversation = (conversation == currentConversation);
                bool foldout = isCurrentConversation;
                foldout = EditorGUILayout.Foldout(foldout, conversation.Title);
                EditorGUI.BeginDisabledGroup(index >= (database.conversations.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", conversation.Title)), "OL Minus", GUILayout.Width(16)))
                {
                    conversationToRemove = conversation;
                }
                EditorGUILayout.EndHorizontal();
                if (foldout)
                {
                    if (!isCurrentConversation)
                    {
                        OpenConversation(conversation);
                    }
                    DrawConversation();
                }
                else if (isCurrentConversation)
                {
                    ResetConversationSection();
                }
            }
            if (indexToMoveDown >= 0)
            {
                var conversation = database.conversations[indexToMoveDown];
                database.conversations.RemoveAt(indexToMoveDown);
                database.conversations.Insert(indexToMoveDown + 1, conversation);
                SetDatabaseDirty("Move Conversation Up");
            }
            else if (indexToMoveUp >= 0)
            {
                var conversation = database.conversations[indexToMoveUp];
                database.conversations.RemoveAt(indexToMoveUp);
                database.conversations.Insert(indexToMoveUp - 1, conversation);
                SetDatabaseDirty("Move Conversation Down");
            }
            else if (conversationToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", conversationToRemove.Title),
                                                "Are you sure you want to delete this conversation?\nYou cannot undo this operation!", "Delete", "Cancel"))
                {
                    if (conversationToRemove == currentConversation)
                    {
                        ResetConversationSection();
                    }
                    database.conversations.Remove(conversationToRemove);
                    SetDatabaseDirty("Delete Conversation");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 20
0
        private void DrawQuestEntries(Item item)
        {
            EditorGUILayout.LabelField("Quest Entries", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            int entryCount      = Field.LookupInt(item.fields, "Entry Count");
            int entryToDelete   = -1;
            int entryToMoveUp   = -1;
            int entryToMoveDown = -1;

            for (int i = 1; i <= entryCount; i++)
            {
                DrawQuestEntry(item, i, entryCount, ref entryToDelete, ref entryToMoveUp, ref entryToMoveDown);
            }
            if (entryToDelete != -1)
            {
                DeleteQuestEntry(item, entryToDelete, entryCount);
                SetDatabaseDirty("Delete Quest Entry");
            }
            if (entryToMoveUp != -1)
            {
                MoveQuestEntryUp(item, entryToMoveUp, entryCount);
            }
            if (entryToMoveDown != -1)
            {
                MoveQuestEntryDown(item, entryToMoveDown, entryCount);
            }
            if (GUILayout.Button(new GUIContent("Add New Quest Entry", "Adds a new quest entry to this quest.")))
            {
                entryCount++;
                Field.SetValue(item.fields, "Entry Count", entryCount);
                Field.SetValue(item.fields, string.Format("Entry {0} State", entryCount), "unassigned");
                Field.SetValue(item.fields, string.Format("Entry {0}", entryCount), string.Empty);
                List <string> questLanguages = new List <string>();
                item.fields.ForEach(field =>
                {
                    if (field.title.StartsWith("Description "))
                    {
                        string language = field.title.Substring("Description ".Length);
                        questLanguages.Add(language);
                        languages.Add(language);
                    }
                });
                questLanguages.ForEach(language => item.fields.Add(new Field(string.Format("Entry {0} {1}", entryCount, language), string.Empty, FieldType.Localization)));

                if (entryCount > 1)
                {
                    // Copy any custom "Entry 1 ..." fields to "Entry # ..." fields:
                    var fieldCount = item.fields.Count;
                    for (int i = 0; i < fieldCount; i++)
                    {
                        var field = item.fields[i];
                        if (field.title.StartsWith("Entry 1 "))
                        {
                            // Skip Entry 1, Entry 1 State, or Entry 1 Language:
                            if (string.Equals(field.title, "Entry 1") || string.Equals(field.title, "Entry 1 State"))
                            {
                                continue;
                            }
                            var afterEntryNumber = field.title.Substring("Entry 1 ".Length);
                            if (questLanguages.Contains(afterEntryNumber))
                            {
                                continue;
                            }

                            // Otherwise add:
                            var newFieldTitle = "Entry " + entryCount + " " + afterEntryNumber;
                            if (item.FieldExists(newFieldTitle))
                            {
                                continue;
                            }
                            var copiedField = new Field(field);
                            copiedField.title = newFieldTitle;
                            if (copiedField.type == FieldType.Text)
                            {
                                copiedField.value = string.Empty;
                            }
                            item.fields.Add(copiedField);
                        }
                    }
                }

                SetDatabaseDirty("Add New Quest Entry");
            }
            EditorWindowTools.EndIndentedSection();
        }
        private void DrawExportSection()
        {
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.BeginVertical(GroupBoxStyle);
            switch (exportFormat)
            {
            default:
                EditorGUILayout.HelpBox("Use this feature to export your database to external text-based formats.", MessageType.None);
                break;

            case ExportFormat.CSV:
                EditorGUILayout.HelpBox("Use this feature to export your database to external text-based formats.\nYou can import CSV format into spreadsheet programs such as Excel and Google Sheets. To reimport into the Dialogue System, use Tools > Pixel Crushers > Dialogue System > Import > CSV.", MessageType.None);
                break;

            case ExportFormat.ChatMapperXML:
                EditorGUILayout.HelpBox("Use this feature to export your database to external text-based formats.\nIf exporting to Chat Mapper format for import into Chat Mapper, you must also prepare a Chat Mapper template project that contains all the fields defined in this database. You can use the Dialogue System Chat Mapper template project as a base. To reimport into the Dialogue System, use Tools > Pixel Crushers > Dialogue System > Import > Chat Mapper.", MessageType.None);
                break;

            case ExportFormat.LanguageText:
                EditorGUILayout.HelpBox("Use this feature to export your database to external text-based formats.\nThe Language Text format will export a file for each language containing all the localized text for the language. You can use these text dumps to determine which characters your language-specific fonts need to support.", MessageType.None);
                break;

            case ExportFormat.VoiceoverScript:
                EditorGUILayout.HelpBox("Use this feature to export your database to external text-based formats.\nThe voiceover script option will export a separate CSV file for each language that you can use as a guide to record voice actors. Each row specifies the entrytag filename for use with entrytags.", MessageType.None);
                break;
            }
            if (exportFormat != ExportFormat.LanguageText)
            {
                exportActors        = EditorGUILayout.Toggle("Export Actors", exportActors);
                exportItems         = EditorGUILayout.Toggle("Export Items/Quests", exportItems);
                exportLocations     = EditorGUILayout.Toggle("Export Locations", exportLocations);
                exportVariables     = EditorGUILayout.Toggle("Export Variables", exportVariables);
                exportConversations = EditorGUILayout.Toggle("Export Conversations", exportConversations);
                if (exportFormat == ExportFormat.ChatMapperXML)
                {
                    exportCanvasRect = EditorGUILayout.Toggle(new GUIContent("Export Canvas Positions", "Export the positions of dialogue entry nodes in the Dialogue Editor's canvas"), exportCanvasRect);
                }
                if (exportFormat == ExportFormat.CSV)
                {
                    exportConversationsAfterEntries = EditorGUILayout.Toggle(new GUIContent("Convs. After Entries", "Put the Conversations section after the DialogueEntries section in the CSV file. Normally the Conversations section is before."), exportConversationsAfterEntries);
                }
                entrytagFormat = (EntrytagFormat)EditorGUILayout.EnumPopup("Entrytag Format", entrytagFormat, GUILayout.Width(400));
            }
            encodingType = (EncodingType)EditorGUILayout.EnumPopup("Encoding", encodingType, GUILayout.Width(400));
            EditorGUILayout.BeginHorizontal();
            exportFormat = (ExportFormat)EditorGUILayout.EnumPopup("Format", exportFormat, GUILayout.Width(400));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Export...", GUILayout.Width(100)))
            {
                switch (exportFormat)
                {
                case ExportFormat.ChatMapperXML:
                    TryExportToChatMapperXML();
                    break;

                case ExportFormat.CSV:
                    TryExportToCSV();
                    break;

                case ExportFormat.VoiceoverScript:
                    TryExportToVoiceoverScript();
                    break;

                case ExportFormat.LanguageText:
                    TryExportToLanguageText();
                    break;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorWindowTools.EndIndentedSection();
        }