Example #1
0
        public void ClearBranchListAfterParentRemoteBranch()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            DialogTreeBranch start = tree.GetStart();

            Assert.AreEqual(1, tree.Branches.Count);

            DialogTreeBranch unusedBranch    = tree.CreateNewBranch();
            bool             branchesChanged = false;

            ScriptPanelVM script = new ScriptPanelVM(project, tree);

            script.OnVisibleBranchChange += (t) => branchesChanged = true;
            DialogTreeBranchIdentifier firstChild  = script.AddNewBranch(start, true);
            DialogTreeBranchIdentifier secondChild = script.AddNewBranch(firstChild, true);

            // ensure all 3 branches are currently visible
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == start), $"Should be able to see '{nameof(start)}'");
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == firstChild), $"Should be able to see '{nameof(firstChild)}'");
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == secondChild), $"Should be able to see '{nameof(firstChild)}'");
            Assert.IsFalse(script.Branches.Any(b => b.DialogBranch == unusedBranch), $"Shouldn't be able to see '{nameof(unusedBranch)}'");
            Assert.IsTrue(branchesChanged, $"Branches changed since creation");

            branchesChanged = false;
            script.ClearBranchListAfterParent(unusedBranch);

            // ensure same branches are still currently visible
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == start), $"Should be able to see '{nameof(start)}'");
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == firstChild), $"Should be able to see '{nameof(firstChild)}'");
            Assert.IsTrue(script.Branches.Any(b => b.DialogBranch == secondChild), $"Should be able to see '{nameof(firstChild)}'");
            Assert.IsFalse(script.Branches.Any(b => b.DialogBranch == unusedBranch), $"Shouldn't be able to see '{nameof(unusedBranch)}'");
            Assert.IsFalse(branchesChanged, $"No branches changed");
        }
Example #2
0
        /// <summary>
        /// Shows the script editor panel for the given <see cref="tree"/> identifier
        /// </summary>
        /// <param name="tree">Dialog Tree to show</param>
        public void ShowScriptEditorPanel(DialogTreeIdentifier tree)
        {
            DialogTree dialogTree = m_project[tree];

            if (dialogTree == null)
            {
                return;
            }

            ScriptPanelVM window = Windows.Select(w => w as ScriptPanelVM)
                                   .Where(s => s != null)
                                   .FirstOrDefault(s => s.Tree == tree);

            if (window == null)
            {
                window = new ScriptPanelVM(m_project, dialogTree);
                Windows.Add(window);
            }

            window.IsSelected = true;
            if (m_dockingManager != null)
            {
                m_dockingManager.ActiveContent = window;
            }
        }
Example #3
0
        public void AddNewBranchCommand()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            bool          branchesChanged = false;
            ScriptPanelVM script          = new ScriptPanelVM(project, tree);

            script.OnVisibleBranchChange += (t) => branchesChanged = true;
            Assert.AreEqual(1, tree.Branches.Count);

            script.NewBranchCommand.Execute(null);
            Assert.AreEqual(2, tree.Branches.Count);
            Assert.IsTrue(branchesChanged, $"Command should have triggered change event");
        }
Example #4
0
        public void NewBranchWhenEmpty()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            //ensure there are no branches
            if (tree.Branches.Count > 0)
            {
                for (int i = tree.Branches.Count - 1; i >= 0; i--)
                {
                    tree.RemoveBranch(tree.Branches[i]);
                }
            }
            Assert.AreEqual(0, tree.Branches.Count);

            ScriptPanelVM panel = new ScriptPanelVM(project, tree);

            Assert.AreEqual(0, panel.Branches.Count, "The tree has no branches so the panel shouldn't have any branches");

            panel.NewBranchCommand.Execute(null);
            Assert.AreEqual(1, panel.Branches.Count);
        }