private void RefreshPortraits()
        {
            Project project       = ResourcesHandler.Project;
            Actor   actorSpeaker  = project.GetActorFromID(dialogueNode.SpeakerID);
            Actor   actorListener = project.GetActorFromID(dialogueNode.ListenerID);

            picturePortraitSpeaker.Image = null;
            if (actorSpeaker != null)
            {
                string pathPortraitSpeaker = Path.Combine(EditorHelper.GetProjectDirectory(), actorSpeaker.Portrait);
                if (File.Exists(pathPortraitSpeaker))
                {
                    using (Image temp = Image.FromFile(pathPortraitSpeaker))
                    {
                        picturePortraitSpeaker.Image = new Bitmap(temp);
                    }
                }
            }

            picturePortraitListener.Image = null;
            if (actorListener != null)
            {
                string pathPortraitListener = Path.Combine(EditorHelper.GetProjectDirectory(), actorListener.Portrait);
                if (File.Exists(pathPortraitListener))
                {
                    using (Image temp = Image.FromFile(pathPortraitListener))
                    {
                        picturePortraitListener.Image = new Bitmap(temp);
                    }
                }
            }
        }
        private void RefreshAnimSetList(ComboBox comboBoxMood, string actorID)
        {
            Project project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            var animsets = new List <string>();

            animsets.Add("");

            Actor actor = project.GetActorFromID(actorID);

            if (actor != null && EditorCore.GetActorAnimsets != null)
            {
                List <string> actorAnimsets = EditorCore.GetActorAnimsets(actorID);
                if (actorAnimsets.Count > 0)
                {
                    animsets.AddRange(actorAnimsets);
                }
            }
            else
            {
                animsets.AddRange(EditorCore.Animations.Keys);
            }

            comboBoxMood.DataSource = new BindingSource(animsets, null);
        }
Example #3
0
        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);
            }
        }