Esempio n. 1
0
        void ShiftTask(List <QuestTask> tasks, int oldIndex, int newIndex)
        {
            QuestTask task = tasks[oldIndex];

            tasks.RemoveAt(oldIndex);
            newIndex = Mathf.Clamp(newIndex, 0, tasks.Count);
            tasks.Insert(newIndex, task);
        }
Esempio n. 2
0
        void AddTask(QuestEntry quest)
        {
            QuestTask task = new QuestTask {
                id = System.Guid.NewGuid().ToString()
            };

            quest.Tasks.Add(task);

            EditorUtility.SetDirty(database);
        }
Esempio n. 3
0
        public override void DisplayDatabase()
        {
            EditorGUI.BeginChangeCheck();

            for (int i = 0, l = questTmp.Count; i < l; i++)
            {
                quest = questTmp[i];

                errorId = string.IsNullOrEmpty(quest.id);

                if (!errorId)
                {
                    quest.expanded = EditorGUILayout.Foldout(quest.expanded, quest.displayName);
                }
                else
                {
                    quest.expanded = EditorGUILayout.Foldout(quest.expanded,
                                                             string.Format("{0}: ID cannot be left blank and must be unique", quest.displayName),
                                                             errorFoldoutStyle);
                }

                if (quest.expanded)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);                     // BEGIN Wrapper

                    quest.displayName = EditorGUILayout.TextField("Display Name", quest.displayName);
                    quest.id          = EditorGUILayout.TextField("ID", quest.id);
                    quest.sideQuest   = EditorGUILayout.Toggle("Sidequest?", quest.sideQuest);

                    /***** BEGIN Description *****/
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Description");
                    quest.description = GUILayout.TextArea(quest.description, GUILayout.MaxHeight(60f), GUILayout.MaxWidth(textAreaWidth));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Notes");
                    quest.notes = GUILayout.TextArea(quest.notes, GUILayout.MaxHeight(60f), GUILayout.MaxWidth(textAreaWidth));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndHorizontal();
                    /***** END Description *****/

                    /***** BEGIN Messages *****/
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Success Message");
                    quest.successMessage = GUILayout.TextArea(quest.successMessage, GUILayout.MaxHeight(60f), GUILayout.MaxWidth(textAreaWidth));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Fail Message");
                    quest.failMessage = GUILayout.TextArea(quest.failMessage, GUILayout.MaxHeight(60f), GUILayout.MaxWidth(textAreaWidth));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndHorizontal();
                    /***** END Messages *****/

                    /***** BEGIN Tasks *****/
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Tasks");
                    if (GUILayout.Button("Add Task"))
                    {
                        AddTask(quest);
                    }
                    EditorGUILayout.EndHorizontal();

                    for (int j = 0, jl = quest.Tasks.Count; j < jl; j++)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);                         // BEGIN Wrapper
                        task = questTmp[i].Tasks[j];

                        EditorGUILayout.LabelField(string.Format("{0}. {1}", j + 1, task.displayName), EditorStyles.boldLabel);
                        task.displayName = EditorGUILayout.TextField("Display Text", task.displayName);
                        task.id          = EditorGUILayout.TextField("ID", task.id);

                        EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(200f));                         // BEGIN Meta

                        if (GUILayout.Button("Up"))
                        {
                            MoveTaskUp(i, j);
                        }
                        if (GUILayout.Button("Down"))
                        {
                            MoveTaskDown(i, j);
                        }
                        if (GUILayout.Button("Delete") && ConfirmDelete("Delete Task", task.displayName))
                        {
                            RemoveTask(i, j);
                        }

                        EditorGUILayout.EndHorizontal();                       // END Meta

                        EditorGUILayout.EndVertical();                         // END Wrapper
                    }

                    if (taskAction != TaskAction.Undefined)
                    {
                        UpdateTasks();
                    }
                    /***** END Tasks *****/

                    if (GUILayout.Button(string.Format("Remove {0}", quest.displayName)) && ConfirmDelete("Delete Quest", quest.displayName))
                    {
                        deleteIndex = i;
                    }

                    EditorGUILayout.EndVertical();                     // END Wrapper
                }
            }

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

            if (deleteIndex != -1)
            {
                RemoveQuest(deleteIndex);
                deleteIndex = -1;
            }
        }