Esempio n. 1
0
        public DialogueNodeReply(DialogueNodeReply other)
            : base(other)
        {
            Reply = other.Reply;

            //Clone all child nodes
            DialogueNode currentNode  = this;
            DialogueNode currentOther = other;

            while (currentOther != null && currentOther.Next != null)
            {
                currentNode.Next = currentOther.Next.Clone() as DialogueNode;
                currentNode      = currentNode.Next;
                currentOther     = currentOther.Next;
            }
        }
Esempio n. 2
0
        public void Init(DocumentDialogue inDocument, TreeNode inTreeNode, DialogueNode inDialogueNode)
        {
            document     = inDocument;
            treeNode     = inTreeNode;
            dialogueNode = inDialogueNode as DialogueNodeReply;

            Project project = ResourcesHandler.Project;

            textBoxWorkstring.Text = dialogueNode.Reply;
            RefreshWordCount();

            //AutoComplete
            autoComplete            = new AutoComplete(this, new BindingSource(project.ListConstants, null));
            autoComplete.OnValidate = ValidateAutoComplete;
            autoComplete.OnClose    = CloseAutoComplete;
            autoComplete.OnDrawItem = DrawItemAutoComplete;

            ready = true;
        }
Esempio n. 3
0
        public DialogueNodeReply(DialogueNodeReply other)
            : base(other)
        {
            Reply      = other.Reply;
            Repeat     = other.Repeat;
            Deduction  = other.Deduction;
            AutoSelect = other.AutoSelect;

            //Clone all child nodes
            DialogueNode currentNode  = this;
            DialogueNode currentOther = other;

            while (currentOther != null && currentOther.Next != null)
            {
                currentNode.Next = currentOther.Next.Clone() as DialogueNode;
                currentNode      = currentNode.Next;
                currentOther     = currentOther.Next;
            }
        }
Esempio n. 4
0
        public void PostLoad(Project project)
        {
            //Resolve links with package
            Package = project.GetPackage(PackageName);
            if (Package == null)
            {
                EditorCore.LogError("Loading a Dialogue without Package (forcing default) : " + GetName(), this);
                Package = project.GetDefaultPackage();
            }

            //Resolve links between nodes
            RootNode = GetNodeByID(RootNodeID) as DialogueNodeRoot;

            foreach (DialogueNode node in ListNodes)
            {
                node.Next = GetNodeByID(node.NextID);
                if (node is DialogueNodeChoice)
                {
                    DialogueNodeChoice nodeChoice = node as DialogueNodeChoice;
                    foreach (int replyID in nodeChoice.RepliesIDs)
                    {
                        DialogueNodeReply nodeReply = GetNodeByID(replyID) as DialogueNodeReply;
                        if (nodeReply != null)
                        {
                            nodeChoice.Replies.Add(nodeReply);
                        }
                    }
                }
                else if (node is DialogueNodeGoto)
                {
                    DialogueNodeGoto nodeGoto = node as DialogueNodeGoto;
                    nodeGoto.Goto = GetNodeByID(nodeGoto.GotoID);
                }
                else if (node is DialogueNodeBranch)
                {
                    DialogueNodeBranch nodebranch = node as DialogueNodeBranch;
                    nodebranch.Branch = GetNodeByID(nodebranch.BranchID);
                }
            }

            EditorCore.OnDialoguePostLoad?.Invoke(this);
        }
        static public void ExportToUnrealManifest(string directory, Project project, List <Dialogue> dialogues)
        {
            string path = Path.Combine(directory, "Dialogues.manifest");

            UEManifestRoot root = new UEManifestRoot();

            root.FormatVersion = 1;
            root.Namespace     = "";
            root.Children      = new List <UEManifestEntry>();

            foreach (Dialogue dialogue in dialogues)
            {
                var orderedListNodes = new List <DialogueNode>();
                dialogue.GetOrderedNodes(ref orderedListNodes);
                foreach (DialogueNode dialogueNode in orderedListNodes)
                {
                    if (dialogueNode is DialogueNodeSentence)
                    {
                        DialogueNodeSentence sentence = (dialogueNode as DialogueNodeSentence);
                        AddUEManifestEntry(root, sentence.Sentence);
                    }
                    else if (dialogueNode is DialogueNodeReply)
                    {
                        DialogueNodeReply reply = (dialogueNode as DialogueNodeReply);
                        AddUEManifestEntry(root, reply.Reply);
                    }
                }
            }

            using (StreamWriter file = File.CreateText(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Formatting = Formatting.Indented;
                serializer.Serialize(file, root);
            }
        }
Esempio n. 6
0
        public void RemoveNode(DialogueNode nodeToRemove)
        {
            if (nodeToRemove == null)
            {
                return;
            }

            if (nodeToRemove is DialogueNodeReply)
            {
                //Remove depending nodes
                DialogueNode next = nodeToRemove.Next;
                while (next != null)
                {
                    DialogueNode nextNext = next.Next;
                    RemoveNode(next);
                    next = nextNext;
                }
            }
            else if (nodeToRemove is DialogueNodeChoice)
            {
                //Remove all replies, and let them remove their depending nodes
                DialogueNodeChoice nodechoice = nodeToRemove as DialogueNodeChoice;
                while (nodechoice.Replies.Count > 0)
                {
                    RemoveNode(nodechoice.Replies[0]);
                }
            }
            else if (nodeToRemove is DialogueNodeBranch)
            {
                DialogueNodeBranch nodeBranch = nodeToRemove as DialogueNodeBranch;

                //Remove depending nodes
                DialogueNode next = nodeBranch.Branch;
                while (next != null)
                {
                    DialogueNode nextNext = next.Next;
                    RemoveNode(next);
                    next = nextNext;
                }
            }

            foreach (DialogueNode node in ListNodes)
            {
                //Link next node to previous node
                if (node.Next == nodeToRemove)
                {
                    node.Next = nodeToRemove.Next;
                }

                //Remove from parent choice
                if (node is DialogueNodeChoice && nodeToRemove is DialogueNodeReply)
                {
                    DialogueNodeChoice nodeChoice = node as DialogueNodeChoice;
                    DialogueNodeReply  nodeReply  = nodeToRemove as DialogueNodeReply;
                    if (nodeChoice.Replies.Contains(nodeReply))
                    {
                        nodeChoice.Replies.Remove(nodeReply);
                    }
                }

                //Remove from parent branch
                if (node is DialogueNodeBranch)
                {
                    DialogueNodeBranch nodeBranch = node as DialogueNodeBranch;
                    if (nodeBranch.Branch == nodeToRemove)
                    {
                        nodeBranch.Branch = nodeToRemove.Next;
                    }
                }

                //Clean Goto references
                if (node is DialogueNodeGoto)
                {
                    DialogueNodeGoto nodeGoto = node as DialogueNodeGoto;
                    if (nodeGoto.Goto == nodeToRemove)
                    {
                        nodeGoto.Goto = null;
                    }
                }
            }

            ListNodes.Remove(nodeToRemove);
        }
Esempio n. 7
0
        public void ShowDialogueNodeProperties(DocumentDialogue document, TreeNode treeNode, DialogueNode dialogueNode)
        {
            //SetDoubleBuffered(LayoutPanel);

            WIN32.StopRedraw(this);
            //SuspendLayout();

            Clear();

            if (dialogueNode is DialogueNodeRoot)
            {
                DialogueNodeRoot castNode = dialogueNode as DialogueNodeRoot;

                FormPropertiesRoot properties = new FormPropertiesRoot();
                properties.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }
            else if (dialogueNode is DialogueNodeSentence)
            {
                DialogueNodeSentence castNode = dialogueNode as DialogueNodeSentence;

                FormPropertiesSentence properties = new FormPropertiesSentence();
                properties.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }
            else if (dialogueNode is DialogueNodeChoice)
            {
                DialogueNodeChoice castNode = dialogueNode as DialogueNodeChoice;

                FormPropertiesChoice properties = new FormPropertiesChoice();
                properties.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }
            else if (dialogueNode is DialogueNodeReply)
            {
                DialogueNodeReply castNode = dialogueNode as DialogueNodeReply;

                FormPropertiesReply properties = new FormPropertiesReply();
                properties.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }
            else if (dialogueNode is DialogueNodeGoto)
            {
                DialogueNodeGoto castNode = dialogueNode as DialogueNodeGoto;

                //FormPropertiesGoto properties = new FormPropertiesGoto();
                //properties.Init(document, treeNode, castNode);
                //layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }
            else if (dialogueNode is DialogueNodeBranch)
            {
                DialogueNodeBranch castNode = dialogueNode as DialogueNodeBranch;

                FormPropertiesBranch properties = new FormPropertiesBranch();
                properties.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(properties);

                FormPropertiesCommon propertiesCommon = new FormPropertiesCommon();
                propertiesCommon.Init(document, treeNode, castNode);
                layoutPanel.Controls.Add(propertiesCommon);
            }

            layoutPanel.VerticalScroll.Value = 0;

            //ResumeLayout();

            WIN32.ResumeRedraw(this);
            this.Refresh();
        }