예제 #1
0
        public void Init(DocumentDialogue inDocument, TreeNode inTreeNode, DialogueNode inDialogueNode)
        {
            document     = inDocument;
            treeNode     = inTreeNode;
            dialogueNode = inDialogueNode as DialogueNodeBranch;

            textBoxWorkstring.Text = dialogueNode.Workstring;

            ready = true;
        }
예제 #2
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);
        }
예제 #3
0
        public DialogueNodeBranch(DialogueNodeBranch other)
            : base(other)
        {
            Workstring = other.Workstring;
            Branch     = null;
            BranchID   = ID_NULL;

            if (other.Branch != null)
            {
                Branch = other.Branch.Clone() as DialogueNode;

                //Clone all child nodes
                DialogueNode currentNode  = Branch;
                DialogueNode currentOther = other.Branch;
                while (currentOther != null && currentOther.Next != null)
                {
                    currentNode.Next = currentOther.Next.Clone() as DialogueNode;
                    currentNode      = currentNode.Next;
                    currentOther     = currentOther.Next;
                }
            }
        }
예제 #4
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);
        }
예제 #5
0
        public void PreSave(Project project)
        {
            //Prepare File
            VersionProject = EditorCore.VersionProject;
            VersionEditor  = EditorVersion.GetVersion();

            if (Package == null)
            {
                EditorCore.LogError("Saving a Dialogue without Package (forcing default) : " + GetName(), this);
                Package = project.GetDefaultPackage();
            }

            if (Package != null)
            {
                PackageName = Package.Name;
            }

            //Sanitize texts
            //dialogue.Comment = EditorCore.SanitizeText(dialogue.Comment);

            //Prepare nodes links
            RootNodeID = (RootNode != null) ? RootNode.ID : DialogueNode.ID_NULL;

            foreach (DialogueNode node in ListNodes)
            {
                node.NextID = (node.Next != null) ? node.Next.ID : DialogueNode.ID_NULL;

                if (node is DialogueNodeSentence)
                {
                    //Generate ID
                    DialogueNodeSentence nodeSentence = node as DialogueNodeSentence;
                    nodeSentence.VoicingID = EditorHelper.GetPrettyNodeVoicingID(this, nodeSentence);

                    //Sanitize texts
                    nodeSentence.Sentence = EditorHelper.SanitizeText(nodeSentence.Sentence);
                    //nodeSentence.Comment = EditorHelper.SanitizeText(nodeSentence.Comment);
                }
                else if (node is DialogueNodeChoice)
                {
                    DialogueNodeChoice nodeChoice = node as DialogueNodeChoice;

                    //Sanitize texts
                    nodeChoice.Choice = EditorHelper.SanitizeText(nodeChoice.Choice);

                    nodeChoice.RepliesIDs.Clear();
                    foreach (DialogueNodeReply nodeReply in nodeChoice.Replies)
                    {
                        //Sanitize texts
                        nodeReply.Reply = EditorHelper.SanitizeText(nodeReply.Reply);

                        nodeChoice.RepliesIDs.Add(nodeReply.ID);
                    }
                }
                else if (node is DialogueNodeGoto)
                {
                    DialogueNodeGoto nodeGoto = node as DialogueNodeGoto;
                    nodeGoto.GotoID = (nodeGoto.Goto != null) ? nodeGoto.Goto.ID : DialogueNode.ID_NULL;
                }
                else if (node is DialogueNodeBranch)
                {
                    DialogueNodeBranch nodeBranch = node as DialogueNodeBranch;
                    nodeBranch.BranchID = (nodeBranch.Branch != null) ? nodeBranch.Branch.ID : DialogueNode.ID_NULL;
                }
            }
        }
예제 #6
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();
        }