Example #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     List<NodeItem> items = (List<NodeItem>)EditingNode.Items;
     if (items.Count < (MaxOutputs + ConvoNodeStart))
     {
         NodeCompositeItem newNode = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.TEXTBOX };
         newNode.Name = "button_" + findUnusedButtonIndex().ToString().PadLeft(2, '0');
         ItemTextBoxPart btnText = new ItemTextBoxPart("Enter player text");
         btnText.Name = "ConvText";
         ItemTextBoxPart btnMethod = new ItemTextBoxPart("Enter script method");
         btnMethod.Name = "ConvMethod";
         newNode.AddPart(btnText);
         newNode.AddPart(btnMethod);
         newNode.Clicked += MainForm.GetConvMouseHandler();
         NodeTextBoxItem nodeName = (NodeTextBoxItem)items[0];
         EditingNode.AddItem(newNode);
         lbxChoiceNodes.Items.Clear();
         if (items.Count > ConvoNodeStart)
         {
             for (int i = ConvoNodeStart; i < items.Count; i++)
             {
                 NodeCompositeItem item = (NodeCompositeItem)items[i];
                 String text = "";
                 foreach(ItemTextBoxPart part in item.Parts)
                 {
                     if (part.Name == "ConvText")
                         text = part.Text;
                 }
                 lbxChoiceNodes.Items.Add(text);
             }
         }
     }
     else
     {
         MessageBox.Show("A maximum of " + MaxOutputs + " is allowed.");
     }
 }
 private void rebuildGraph(GraphControl graph)
 {
     Dictionary<String, CConnectionFields> inputs = new Dictionary<String, CConnectionFields>();
     Dictionary<String, CConnectionFields> outputs = new Dictionary<String, CConnectionFields>();
     foreach(CNodeFields node in m_graphFields.Nodes)
     {
         m_idNameMap.Add(node.id, node.name);
         Node n = new Node(node.Title);
         n.Location = node.Location;
         foreach(CNodeItemFields item in node.Items)
         {
             String name = "";
             if(item.name != null)
                 name = item.name.Split(':')[1];
             if (item.Input != null)
             {
                 foreach (CConnectionFields conn in item.Input)
                 {
                     if (!inputs.ContainsKey(conn.id))
                         inputs.Add(conn.id, conn);
                 }
             }
             if (item.Output != null)
             {
                 foreach (CConnectionFields conn in item.Output)
                 {
                     if (!outputs.ContainsKey(conn.id))
                         outputs.Add(conn.id, conn);
                 }
             }
             switch (item.ItemType)
             {
                 case "Graph.Items.NodeCompositeItem":
                     {
                         NodeCompositeItem temp = new NodeCompositeItem(item.IOMode);
                         temp.Name = name;
                         foreach(CItemPartFields part in item.ItemParts)
                         {
                             switch(part.PartType)
                             {
                                 case "Graph.Items.ItemTextBoxPart":
                                     {
                                         ItemTextBoxPart p = new ItemTextBoxPart(part.Text);
                                         p.Name = part.name;
                                         temp.AddPart(p);
                                     }
                                     break;
                                 default:
                                     {
                                     }
                                     break;
                             }
                         }
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         if (temp.Name.Contains("button_"))
                             temp.Clicked += m_parentForm.GetConvMouseHandler();
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeTextBoxItem":
                     {
                         NodeTextBoxItem temp = new NodeTextBoxItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeLabelItem":
                     {
                         NodeLabelItem temp = new NodeLabelItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         if (temp.Name == "EditNodeItem")
                             temp.Clicked += m_parentForm.GetEditMouseHandler();
                         n.AddItem(temp);
                     }
                     break;
                 default:
                     {
                         //NodeItem temp = new NodeItem(item.IOMode);
                     }
                     break;
             }
         }
         graph.AddNode(n);
     }
     rebuildConnections(graph, inputs, outputs);
 }
Example #3
0
 private void SomeNode_MouseDown(object sender, MouseEventArgs e)
 {
     var node = new Node("Some node");
     node.AddItem(new NodeLabelItem("Entry 1", NodeIOMode.Input) { Tag = TagType.COLOR });
     node.AddItem(new NodeLabelItem("Entry 2", NodeIOMode.Input) { Tag = TagType.IMAGE });
     node.AddItem(new NodeLabelItem("Entry 3", NodeIOMode.Input) { Tag = TagType.TEXTBOX });
     node.AddItem(new NodeTextBoxItem("TEXTTEXT", NodeIOMode.Output) { Tag = TagType.TEXTBOX });
     node.AddItem(new NodeDropDownItem(new string[] { "1", "2", "3", "4" }, 0, NodeIOMode.Output) { Tag = TagType.TEXTBOX });
     var compItem = new NodeCompositeItem(NodeIOMode.InOut) { Tag = TagType.COMPOSITE };
     var txtPart = new ItemTextBoxPart("Test text");
     compItem.AddPart(txtPart);
     node.AddItem(compItem);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }
Example #4
0
 private void CompNode_MouseDown(object sender, MouseEventArgs e)
 {
     var compNode = new Node("Composite Node");
     compNode.Location = new Point(300, 150);
     var compItem = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.COMPOSITE };
     var compTxtPart = new ItemTextBoxPart("Test text");
     compItem.AddPart(compTxtPart);
     var compTxtPart2 = new ItemTextBoxPart("Test 2 text with really long text");
     compItem.AddPart(compTxtPart2);
     compNode.AddItem(compItem);
     this.DoDragDrop(compNode, DragDropEffects.Copy);
 }
Example #5
0
 private void lblConvoNode_MouseDown(object sender, MouseEventArgs e)
 {
     List<Node> nodes = (List<Node>)graphCtrl.Nodes;
     String nodeName = m_settings.Attributes["[Default]"]["DEFAULTNODENAME"] + "_" + getConvNodeCount().ToString().PadLeft(4, '0');
     var node = new Node("Conversation Node");
     var nodeNameItem = new NodeTextBoxItem(nodeName);
     nodeNameItem.Name = "NodeName";
     node.AddItem(nodeNameItem);
     NodeTextBoxItem displayText = new NodeTextBoxItem("Enter NPC text", NodeIOMode.None);
     displayText.Name = "DisplayText";
     node.AddItem(displayText);
     var inputLabel = new NodeLabelItem("Conversation input", NodeIOMode.Input) { Tag = TagType.LABEL };
     inputLabel.Name = nodeName + "_in";
     node.AddItem(inputLabel);
     var editNode = new NodeLabelItem("Click Here To Edit Output List");
     editNode.Name = "EditNodeItem";
     editNode.Clicked += new EventHandler<NodeItemEventArgs>(editOutputListNode_MouseDown);
     node.AddItem(editNode);
     NodeCompositeItem firstButton = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.TEXTBOX };
     firstButton.Name = "button_1";
     ItemTextBoxPart btnText = new ItemTextBoxPart("Enter player text");
     btnText.Name = "ConvText";
     ItemTextBoxPart btnMethod = new ItemTextBoxPart("Enter script method");
     btnMethod.Name = "ConvMethod";
     firstButton.AddPart(btnText);
     firstButton.AddPart(btnMethod);
     firstButton.Clicked += new EventHandler<NodeItemEventArgs>(editConvNode_MouseDown);
     node.AddItem(firstButton);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }