Пример #1
0
            public InsertNodeTool(ConversationDataControl content, ConversationNodeDataControl parent, int nodeType, int index)
            {
                this.content    = content;
                this.isRootNode = parent == null;
                this.parent     = isRootNode ? content.getRootNode() : parent;
                ConversationNode node = null;

                switch (nodeType)
                {
                case DIALOG_NODE: node = new DialogueConversationNode(); break;

                case OPTION_NODE: node = new OptionConversationNode(); break;
                }


                this.index = index;
                var parentRect = isRootNode ? new RectInt(0, 25, 0, 0) : parent.getEditorRect();
                var childRect  = isRootNode ? content.getRootNode().getEditorRect() : parent.getChilds()[index].getEditorRect();

                var center = (parentRect.center + childRect.center) / 2f;

                node.setEditorX((int)(center.x - node.getEditorWidth() / 2f));
                node.setEditorY((int)(center.y - node.getEditorHeight() / 2f));

                this.newNode  = ConversationNodeDataControlFactory.Instance.CreateDataControlFor(content, node);
                this.subTools = CreateTools();
            }
Пример #2
0
            private List <Tool> CreateTools()
            {
                if (oldNode.getChildCount() > 1 && !Controller.Instance.ShowStrictConfirmDialog("Forbidden!", "Replacing this node will keep only the first child (the rest nodes will be deleted!). Continue?"))
                {
                    return(null);
                }

                var tools = from node in content.getAllNodes()
                            from child in node.getChilds().Select((n, i) => new { n, i })
                            where child.n == oldNode
                            select(Tool) new ConversationNodeDataControl.LinkConversationNodeTool(content, node, newNode, child.i);

                var toolsList = tools.ToList();

                if (oldNode.getChildCount() > 0)
                {
                    toolsList.Add(new ConversationNodeDataControl.AddRemoveConversationNodeTool(newNode, oldNode.getChilds()[0], 0));
                }

                if (oldNode == content.getRootNode())
                {
                    isRoot = true;
                }

                return(toolsList);
            }
Пример #3
0
            private List <ConversationNodeDataControl.AddRemoveConversationNodeTool> CreateTools()
            {
                if (toRemove.getChildCount() > 1 && !Controller.Instance.ShowStrictConfirmDialog("Forbidden!", "Deleting this node will keep only the first child (the rest nodes will be deleted!). Continue?"))
                {
                    return(null);
                }

                if (toRemove == content.getRootNode())
                {
                    if (toRemove.getChildCount() == 0)
                    {
                        Controller.Instance.ShowErrorDialog("Forbidden!", "Deleting the last node is forbidden!");
                        return(null);
                    }

                    isRoot = true;
                }


                var tools = from node in content.getAllNodes()
                            from child in node.getChilds().Select((n, i) => new { n, i })
                            orderby child.i descending
                            where child.n == toRemove
                            select new ConversationNodeDataControl.AddRemoveConversationNodeTool(node, child.i);

                return(tools.ToList());
            }