Пример #1
0
        private void DrawControls()
        {
            EditorGUIUtility.LookLikeControls();

            // Project Format:
            EditorGUILayout.BeginHorizontal();
            ChatMapperProjectFormat newFormat = (ChatMapperProjectFormat)EditorGUILayout.Popup(new GUIContent("Project Format", "Converting from CMP requires Chat Mapper Commercial."), (int)prefs.projectFormat, FormatOptions);

            if (newFormat != prefs.projectFormat)
            {
                for (int i = 0; i < prefs.projectFilenames.Count; i++)
                {
                    if (newFormat == ChatMapperProjectFormat.Cmp)
                    {
                        prefs.projectFilenames[i] = prefs.projectFilenames[i].Replace("xml", "cmp");
                    }
                    else
                    {
                        prefs.projectFilenames[i] = prefs.projectFilenames[i].Replace("cmp", "xml");
                    }
                }
                prefs.projectFormat        = newFormat;
                GUIUtility.keyboardControl = 0;
            }
            EditorGUILayout.EndHorizontal();

            // Path to ChatMapper.exe:
            if (prefs.projectFormat == ChatMapperProjectFormat.Cmp)
            {
                if (string.IsNullOrEmpty(prefs.pathToChatMapperExe))
                {
                    EditorGUILayout.HelpBox("To directly convert CMP files, the Dialogue System will run ChatMapper.exe in the background. Specify the location of ChatMapper.exe in the field below.", MessageType.Info);
                }
            }
            EditorGUILayout.BeginHorizontal();
            prefs.pathToChatMapperExe = EditorGUILayout.TextField(new GUIContent("Path to ChatMapper.exe", "Optional if converting XML. Also used to open CMP files in Project with double-click."), prefs.pathToChatMapperExe);
            if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                prefs.pathToChatMapperExe  = EditorUtility.OpenFilePanel("Path to ChatMapper.exe", "", "exe");
                GUIUtility.keyboardControl = 0;
            }
            EditorGUILayout.EndHorizontal();

            // Paths to Chat Mapper Projects:
            if (!HasValidProjectFilenames())
            {
                EditorGUILayout.HelpBox("Specify the Chat Mapper project(s) to convert. Click '+' to add a Chat Mapper project", MessageType.Info);
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Chat Mapper Projects", "Specify project to convert here."));
            if (GUILayout.Button(new GUIContent("+", "Add another Chat Mapper project to convert"), EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                prefs.projectFilenames.Add(string.Empty);
                prefs.includeProjectFilenames.Add(true);
            }
            EditorGUILayout.EndHorizontal();
            if (prefs.includeProjectFilenames.Count < prefs.projectFilenames.Count)
            {
                for (int i = prefs.includeProjectFilenames.Count; i < prefs.projectFilenames.Count; i++)
                {
                    prefs.includeProjectFilenames.Add(true);
                }
            }
            int projectFilenameToDelete = -1;

            for (int i = 0; i < prefs.projectFilenames.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                prefs.projectFilenames[i]        = EditorGUILayout.TextField("    Filename", prefs.projectFilenames[i]);
                prefs.includeProjectFilenames[i] = EditorGUILayout.Toggle(prefs.includeProjectFilenames[i], GUILayout.Width(16));
                if (GUILayout.Button("...", EditorStyles.miniButtonMid, GUILayout.Width(22)))
                {
                    prefs.projectFilenames[i]  = EditorUtility.OpenFilePanel("Select Chat Mapper Project", EditorWindowTools.GetDirectoryName(prefs.projectFilenames[i]), GetFormatExtension(prefs.projectFormat));
                    GUIUtility.keyboardControl = 0;
                }
                if (GUILayout.Button(new GUIContent("-", "Remove this slot."), EditorStyles.miniButtonRight, GUILayout.Width(22)))
                {
                    projectFilenameToDelete = i;
                }
                EditorGUILayout.EndHorizontal();
            }
            if (projectFilenameToDelete >= 0)
            {
                prefs.projectFilenames.RemoveAt(projectFilenameToDelete);
            }

            // Portrait Folder:
            EditorGUILayout.BeginHorizontal();
            prefs.portraitFolder = EditorGUILayout.TextField(new GUIContent("Portrait Folder", "Optional folder containing actor portrait textures. The converter will search this folder for textures matching any actor pictures defined in the Chat Mapper project."), prefs.portraitFolder);
            if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                prefs.portraitFolder       = EditorUtility.OpenFolderPanel("Location of Portrait Textures", prefs.portraitFolder, "");
                prefs.portraitFolder       = "Assets" + prefs.portraitFolder.Replace(Application.dataPath, string.Empty);
                GUIUtility.keyboardControl = 0;
            }
            EditorGUILayout.EndHorizontal();

            // Save To:
            if (string.IsNullOrEmpty(prefs.outputFolder))
            {
                EditorGUILayout.HelpBox("In the field below, specify the folder to create the dialogue database asset(s) in.", MessageType.Info);
            }
            EditorGUILayout.BeginHorizontal();
            prefs.outputFolder = EditorGUILayout.TextField(new GUIContent("Save To", "Folder where dialogue database assets will be saved."), prefs.outputFolder);
            if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22)))
            {
                prefs.outputFolder         = EditorUtility.SaveFolderPanel("Path to Save Database", prefs.outputFolder, "");
                prefs.outputFolder         = "Assets" + prefs.outputFolder.Replace(Application.dataPath, string.Empty);
                GUIUtility.keyboardControl = 0;
            }
            EditorGUILayout.EndHorizontal();

            // Project/Database Name:
            bool hasMultipleProjects = (prefs.projectFilenames.Count > 1);

            if (hasMultipleProjects)
            {
                prefs.useProjectName = true;
            }
            EditorGUI.BeginDisabledGroup(hasMultipleProjects);
            prefs.useProjectName = EditorGUILayout.Toggle(new GUIContent("Use Project Name", "Tick to use project name defined in Chat Mapper project, untick to specify a name."), prefs.useProjectName);
            EditorGUI.EndDisabledGroup();
            if (!prefs.useProjectName)
            {
                prefs.databaseName = EditorGUILayout.TextField(new GUIContent("Dialogue Database Name", "Filename to create in Save To folder."), prefs.databaseName);
            }

            // Overwrite:
            prefs.overwrite = EditorGUILayout.Toggle(new GUIContent("Overwrite", "Tick to overwrite the dialogue database if it exists, untick to create a new copy."), prefs.overwrite);

            // Buttons:
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Clear", GUILayout.Width(100)))
            {
                ClearPrefs();
            }
            bool disabled = (string.IsNullOrEmpty(prefs.pathToChatMapperExe) && (prefs.projectFormat == ChatMapperProjectFormat.Cmp)) ||
                            !HasValidProjectFilenames() ||
                            string.IsNullOrEmpty(prefs.outputFolder) ||
                            (!prefs.useProjectName && string.IsNullOrEmpty(prefs.databaseName));

            EditorGUI.BeginDisabledGroup(disabled);
            if (GUILayout.Button("Convert", GUILayout.Width(100)))
            {
                ConvertChatMapperProjects();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            if (GUI.changed)
            {
                SavePrefs();
            }
        }
Пример #2
0
 private string GetFormatExtension(ChatMapperProjectFormat format)
 {
     return((format == ChatMapperProjectFormat.Cmp) ? "cmp" : "xml");
 }
Пример #3
0
 private string GetFormatExtension(ChatMapperProjectFormat format)
 {
     return (format == ChatMapperProjectFormat.Cmp) ? "cmp" : "xml";
 }