public void OpenDocumentDialogue(Dialogue dialogue, int node) { foreach (DocumentDialogue document in documentDialogues) { if (document.Dialogue == dialogue) { document.Activate(); //OnActiveDocumentChanged will handle the refresh document.SelectNode(node); return; } } DocumentDialogue newDocument = new DocumentDialogue(dialogue); newDocument.Show(dockPanel, DockState.Document); documentDialogues.Add(newDocument); newDocument.SelectNode(node); EditorHelper.CheckDialogueErrors(dialogue); }
protected void PlayNode(DialogueNode nextNode, bool forward = true) { if (forward && currentNode != null && !(currentNode is DialogueNodeReply) && !(currentNode is DialogueNodeGoto)) { previousNodes.Add(currentNode); } if (nextNode == null) { Finish(); return; } currentNode = nextNode; currentDocument.SelectNode(currentNode); ResetGroups(); if (currentNode.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AlwaysFalse) { PlayNode(currentNode.Next); return; } if (currentNode is DialogueNodeSentence) { var sentence = currentNode as DialogueNodeSentence; ResetSentence(); Actor speaker = ResourcesHandler.Project.GetActorFromID(sentence.SpeakerID); if (speaker != null) { labelSpeaker.Text = speaker.Name; string strPathPortraitSpeaker = Path.Combine(EditorHelper.GetProjectDirectory(), speaker.Portrait); if (File.Exists(strPathPortraitSpeaker)) { pictureBoxSpeaker.Image = Image.FromFile(strPathPortraitSpeaker); } } Actor listener = ResourcesHandler.Project.GetActorFromID(sentence.ListenerID); if (listener != null) { labelListener.Text = listener.Name; string strPathPortraitListener = Path.Combine(EditorHelper.GetProjectDirectory(), listener.Portrait); if (File.Exists(strPathPortraitListener)) { pictureBoxListener.Image = Image.FromFile(strPathPortraitListener); } } if (checkBoxOptionConstants.Checked) { labelSentence.Text = EditorHelper.FormatTextEntry(sentence.Sentence, EditorCore.LanguageWorkstring); } else { labelSentence.Text = sentence.Sentence; } } else if (currentNode is DialogueNodeChoice) { var choice = currentNode as DialogueNodeChoice; groupBoxChoice.Visible = true; labelChoice.Text = String.Format("Choice : {0}", choice.Choice); listBoxReplies.DataSource = new BindingSource(choice.Replies, null); checkBoxShowReplyConditions.Checked = false; radioButtonReplyConditionsTrue.Checked = true; foreach (DialogueNodeReply reply in choice.Replies) { if (reply.Conditions.Count > 0) { labelRepliesConditions.Enabled = true; checkBoxShowReplyConditions.Enabled = true; radioButtonReplyConditionsTrue.Enabled = true; radioButtonReplyConditionsFalse.Enabled = true; break; } } if (choice.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime) { ShowConditions(choice); } } else if (currentNode is DialogueNodeGoto) { var nodeGoto = currentNode as DialogueNodeGoto; if (nodeGoto.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime) { groupBoxGoto.Visible = true; labelGoto.Text = String.Format("Goto > \"{0}\"", GetGotoText(nodeGoto.Goto)); ShowConditions(nodeGoto); } else { PlayNode(nodeGoto.Goto); } } else if (currentNode is DialogueNodeBranch) { var nodeBranch = currentNode as DialogueNodeBranch; if (nodeBranch.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime) { groupBoxGoto.Visible = true; labelGoto.Text = String.Format("Branch > \"{0}\"", GetGotoText(nodeBranch.Branch)); ShowConditions(nodeBranch); } else { PlayNode(nodeBranch.Branch); } } }