static public void ExportFaceFx_Internal(string directory, Project project, List <Dialogue> dialogues, List <Language> languages, bool workstringOnly) { foreach (Language language in languages) { string languagePath = Path.Combine(directory, language.LocalizationCode); foreach (Dialogue dialogue in dialogues) { var orderedListNodes = new List <DialogueNode>(); dialogue.GetOrderedNodes(ref orderedListNodes); foreach (DialogueNode dialogueNode in orderedListNodes) { if (dialogueNode is DialogueNodeSentence || dialogueNode is DialogueNodeReply) { string nodeVoicingID = EditorHelper.GetPrettyNodeVoicingID(dialogue, dialogueNode); string path = Path.Combine(languagePath, nodeVoicingID + ".txt"); string lineToWrite = ""; if (dialogueNode is DialogueNodeSentence) { lineToWrite = (dialogueNode as DialogueNodeSentence).Sentence; } else { lineToWrite = (dialogueNode as DialogueNodeReply).Reply; } if (!workstringOnly) { var entry = dialogue.Translations.GetNodeEntry(dialogueNode, language); lineToWrite = (entry != null) ? entry.Text : ""; } //Export empy files //if (lineToWrite.Count() == 0) // continue; lineToWrite = EditorHelper.FormatTextEntry(lineToWrite, language); if (!Directory.Exists(languagePath)) { Directory.CreateDirectory(languagePath); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.UTF8)) { file.WriteLine(lineToWrite); } } } } } }
static public void ExportDialoguesToWwiseTextFile(string directory, Project project, List <Dialogue> dialogues, Language language, DateTime dateFrom) { string path = Path.Combine(directory, "Wwise_" + project.GetName() + "_" + language.VoicingCode + ".txt"); using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.Unicode)) { file.WriteLine("Filename\tContainer\tSVComment\tComment"); foreach (Dialogue dialogue in dialogues) { var orderedListNodes = new List <DialogueNode>(); dialogue.GetOrderedNodes(ref orderedListNodes); foreach (DialogueNode dialogueNode in orderedListNodes) { if (dialogueNode is DialogueNodeSentence) { DialogueNodeSentence dialogueNodeSentence = dialogueNode as DialogueNodeSentence; //if (dialogueNodeSentence.LastEditDate < dateFrom) //No need for that, reexport everything // continue; string nodeID = EditorHelper.GetPrettyNodeVoicingID(dialogue, dialogueNodeSentence); string container = dialogue.SceneType; string speaker = project.GetActorName(dialogueNodeSentence.SpeakerID); string voicedText = EditorHelper.FormatTextEntry(dialogueNodeSentence.Sentence, language); //language = workstring if workstringOnly if (speaker == "") { speaker = "Undefined"; } //Filename, Container, SVComment, Comment file.WriteLine(nodeID + "\t" + container + "\t" + speaker + "\t" + voicedText); } } } } }
static public void ExportDialoguesToCsv(string directory, Project project, List <Dialogue> dialogues, List <Language> languages, DateTime dateFrom, ExporterStats.ProjectStats projectStats) { //Ensure no export of a Workstring language //languages.Remove(EditorCore.LanguageWorkstring); string path = Path.Combine(directory, "Loca_" + project.GetName() + ".csv"); using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.UTF8)) { //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voice Intensity, Speaker, Workstring Text, Words, ...Languages..., comments { ExporterCsv.CsvLineWriter header = new ExporterCsv.CsvLineWriter(); header.AddField("Dialogue"); header.AddField("Node ID"); header.AddField("Timestamp"); header.AddField("Voicing ID"); header.AddField("Index"); header.AddField("Package"); header.AddField("Scene Type"); header.AddField("Context"); header.AddField("Voicing"); header.AddField("Voice Intensity"); header.AddField("Speaker"); header.AddField("Workstring Text"); //TODO: old workstring for updated texts ? header.AddField("Words"); //TODO: characters count ? foreach (var language in languages) { header.AddField(language.Name + " State"); header.AddField(language.Name + " Text"); header.AddField(language.Name + " Words"); //TODO: characters count ? } header.AddField("Comments"); header.WriteLine(file); } //file.Write("\n"); foreach (Dialogue dialogue in dialogues) { int index = 0; var orderedListNodes = new List <DialogueNode>(); dialogue.GetOrderedNodes(ref orderedListNodes); //Process global Dialogue information { string package = dialogue.Package.Name; string sceneType = dialogue.SceneType; string context = dialogue.Context; ExporterCsv.CsvLineWriter line = new ExporterCsv.CsvLineWriter(); //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments line.AddField(dialogue.GetName()); line.AddField(TranslationTable.DialogueNodePrefix + dialogue.RootNodeID); line.AddEmptyField(); line.AddEmptyField(); line.AddField(index); line.AddField(package); line.AddField(sceneType); line.AddField(context); line.AddEmptyField(); line.AddEmptyField(); line.AddEmptyField(); line.AddEmptyField(); line.AddEmptyField(); //Locas line.AddEmptyField(); line.AddEmptyField(); line.AddEmptyField(); line.AddEmptyField(); line.WriteLine(file); } foreach (DialogueNode dialogueNode in orderedListNodes) { if (dialogueNode is DialogueNodeSentence || dialogueNode is DialogueNodeReply) { ++index; string context = ""; string speaker = ""; string workstring = ""; DateTime workstringTimestamp; bool todo = false; string voicingID; string voicing; string voiceIntensity; if (dialogueNode is DialogueNodeSentence) { var dialogueNodeSentence = dialogueNode as DialogueNodeSentence; context = dialogueNodeSentence.Context; workstring = dialogueNodeSentence.Sentence; workstringTimestamp = dialogueNodeSentence.LastEditDate; speaker = project.GetActorName(dialogueNodeSentence.SpeakerID); if (speaker == "") { speaker = "<Undefined>"; } voicingID = EditorHelper.GetPrettyNodeVoicingID(dialogue, dialogueNodeSentence); voicing = dialogueNodeSentence.Comment; voiceIntensity = dialogueNodeSentence.VoiceIntensity; } else { var dialogueNodeReply = dialogueNode as DialogueNodeReply; context = "<User Interface>"; speaker = "<UI>"; workstring = dialogueNodeReply.Reply; workstringTimestamp = dialogueNodeReply.LastEditDate; voicingID = ""; voicing = ""; voiceIntensity = ""; } string[] split = workstring.Split(ExporterStats.DelimiterChars, StringSplitOptions.RemoveEmptyEntries); int words = split.Length; //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments ExporterCsv.CsvLineWriter line = new ExporterCsv.CsvLineWriter(); line.AddField(dialogue.GetName()); line.AddField(TranslationTable.DialogueNodePrefix + dialogueNode.ID); line.AddField(workstringTimestamp); line.AddField(voicingID); line.AddField(index); line.AddEmptyField(); line.AddEmptyField(); line.AddField(context); line.AddField(voicing); line.AddField(voiceIntensity); line.AddField(speaker); line.AddField(workstring); line.AddField(words); foreach (var language in languages) { var entry = dialogue.Translations.GetNodeEntry(dialogueNode, language); if (entry != null) { if (entry.SourceDate < workstringTimestamp) { todo = true; line.AddField("UPDATE"); } else { line.AddField("OK"); } line.AddField(entry.Text); line.AddEmptyField(); } else { todo = true; line.AddField("NEW"); line.AddEmptyField(); line.AddEmptyField(); } } line.AddEmptyField(); line.WriteLine(file); if (todo) { if (dialogueNode is DialogueNodeSentence) { var dialogueNodeSentence = dialogueNode as DialogueNodeSentence; projectStats.AddSentence(dialogue, dialogueNodeSentence.SpeakerID, workstring); } else { var dialogueNodeReply = dialogueNode as DialogueNodeReply; projectStats.AddReply(dialogue, workstring); } } } } } } }
public void PreSave(Project project) { //Prepare File VersionProject = EditorCore.VersionProject; VersionEditor = EditorVersion.GetVersion(); if (Package == null) { EditorCore.LogError("Saving a Dialogue without Package (forcing default) : " + GetName(), this); Package = project.GetDefaultPackage(); } if (Package != null) { PackageName = Package.Name; } //Sanitize texts //dialogue.Comment = EditorCore.SanitizeText(dialogue.Comment); //Prepare nodes links RootNodeID = (RootNode != null) ? RootNode.ID : DialogueNode.ID_NULL; foreach (DialogueNode node in ListNodes) { node.NextID = (node.Next != null) ? node.Next.ID : DialogueNode.ID_NULL; if (node is DialogueNodeSentence) { //Generate ID DialogueNodeSentence nodeSentence = node as DialogueNodeSentence; nodeSentence.VoicingID = EditorHelper.GetPrettyNodeVoicingID(this, nodeSentence); //Sanitize texts nodeSentence.Sentence = EditorHelper.SanitizeText(nodeSentence.Sentence); //nodeSentence.Comment = EditorHelper.SanitizeText(nodeSentence.Comment); } else if (node is DialogueNodeChoice) { DialogueNodeChoice nodeChoice = node as DialogueNodeChoice; //Sanitize texts nodeChoice.Choice = EditorHelper.SanitizeText(nodeChoice.Choice); nodeChoice.RepliesIDs.Clear(); foreach (DialogueNodeReply nodeReply in nodeChoice.Replies) { //Sanitize texts nodeReply.Reply = EditorHelper.SanitizeText(nodeReply.Reply); nodeChoice.RepliesIDs.Add(nodeReply.ID); } } else if (node is DialogueNodeGoto) { DialogueNodeGoto nodeGoto = node as DialogueNodeGoto; nodeGoto.GotoID = (nodeGoto.Goto != null) ? nodeGoto.Goto.ID : DialogueNode.ID_NULL; } else if (node is DialogueNodeBranch) { DialogueNodeBranch nodeBranch = node as DialogueNodeBranch; nodeBranch.BranchID = (nodeBranch.Branch != null) ? nodeBranch.Branch.ID : DialogueNode.ID_NULL; } } }
static public void ExportLocasToCSVFile(string directory, Project project, List <Dialogue> dialogues, Language language, bool workstringOnly, bool workstringFallback, DateTime dateFrom, ExporterStats.ProjectStats projectStats) { string path = Path.Combine(directory, "Loca_" + project.GetName() + "_" + language.VoicingCode + ".csv"); using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.UTF8)) { //status, scene, voicing id, index, speaker, context, voicing comments, intensity, sentence, comments { ExporterCsv.CsvLineWriter header = new ExporterCsv.CsvLineWriter(); header.AddField("Status"); header.AddField("Dialogue"); header.AddField("Voicing ID"); header.AddField("Index"); header.AddField("Speaker"); header.AddField("Context"); header.AddField("Voicing Comments"); header.AddField("Voicing Intensity"); header.AddField("Sentence"); header.AddField("Comments"); header.WriteLine(file); } foreach (Dialogue dialogue in dialogues) { int index = 1; var orderedListNodes = new List <DialogueNode>(); dialogue.GetOrderedNodes(ref orderedListNodes); foreach (DialogueNode dialogueNode in orderedListNodes) { if (dialogueNode is DialogueNodeSentence) { DialogueNodeSentence dialogueNodeSentence = dialogueNode as DialogueNodeSentence; bool done = false; if (dialogueNodeSentence.LastEditDate < dateFrom) { done = true; } string nodeID = EditorHelper.GetPrettyNodeVoicingID(dialogue, dialogueNodeSentence); string speaker = project.GetActorName(dialogueNodeSentence.SpeakerID); string scene = dialogue.GetName(); string context = dialogueNodeSentence.Context; string comment = dialogueNodeSentence.Comment; string intensity = dialogueNodeSentence.VoiceIntensity; string status = (done) ? "OK" : "TODO"; string voicedText = dialogueNodeSentence.Sentence; if (!workstringOnly) { TranslationEntry entry = dialogue.Translations.GetNodeEntry(dialogueNode, language); if (entry == null) { if (!workstringFallback) { voicedText = "<Missing Translation>"; } } else { voicedText = entry.Text; } } // use null as langage to force constant replacement in csv file voicedText = EditorHelper.FormatTextEntry(voicedText, null); //language = workstring if workstringOnly //voicedText = voicedText.Replace("’", "'"); //voicedText = voicedText.Replace("…", "..."); if (speaker == "") { speaker = "<Undefined>"; } //status, scene, node id, index, speaker, context, voicing comments, intensity, sentence, comments ExporterCsv.CsvLineWriter line = new ExporterCsv.CsvLineWriter(); line.AddField(status); line.AddField(scene); line.AddField(nodeID); line.AddField(index); line.AddField(speaker); line.AddField(context); line.AddField(comment); line.AddField(intensity); line.AddField(voicedText); line.AddEmptyField(); line.WriteLine(file); ++index; if (!done) { projectStats.AddSentence(dialogue, dialogueNodeSentence.SpeakerID, voicedText); } } } } } }