コード例 #1
0
ファイル: EditorHelper.cs プロジェクト: CannibalVox/dialogue
 static public string GetPrettyNodeVoicingID(Dialogue dialogue, DialogueNode node)
 {
     return(String.Format("VX_{0}_{1}", dialogue.GetName(), node.ID.ToString()));
 }
コード例 #2
0
ファイル: EditorHelper.cs プロジェクト: CannibalVox/dialogue
        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);
                                    }
                                }
                            }
                        }
                    }
                }
                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;
                }
                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);
            }
        }
コード例 #3
0
 static public void Check(Dialogue dialogue)
 {
     EditorHelper.CheckDialogueErrors(dialogue);
 }
コード例 #4
0
 public void OpenDocumentDialogue(Dialogue dialogue)
 {
     OpenDocumentDialogue(dialogue, DialogueNode.ID_NULL);
 }
コード例 #5
0
 public DialogueViewModel(CommandExecutor cmdExec, Dialogue dialogue)
 {
     _dialogue = dialogue;
     _cmdExec  = cmdExec;
 }
コード例 #6
0
 static public void ReloadDialogue(Dialogue dialogue)
 {
     ReloadDialogue(dialogue.GetName());
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 public SetNameUndoableCommand(Dialogue dialogue, string name)
 {
     _dialogue = dialogue;
     _name     = name;
     _oldName  = dialogue.Name;
 }
コード例 #9
0
ファイル: NodeViewModel.cs プロジェクト: Floofy-KH/utils
 public AddChoiceUndoableCommand(CommandExecutor cmdExec, NodeViewModel node, ImpObservableCollection <ConnectorViewModel> outgoingConnectors, DialogueEntry entry, Dialogue dialogue, string content)
 {
     _outgoingConnectors = outgoingConnectors;
     _dialogue           = dialogue;
     _dialogueEntry      = entry;
     _content            = content;
     _node    = node;
     _cmdExec = cmdExec;
 }
コード例 #10
0
        //--------------------------------------------------------------------------------------------------------------
        // Class Methods

        public DialogConfirmDelete(Dialogue dialogue)
        {
            InitializeComponent();

            labelInfos.Text = string.Format(labelInfos.Text, dialogue.GetName());
        }
コード例 #11
0
ファイル: NodeViewModel.cs プロジェクト: Floofy-KH/utils
 public AddChoiceCommand(CommandExecutor cmdExec, NodeViewModel node, ImpObservableCollection <ConnectorViewModel> outgoingConnectors, DialogueEntry entry, Dialogue dialogue, string content)
 {
     _cmdExec = cmdExec;
     _cmd     = new NodeViewModel.AddChoiceUndoableCommand(_cmdExec, node, outgoingConnectors, entry, dialogue, content);
 }
コード例 #12
0
        public void Init(DocumentDialogue indocument, TreeNode inTreeNode, DialogueNodeRoot inDialogueNode)
        {
            document     = indocument;
            treeNode     = inTreeNode;
            dialogueNode = inDialogueNode;
            dialogue     = document.Dialogue;

            textBoxVoiceBank.Text = dialogue.VoiceBank;
            textBoxContext.Text   = dialogue.Context;
            textBoxComment.Text   = dialogue.Comment;

            comboBoxPackage.DataSource    = new BindingSource(ResourcesHandler.Project.ListPackages, null);
            comboBoxPackage.DisplayMember = "Name";
            comboBoxPackage.SelectedItem  = dialogue.Package;

            comboBoxSceneType.DataSource    = new BindingSource(EditorCore.CustomLists["SceneTypes"], null);
            comboBoxSceneType.ValueMember   = "Key";
            comboBoxSceneType.DisplayMember = "Value";
            comboBoxSceneType.SelectedValue = dialogue.SceneType;

            comboBoxCamera.DataSource    = new BindingSource(EditorCore.CustomLists["Cameras"], null);
            comboBoxCamera.ValueMember   = "Key";
            comboBoxCamera.DisplayMember = "Value";
            comboBoxCamera.SelectedValue = dialogue.Camera;
            textBoxCameraBlendTime.Text  = dialogue.CameraBlendTime.ToString();

            foreach (var actorID in dialogue.ListAdditionalActors)
            {
                Actor actor = ResourcesHandler.Project.GetActorFromID(actorID);
                if (actor != null)
                {
                    additionalActors.Add(actor.Name);
                }
                else
                {
                    additionalActors.Add("<Undefined>");
                }
            }

            listBoxAdditionalActors.DataSource = new BindingSource(additionalActors, null);

            var actors = new Dictionary <string, string>();

            actors.Add("", "");
            foreach (Actor actor in ResourcesHandler.Project.ListActors)
            {
                actors.Add(actor.ID, actor.Name);
            }

            comboBoxAdditionalActors.DataSource    = new BindingSource(actors, null);
            comboBoxAdditionalActors.ValueMember   = "Key";
            comboBoxAdditionalActors.DisplayMember = "Value";

            /*comboBoxSpatialized.DataSource = new BindingSource(EditorHelper.GetTriBoolDictionary("<Auto>"), null);
             * comboBoxSpatialized.ValueMember = "Key";
             * comboBoxSpatialized.DisplayMember = "Value";
             * comboBoxSpatialized.SelectedValue = dialogue.Spatialized;*/

            RefreshAdditionalActorView();

            ready = true;
        }
コード例 #13
0
ファイル: EditorCore.cs プロジェクト: Legulysse/dialogue
 public static void AddSearchResult(string message, Dialogue dialogue, DialogueNode node)
 {
     SearchResults.WriteLine(message, dialogue.GetName(), node.ID);
 }
コード例 #14
0
ファイル: EditorCore.cs プロジェクト: Legulysse/dialogue
 static public void LogError(string message, Dialogue dialogue, DialogueNode node)
 {
     LogError(message, dialogue.GetName(), node.ID);
 }
コード例 #15
0
ファイル: EditorCore.cs プロジェクト: Legulysse/dialogue
 static public void LogWarning(string message, Dialogue dialogue)
 {
     LogWarning(message, dialogue.GetName(), DialogueNode.ID_NULL);
 }