Пример #1
0
        private void OnSaveAllFiles(object sender, EventArgs e)
        {
            if (documentProject != null)
            {
                if (ResourcesHandler.Project.Dirty)
                {
                    ResourcesHandler.SaveProject();
                    documentProject.RefreshTitle();
                }
            }

            foreach (DocumentDialogue document in documentDialogues)
            {
                var documentDialogue = document as DocumentDialogue;
                documentDialogue.ResolvePendingDirty();
                if (ResourcesHandler.IsDirty(documentDialogue.Dialogue))
                {
                    ResourcesHandler.SaveDialogue(documentDialogue.Dialogue);
                    documentDialogue.OnPostSave();
                    documentDialogue.RefreshTitle();
                }
            }
        }
Пример #2
0
        public bool CloseAllDocuments()
        {
            if (ResourcesHandler.Project != null)
            {
                Project dirtyProject   = (ResourcesHandler.Project.Dirty) ? ResourcesHandler.Project : null;
                var     dirtyDialogues = ResourcesHandler.GetAllDialoguesDirty();

                if (!ShowPopupCloseDocuments(dirtyProject, dirtyDialogues))
                {
                    return(false);
                }
            }

            //At this point, what should have been saved is saved, so we can force close every document
            while (documentDialogues.Count > 0)
            {
                CloseDocumentDialogue(documentDialogues[0], true);
            }

            CloseDocumentProject(true);

            return(true);
        }
Пример #3
0
        private void OnNewDialogue(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
                return;

            string projectDirectory = EditorHelper.GetProjectDirectory();

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Title = "Create Dialogue";
            dialog.Filter = "Dialogue Files|*" + Dialogue.GetExtension();
            dialog.InitialDirectory = projectDirectory;

            DialogResult result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                Dialogue newDialogue = ResourcesHandler.CreateDialogueFile(dialog.FileName);
                if (newDialogue != null)
                {
                    EditorCore.ProjectExplorer.ResyncFile(newDialogue, true);

                    OpenDocumentDialogue(newDialogue);
                }
            }
        }
Пример #4
0
        public bool TryToReloadOrSaveDialogueIfDirty(Dialogue dialogue)
        {
            if (!ResourcesHandler.IsDirty(dialogue))
            {
                return true;
            }
            else if (ShowPopupCloseDocuments(null, new List<Dialogue>() { dialogue }))
            {
                // Just in case, force a reload of the whole document to ensure we leave in a valid state
                foreach (DocumentDialogue document in documentDialogues)
                {
                    if (document.Dialogue == dialogue)
                    {
                        ResourcesHandler.ReloadDialogue(dialogue);
                        document.OnPostReload();
                        break;
                    }
                }

                return true;
            }

            return false;
        }
Пример #5
0
        private void OnPackageNewDialogue(object sender, EventArgs e)
        {
            Package package = tree.SelectedNode.Tag as Package;

            if (package != null)
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Title            = "Create Dialogue";
                dialog.Filter           = "Dialogue Files|*" + Dialogue.GetExtension();
                dialog.InitialDirectory = EditorHelper.GetProjectDirectory();

                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    Dialogue newDialogue = ResourcesHandler.CreateDialogueFile(dialog.FileName, package);
                    if (newDialogue != null)
                    {
                        ResyncFile(newDialogue, true);

                        EditorCore.MainWindow.OpenDocumentDialogue(newDialogue);
                    }
                }
            }
        }
Пример #6
0
        private void OnEditIDClicked(object sender, EventArgs e)
        {
            if (!ready)
            {
                return;
            }

            DialogRename dialog = new DialogRename(currentActor.ID);

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string oldID = currentActor.ID;
                if (project.ChangeActorID(currentActor, dialog.NewID))
                {
                    List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues();
                    foreach (Dialogue dialogue in dialogues)
                    {
                        if (dialogue.UpdateActorID(oldID, currentActor.ID))
                        {
                            ResourcesHandler.SetDirty(dialogue);
                        }
                    }

                    textBoxID.Text = currentActor.ID;

                    SetDirty();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }
                }
            }
        }
Пример #7
0
        static public bool ImportDialoguesFromCsv(string importPath, List <Package> packages, List <Language> languages, bool importLocalization, bool importWorkstring, bool importInformation)
        {
            var project = ResourcesHandler.Project;

            //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments
            var headerRedirects = new Dictionary <string, string>();

            headerRedirects.Add("ID", "Node ID");
            headerRedirects.Add("Workstring", "Workstring Text");

            if (importPath == String.Empty)
            {
                EditorCore.LogError("Import Localization failed : no file specified");
                return(false);
            }

            if (!File.Exists(importPath))
            {
                EditorCore.LogError("Import Localization failed : file not found");
                return(false);
            }

            while (Utility.IsFileLocked(importPath))
            {
                EditorCore.LogError("Import Localization failed : file is locked");

                var          dialogLocked = new DialogLockedFile(importPath);
                DialogResult eResult      = dialogLocked.ShowDialog();
                if (eResult == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            DateTime currentTime = Utility.GetCurrentTime();

            using (System.IO.StreamReader file = new System.IO.StreamReader(importPath, Encoding.UTF8))
            {
                ExporterCsv.CsvFileReader reader = new ExporterCsv.CsvFileReader();
                if (reader.ParseHeaders(file, headerRedirects))
                {
                    while (reader.ParseNextLine())
                    {
                        Dialogue dialogue = ResourcesHandler.GetDialogue(reader.GetCell("Dialogue"));
                        if (dialogue != null)
                        {
                            if (!packages.Contains(dialogue.Package))
                            {
                                continue;
                            }

                            int          id   = TranslationTable.GetNodeIDFromPrefixedString(reader.GetCell("ID"));
                            DialogueNode node = dialogue.GetNodeByID(id);
                            if (node == null)
                            {
                                continue;
                            }

                            if (node is DialogueNodeRoot)
                            {
                                var dialogueNodeRoot = node as DialogueNodeRoot;

                                if (importInformation)
                                {
                                    //Import general Dialogue informations
                                    dialogue.Package   = project.GetPackage(reader.GetCell("Package"));
                                    dialogue.SceneType = reader.GetCell("Scene Type");
                                    dialogue.Context   = reader.GetCell("Context");
                                }
                            }
                            else
                            {
                                DateTime timestampLoca = reader.GetCellAsDate("Timestamp");
                                DateTime timestampWorkstring;

                                if (node is DialogueNodeSentence)
                                {
                                    var dialogueNodeSentence = node as DialogueNodeSentence;

                                    if (importWorkstring)
                                    {
                                        //The current workstring is more recent than the modified workstring
                                        if (dialogueNodeSentence.LastEditDate > timestampLoca)
                                        {
                                            //TODO: popup or option to choose what to do here
                                            EditorCore.LogWarning(String.Format("{0} {1} - New workstring older than currently registered workstring, but updated anyway", dialogue.GetName(), id), dialogue, node);
                                        }

                                        dialogueNodeSentence.Sentence     = reader.GetCell("Workstring");
                                        dialogueNodeSentence.LastEditDate = currentTime;
                                        timestampLoca = currentTime;
                                    }

                                    if (importInformation)
                                    {
                                        //Import Sentence informations (Voicing, Context, Speaker..)
                                        string context = reader.GetCell("Context");
                                        dialogueNodeSentence.Context = context;

                                        string voicing = reader.GetCell("Voicing");
                                        dialogueNodeSentence.Comment = voicing;

                                        string voiceIntensity = reader.GetCell("Voice Intensity");
                                        dialogueNodeSentence.VoiceIntensity = voiceIntensity;

                                        string speakerID = ResourcesHandler.Project.GetActorID(reader.GetCell("Speaker"));
                                        dialogueNodeSentence.SpeakerID = speakerID;
                                    }

                                    timestampWorkstring = dialogueNodeSentence.LastEditDate;
                                }
                                else
                                {
                                    var dialogueNodeReply = node as DialogueNodeReply;

                                    if (importWorkstring)
                                    {
                                        //The current workstring is more recent than the modified workstring
                                        if (dialogueNodeReply.LastEditDate > timestampLoca)
                                        {
                                            //TODO: popup or option to choose what to do here
                                            EditorCore.LogWarning(String.Format("{0} {1} - New workstring older than currently registered workstring, but updated anyway", dialogue.GetName(), id), dialogue, node);
                                        }

                                        dialogueNodeReply.Reply        = reader.GetCell("Workstring");
                                        dialogueNodeReply.LastEditDate = currentTime;
                                        timestampLoca = currentTime;
                                    }

                                    timestampWorkstring = dialogueNodeReply.LastEditDate;
                                }

                                if (importLocalization)
                                {
                                    foreach (var language in languages)
                                    {
                                        //TODO: extract this part in a function, to be used from other importers

                                        ETranslationResult translationResult = dialogue.Translations.AddOrUpdateNodeEntry(
                                            id,
                                            language,
                                            timestampLoca,
                                            reader.GetCell(language.Name + " Text")
                                            );

                                        if (translationResult == ETranslationResult.Accepted ||
                                            translationResult == ETranslationResult.Accepted_IdenticalTimestamp ||
                                            translationResult == ETranslationResult.Accepted_IdenticalText)
                                        {
                                            //The current workstring is more recent than the localized entry
                                            if (timestampWorkstring > timestampLoca)
                                            {
                                                EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but based on an outdated workstring, will be re-exported", dialogue.GetName(), id, language.Name), dialogue, node);
                                            }
                                            else
                                            {
                                                //EditorCore.LogInfo(String.Format("{0} {1} - Translation accepted", dialogue.GetName(), id), dialogue.GetName(), id);
                                            }
                                        }

                                        if (translationResult == ETranslationResult.Accepted_IdenticalTimestamp)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but with an identical timestamp as the previous entry", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Accepted_IdenticalText)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation accepted but with an identical text as the previous entry", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_EmptyText)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation refused : empty text", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_Outdated)
                                        {
                                            EditorCore.LogWarning(String.Format("{0} {1} - [{2}] Translation refused : outdated timestamp", dialogue.GetName(), id, language.Name), dialogue, node);
                                        }
                                        else if (translationResult == ETranslationResult.Refused_Identical)
                                        {
                                            //ignored
                                        }
                                    }
                                }
                            }
                        }

                        ResourcesHandler.SetDirty(dialogue);
                    }

                    ResourcesHandler.SaveAllDirty();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }

                    EditorCore.ProjectExplorer.ResyncAllFiles();
                }
            }
            return(true);
        }
Пример #8
0
        static public bool ImportConstantsFromCsv(string importPath, List <Language> languages, bool importLocalization, bool importWorkstring, bool importInformation)
        {
            var project = ResourcesHandler.Project;

            if (importPath == String.Empty)
            {
                EditorCore.LogError("Import Constants failed : no file specified");
                return(false);
            }

            if (!File.Exists(importPath))
            {
                EditorCore.LogError("Import Constants failed : file not found");
                return(false);
            }

            while (Utility.IsFileLocked(importPath))
            {
                EditorCore.LogError("Import Constants failed : file is locked");

                var          dialogLocked = new DialogLockedFile(importPath);
                DialogResult eResult      = dialogLocked.ShowDialog();
                if (eResult == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            DateTime currentTime = Utility.GetCurrentTime();

            using (System.IO.StreamReader file = new System.IO.StreamReader(importPath, Encoding.UTF8))
            {
                ExporterCsv.CsvFileReader reader = new ExporterCsv.CsvFileReader();
                if (reader.ParseHeaders(file))
                {
                    while (reader.ParseNextLine())
                    {
                        string   id       = reader.GetCell("ID");
                        Constant constant = project.ListConstants.Find(item => item.ID == id);
                        if (constant != null)
                        {
                            DateTime timestampLoca = reader.GetCellAsDate("Timestamp");
                            DateTime timestampWorkstring;

                            if (importWorkstring)
                            {
                                //The current workstring is more recent than the modified workstring
                                if (constant.LastEditDate > timestampLoca)
                                {
                                    //TODO: popup or option to choose what to do here
                                    EditorCore.LogWarning(String.Format("Constant {0} - New workstring older than currently registered workstring, but updated anyway", id));
                                }

                                constant.Workstring   = reader.GetCell("Workstring");
                                constant.LastEditDate = currentTime;
                                timestampLoca         = currentTime;
                            }

                            if (importInformation)
                            {
                                string voicing = reader.GetCell("Comment");
                                constant.Comment = voicing;
                            }

                            timestampWorkstring = constant.LastEditDate;

                            if (importLocalization)
                            {
                                foreach (var language in languages)
                                {
                                    //TODO: extract this part in a function, to be used from other importers

                                    ETranslationResult translationResult = project.Translations.AddOrUpdateEntry(
                                        id,
                                        language,
                                        timestampLoca,
                                        reader.GetCell(language.Name + " Text")
                                        );

                                    if (translationResult == ETranslationResult.Accepted ||
                                        translationResult == ETranslationResult.Accepted_IdenticalTimestamp ||
                                        translationResult == ETranslationResult.Accepted_IdenticalText)
                                    {
                                        //The current workstring is more recent than the localized entry
                                        if (timestampWorkstring > timestampLoca)
                                        {
                                            EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but based on an outdated workstring, will be re-exported", id, language.Name));
                                        }
                                        else
                                        {
                                            //EditorCore.LogInfo(String.Format("{0} {1} - Translation accepted", dialogue.GetName(), id), dialogue.GetName(), id);
                                        }
                                    }

                                    if (translationResult == ETranslationResult.Accepted_IdenticalTimestamp)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but with an identical timestamp as the previous entry", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Accepted_IdenticalText)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation accepted but with an identical text as the previous entry", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_EmptyText)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation refused : empty text", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_Outdated)
                                    {
                                        EditorCore.LogWarning(String.Format("Constant {0} - [{1}] Translation refused : outdated timestamp", id, language.Name));
                                    }
                                    else if (translationResult == ETranslationResult.Refused_Identical)
                                    {
                                        //ignored
                                    }
                                }
                            }
                        }
                    }

                    ResourcesHandler.SaveProject();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }
                }
            }

            return(true);
        }
Пример #9
0
        //--------------------------------------------------------------------------------------------------------------
        // Exports

        static public bool ExportToCsv()
        {
            var project = ResourcesHandler.Project;

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Path.Combine(projectDirectory, EditorCore.Settings.DirectoryExportDialogues);

            var dialog = new DialogExport("Export Dialogues",
                                          exportDirectory,
                                          true, false,
                                          true, false,
                                          true, DateTime.MinValue);
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return(false);
            }

            EditorCore.Settings.DirectoryExportDialogues = Utility.GetRelativePath(dialog.ExportPath, projectDirectory);

            exportDirectory = dialog.ExportPath;
            if (dialog.UseDateDirectory)
            {
                exportDirectory = Path.Combine(exportDirectory, Utility.GetCurrentDateAsString());
            }

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            var packageGroups = new List <List <Package> >();

            if (dialog.UsePackagesDirectory)
            {
                foreach (var package in dialog.ListPackages)
                {
                    packageGroups.Add(new List <Package>()
                    {
                        package
                    });
                }
            }
            else
            {
                packageGroups.Add(dialog.ListPackages);
            }

            ExporterStats.ProjectStats projectStats = new ExporterStats.ProjectStats();

            //Ensure no export of a Workstring language
            var listLanguages = new List <Language>();   // { EditorCore.LanguageWorkstring };

            if (!dialog.WorkstringOnly)
            {
                listLanguages = dialog.ListLanguages;
            }

            foreach (var packageGroup in packageGroups)     //Either a list of individual packages, or 1 entry with all the packages
            {
                var packageDirectory = exportDirectory;
                if (dialog.UsePackagesDirectory)
                {
                    packageDirectory = Path.Combine(packageDirectory, packageGroup[0].Name);
                }

                if (!Directory.Exists(packageDirectory))
                {
                    Directory.CreateDirectory(packageDirectory);
                }

                var dialogues = dialog.SelectedDialogues;
                if (!dialog.UseCustomSelection)
                {
                    dialogues = ResourcesHandler.GetAllDialoguesFromPackages(packageGroup);
                }

                ExportDialoguesToCsv(packageDirectory, project, dialogues, listLanguages, dialog.DateFrom, projectStats);

                ExporterStats.Export("TodoTranslationsCount", projectStats, packageDirectory, packageGroup, listLanguages, dialog.WorkstringOnly, dialog.WorkstringFallback);
            }

            if (dialog.Constants)
            {
                ExportConstantsToCsv(exportDirectory, project, listLanguages);
            }

            System.Diagnostics.Process.Start(exportDirectory);

            return(true);
        }
Пример #10
0
        private void SearchClick(object sender, EventArgs e)
        {
            string workstring      = textBoxWorkstring.Text;
            bool   searchSentences = checkBoxSentences.Checked;
            bool   searchReplies   = checkBoxReplies.Checked;
            bool   searchChoices   = checkBoxChoices.Checked;

            List <Result> results = new List <Result>();

            var dialogues = ResourcesHandler.GetAllDialogues();

            foreach (var dialogue in dialogues)
            {
                foreach (var node in dialogue.ListNodes)
                {
                    foreach (var condition in node.Conditions)
                    {
                        if (Check(condition))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (condition as NodeCondition).GetDisplayText()), dialogue, node));
                        }
                    }
                    foreach (var action in node.Actions)
                    {
                        if (Check(action))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (action as NodeAction).GetDisplayText()), dialogue, node));
                        }
                    }
                    foreach (var flag in node.Flags)
                    {
                        if (Check(flag))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (flag as NodeFlag).GetDisplayText()), dialogue, node));
                        }
                    }

                    if (workstring.Length > 0)
                    {
                        if (searchSentences)
                        {
                            var sentence = node as DialogueNodeSentence;
                            if (sentence != null && sentence.Sentence.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(sentence.Sentence)), dialogue, node));
                            }
                        }

                        if (searchReplies)
                        {
                            var reply = node as DialogueNodeReply;
                            if (reply != null && reply.Reply.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(reply.Reply)), dialogue, node));
                            }
                        }

                        if (searchChoices)
                        {
                            var choice = node as DialogueNodeChoice;
                            if (choice != null && choice.Choice.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(choice.Choice)), dialogue, node));
                            }
                        }
                    }
                }
            }

            EditorCore.StartSearchResult();
            foreach (var result in results)
            {
                EditorCore.AddSearchResult(result.text, result.dialogue, result.node);
            }
            EditorCore.EndSearchResult();
        }
Пример #11
0
        private void OnShowAllStats(object sender, EventArgs e)
        {
            DialogStats dialog = new DialogStats(ResourcesHandler.GetAllDialogues());

            dialog.ShowDialog();
        }
Пример #12
0
        static public bool ExportToAriaCode()
        {
            var project = ResourcesHandler.Project;

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Properties.Settings.Default.ModPath;

            var dialog = new CodeExport("Export Dialogues",
                                        exportDirectory);
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return(false);
            }

            EditorCore.Settings.DirectoryExportDialogues = Utility.GetRelativePath(dialog.ExportPath, projectDirectory);

            exportDirectory = dialog.ExportPath;

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            ExporterStats.ProjectStats projectStats = new ExporterStats.ProjectStats();

            string outputDirectory = Path.Combine(exportDirectory, "scripts", "globals", "static_data", "generated_dialog");

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            foreach (var package in dialog.ListPackages)     //Either a list of individual packages, or 1 entry with all the packages
            {
                var packageDirectory = Path.Combine(outputDirectory, package.Name);

                if (!Directory.Exists(packageDirectory))
                {
                    Directory.CreateDirectory(packageDirectory);
                }

                var dialogues = dialog.SelectedDialogues;
                if (!dialog.UseCustomSelection)
                {
                    dialogues = ResourcesHandler.GetAllDialoguesFromPackages(new List <Package>()
                    {
                        package
                    });
                }

                foreach (var singleDialog in dialogues)
                {
                    string luaContents = BuildLuaFile(singleDialog);
                    File.WriteAllText(Path.Combine(packageDirectory, singleDialog.GetName() + ".lua"), luaContents);
                }

                //Make generated_dialog/<package>/main.lua
                StringBuilder packageMainBuilder = new StringBuilder();
                AddAutogenerateHeader(packageMainBuilder);
                packageMainBuilder.AppendFormat("GeneratedDialog.{0} = {{}}{1}", package.Name, Environment.NewLine);

                foreach (var requireDialog in ResourcesHandler.GetAllDialoguesFromPackages(new List <Package>()
                {
                    package
                }))
                {
                    string dialogFile = Path.Combine(packageDirectory, requireDialog.GetName() + ".lua");
                    if (File.Exists(dialogFile))
                    {
                        packageMainBuilder.AppendFormat("require 'globals.static_data.generated_dialog.{0}.{1}'{2}", package.Name, requireDialog.GetName(), Environment.NewLine);
                    }
                }

                File.WriteAllText(Path.Combine(packageDirectory, "main.lua"), packageMainBuilder.ToString());
            }

            //Make generated_dialog/main.lua
            StringBuilder builder = new StringBuilder();

            AddAutogenerateHeader(builder);
            builder.AppendLine("GeneratedDialog = {}");
            foreach (var package in project.ListPackages)
            {
                if (File.Exists(Path.Combine(outputDirectory, package.Name, "main.lua")))
                {
                    builder.AppendFormat("require 'globals.static_data.generated_dialog.{0}.main'{1}", package.Name, Environment.NewLine);
                }
            }

            File.WriteAllText(Path.Combine(outputDirectory, "main.lua"), builder.ToString());

            System.Diagnostics.Process.Start(exportDirectory);

            Properties.Settings.Default.ModPath = exportDirectory;
            Properties.Settings.Default.Save();

            return(true);
        }
Пример #13
0
        //--------------------------------------------------------------------------------------------------------------
        // Exports

        static public bool ExportAll()
        {
            Project project = ResourcesHandler.Project;

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Path.Combine(projectDirectory, EditorCore.Settings.DirectoryExportVoicing);

            var dialog = new DialogExport("Export Voicing",
                                          exportDirectory,
                                          true, false,
                                          false, true,
                                          true, project.LastVoicingExportDate);
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return(false);
            }

            EditorCore.Settings.DirectoryExportVoicing = Utility.GetRelativePath(dialog.ExportPath, projectDirectory);

            DateTime dateNow = Utility.GetCurrentTime();

            project.LastVoicingExportDate = dateNow;
            project.Dirty = true;

            exportDirectory = dialog.ExportPath;
            if (dialog.UseDateDirectory)
            {
                exportDirectory = Path.Combine(exportDirectory, Utility.GetDateAsString(dateNow));
            }

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            var packageGroups = new List <List <Package> >();

            if (dialog.UsePackagesDirectory)
            {
                foreach (var package in dialog.ListPackages)
                {
                    packageGroups.Add(new List <Package>()
                    {
                        package
                    });
                }
            }
            else
            {
                packageGroups.Add(dialog.ListPackages);
            }

            var listLanguages = new List <Language>()
            {
                EditorCore.LanguageWorkstring
            };

            if (!dialog.WorkstringOnly)
            {
                listLanguages = dialog.ListLanguages;
            }

            ExporterStats.ProjectStats projectStats = new ExporterStats.ProjectStats();

            foreach (var packageGroup in packageGroups)     //Either a list of individual packages, or 1 entry with all the packages
            {
                var packageDirectory = exportDirectory;
                if (dialog.UsePackagesDirectory)
                {
                    packageDirectory = Path.Combine(packageDirectory, packageGroup[0].Name);
                }

                var dialogues = dialog.SelectedDialogues;
                if (!dialog.UseCustomSelection)
                {
                    dialogues = ResourcesHandler.GetAllDialoguesFromPackages(packageGroup);
                }

                var dateFrom = dialog.DateFrom;

                foreach (var language in listLanguages)
                {
                    string languageDirectory = Path.Combine(packageDirectory, language.VoicingCode);

                    if (!Directory.Exists(languageDirectory))
                    {
                        Directory.CreateDirectory(languageDirectory);
                    }

                    ExportLocasToCSVFile(languageDirectory, project, dialogues, language, dialog.WorkstringOnly, dialog.WorkstringFallback, dateFrom, projectStats);
                    ExportDialoguesToCSVFile(languageDirectory, project, dialogues, language, dateFrom);
                    ExportActorsToCSVFile(languageDirectory, project, dialogues, language, dateFrom);
                    ExportDialoguesToWwiseTextFile(languageDirectory, project, dialogues, language, dateFrom);
                }
            }

            ExporterStats.Export("TodoVoicingCount", projectStats, exportDirectory, dialog.ListPackages, listLanguages, dialog.WorkstringOnly, dialog.WorkstringFallback);

            System.Diagnostics.Process.Start(exportDirectory);

            return(true);
        }
        private void populateDialogueTreeView(List <Dialogue> inCheckedDialogues)
        {
            var project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            dialogueTreeView.BeginUpdate();

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = dialogueTreeView.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                if (dialogue == null)
                {
                    continue;
                }

                if (dialogue.Package == null)
                {
                    continue;
                }

                TreeNode[] nodePackages = dialogueTreeView.Nodes.Find(GetPackageKey(dialogue.Package.Name), false);
                if (nodePackages.Count() > 0)
                {
                    TreeNode nodeParent = nodePackages[0];

                    string   path       = dialogue.GetFilePath();
                    string[] folders    = path.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                    string   folderPath = "";
                    foreach (string folder in folders)
                    {
                        folderPath = Path.Combine(folderPath, folder);

                        TreeNode[] nodeFolders = nodeParent.Nodes.Find(folder, false);
                        if (nodeFolders.Count() > 0)
                        {
                            nodeParent = nodeFolders[0];
                        }
                        else
                        {
                            nodeParent     = nodeParent.Nodes.Add(folder, folder);
                            nodeParent.Tag = new Folder()
                            {
                                Path = folderPath
                            };
                            EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
                        }
                    }

                    TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
                    nodeDialogue.Checked = checkedDialogues.Contains(dialogue);
                    nodeDialogue.Tag     = dialogue;
                    EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);
                }
            }

            dialogueTreeView.EndUpdate();

            foreach (TreeNode node in dialogueTreeView.Nodes)
            {
                node.Expand();
            }
        }
Пример #15
0
        public void Init()
        {
            //Panels
            deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            LoadPanels();

            //Status Bar
            statusProgressBar.Visible = false;
            statusLabel.Visible       = false;

            //Settings
            EditorCore.Settings.Load();    //Load if file exists
            EditorCore.Settings.Save();    //Ensure file exists

            //Load last project
            if (File.Exists(EditorCore.Settings.LastProject))
            {
                ResourcesHandler.LoadProjectFile(EditorCore.Settings.LastProject);
                EditorCore.ProjectExplorer.ResyncAllFiles();
            }

            //Memory usage
            RefreshMemoryUsage();

            statusTimer          = new Timer();
            statusTimer.Interval = 2000;
            statusTimer.Tick    += new EventHandler(delegate
            {
                RefreshMemoryUsage();
            });
            statusTimer.Start();

//#if DEBUG

/*
 *          // * INTENT
 *          //
 *          // Debug code to generate 5000 dummy dialogues (150,000 sentences, 2,700,000 words) (Bible is less than 800,000 words)
 *          // -> 10 chapters, 10 quest each, 50 files each, 30 sentences each.
 *          //
 *          //  * USAGE
 *          //
 *          // uncomment and tweak this section
 *          // open the tool
 *          // wait one minute for the generation to finish (you can look at the chapter folders being created as a countdown)
 *          // close the tool
 *          // comment this section
 *          // reopen the tool
 *          //
 *          // * NOTES
 *          //
 *          // it's faster in release ;)
 *          // you must have a project already opened previously (LastProject != null)
 *          // you can create a 'ProjectBig' folder to store this test project, its included in the git ignore file
 *          //
 *
 *          if (ResourcesHandler.Project.ListActors.Count == 0)
 *          {
 *              ResourcesHandler.Project.AddActor(new Actor() { ID = ResourcesHandler.Project.GenerateNewActorID(), Name = "Default Speaker" });
 *          }
 *
 *          Actor defaultSpeaker = ResourcesHandler.Project.ListActors[0];
 *
 *          int indexFile = 0;
 *          for (int a = 1; a <= 10; ++a)
 *          {
 *              string chapter = string.Format("Chapter_{0:000000}", a);
 *
 *              for (int b = 1; b <= 10; ++b)
 *              {
 *                  string quest = string.Format("Quest_{0:000000}", b);
 *
 *                  for (int c = 1; c <= 50; ++c)
 *                  {
 ++indexFile;
 *                      string file = string.Format("File_{0:000000}", indexFile);
 *                      Dialogue dialogue = ResourcesHandler.CreateDialogueFile(Path.Combine(chapter, quest, file));
 *                      if (dialogue != null)
 *                      {
 *                          DialogueNode current = dialogue.RootNode;
 *                          for (int s = 1; s <= 30; ++s)
 *                          {
 *                              DialogueNodeSentence sentence = new DialogueNodeSentence();
 *                              dialogue.AddNode(sentence);
 *                              sentence.SpeakerID = defaultSpeaker.ID;
 *                              sentence.Sentence = "Hello, I'm a dialogue sentence. I'm just here to fill this void space. Please enjoy your day - " + indexFile + "_" + sentence.ID;
 *                              current.Next = sentence;
 *
 *                              current = sentence;
 *                          }
 *
 *                          ResourcesHandler.SaveDialogue(dialogue);
 *                      }
 *                  }
 *              }
 *          }
 *
 *          EditorCore.ProjectExplorer.ResyncAllFiles();
 */
//#endif
        }
Пример #16
0
 public void OpenDocumentDialogue(string name, int node)
 {
     var dialogue = ResourcesHandler.GetDialogue(name);
     if (dialogue != null)
         OpenDocumentDialogue(dialogue, node);
 }
Пример #17
0
        public void ResyncAllFiles()
        {
            Clear();

            Project project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                var sceneTypes = new Dictionary <string, string>();
                sceneTypes.Add("", "");
                foreach (var kvp in EditorCore.CustomLists["SceneTypes"])
                {
                    sceneTypes.Add(kvp.Key, kvp.Value);
                }

                comboBoxSearchSceneType.DataSource    = new BindingSource(sceneTypes, null);
                comboBoxSearchSceneType.ValueMember   = "Key";
                comboBoxSearchSceneType.DisplayMember = "Value";

                comboBoxSearchSceneType.Enabled = true;
            }

            if (project.ListActors.Count > 0)
            {
                var actors = new Dictionary <string, string>();
                actors.Add("", "");
                foreach (var actor in project.ListActors)
                {
                    actors.Add(actor.ID, actor.Name);
                }

                comboBoxSearchActor.DataSource    = new BindingSource(actors, null);
                comboBoxSearchActor.ValueMember   = "Key";
                comboBoxSearchActor.DisplayMember = "Value";

                comboBoxSearchActor.Enabled = true;
            }

            tree.BeginUpdate();

            TreeNode nodeProject = tree.Nodes.Add("Project", String.Format("Project {0}", project.GetName()));

            nodeProject.Tag = project;
            EditorHelper.SetNodeIcon(nodeProject, ENodeIcon.Project);

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = tree.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                nodePackage.ContextMenuStrip = menuPackage;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                ResyncFile(dialogue, false);
            }

            tree.EndUpdate();

            //tree.CollapseAll();
            foreach (TreeNode node in tree.Nodes)
            {
                node.Expand();
            }
        }
Пример #18
0
        public void Init()
        {
            //Panels
            deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            LoadPanels();

            //Status Bar
            statusProgressBar.Visible = false;
            statusLabel.Visible       = false;

            //Settings
            EditorCore.Settings.Load();    //Load if file exists
            EditorCore.Settings.Save();    //Ensure file exists

            //Load last project
            if (File.Exists(EditorCore.Settings.LastProject))
            {
                ResourcesHandler.LoadProjectFile(EditorCore.Settings.LastProject);
                EditorCore.ProjectExplorer.ResyncAllFiles();
            }

            //Memory usage
            RefreshMemoryUsage();

            statusTimer          = new Timer();
            statusTimer.Interval = 2000;
            statusTimer.Tick    += new EventHandler(delegate
            {
                RefreshMemoryUsage();
            });
            statusTimer.Start();

//#if DEBUG
            //Debug code to generate 11250 dummy dialogues (337500 sentences)
            //
            //  * USAGE
            //
            // uncomment and tweak this section
            // open the tool
            // wait one minute for the generation to finish (you can look at the chapter folders being created as a countdown)
            // close the tool
            // comment this section
            // reopen the tool
            //
            // * NOTES
            //
            // it's faster in release ;)
            //

            /*
             * int indexFile = 0;
             * for (int a = 1; a <= 15; ++a)
             * {
             *  string chapter = string.Format("Chapter_{0:000000}", a);
             *
             *  for (int b = 1; b <= 15; ++b)
             *  {
             *      string quest = string.Format("Quest_{0:000000}", b);
             *
             *      for (int c = 1; c <= 50; ++c)
             *      {
             ++indexFile;
             *          string file = string.Format("File_{0:000000}", indexFile);
             *          Dialogue dialogue = ResourcesHandler.CreateDialogueFile(Path.Combine(chapter, quest, file));
             *
             *          DialogueNode current = dialogue.RootNode;
             *          for (int s = 1; s <= 30; ++s)
             *          {
             *              DialogueNodeSentence sentence = new DialogueNodeSentence();
             *              dialogue.AddNode(sentence);
             *              sentence.Sentence = "Hello, I'm a dialogue sentence. I'm just here to fill this void space. Please enjoy your day - " + indexFile + "_" + sentence.ID;
             *              current.Next = sentence;
             *
             *              current = sentence;
             *          }
             *
             *          ResourcesHandler.SaveDialogue(dialogue);
             *      }
             *  }
             * }
             * EditorCore.ProjectExplorer.ResyncAllFiles();
             */
//#endif
        }