Exemple #1
0
        public Dialogue()
        {
            VersionProject  = "";
            VersionEditor   = "";
            PackageName     = "";
            LastIndex       = 0;
            SceneType       = "";
            VoiceBank       = "";
            Context         = "";
            Comment         = "";
            Camera          = "";
            CameraBlendTime = -1.0f;
            //Spatialized = Utility.ETriBool.TB_undefined;

            ListNodes            = new List <DialogueNode>();
            ListAdditionalActors = new List <string>();

            path = "";
            name = "";

            Translations = new TranslationTable();

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                SceneType = EditorCore.CustomLists["SceneTypes"].First().Key;
            }
        }
Exemple #2
0
        public Project()
        {
            VersionProject        = "";
            VersionEditor         = "";
            MaxLengthSentence     = 150;
            MaxLengthReply        = 50;
            LastVoicingExportDate = new DateTime(0);

            ListPackages = new List <Package>()
            {
                new Package()
                {
                    Name = "Default"
                }
            };
            ListLanguages = new List <Language>()
            {
                new Language()
                {
                    Name = "English", LocalizationCode = "en", VoicingCode = "en"
                }
            };
            ListActors = new List <Actor>();

            ListVoiceKits   = new List <VoiceKit>();
            ListVoiceActors = new List <VoiceActor>();

            ListConstants = new List <Constant>();
            Translations  = new TranslationTable();

            Dirty = false;
            path  = "";
            name  = "";
        }
Exemple #3
0
        public Dialogue()
        {
            VersionProject = "";
            VersionEditor  = "";
            PackageName    = "";
            LastIndex      = DialogueNode.ID_NULL;
            SceneType      = "";
            VoiceBank      = "";
            Context        = "";
            Comment        = "";

            ListNodes            = new List <DialogueNode>();
            ListAdditionalActors = new List <string>();

            Translations = new TranslationTable();

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                SceneType = EditorCore.CustomLists["SceneTypes"].First().Key;
            }
        }
        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);
        }