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); } } } } } } }
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); } } } } } }