Пример #1
0
        private void convTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //after we change focus in our convTree we need to clean up a bit
            propTextBox.Clear();
            dialogTreeNode dNode = (dialogTreeNode)convTree.SelectedNode;

            //based on what kind of node we have, change our display accordingly
            switch (dNode.sType)
            {
            case dNodeType.displayText:
                dNodeDisplayText dispText = (dNodeDisplayText)convTree.SelectedNode;
                propTextBox.Text = dispText.dispText;
                nodePropBox.Text = "NPC Text";
                propTextBox.Show();
                break;

            case dNodeType.userResponse:
                dNodeUserResponse userResponse = (dNodeUserResponse)convTree.SelectedNode;
                propTextBox.Text = userResponse.responseText;
                nodePropBox.Text = "Player Response Text";
                propTextBox.Show();
                break;

            case dNodeType.root:
                propTextBox.Hide();
                nodePropBox.Text = "";
                break;
            }
        }
Пример #2
0
        private bool addUserResponseNode(TreeNode selectedNode = null, dNodeUserResponse newNode = null)
        {
            if (selectedNode == null)
            {
                selectedNode = convTree.SelectedNode;
            }
            if (newNode == null)
            {
                newNode = new dNodeUserResponse();
            }

            dialogTreeNode dNode        = (dialogTreeNode)selectedNode;
            int            newNodeIndex = 0;

            //add a container for our responses if we don't already have one
            switch (dNode.sType)
            {
            case dNodeType.responseContainer:
                //we don't need to do anything extra
                newNodeIndex = selectedNode.Nodes.Add(newNode);
                break;

            case dNodeType.userResponse:
                //we need to select the parent (the response container node) first
                newNodeIndex = addNodeAfter(selectedNode, newNode);
                selectedNode = selectedNode.Parent;
                break;


            default:
                //if we had a display text node, we need to select the parent before
                //making the response container
                //if (dNode.sType == dNodeType.displayText) selectedNode = selectedNode.Parent;

                //we need to make a response container first
                dialogTreeNode container = new dialogTreeNode(dNodeType.responseContainer);
                container.Text = "[Display Options]";
                selectedNode.Nodes.Add(container);
                //addNodeAfter(selectedNode, container);
                selectedNode.Expand();
                selectedNode = container;

                newNodeIndex = selectedNode.Nodes.Add(newNode);
                break;
            }

            //add a dialog option now



            selectedNode.Expand();
            convTree.SelectedNode = selectedNode.Nodes[newNodeIndex];

            return(true);
        }
Пример #3
0
        public override object Clone()
        {
            dNodeUserResponse clone = new dNodeUserResponse();

            clone.responseText = this.responseText;
            clone.Text         = this.Text;
            clone.sType        = this.sType;


            foreach (TreeNode node in this.Nodes)
            {
                clone.Nodes.Add((TreeNode)node.Clone());
            }
            return(clone);
        }
Пример #4
0
        private void convTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            //if we didn't have anything selected (form just loaded) don't bother doing anything
            if (convTree.SelectedNode == null)
            {
                return;
            }

            //save what the user typed in the textbox, associate with the selected node
            dialogTreeNode dNode = (dialogTreeNode)convTree.SelectedNode;


            //based on what kind of node we have we'll save accordingly
            switch (dNode.sType)
            {
            case dNodeType.displayText:
                dNodeDisplayText dispTextNode = (dNodeDisplayText)dNode;
                dispTextNode.dispText = propTextBox.Text;

                //if the text box is empty, we'll set the treeview text to default
                //otherwise we'll set it to what the response is
                if (propTextBox.Text.Trim() != "")
                {
                    dispTextNode.Text = propTextBox.Text;
                }
                else
                {
                    dispTextNode.Text = "[Display Text]";
                }
                break;

            case dNodeType.userResponse:
                dNodeUserResponse responseNode = (dNodeUserResponse)dNode;
                responseNode.responseText = propTextBox.Text;
                if (propTextBox.Text.Trim() != "")
                {
                    responseNode.Text = propTextBox.Text;
                }
                else
                {
                    responseNode.Text = "[User Response]";
                }
                break;
            }
        }
Пример #5
0
        //drag drop complete
        private void convTree_DragDrop(object sender, DragEventArgs e)
        {
            // Retrieve the client coordinates of the drop location.
            Point targetPoint = convTree.PointToClient(new Point(e.X, e.Y));

            // Retrieve the node at the drop location.
            TreeNode  targetNode = convTree.GetNodeAt(targetPoint);
            TreeNode  draggedNode;
            dNodeType draggedNodeType;

            // Retrieve the node that was dragged.
            if (e.Data.GetDataPresent(typeof(dNodeDisplayText)))
            {
                dNodeDisplayText dispTextNode = (dNodeDisplayText)e.Data.GetData(typeof(dNodeDisplayText));
                draggedNode     = dispTextNode;
                draggedNodeType = dNodeType.displayText;
            }
            else if (e.Data.GetDataPresent(typeof(dNodeUserResponse)))
            {
                dNodeUserResponse userRespNode = (dNodeUserResponse)e.Data.GetData(typeof(dNodeUserResponse));
                draggedNode     = userRespNode;
                draggedNodeType = dNodeType.userResponse;
            }
            else if (e.Data.GetDataPresent(typeof(dialogTreeNode)))
            {
                dialogTreeNode dTreeNode = (dialogTreeNode)e.Data.GetData(typeof(dialogTreeNode));

                if (dTreeNode.sType == dNodeType.responseContainer)
                {
                    draggedNode     = dTreeNode;
                    draggedNodeType = dNodeType.responseContainer;
                }

                else if (dTreeNode.sType == dNodeType.root)
                {
                    System.Media.SystemSounds.Exclamation.Play();;
                    statusStripLabel.Text = "Can't move the root node!";
                    return;
                }
                else
                {
                    //undefined dialog Tree Node object being dragged!
                    return;
                }
            }
            else
            {
                MessageBox.Show("Can't Drag that object!");
                return;
            }

            // Confirm that the node at the drop location is not
            // the dragged node and that target node isn't null
            // (for example if you drag outside the control)
            if (!draggedNode.Equals(targetNode) && targetNode != null)
            {
                bool nodeAdded;

                //targetNode.Nodes.Add(draggedNode);
                //depending on the node we were dragging, let's make a copy of it
                switch (draggedNodeType)
                {
                case dNodeType.displayText:
                    dNodeDisplayText dispTextNode = (dNodeDisplayText)draggedNode;
                    nodeAdded = addDisplayTextNode(targetNode, (dNodeDisplayText)dispTextNode.Clone());
                    break;

                case dNodeType.userResponse:
                    dNodeUserResponse userRespNode = (dNodeUserResponse)draggedNode;
                    nodeAdded = addUserResponseNode(targetNode, (dNodeUserResponse)userRespNode.Clone());
                    break;

                default:
                    throw new Exception("draggedNodeType doesn't match any known types.");
                }

                // Remove the node from its current location if we successfully added
                if (nodeAdded)
                {
                    draggedNode.Remove();
                }

                // Expand the node at the location
                // to show the dropped node.
                targetNode.Expand();
            }
        }
Пример #6
0
        private bool addUserResponseNode(TreeNode selectedNode = null, dNodeUserResponse newNode = null)
        {
            if (selectedNode == null)
            {
                selectedNode = convTree.SelectedNode;
            }
            if (newNode == null)
            {
                newNode = new dNodeUserResponse();
            }

            dialogTreeNode dNode = (dialogTreeNode)selectedNode;
            int newNodeIndex = 0;

            //add a container for our responses if we don't already have one
            switch (dNode.sType)
            {
                case dNodeType.responseContainer:
                    //we don't need to do anything extra
                    newNodeIndex = selectedNode.Nodes.Add(newNode);
                    break;
                case dNodeType.userResponse:
                    //we need to select the parent (the response container node) first
                    newNodeIndex = addNodeAfter(selectedNode, newNode);
                    selectedNode = selectedNode.Parent;
                    break;

                default:
                    //if we had a display text node, we need to select the parent before
                    //making the response container
                    //if (dNode.sType == dNodeType.displayText) selectedNode = selectedNode.Parent;

                    //we need to make a response container first
                    dialogTreeNode container = new dialogTreeNode(dNodeType.responseContainer);
                    container.Text = "[Display Options]";
                    selectedNode.Nodes.Add(container);
                    //addNodeAfter(selectedNode, container);
                    selectedNode.Expand();
                    selectedNode = container;

                    newNodeIndex = selectedNode.Nodes.Add(newNode);
                    break;
            }

            //add a dialog option now

            selectedNode.Expand();
            convTree.SelectedNode = selectedNode.Nodes[newNodeIndex];

            return true;
        }
Пример #7
0
        public override object Clone()
        {
            dNodeUserResponse clone = new dNodeUserResponse();
            clone.responseText = this.responseText;
            clone.Text = this.Text;
            clone.sType = this.sType;

            foreach (TreeNode node in this.Nodes)
            {
                clone.Nodes.Add((TreeNode)node.Clone());
            }
            return clone;
        }