private void OnPackageChanged(object sender, EventArgs e) { if (!ready) { return; } if (currentPackage.Name == textBoxPackage.Text) //Since I use the validated event, this may be called even without modifications { return; } DialogResult result = MessageBox.Show("Renaming a Package will update all dialogues associated.\nDo you wish to continue ?", "Rename Package...", MessageBoxButtons.OKCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button2); if (result == DialogResult.Cancel) { ready = false; textBoxPackage.Text = currentPackage.Name; ready = true; return; } currentPackage.Name = textBoxPackage.Text; (listBoxPackages.DataSource as BindingSource).ResetBindings(false); List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues(); foreach (Dialogue dialogue in dialogues) { if (dialogue.Package == currentPackage) { ResourcesHandler.SetDirty(dialogue); } } SetDirty(); if (EditorCore.MainWindow != null) { EditorCore.MainWindow.RefreshDirtyFlags(); } if (EditorCore.ProjectExplorer != null) { EditorCore.ProjectExplorer.ResyncAllFiles(); } }
private void OnRemoveActor(object sender, EventArgs e) { int index = listBoxActors.SelectedIndex; if (project.ListActors.Count == 0) { return; } string oldID = currentActor.ID; currentActor = null; project.ListActors.RemoveAt(index); (listBoxActors.DataSource as BindingSource).ResetBindings(false); if (project.ListActors.Count > 0) { listBoxActors.SelectedIndex = 0; if (currentActor == null) { currentActor = listBoxActors.SelectedItem as Actor; RefreshActorView(); } } List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues(); foreach (Dialogue dialogue in dialogues) { if (dialogue.UpdateActorID(oldID, "")) { ResourcesHandler.SetDirty(dialogue); } } SetDirty(); if (EditorCore.MainWindow != null) { EditorCore.MainWindow.RefreshDirtyFlags(); } }
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(); } } } }
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); }