示例#1
0
 public static void SortSubNodes(ContentNode myNode)
 {
     foreach (ContentNode subNode in myNode.subNodes)
     {
         SortSubNodes(subNode);
     }
     myNode.subNodes = SortList(myNode.subNodes);
 }
示例#2
0
        public void AddNode()
        {
            try
            {
                //int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
                //int cnod = Convert.ToInt32(currentSelectedNode.Name);
                //ContentNode chdnod = new ContentNode();
                ContentNode chdnod = f_convo.GetContentNodeById(Convert.ToInt32(treeView1.SelectedNode.Name));
                if (!chdnod.isLink)
                {
                    PushToUndoStack();

                    f_convo.NextIdNum++;
                    //TreeView Stuff
                    //TreeNode nod = new TreeNode();
                    //nod.Name = f_convo.NextIdNum.ToString();
                    //nod.Text = "Continue";
                    //treeView1.SelectedNode.Nodes.Add(nod);
                    //treeView1.SelectedNode.ExpandAll();

                    //ContentNode Stuff
                    ContentNode newNode = new ContentNode();
                    newNode = newNode.NewContentNode(f_convo.NextIdNum);
                    //newNode.conversationText = nod.Text;
                    //newNode.orderNum = treeView1.SelectedNode.Nodes.Count - 1;
                    newNode.orderNum = treeView1.SelectedNode.Nodes.Count;
                    ContentNode pnod = f_convo.GetContentNodeById(Convert.ToInt32(treeView1.SelectedNode.Name));
                    //int pnod = Convert.ToInt32(treeView1.SelectedNode.Name);
                    //f_convo.GetContentNodeById(pnod).IsExpanded = true;
                    pnod.IsExpanded = true;
                    if (pnod.pcNode == true)
                    {
                        newNode.pcNode = false;
                    }
                    else
                    {
                        newNode.pcNode = true;
                    }
                    pnod.AddNodeToSubNode(newNode);

                    refreshTreeView();
                    TreeNode[] tn = treeView1.Nodes.Find(f_convo.NextIdNum.ToString(), true);
                    if (tn[0] != null)
                    {
                        treeView1.SelectedNode = tn[0];
                        currentSelectedNode = tn[0];
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("add node failed: " + ex.ToString());
            }
        }
示例#3
0
        private void btnCondMoveUp_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            ContentNode chdnod = new ContentNode();
            chdnod = f_convo.GetContentNodeById(cnod);
            int oldIndex = getIndexOfSelectedCondition();
            int newIndex = oldIndex - 1;

            if (newIndex >= 0)
            {
                var item = chdnod.conditions[oldIndex];
                chdnod.conditions.RemoveAt(oldIndex);
                chdnod.conditions.Insert(newIndex, item);
                setupConditionsDataGridView();
            }
        }
示例#4
0
 public void ResetOrderNumBasedOnIndex(ContentNode node)
 {
     //ContentNode returnNode = new ContentNode();
     for (int i = 0; i < node.subNodes.Count; i++)
     {
         node.subNodes[i].orderNum = i;
     }
     foreach (ContentNode n in node.subNodes)
     {
         ResetOrderNumBasedOnIndex(n);
     }
     //return returnNode;
 }
示例#5
0
 private void btnClearNodeImage_Click(object sender, EventArgs e)
 {
     int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
     ContentNode chdnod = new ContentNode();
     chdnod = f_convo.GetContentNodeById(cnod);
     chdnod.NodePortraitBitmap = "";
     txtNodeImage.Text = "";
 }
示例#6
0
 public void PasteAsLink()
 {
     pasteFromClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         ContentNode chdnod = new ContentNode();
         chdnod = f_convo.GetContentNodeById(cnod);
         if (!chdnod.isLink)
         {
             PushToUndoStack();
             //MessageBox.Show("You selected idNum = " + pasteFromClipboardNode.ToString() + " to paste as link from the clipboard");
             ContentNode copy = createLinkNode(f_convo.GetContentNodeById(copyToClipboardNode));
             copy.linkTo = copyToClipboardNode;
             ContentNode subcnt = f_convo.GetContentNodeById(pasteFromClipboardNode);
             copy.orderNum = subcnt.subNodes.Count;
             f_convo.GetContentNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
             refreshTreeView();
         }
     }
     catch { MessageBox.Show("paste as link node failed"); }
 }
示例#7
0
 public void PasteNodes()
 {
     pasteFromClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     if (f_convo.GetContentNodeById(copyToClipboardNode).pcNode == f_convo.GetContentNodeById(pasteFromClipboardNode).pcNode)
     {
         prntForm.logText("You can't paste a PC node to a PC node or a NPC node to a NPC node");
     }
     else
     {
         try
         {
             int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
             ContentNode chdnod = new ContentNode();
             chdnod = f_convo.GetContentNodeById(cnod);
             if (!chdnod.isLink)
             {
                 PushToUndoStack();
                 prntForm.logText("You selected idNum = " + pasteFromClipboardNode.ToString() + " to paste from the clipboard");
                 ContentNode copy = duplicateNode(f_convo.GetContentNodeById(copyToClipboardNode));
                 //ContentNode copy = f_convo.GetContentNodeById(copyToClipboardNode).Clone();
                 f_convo.GetContentNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
                 refreshTreeView();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("paste node failed: " + ex.ToString());
         }
     }
 }
示例#8
0
        public ContentNode DuplicateContentNode()
        {
            ContentNode newNode = new ContentNode();
            newNode.conversationText = this.conversationText;
            newNode.idNum = this.idNum;
            newNode.pcNode = this.pcNode;
            newNode.linkTo = this.linkTo;
            newNode.NodePortraitBitmap = this.NodePortraitBitmap;
            //newNode.NodeSound = this.NodeSound;
            newNode.IsExpanded = this.IsExpanded;
            newNode.ShowOnlyOnce = this.ShowOnlyOnce;
            newNode.NodeIsActive = this.NodeIsActive;
            newNode.NodeNpcName = this.NodeNpcName;

            newNode.actions = new List<Action>();
            foreach (Action a in this.actions)
            {
                Action ac = a.DeepCopy();
                newNode.actions.Add(ac);
            }
            newNode.conditions = new List<Condition>();
            foreach (Condition c in this.conditions)
            {
                Condition cc = c.DeepCopy();
                newNode.conditions.Add(cc);
            }

            return newNode;
        }
示例#9
0
 public ContentNode NewContentNode(int nextIdNum)
 {
     ContentNode newNode = new ContentNode();
     //newNode.passRefs(game);
     newNode.idNum = nextIdNum;
     return newNode;
 }
示例#10
0
 public void AddNodeToSubNode(ContentNode contentNode)
 {
     subNodes.Add(contentNode);
 }
示例#11
0
 public ContentNode Duplicate()
 {
     ContentNode copy = new ContentNode();
     copy = (ContentNode)this.MemberwiseClone();
     //copy.passRefs(game);
     //copy.conversationText = this.conversationText;
     //copy.idNum = this.idNum;
     copy.actions = new List<Action>();
     foreach (Action a in this.actions)
     {
         Action ac = a.DeepCopy();
         copy.actions.Add(ac);
     }
     copy.conditions = new List<Condition>();
     foreach (Condition c in this.conditions)
     {
         Condition cc = c.DeepCopy();
         copy.conditions.Add(cc);
     }
     foreach (ContentNode node in this.subNodes)
     {
         copy.subNodes.Add(node.Duplicate());
     }
     return copy;
 }
示例#12
0
 public void RemoveNodeFromRoot(ContentNode contentNode)
 {
     subNodes.Remove(contentNode);
 }
示例#13
0
 public void RemoveNodeFromRoot(ContentNode contentNode)
 {
     subNodes.Remove(contentNode);
 }
示例#14
0
 public void AddNodeToRoot(ContentNode contentNode)
 {
     subNodes.Add(contentNode);
 }
示例#15
0
        public string GetTextById(int idNum)
        {
            ContentNode tempNode = GetContentNodeById(idNum);

            return(tempNode.conversationText);
        }
示例#16
0
 public ContentNode NewContentNodeLink(int nextOrderNum)
 {
     ContentNode newNode = new ContentNode();
     //newNode.passRefs(game);
     newNode.orderNum = nextOrderNum;
     return newNode;
 }
示例#17
0
 public void FollowLink()
 {
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         ContentNode chdnod = new ContentNode();
         chdnod = f_convo.GetContentNodeById(cnod);
         TreeNode[] tn = treeView1.Nodes.Find(chdnod.linkTo.ToString(), true);
         //TreeNode[] tn = treeView1.Nodes.Find(f_convo.NextIdNum.ToString(), true);
         if (tn[0] != null)
         {
             treeView1.SelectedNode = tn[0];
             currentSelectedNode = tn[0];
         }
     }
     catch { MessageBox.Show("follow link node failed"); }
 }
示例#18
0
 public void RemoveNodeFromSubNode(ContentNode contentNode)
 {
     bool returnvalue = subNodes.Remove(contentNode);
 }
示例#19
0
 public void PasteAsRelocatedNodes()
 {
     int relocateFromClipboardToThisNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     if (f_convo.GetContentNodeById(copyToClipboardNode).pcNode == f_convo.GetContentNodeById(relocateFromClipboardToThisNode).pcNode)
     {
         prntForm.logText("You can't paste a PC node to a PC node or a NPC node to a NPC node");
     }
     else
     {
         try
         {
             //get the clipboardNode
             ContentNode clipboardNode = f_convo.GetContentNodeById(copyToClipboardNode);
             ContentNode clipboardNodeParentNode = f_convo.GetContentNodeById(copyToClipboardNodeParentNode);
             ContentNode relocateToNode = f_convo.GetContentNodeById(relocateFromClipboardToThisNode);
             //add this node to the relocateToNode's subNodes list
             //remove
             int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
             ContentNode chdnod = new ContentNode();
             chdnod = f_convo.GetContentNodeById(cnod);
             if (!chdnod.isLink)
             {
                 PushToUndoStack();
                 prntForm.logText("You selected idNum = " + relocateFromClipboardToThisNode.ToString() + " to relocate from the clipboard");
                 ContentNode copy = duplicateNodeKeepIds(clipboardNode);
                 //ContentNode copy = f_convo.GetContentNodeById(copyToClipboardNode).Clone();
                 relocateToNode.AddNodeToSubNode(copy);
                 clipboardNodeParentNode.RemoveNodeFromSubNode(clipboardNode);
                 //f_convo.GetContentNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
                 //f_convo.GetContentNodeById(prnod).RemoveNodeFromSubNode(f_convo.GetContentNodeById(rnod));
                 refreshTreeView();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("paste node failed: " + ex.ToString());
         }
     }
 }
示例#20
0
 private void loadAndOrButtonValues(ContentNode cnod)
 {
     for (int i = 0; i < dgvCondition.Rows.Count; i++)
     {
         //AndOr column is index 1
         dgvCondition[1, i].Value = cnod.conditions[i].c_btnAndOr;
     }
 }
示例#21
0
        public TreeNode PopulateTreeNode(ContentNode node)
        {
            TreeNode treenode = new TreeNode(node.conversationText);  // Add the Text to the Node
            if (node.IsExpanded) { treenode.Expand(); }
            treenode.Name = node.idNum.ToString();
            if ((node.conditions.Count > 0) && (node.actions.Count > 0))
            {
                treenode.ImageIndex = 3;
                treenode.SelectedImageIndex = 3;
            }
            else if (node.conditions.Count > 0)
            {
                treenode.ImageIndex = 1;
                treenode.SelectedImageIndex = 1;
            }
            else if (node.actions.Count > 0)
            {
                treenode.ImageIndex = 2;
                treenode.SelectedImageIndex = 2;
            }
            else
            {
                treenode.ImageIndex = 0;
                treenode.SelectedImageIndex = 0;
            }

            if (node.isLink)
            {
                treenode.Text = f_convo.GetContentNodeById(node.linkTo).conversationText;
                node.conversationText = f_convo.GetContentNodeById(node.linkTo).conversationText;
            }
            if (node.pcNode == false)
            {
                treenode.ForeColor = Color.Red;
            }
            else
            {
                treenode.ForeColor = Color.Blue;
            }
            if (node.subNodes.Count == 0)
            {
                treenode.Text = treenode.Text + " [END DIALOG]";
            }
            /*
            prntForm.logText("node IdNum = " + node.idNum.ToString());
            prntForm.logText(Environment.NewLine);
            prntForm.logText("node.subNodes.Count = " + node.subNodes.Count.ToString());
            prntForm.logText(Environment.NewLine);
            */
            for (int i = 0; i < node.subNodes.Count; i++)
            {
                /*
                prntForm.logText("node.subNodes[" + i.ToString() + "].subNodes.Count = " + node.subNodes[i].subNodes.Count.ToString());
                prntForm.logText(Environment.NewLine);
                */
                if (node.subNodes[i].subNodes.Count >= 0)
                {
                    /*
                    prntForm.logText("node.subNodes[" + i.ToString() + "].idNum = " + node.subNodes[i].idNum.ToString());
                    prntForm.logText(Environment.NewLine);
                    */
                    treenode.Nodes.Add(PopulateTreeNode(node.subNodes[i]));
                }
            }
            if (node.isLink)
            {
                treenode.ForeColor = Color.Gray;
            }
            return treenode;
        }
示例#22
0
 private void loadValueForCondComboBoxes(ContentNode cnod)
 {
     for (int i = 0; i < dgvCondition.Rows.Count; i++)
     {
         //AndOr column is index 1
         if (scriptList.Contains(cnod.conditions[i].c_script))
         {
             dgvCondition[3, i].Value = cnod.conditions[i].c_script;
         }
         else
         {
             prntForm.logText("[ERROR] Can't find the script that was assigned to this node, choose one from the list." + Environment.NewLine);
         }
     }
 }
示例#23
0
        private void btnActMoveDown_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            ContentNode chdnod = new ContentNode();
            chdnod = f_convo.GetContentNodeById(cnod);
            int oldIndex = getIndexOfSelectedAction();
            int newIndex = oldIndex + 1;

            if ((newIndex < chdnod.actions.Count) && (oldIndex >= 0))
            {
                var item = chdnod.actions[oldIndex];
                chdnod.actions.RemoveAt(oldIndex);
                chdnod.actions.Insert(newIndex, item);
                setupActionsDataGridView();
            }
        }
示例#24
0
        private void setupConditionsDataGridView()
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            ContentNode chdnod = new ContentNode();
            chdnod = f_convo.GetContentNodeById(cnod);

            dgvCondition.DataSource = chdnod.conditions;
            dgvCondition.AutoGenerateColumns = false;

            DataGridViewColumn column0 = new DataGridViewCheckBoxColumn();
            //column0.DataPropertyName = "Select";
            column0.HeaderText = "Select";
            column0.Name = "select";
            column0.Width = 45;

            DataGridViewColumn columnA = new DataGridViewButtonColumn();
            columnA.DataPropertyName = "c_btnAndOr";
            columnA.HeaderText = "AndOr";
            columnA.Name = "c_btnAndOr";
            columnA.Width = 45;

            DataGridViewColumn columnB = new DataGridViewCheckBoxColumn();
            columnB.DataPropertyName = "c_not";
            columnB.HeaderText = "Not";
            columnB.Name = "c_not";
            columnB.Width = 35;

            DataGridViewComboBoxColumn selScript = new DataGridViewComboBoxColumn();
            selScript.Items.Add("none");
            foreach (string script in scriptList)
            {
                selScript.Items.Add(script);
            }
            selScript.DefaultCellStyle.NullValue = "none";
            selScript.Name = "selectScript";
            selScript.Width = 150;

            DataGridViewColumn columnD = new DataGridViewTextBoxColumn();
            columnD.DataPropertyName = "c_parameter_1";
            columnD.HeaderText = "Parameter 1";
            columnD.Name = "c_parameter_1";
            columnD.Width = 130;

            DataGridViewColumn columnE = new DataGridViewTextBoxColumn();
            columnE.DataPropertyName = "c_parameter_2";
            columnE.HeaderText = "Parameter 2";
            columnE.Name = "c_parameter_2";
            columnE.Width = 130;

            DataGridViewColumn columnF = new DataGridViewTextBoxColumn();
            columnF.DataPropertyName = "c_parameter_3";
            columnF.HeaderText = "Parameter 3";
            columnF.Name = "c_parameter_3";
            columnF.Width = 130;

            DataGridViewColumn columnG = new DataGridViewTextBoxColumn();
            columnG.DataPropertyName = "c_parameter_4";
            columnG.HeaderText = "Parameter 4";
            columnG.Name = "c_parameter_4";
            columnG.Width = 130;

            dgvCondition.Columns.Clear();
            dgvCondition.Columns.Add(column0);
            dgvCondition.Columns.Add(columnA);
            dgvCondition.Columns.Add(columnB);
            //dgvCondition.Columns.Add(columnC);
            dgvCondition.Columns.Add(selScript);
            dgvCondition.Columns.Add(columnD);
            dgvCondition.Columns.Add(columnE);
            dgvCondition.Columns.Add(columnF);
            dgvCondition.Columns.Add(columnG);
            loadAndOrButtonValues(chdnod);
            loadValueForCondComboBoxes(chdnod);
            //loadSelectScriptButtonValues();
        }
示例#25
0
        private void btnCondMoveDown_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            ContentNode chdnod = new ContentNode();
            chdnod = f_convo.GetContentNodeById(cnod);
            int oldIndex = getIndexOfSelectedCondition();
            int newIndex = oldIndex + 1;

            if ((newIndex < chdnod.conditions.Count) && (oldIndex >= 0))
            {
                var item = chdnod.conditions[oldIndex];
                chdnod.conditions.RemoveAt(oldIndex);
                //newIndex--; // the actual index could have shifted due to the removal
                chdnod.conditions.Insert(newIndex, item);
                setupConditionsDataGridView();
            }
        }
示例#26
0
 public void CopyNodes()
 {
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         int prnod = Convert.ToInt32(treeView1.SelectedNode.Parent.Name);
         ContentNode chdnod = new ContentNode();
         chdnod = f_convo.GetContentNodeById(cnod);
         if (!chdnod.isLink)
         {
             copyToClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
             copyToClipboardNodeParentNode = Convert.ToInt32(treeView1.SelectedNode.Parent.Name);
             prntForm.logText("You selected idNum = " + copyToClipboardNode.ToString() + " to copy to the clipboard");
         }
     }
     catch { MessageBox.Show("copy node failed"); }
 }
示例#27
0
        private void btnOpenNodeImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = prntForm._mainDirectory + "\\modules\\" + ce_mod.moduleName + "\\graphics";
            //Empty the FileName text box of the dialog
            openFileDialog1.FileName = String.Empty;
            openFileDialog1.Filter = "png files (*.png)|*.png|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
            if (result == DialogResult.OK) // Test result.
            {
                string filename = Path.GetFileName(openFileDialog1.FileName);
                int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
                ContentNode chdnod = new ContentNode();
                chdnod = f_convo.GetContentNodeById(cnod);
                chdnod.NodePortraitBitmap = filename;
                txtNodeImage.Text = filename;
            }
        }
示例#28
0
 public ContentNode duplicateNode(ContentNode copiedNode)
 {
     f_convo.NextIdNum++;
     prntForm.logText("NextIdNum = " + f_convo.NextIdNum.ToString());
     ContentNode copy = new ContentNode();
     copy = copiedNode.DuplicateContentNode(f_convo.NextIdNum);
     //copy.conversationText = copiedNode.conversationText;
     copy.idNum = f_convo.NextIdNum;
     foreach (ContentNode node in copiedNode.subNodes)
     {
         copy.subNodes.Add(duplicateNode(node));
     }
     return copy;
 }
示例#29
0
 private void ConvoEditor_Load(object sender, EventArgs e)
 {
     // load the file that has the selected node name if it exists
     string filenameOnly = ce_mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json";
     string dirFullPath = prntForm._mainDirectory + "\\modules\\" + ce_mod.moduleName + "\\dialog";
     if (File.Exists(dirFullPath + "\\" + filenameOnly))
     {
         openFile(dirFullPath, filenameOnly);
         if (f_convo == null)
         {
             f_convo = new Convo();
             f_convo.ConvoFileName = filenameOnly;
             //initializeConditionsTab();
             //initializeActionsTab();
             // start off by adding a base treeview node
             ContentNode contentNode = new ContentNode();
             contentNode.idNum = f_convo.NextIdNum;
             contentNode.conversationText = "root";
             f_convo.AddNodeToRoot(contentNode);
             TreeNode mainNode = new TreeNode();
             mainNode.Name = "0";
             mainNode.Text = "root";
             treeView1.Nodes.Add(mainNode);
         }
         else
         {
             //initializeConditionsTab();
             //initializeActionsTab();
         }
     }
     else
     {
         f_convo.ConvoFileName = filenameOnly;
         //initializeConditionsTab();
         //initializeActionsTab();
         // start off by adding a base treeview node
         ContentNode contentNode = new ContentNode();
         contentNode.idNum = f_convo.NextIdNum;
         contentNode.conversationText = "root";
         f_convo.AddNodeToRoot(contentNode);
         TreeNode mainNode = new TreeNode();
         mainNode.Name = "0";
         mainNode.Text = "root";
         treeView1.Nodes.Add(mainNode);
     }
     currentSelectedNode = null;
     txtImage.Text = f_convo.NpcPortraitBitmap;
     txtDefaultNpcName.Text = f_convo.DefaultNpcName;
     chkNarrator.Checked = f_convo.Narration;
     chkPartyChat.Checked = f_convo.PartyChat;
     chkMainPcOnly.Checked = f_convo.SpeakToMainPcOnly;
     SortConversation(f_convo);
     ResetOrderNumBasedOnIndex(f_convo.subNodes[0]);
     prntForm.openConvosList.Add(f_convo);
     fillScriptList();
 }
示例#30
0
 public ContentNode duplicateNodeKeepIds(ContentNode copiedNode)
 {
     ContentNode copy = new ContentNode();
     copy = copiedNode.DuplicateContentNode();
     foreach (ContentNode node in copiedNode.subNodes)
     {
         copy.subNodes.Add(duplicateNodeKeepIds(node));
     }
     return copy;
 }
示例#31
0
 private ContentNode createLinkNode(ContentNode copiedNode)
 {
     f_convo.NextIdNum++;
     ContentNode copy = new ContentNode();
     copy.conversationText = copiedNode.conversationText;
     copy.idNum = f_convo.NextIdNum;
     return copy;
 }
示例#32
0
 public void RemoveNodeFromSubNode(ContentNode contentNode)
 {
     bool returnvalue = subNodes.Remove(contentNode);
 }