private void AddNode_Click(object sender, EventArgs e) { TreeNode selectedNode = tree.SelectedNode; if (selectedNode.Nodes.Count == 1) { if ((selectedNode.Nodes[0].Tag as ConversationNode).isLinkedNode) { MessageBox.Show("You cannot add a node here because this node is already attatched to a linked node." + " Delete the linked node to proceed.", "Sorry, Bro."); return; } } int imageIndex = 0; if (selectedNode == tree.Nodes["root"]) { imageIndex = 2; } else if (selectedNode.ImageIndex == 1) { imageIndex = 2; } else if (selectedNode.ImageIndex == 2) { imageIndex = 1; } TreeNode node = new TreeNode("", imageIndex, imageIndex); selectedNode.Nodes.Add(node); int maxNumber = SearchTreeForMax(tree.Nodes, imageIndex); ConversationNodeSpeakerType type = ConversationNodeSpeakerType.PC; if (imageIndex == 2) { node.Name = "n" + (maxNumber + 1).ToString(); type = ConversationNodeSpeakerType.NPC; } else if (imageIndex == 1) { node.Name = "p" + (maxNumber + 1).ToString(); } ConversationNode convNode = new ConversationNode(type, "", node.Name, selectedNode.Tag as ConversationNode); node.Tag = convNode; tree.SelectedNode = node; text.Focus(); }
/// <summary> /// Please input your information for storage :) /// </summary> /// <param name="speakerType"></param> /// <param name="soundEffect"></param> /// <param name="dialogue"></param> public ConversationNode(ConversationNodeSpeakerType speakerType, string dialog, string tag, ConversationNode parentNode) { this.speakerType = speakerType; this.dialog = dialog; this.tag = tag; this.parentNode = parentNode; if (parentNode != null) { parentNode.nodes.Add(this); } }
private void printTree(TreeNode search, ConversationNodeSpeakerType type) { ConversationNode cn = search.Tag as ConversationNode; if (cn.speakerType == type && !cn.isLinkedNode) { stringToPrint += cn.tag + " - " + cn.dialog + "\n"; } foreach (TreeNode node in search.Nodes) { printTree(node, type); } }
public ConversationNode(SerializationInfo info, StreamingContext context) { speakerType = (ConversationNodeSpeakerType)info.GetInt32("speakerType"); dialog = info.GetString("dialog"); tag = info.GetString("tag"); executeScripts = (List <string>)info.GetValue("executeScripts", typeof(List <string>)); checkScript = info.GetString("checkScript"); nodes = (List <ConversationNode>)info.GetValue("nodes", typeof(List <ConversationNode>)); parentNode = (ConversationNode)info.GetValue("parentNode", typeof(ConversationNode)); isLinkedNode = info.GetBoolean("isLinkedNode"); nodeLinkedTo = (ConversationNode)info.GetValue("nodeLinkedTo", typeof(ConversationNode)); checkScriptInverted = info.GetBoolean("checkScriptInverted"); checkScriptDescription = info.GetString("checkScriptDescription"); executeScriptDescriptions = (List <string>)info.GetValue("executeScriptDescriptions", typeof(List <string>)); }