示例#1
0
        private void FNodeEdit_Activated(object sender, EventArgs e)
        {
            if (m_settings != null)
            {
                MaxOutputs     = int.Parse(m_settings.Attributes["[Default]"]["MAXOUTPUTS"]);
                ConvoNodeStart = int.Parse(m_settings.Attributes["[Default]"]["CONVOOUTNODESTART"]);
            }
            lbxChoiceNodes.Items.Clear();
            List <NodeItem> items = (List <NodeItem>)EditingNode.Items;

            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);
                }
            }
        }
示例#2
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.");
            }
        }
示例#3
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);
        }
示例#4
0
        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);
        }
示例#5
0
            private String getConvoNodeScript(String convName, Node node)
            {
                String script = "";
                List<NodeItem> items = (List<NodeItem>)node.Items;
                NodeTextBoxItem nameItem = (NodeTextBoxItem)items[0];
                script += "\tnew ScriptObject(" + convName + "_" + nameItem.Text + ") {" + Environment.NewLine;
                script += "\t\tclass = \"ConversationNode\";" + Environment.NewLine;
                script += "\t\tcanSave = \"1\";" + Environment.NewLine;
                script += "\t\tcanSaveDynamicFields = \"1\";" + Environment.NewLine;
                int outNodeCount = items.Count - int.Parse(m_settings.Attributes["[Default]"]["CONVOOUTNODESTART"]);
                int start = int.Parse(m_settings.Attributes["[Default]"]["CONVOOUTNODESTART"]);
                NodeTextBoxItem nodeText = (NodeTextBoxItem)items[1];
                script += "\t\t\tdisplayText = \"" + conditionText(nodeText.Text) + "\";" + Environment.NewLine;
                script += "\t\t\tnumOutLinks = " + outNodeCount + ";" + Environment.NewLine;

                String target = "";
                List<String> foundNodes = new List<String>();
                for (int i = start; i < items.Count; i++)
                {
                    NodeCompositeItem textItem = (NodeCompositeItem)items[i];
                    String Text = "";
                    String Method = "";
                    foreach(ItemTextBoxPart part in textItem.Parts)
                    {
                        if (part.Name == "ConvText")
                            Text = part.Text;
                        if (part.Name == "ConvMethod")
                            Method = part.Text;
                    }
                    NodeOutputConnector conn = (NodeOutputConnector)textItem.Output;
                    foreach (NodeConnection con in conn.Connectors)
                    {
                        bool found = false;
                        if (con.To.Node == textItem.Node)
                            continue;
                        foreach (NodeConnection targetCon in con.To.Node.Connections)
                        {
                            if (targetCon.From.Item != textItem)
                                continue;
                            foreach (NodeItem item in con.To.Node.Items)
                            {
                                if (item.Name == "NodeName" && item.GetType().ToString() == "Graph.Items.NodeTextBoxItem")
                                {
                                    NodeTextBoxItem targetItem = (NodeTextBoxItem)item;
                                    if (foundNodes.Contains(targetItem.Text))
                                        continue;
                                    target = targetItem.Text;
                                    foundNodes.Add(target);
                                    found = true;
                                }
                                if (item.Name == "NodeName" && item.GetType().ToString() == "Graph.Items.NodeLabelItem")
                                {
                                    NodeLabelItem targetItem = (NodeLabelItem)item;
                                    if (foundNodes.Contains(targetItem.Text))
                                        continue;
                                    target = targetItem.Text;
                                    foundNodes.Add(target);
                                    found = true;
                                }
                                if (found)
                                    continue;
                            }
                        }
                    }
                    script += "\t\t\tbutton" + (i - start).ToString() + "next = " + convName + "_" + target + ";" + Environment.NewLine;
                    script += "\t\t\tbutton" + (i - start).ToString() + " = \"" + conditionText(Text) + "\";" + Environment.NewLine;
                    if (Method != "Enter script method")
                        script += "\t\t\tbutton" + (i - start).ToString() + "cmd = \"" + conditionText(Method) + ";\";" + Environment.NewLine;
                }
                script += "\t};" + Environment.NewLine;
                m_log.WriteLine("Generated Conversation Node " + nameItem.Text);
                return script;
            }
示例#6
0
        public CGraphFields(GraphControl control, ObjectIDGenerator idGen)
        {
            Dictionary <String, CNodeItemFields> idFieldMap = new Dictionary <String, CNodeItemFields>();
            Dictionary <NodeItem, String>        idItemMap  = new Dictionary <NodeItem, String>();
            bool first = false;

            id    = idGen.GetId(control, out first).ToString();
            name  = control.Name;
            Nodes = new List <CNodeFields>();
            List <Node> nodes = (List <Node>)control.Nodes;

            foreach (Node node in nodes)
            {
                CNodeFields nFields = new CNodeFields();
                nFields.Title    = node.Title;
                nFields.name     = getNodeName(node);
                nFields.Location = node.Location;
                nFields.Items    = new List <CNodeItemFields>();
                bool nfirst = false;
                nFields.id = idGen.GetId(nFields, out nfirst).ToString();
                foreach (NodeItem item in node.Items)
                {
                    CNodeItemFields iFields = new CNodeItemFields();
                    bool            ifirst  = false;
                    iFields.id = idGen.GetId(iFields, out ifirst).ToString();
                    String fName = nFields.name + ":" + (item.Name == null ? iFields.id : item.Name);
                    idFieldMap.Add(fName, iFields);
                    idItemMap.Add(item, fName);
                    iFields.Input      = new List <CConnectionFields>();
                    iFields.Output     = new List <CConnectionFields>();
                    iFields.ItemParts  = new List <CItemPartFields>();
                    iFields.name       = fName;
                    iFields.ParentNode = nFields.id;
                    if (item.Tag != null)
                    {
                        iFields.Tag = item.Tag.GetType().ToString();
                    }
                    iFields.IOMode   = getIOMode(item);
                    iFields.ItemType = item.GetType().ToString();
                    switch (iFields.ItemType)
                    {
                    case "Graph.Items.NodeTextBoxItem":
                    {
                        NodeTextBoxItem temp = item as NodeTextBoxItem;
                        iFields.Text = temp.Text;
                    }
                    break;

                    case "Graph.Items.NodeLabelItem":
                    {
                        NodeLabelItem temp = item as NodeLabelItem;
                        iFields.Text = temp.Text;
                    }
                    break;

                    case "Graph.Items.NodeCompositeItem":
                    {
                        NodeCompositeItem temp = item as NodeCompositeItem;
                        foreach (ItemPart part in temp.Parts)
                        {
                            CItemPartFields pFields = new CItemPartFields();
                            bool            pfirst  = false;
                            pFields.id       = idGen.GetId(pFields, out pfirst).ToString();
                            pFields.name     = part.Name;
                            pFields.PartType = part.GetType().ToString();
                            switch (pFields.PartType)
                            {
                            case "Graph.Items.ItemTextBoxPart":
                            {
                                ItemTextBoxPart tempPart = part as ItemTextBoxPart;
                                pFields.Text = tempPart.Text;
                            }
                            break;

                            default:
                                break;
                            }
                            iFields.ItemParts.Add(pFields);
                        }
                    }
                    break;
                    }
                    nFields.Items.Add(iFields);
                }
                foreach (NodeItem item in node.Items)
                {
                    // now get connection info
                    String iid = idItemMap[item];
                    if (item.Input.Enabled && item.Input.HasConnection)
                    {
                        foreach (NodeConnection conn in item.Input.Connectors)
                        {
                            CConnectionFields cFields = new CConnectionFields();
                            bool cfirst = false;
                            cFields.id = idGen.GetId(cFields, out cfirst).ToString();
                            Node   nFrom    = conn.From.Node;
                            String fromName = "";
                            foreach (NodeItem nItem in nFrom.Items)
                            {
                                if (nItem.Name == "NodeName")
                                {
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeTextBoxItem")
                                    {
                                        NodeTextBoxItem i = nItem as NodeTextBoxItem;
                                        fromName = i.Text;
                                    }
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeLabelItem")
                                    {
                                        NodeLabelItem i = nItem as NodeLabelItem;
                                        fromName = i.Text;
                                    }
                                }
                            }
                            Node   nTo    = conn.To.Node;
                            String toName = "";
                            foreach (NodeItem nItem in nTo.Items)
                            {
                                if (nItem.Name == "NodeName")
                                {
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeTextBoxItem")
                                    {
                                        NodeTextBoxItem i = nItem as NodeTextBoxItem;
                                        toName = i.Text;
                                    }
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeLabelItem")
                                    {
                                        NodeLabelItem i = nItem as NodeLabelItem;
                                        toName = i.Text;
                                    }
                                }
                            }
                            if (conn.Tag != null)
                            {
                                cFields.Tag = conn.Tag.GetType().ToString();
                            }
                            else if (item.Tag != null)
                            {
                                cFields.Tag = item.Tag.GetType().ToString();
                            }
                            cFields.name = (conn.Name == null ? cFields.id : conn.Name);
                            cFields.From = fromName + ":" + conn.From.Item.Name;
                            cFields.To   = toName + ":" + conn.To.Item.Name;
                            idFieldMap[iid].Input.Add(cFields);
                        }
                    }
                    if (item.Output.Enabled && item.Output.HasConnection)
                    {
                        foreach (NodeConnection conn in item.Output.Connectors)
                        {
                            CConnectionFields cFields = new CConnectionFields();
                            bool cfirst = false;
                            cFields.id = idGen.GetId(cFields, out cfirst).ToString();
                            Node   nFrom    = conn.From.Node;
                            String fromName = "";
                            foreach (NodeItem nItem in nFrom.Items)
                            {
                                if (nItem.Name == "NodeName")
                                {
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeTextBoxItem")
                                    {
                                        NodeTextBoxItem i = nItem as NodeTextBoxItem;
                                        fromName = i.Text;
                                    }
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeLabelItem")
                                    {
                                        NodeLabelItem i = nItem as NodeLabelItem;
                                        fromName = i.Text;
                                    }
                                }
                            }
                            Node   nTo    = conn.To.Node;
                            String toName = "";
                            foreach (NodeItem nItem in nTo.Items)
                            {
                                if (nItem.Name == "NodeName")
                                {
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeTextBoxItem")
                                    {
                                        NodeTextBoxItem i = nItem as NodeTextBoxItem;
                                        toName = i.Text;
                                    }
                                    if (nItem.GetType().ToString() == "Graph.Items.NodeLabelItem")
                                    {
                                        NodeLabelItem i = nItem as NodeLabelItem;
                                        toName = i.Text;
                                    }
                                }
                            }
                            if (conn.Tag != null)
                            {
                                cFields.Tag = conn.Tag.GetType().ToString();
                            }
                            else if (item.Tag != null)
                            {
                                cFields.Tag = item.Tag.GetType().ToString();
                            }
                            cFields.name = (conn.Name == null ? cFields.id : conn.Name);
                            cFields.From = fromName + ":" + conn.From.Item.Name;
                            cFields.To   = toName + ":" + conn.To.Item.Name;
                            idFieldMap[iid].Input.Add(cFields);
                        }
                    }
                }
                Nodes.Add(nFields);
            }
        }