private void RefreshPortraits()
        {
            Project project       = ResourcesHandler.Project;
            Actor   actorSpeaker  = project.GetActorFromID(dialogueNode.SpeakerID);
            Actor   actorListener = project.GetActorFromID(dialogueNode.ListenerID);

            picturePortraitSpeaker.Image = null;
            if (actorSpeaker != null)
            {
                string pathPortraitSpeaker = Path.Combine(EditorHelper.GetProjectDirectory(), actorSpeaker.Portrait);
                if (File.Exists(pathPortraitSpeaker))
                {
                    using (Image temp = Image.FromFile(pathPortraitSpeaker))
                    {
                        picturePortraitSpeaker.Image = new Bitmap(temp);
                    }
                }
            }

            picturePortraitListener.Image = null;
            if (actorListener != null)
            {
                string pathPortraitListener = Path.Combine(EditorHelper.GetProjectDirectory(), actorListener.Portrait);
                if (File.Exists(pathPortraitListener))
                {
                    using (Image temp = Image.FromFile(pathPortraitListener))
                    {
                        picturePortraitListener.Image = new Bitmap(temp);
                    }
                }
            }
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------------------------------------------
        // Imports

        static public void LoadProjectFile(Project project)
        {
            //Deserialize
            string path = Path.Combine(EditorHelper.GetProjectDirectory(), project.GetFileName());

            DeserializeFromFile(path, project);
        }
        private void OnFolderNewDialogue(object sender, EventArgs e)
        {
            Folder folder = tree.SelectedNode.Tag as Folder;

            if (folder != null)
            {
                var root = tree.SelectedNode.GetRootNode();

                Package package = root.Tag as Package;
                if (package != null)
                {
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.Title            = "Create Dialogue";
                    dialog.Filter           = "Dialogue Files|*" + Dialogue.GetExtension();
                    dialog.InitialDirectory = Path.Combine(EditorHelper.GetProjectDirectory(), folder.Path);

                    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);
                        }
                    }
                }
            }
        }
        private void OnDocumentDelete(object sender, EventArgs e)
        {
            Dialogue dialogue = tree.SelectedNode.Tag as Dialogue;

            if (dialogue != null)
            {
                var          dialog  = new DialogConfirmDelete(dialogue);
                DialogResult eResult = dialog.ShowDialog();
                if (eResult == DialogResult.Cancel)
                {
                    return;
                }

                if (EditorCore.MainWindow != null)
                {
                    EditorCore.MainWindow.CloseDocumentDialogue(dialogue, true);
                }

                TreeNode nodeFolder = tree.SelectedNode.Parent;

                tree.Nodes.Remove(tree.SelectedNode);
                tree.SelectedNode = null;

                DeleteIfEmptyFolder(nodeFolder);

                ResourcesHandler.RemoveDialogue(dialogue);

                string filePathName = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePathName());
                if (File.Exists(filePathName))
                {
                    File.Delete(filePathName);
                }
            }
        }
Esempio n. 5
0
        //--------------------------------------------------------------------------------------------------------------
        // Exports

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

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Path.Combine(projectDirectory, "Constants.dlc");

            var constants = new Constants();

            constants.constants = project.ListConstants;

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

            using (StreamWriter file = File.CreateText(exportDirectory))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Formatting          = Formatting.Indented;
                serializer.TypeNameHandling    = TypeNameHandling.Auto;
                serializer.SerializationBinder = EditorCore.SerializationBinder;
                serializer.Serialize(file, constants);
            }

            return(true);
        }
Esempio n. 6
0
        private void OnEditPictureClicked(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title = "Select Picture";
            //dialog.Filter = "Project Files|*.project|Dialogue Files|*.dlg";
            dialog.Filter = "Image Files|*.bmp; *.jpg; *.png; *.gif";

            string pathCurrentPortrait = Path.Combine(EditorHelper.GetProjectDirectory(), textBoxPortrait.Text);
            string dirPortraits        = Path.Combine(EditorHelper.GetProjectDirectory(), EditorCore.Settings.DirectoryPortraits);

            dialog.InitialDirectory = EditorHelper.GetProjectDirectory();
            if (File.Exists(pathCurrentPortrait))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(pathCurrentPortrait);
            }
            else if (Directory.Exists(dirPortraits))
            {
                dialog.InitialDirectory = dirPortraits;
            }

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                textBoxPortrait.Text = Utility.GetRelativePath(dialog.FileName, EditorHelper.GetProjectDirectory());
            }
        }
Esempio n. 7
0
        private void OnEditPathClick(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.Description = "Select the Aria mod directory :";

            dialog.SelectedPath = EditorHelper.GetProjectDirectory();
            if (Directory.Exists(textBoxPath.Text))
            {
                dialog.SelectedPath = textBoxPath.Text;
            }

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string modPath = dialog.SelectedPath;
                if (!Directory.Exists(Path.Combine(modPath, "scripts", "globals", "static_data")))
                {
                    MessageBox.Show("Mod static data not found.");
                }
                else
                {
                    textBoxPath.Text = dialog.SelectedPath;
                }
            }
        }
Esempio n. 8
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);
                }
            }
        }
        private void OnDocumentOpenDirectory(object sender, EventArgs e)
        {
            Dialogue dialogue = tree.SelectedNode.Tag as Dialogue;

            if (dialogue != null)
            {
                Process.Start(Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePath()));
            }
        }
        private void OnFolderOpenDirectory(object sender, EventArgs e)
        {
            Folder folder = tree.SelectedNode.Tag as Folder;

            if (folder != null)
            {
                Process.Start(Path.Combine(EditorHelper.GetProjectDirectory(), folder.Path));
            }
        }
Esempio n. 11
0
        static public void SaveDialogueFile(Project project, Dialogue dialogue)
        {
            //PreSave
            dialogue.PreSave(project);

            //Serialize
            string path = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePathName());

            SerializeToFile(path, dialogue);
        }
Esempio n. 12
0
        //--------------------------------------------------------------------------------------------------------------
        // Exports

        static public void SaveProjectFile(Project project)
        {
            //PreSave
            project.PreSave();

            //Serialize
            string path = Path.Combine(EditorHelper.GetProjectDirectory(), project.GetFileName());

            SerializeToFile(path, project);

            ExporterConstants.ExportToUnreal4();
        }
Esempio n. 13
0
        static public bool LoadDialogueFile(Project project, Dialogue dialogue)
        {
            //Deserialize
            string path = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePathName());

            if (!DeserializeFromFile(path, dialogue))
            {
                return(false);
            }

            //PostLoad
            dialogue.PostLoad(project);
            return(true);
        }
Esempio n. 14
0
        static public bool RemoveDialogueFile(Dialogue dialogue)
        {
            if (RemoveDialogue(dialogue))
            {
                string filePathName = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePathName());
                if (File.Exists(filePathName))
                {
                    File.Delete(filePathName);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 15
0
        private void buttonChooseDialogues_Click(object sender, EventArgs e)
        {
            var    project          = ResourcesHandler.Project;
            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Path.Combine(projectDirectory, EditorCore.Settings.DirectoryExportDialogues);

            var          dialog = new DialogDocumentSelector("Choose Dialogues..", SelectedDialogues);
            DialogResult result = dialog.ShowDialog();

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

            SelectedDialogues = dialog.checkedDialogues;
        }
Esempio n. 16
0
        //--------------------------------------------------------------------------------------------------------------
        // Imports

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

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

            var          dialog = new DialogImport(importPath);
            DialogResult result = dialog.ShowDialog();

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

            bool resultConstants = false;

            if (dialog.ImportConstants)
            {
                resultConstants = ImportConstantsFromCsv(dialog.ImportPathConstants, dialog.ListLanguages, true, false, false);
                if (resultConstants)
                {
                    EditorCore.LogInfo("Import Constants Finished");
                }
                else
                {
                    EditorCore.LogError("Import Constants Failed");
                }
            }

            bool resultDialogues = false;

            if (dialog.ImportLocalization || dialog.ImportWorkstring || dialog.ImportInformation)
            {
                resultDialogues = ImportDialoguesFromCsv(dialog.ImportPathDialogues, dialog.ListPackages, dialog.ListLanguages, dialog.ImportLocalization, dialog.ImportWorkstring, dialog.ImportInformation);
                if (resultDialogues)
                {
                    EditorCore.LogInfo("Import Dialogues Finished");
                }
                else
                {
                    EditorCore.LogError("Import Dialogues Failed");
                }
            }

            return(resultConstants || resultDialogues);
        }
Esempio n. 17
0
        private void OnPictureChanged(object sender, EventArgs e)
        {
            if (!ready)
            {
                return;
            }

            if (File.Exists(Path.Combine(EditorHelper.GetProjectDirectory(), textBoxPortrait.Text)))
            {
                EditorCore.Settings.DirectoryPortraits = Path.GetDirectoryName(textBoxPortrait.Text);
            }

            currentActor.Portrait = textBoxPortrait.Text;
            RefreshPortrait();

            SetDirty();
        }
Esempio n. 18
0
        private void OnDocumentRename(object sender, EventArgs e)
        {
            Dialogue dialogue = tree.SelectedNode.Tag as Dialogue;

            if (dialogue != null)
            {
                bool proceed = false;
                if (EditorCore.MainWindow != null)
                {
                    proceed = EditorCore.MainWindow.TryToReloadOrSaveDialogueIfDirty(dialogue);
                }

                if (proceed)
                {
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.Title            = "Rename Dialogue";
                    dialog.Filter           = "Dialogue Files|*" + Dialogue.GetExtension();
                    dialog.InitialDirectory = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePath());

                    DialogResult result = dialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        if (EditorCore.MainWindow != null)
                        {
                            EditorCore.MainWindow.CloseDocumentDialogue(dialogue, true);
                        }

                        TreeNode nodeFolder = tree.SelectedNode.Parent;

                        tree.Nodes.Remove(tree.SelectedNode);
                        tree.SelectedNode = null;

                        DeleteIfEmptyFolder(nodeFolder);

                        ResourcesHandler.RenameDialogueFile(dialogue, dialog.FileName);

                        ResyncFile(dialogue, true);

                        if (EditorCore.MainWindow != null)
                        {
                            EditorCore.MainWindow.OpenDocumentDialogue(dialogue);
                        }
                    }
                }
            }
        }
Esempio n. 19
0
        private void OnEditPathClick(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.Description = "Select the export directory :";

            dialog.SelectedPath = EditorHelper.GetProjectDirectory();
            if (Directory.Exists(textBoxPath.Text))
            {
                dialog.SelectedPath = textBoxPath.Text;
            }

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                textBoxPath.Text = dialog.SelectedPath;
            }
        }
Esempio n. 20
0
        private void OnEditPathClick(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title            = "Select the import file for Dialogues :";
            dialog.Filter           = "Csv Files|*.csv";
            dialog.InitialDirectory = EditorHelper.GetProjectDirectory();
            if (Directory.Exists(ImportPathDialogues))
            {
                dialog.InitialDirectory = ImportPathDialogues;
            }

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                textBoxPath.Text = dialog.FileName;
            }
        }
Esempio n. 21
0
        public void RefreshPortrait()
        {
            string pathPortrait = Path.Combine(EditorHelper.GetProjectDirectory(), textBoxPortrait.Text);

            if (File.Exists(pathPortrait))
            {
                using (Image temp = Image.FromFile(pathPortrait))
                {
                    pictureBoxPortrait.Image = new Bitmap(temp);
                }
                //pictureBoxPortrait.Image = Image.FromFile(strPathPortrait);
            }
            else
            {
                if (pictureBoxPortrait.Image != null)
                {
                    pictureBoxPortrait.Image.Dispose();
                }
                pictureBoxPortrait.Image = null;
            }
        }
Esempio n. 22
0
        protected void PlayNode(DialogueNode nextNode, bool forward = true)
        {
            if (forward && currentNode != null && !(currentNode is DialogueNodeReply) && !(currentNode is DialogueNodeGoto))
            {
                previousNodes.Add(currentNode);
            }

            if (nextNode == null)
            {
                Finish();
                return;
            }

            currentNode = nextNode;

            currentDocument.SelectNode(currentNode);

            ResetGroups();

            if (currentNode.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AlwaysFalse)
            {
                PlayNode(currentNode.Next);
                return;
            }

            if (currentNode is DialogueNodeSentence)
            {
                var sentence = currentNode as DialogueNodeSentence;

                ResetSentence();

                Actor speaker = ResourcesHandler.Project.GetActorFromID(sentence.SpeakerID);
                if (speaker != null)
                {
                    labelSpeaker.Text = speaker.Name;

                    string strPathPortraitSpeaker = Path.Combine(EditorHelper.GetProjectDirectory(), speaker.Portrait);
                    if (File.Exists(strPathPortraitSpeaker))
                    {
                        pictureBoxSpeaker.Image = Image.FromFile(strPathPortraitSpeaker);
                    }
                }

                Actor listener = ResourcesHandler.Project.GetActorFromID(sentence.ListenerID);
                if (listener != null)
                {
                    labelListener.Text = listener.Name;

                    string strPathPortraitListener = Path.Combine(EditorHelper.GetProjectDirectory(), listener.Portrait);
                    if (File.Exists(strPathPortraitListener))
                    {
                        pictureBoxListener.Image = Image.FromFile(strPathPortraitListener);
                    }
                }

                if (checkBoxOptionConstants.Checked)
                {
                    labelSentence.Text = EditorHelper.FormatTextEntry(sentence.Sentence, EditorCore.LanguageWorkstring);
                }
                else
                {
                    labelSentence.Text = sentence.Sentence;
                }
            }
            else if (currentNode is DialogueNodeChoice)
            {
                var choice = currentNode as DialogueNodeChoice;

                groupBoxChoice.Visible    = true;
                labelChoice.Text          = String.Format("Choice : {0}", choice.Choice);
                listBoxReplies.DataSource = new BindingSource(choice.Replies, null);

                checkBoxShowReplyConditions.Checked    = false;
                radioButtonReplyConditionsTrue.Checked = true;

                foreach (DialogueNodeReply reply in choice.Replies)
                {
                    if (reply.Conditions.Count > 0)
                    {
                        labelRepliesConditions.Enabled          = true;
                        checkBoxShowReplyConditions.Enabled     = true;
                        radioButtonReplyConditionsTrue.Enabled  = true;
                        radioButtonReplyConditionsFalse.Enabled = true;
                        break;
                    }
                }

                if (choice.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    ShowConditions(choice);
                }
            }
            else if (currentNode is DialogueNodeGoto)
            {
                var nodeGoto = currentNode as DialogueNodeGoto;

                if (nodeGoto.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    groupBoxGoto.Visible = true;
                    labelGoto.Text       = String.Format("Goto > \"{0}\"", GetGotoText(nodeGoto.Goto));

                    ShowConditions(nodeGoto);
                }
                else
                {
                    PlayNode(nodeGoto.Goto);
                }
            }
            else if (currentNode is DialogueNodeBranch)
            {
                var nodeBranch = currentNode as DialogueNodeBranch;

                if (nodeBranch.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    groupBoxGoto.Visible = true;
                    labelGoto.Text       = String.Format("Branch > \"{0}\"", GetGotoText(nodeBranch.Branch));

                    ShowConditions(nodeBranch);
                }
                else
                {
                    PlayNode(nodeBranch.Branch);
                }
            }
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
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);
        }