static public void SetDirty(Dialogue dialogue) { if (dialogue != null) { SetDirty(dialogue.GetName()); } }
public void WriteDialog(Dialogue dialog) { OpenBracket(string.Format("GeneratedDialog.{0}.{1}", dialog.PackageName, dialog.GetName()), "GeneratedDialogTree"); RenderObject(dialog); CloseClassBracket(); builder.AppendLine(); }
static public bool IsDirty(Dialogue dialogue) { if (dialogue != null) { return(IsDirty(dialogue.GetName())); } return(false); }
public void ResyncFile(Dialogue dialogue, bool focus) { if (dialogue == null) { return; } if (dialogue.Package == null) { EditorCore.LogError("Unable to show a Dialogue without Package in project explorer : " + dialogue.GetName()); return; } TreeNode[] nodePackages = tree.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 }; nodeParent.ContextMenuStrip = menuFolder; EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder); } } TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName()); nodeDialogue.ContextMenuStrip = menuDocument; EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue); nodeDialogue.Tag = dialogue; if (focus) { nodeDialogue.EnsureVisible(); } } else { EditorCore.LogError("Unable to show a Dialogue with unknown Package in project explorer : " + dialogue.GetName() + " in " + dialogue.Package.Name); } }
private void OnDocumentCopyName(object sender, EventArgs e) { Dialogue dialogue = tree.SelectedNode.Tag as Dialogue; if (dialogue != null) { Clipboard.SetText(dialogue.GetName()); } }
static public void SaveDialogue(Dialogue dialogue) { var holder = dialogues[dialogue.GetName()]; if (dialogue != null && holder != null) { ExporterJson.SaveDialogueFile(Project, dialogue); holder.Dirty = false; } }
static public void ReloadDialogueFromString(Dialogue dialogue, string content) { var holder = dialogues[dialogue.GetName()]; if (dialogue != null && holder != null) { ExporterJson.LoadDialogueFromString(Project, dialogue, content); holder.Dirty = true; } }
static public bool RemoveDialogue(Dialogue dialogue) { string name = dialogue.GetName(); if (dialogues.ContainsKey(name)) { dialogues.Remove(name); return(true); } return(false); }
public void AddReply(Dialogue dialogue, string text) { DialogueStats dialogueStats = Dialogues.GetOrAdd(dialogue.GetName(), (key) => new DialogueStats()); Packages.Add(dialogue.Package); string[] split = text.Split(DelimiterChars, StringSplitOptions.RemoveEmptyEntries); int words = split.Length; dialogueStats.ReplyWords += words; dialogueStats.Replies += 1; ReplyWords += words; Replies += 1; }
static private bool AddDialogue(Dialogue dialogue) { string name = dialogue.GetName(); if (CheckDialogueNameAvailable(dialogue.GetFilePath(), name, true)) { dialogues.Add(name, new ResourceHolder { Dialogue = dialogue }); return(true); } return(false); }
//-------------------------------------------------------------------------------------------------------------- // static public bool AddDialogue(Dialogue dialogue) { string name = dialogue.GetName(); if (!dialogues.ContainsKey(name)) { dialogues.Add(name, new ResourceHolder { Dialogue = dialogue }); return(true); } EditorCore.LogError("Dialogue already exists (ignored) : " + name + " at \"" + dialogue.GetFilePath() + "\" and \"" + dialogues[name].Dialogue.GetFilePath() + "\""); return(false); }
public void AddSentence(Dialogue dialogue, string actorID, string text) { DialogueStats dialogueStats = Dialogues.GetOrAdd(dialogue.GetName(), (key) => new DialogueStats()); ActorStats actorStats = Actors.GetOrAdd(actorID, (key) => new ActorStats()); Packages.Add(dialogue.Package); string[] split = text.Split(DelimiterChars, StringSplitOptions.RemoveEmptyEntries); int words = split.Length; dialogueStats.SentenceWords += words; dialogueStats.Sentences += 1; SentenceWords += words; Sentences += 1; actorStats.Words += words; actorStats.Sentences += 1; }
private void RenderObject(Dialogue dialog) { WriteString("Package", dialog.PackageName); WriteString("Name", dialog.GetName()); WriteNumber("RootNode", dialog.RootNodeID); OpenBracket("NodeList"); var orderedListNodes = new List <DialogueNode>(); dialog.GetOrderedNodes(ref orderedListNodes); RenderObject(orderedListNodes); CloseBracket(); OpenBracket("IDToIndex"); for (int i = 0; i < orderedListNodes.Count; i++) { WriteNumber("[" + orderedListNodes[i].ID + "]", i + 1); } CloseBracket(); }
//-------------------------------------------------------------------------------------------------------------- // Class Methods public DialogConfirmDelete(Dialogue dialogue) { InitializeComponent(); labelInfos.Text = string.Format(labelInfos.Text, dialogue.GetName()); }
static public string GetPrettyNodeVoicingID(Dialogue dialogue, DialogueNode node) { return(String.Format("VX_{0}_{1}", dialogue.GetName(), node.ID.ToString())); }
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); }
public void ResyncFile(Dialogue dialogue, Package previousPackage, bool focus) { if (dialogue == null) { return; } if (previousPackage != null) { TreeNode[] nodePackages = tree.Nodes.Find(GetPackageKey(previousPackage.Name), false); if (nodePackages.Count() > 0) { TreeNode nodeParent = nodePackages[0]; TreeNode[] nodeChildren = nodeParent.Nodes.Find(dialogue.GetFileName(), true); if (nodeChildren.Count() > 0) { TreeNode nodeDialogue = nodeChildren[0]; TreeNode nodeFolder = nodeDialogue.Parent; nodeDialogue.Remove(); DeleteIfEmptyFolder(nodeFolder); } } else { EditorCore.LogError("Unable to update a Dialogue with unknown Package in project explorer : " + dialogue.GetName() + " in " + previousPackage.Name); } } ResyncFile(dialogue, focus); }
public static void AddSearchResult(string message, Dialogue dialogue, DialogueNode node) { SearchResults.WriteLine(message, dialogue.GetName(), node.ID); }
static public void LogError(string message, Dialogue dialogue, DialogueNode node) { LogError(message, dialogue.GetName(), node.ID); }
static public void LogWarning(string message, Dialogue dialogue) { LogWarning(message, dialogue.GetName(), DialogueNode.ID_NULL); }
public static void CheckDialogueErrors(Dialogue dialogue) { Project project = ResourcesHandler.Project; if (!EditorCore.CustomLists["SceneTypes"].ContainsKey(dialogue.SceneType)) { EditorCore.LogError(String.Format("{0} - Unknown Scene Type : {1}", dialogue.GetName(), dialogue.SceneType), dialogue); } if (!EditorCore.CustomLists["Cameras"].ContainsKey(dialogue.Camera)) { EditorCore.LogError(String.Format("{0} - Unknown Camera : {1}", dialogue.GetName(), dialogue.Camera), dialogue); } var usedIDs = new HashSet <int>(); foreach (DialogueNode node in dialogue.ListNodes) { if (usedIDs.Contains(node.ID)) { EditorCore.LogError(String.Format("{0} - Identical ID between two nodes : {1}", dialogue.GetName(), node.ID), dialogue, node); } else { usedIDs.Add(node.ID); } if (node is DialogueNodeSentence) { var nodeSentence = node as DialogueNodeSentence; bool validSpeaker = false; if (nodeSentence.SpeakerID == "") { EditorCore.LogError(String.Format("{0} {1} - Sentence has no Speaker", dialogue.GetName(), node.ID), dialogue, node); } else { if (project.GetActorFromID(nodeSentence.SpeakerID) == null) { EditorCore.LogError(String.Format("{0} {1} - Sentence has an invalid Speaker : {2}", dialogue.GetName(), node.ID, nodeSentence.SpeakerID), dialogue, node); } else { validSpeaker = true; } } if (nodeSentence.ListenerID != "") { if (project.GetActorFromID(nodeSentence.ListenerID) == null) { EditorCore.LogError(String.Format("{0} {1} - Sentence has an invalid Listener : {2}", dialogue.GetName(), node.ID, nodeSentence.ListenerID), dialogue, node); } else if (validSpeaker) { var speaker = project.GetActorFromID(nodeSentence.SpeakerID); var listener = project.GetActorFromID(nodeSentence.ListenerID); if (speaker == listener) { EditorCore.LogError(String.Format("{0} {1} - Listener is also Speaker", dialogue.GetName(), node.ID), dialogue, node); } else { if (speaker.VoiceKit != String.Empty) { if (speaker.VoiceKit == listener.VoiceKit) { EditorCore.LogWarning(String.Format("{0} {1} - Speaker and Listener have the same Voice Kit", dialogue.GetName(), node.ID), dialogue, node); } else if (project.GetVoiceActorNameFromKit(speaker.VoiceKit) == project.GetVoiceActorNameFromKit(listener.VoiceKit)) { EditorCore.LogWarning(String.Format("{0} {1} - Speaker and Listener have the same Voice Actor", dialogue.GetName(), node.ID), dialogue, node); } } } } } if (nodeSentence.Sentence.Length > project.MaxLengthSentence) { EditorCore.LogWarning(String.Format("{0} {1} - Sentence has too many characters", dialogue.GetName(), node.ID), dialogue, node); } } else if (node is DialogueNodeChoice) { var nodeChoice = node as DialogueNodeChoice; if (nodeChoice.Replies.Count == 0) { EditorCore.LogError(String.Format("{0} {1} - Choice has no Reply", dialogue.GetName(), node.ID), dialogue, node); } } else if (node is DialogueNodeReply) { var nodeReply = node as DialogueNodeReply; if (nodeReply.Reply.Length > project.MaxLengthReply) { EditorCore.LogWarning(String.Format("{0} {1} - Reply has too many characters", dialogue.GetName(), node.ID), dialogue, node); } } else if (node is DialogueNodeGoto) { var nodeGoto = node as DialogueNodeGoto; if (nodeGoto.Goto == null) { EditorCore.LogError(String.Format("{0} {1} - Goto has no Target", dialogue.GetName(), node.ID), dialogue, node); } } else if (node is DialogueNodeBranch) { var nodeBranch = node as DialogueNodeBranch; if (nodeBranch.Branch == null) { EditorCore.LogError(String.Format("{0} {1} - Branch has no Target", dialogue.GetName(), node.ID), dialogue, node); } } } if (EditorCore.OnCheckDialogueErrors != null) { EditorCore.OnCheckDialogueErrors(dialogue); } }
static public void ReloadDialogue(Dialogue dialogue) { ReloadDialogue(dialogue.GetName()); }