Example #1
0
        private void OnMouseDown()
        {
            CachedMusicTreeNode hitNode = null;

            foreach (var node in tree.AllNodes)
            {
                var bounds = cachedPositioning.GetBoundsFor(node);
                if (bounds.Contains(Event.current.mousePosition))
                {
                    hitNode = node;
                    break;
                }
            }
            if (Event.current.button == 0)
            {
                if (hitNode != null)
                {
                    selection = hitNode;
                    MusicTreeEditorManager.Instance.OnNodeSelected(hitNode);
                }
            }
            else
            {
                if (hitNode != null)
                {
                    OpenNodeContextMenu(hitNode);
                }
            }
            Event.current.Use();
        }
Example #2
0
        private Texture IconTextFor(CachedMusicTreeNode node)
        {
            Texture tex = null;

            if (node.Asset is CueMusicTreeNode)
            {
                //color = Color.red;
                tex = CueIcon;
            }
            else if (node.Asset is SelectorMusicTreeNode)
            {
                //color = Color.green;
                tex = SelectorIcon;
            }
            else if (node.Asset is SequenceMusicTreeNode)
            {
                //color = Color.cyan;
                tex = SequenceIcon;
            }
            else if (node.Asset is ConditionMusicTreeNode)
            {
                tex = ConditionIcon;
            }

            return(tex);
        }
        public void Visit(SequenceMusicTreeNode n, CachedMusicTreeNode nContainer)
        {
            CachedMusicTreeNode first = nContainer.isRunning ? nContainer.ActiveChild : nContainer.LeftmostChild;

            foreach (var ch in nContainer.ChildrenStartingAt(first))
            {
                ch.Accept(this);

                switch (ch.ExecutionState)
                {
                case CachedMusicTreeNode.State.Running:
                    nContainer.ExecutionState = CachedMusicTreeNode.State.Running;
                    nContainer.ActiveChild    = ch;
                    return;

                case CachedMusicTreeNode.State.Idle:
                    throw new Exception("Child should not have set itself to idle");

                case CachedMusicTreeNode.State.Failed:
                    nContainer.ExecutionState = CachedMusicTreeNode.State.Failed;
                    return;

                case CachedMusicTreeNode.State.Complete:
                    continue;

                default:
                    throw new NotImplementedException();
                }
            }

            nContainer.ExecutionState = CachedMusicTreeNode.State.Complete;
            nContainer.ActiveChild    = nContainer.RightmostChild;
        }
Example #4
0
 private Texture BGTexFor(CachedMusicTreeNode node)
 {
     if (node.Asset == MusicTreeEditorManager.Instance.PlayedNode)
     {
         return(MusicTreeEditorWindow.configs.NodePlayed);
     }
     if (selection == node)
     {
         return(MusicTreeEditorWindow.configs.NodeSelected);
     }
     else if (dropTarget == node)
     {
         if (isDropValid)
         {
             return(MusicTreeEditorWindow.configs.NodeDropTarget);
         }
         else
         {
             return(MusicTreeEditorWindow.configs.NodeDropTargetUnable);
         }
     }
     else
     {
         return(MusicTreeEditorWindow.configs.NodeUnselected);
     }
 }
 private void OnCueSelected(CueMusicTreeNode cue, CachedMusicTreeNode owner)
 {
     if (SelectedCueChanged != null)
     {
         SelectedCueChanged(cue, owner);
     }
 }
Example #6
0
        private void DrawLineToParent(CachedMusicTreeNode node, MusicTreeNode musicTreeNode)
        {
            var parentBounds = cachedPositioning.GetBoundsFor(node.Parent);
            var myBounds     = cachedPositioning.GetBoundsFor(node);

            Handles.DrawLine(parentBounds.center, myBounds.center);
        }
Example #7
0
 public NoteSheetEditor(CueMusicTreeNode cue, CachedMusicTreeNode cueOwner)
 {
     this.cue      = cue;
     this.cueOwner = cueOwner;
     trackDrawers  = new List <NoteTrackEditor>();
     MusicTreeEditorManager.Instance.NoteTrackDefinitionsChanged += Instance_NoteTrackDefinitionsChanged;
     UpdateTrackDrawers();
 }
Example #8
0
 private void OnMouseUp()
 {
     Event.current.Use();
     if (dropTarget != null && selection != null && isDropValid)
     {
         MoveNode(selection, dropTarget, dropIndex);
     }
     dropTarget = null;
 }
Example #9
0
        private void DrawNode(Rect bounds, CachedMusicTreeNode node)
        {
            GUI.DrawTexture(bounds, BGTexFor(node));

            Texture tex = IconTextFor(node);

            if (tex != null)
            {
                GUI.DrawTexture(bounds.Resized(Vector2.one * 1), tex);
            }
        }
Example #10
0
 private void UpdateDrawer(CueMusicTreeNode cue, CachedMusicTreeNode owner)
 {
     if (drawer != null)
     {
         drawer.DataUpdated -= Drawer_DataUpdated;
         drawer.OnReplaced();
     }
     drawer              = new NoteSheetEditor(cue, owner);;
     drawer.DataUpdated += Drawer_DataUpdated;
     Repaint();
 }
 public void Visit(CueMusicTreeNode n, CachedMusicTreeNode nContainer)
 {
     if (nContainer.ExecutionState == CachedMusicTreeNode.State.Running)
     {
         //If was already playing, it is assumed to be finished
         nContainer.ExecutionState = CachedMusicTreeNode.State.Complete;
         this.RunningLeaf          = null;
     }
     else
     {
         nContainer.ExecutionState = CachedMusicTreeNode.State.Running;
         this.RunningLeaf          = n;
     }
 }
Example #12
0
        private void OpenNodeContextMenu(CachedMusicTreeNode node)
        {
            GenericMenu menu = new GenericMenu();

            if (node.AllowsMoreChildren)
            {
                menu.AddItem(new GUIContent("Add Cue Node"), false, () => AddChild <CueMusicTreeNode>(node));
                menu.AddItem(new GUIContent("Add Selector Node"), false, () => AddChild <SelectorMusicTreeNode>(node));
                menu.AddItem(new GUIContent("Add Sequence Node"), false, () => AddChild <SequenceMusicTreeNode>(node));
                menu.AddItem(new GUIContent("Add Condition Node"), false, () => AddChild <ConditionMusicTreeNode>(node));
            }
            menu.AddItem(new GUIContent("Delete"), false, () => TryRemoveNode(node));
            menu.ShowAsContext();
        }
        public void Visit(ConditionMusicTreeNode n, CachedMusicTreeNode nContainer)
        {
            var child = nContainer.LeftmostChild;

            if (nContainer.isRunning || Environment.Evaluate(n.condition))
            {
                child.Accept(this);
                nContainer.ExecutionState = child.ExecutionState;
                nContainer.ActiveChild    = child;
            }
            else
            {
                nContainer.ExecutionState = CachedMusicTreeNode.State.Failed;
            }
        }
Example #14
0
        public void OnNodeSelected(CachedMusicTreeNode n)
        {
            SelectedNode = n;
            if (n != null)
            {
                Selection.activeObject = n.Asset;
            }
            if (SelectedNodeChanged != null)
            {
                SelectedNodeChanged(SelectedNode);
            }

            var cue = n.Asset as CueMusicTreeNode;

            if (cue != null)
            {
                OnCueSelected(cue, n);
            }
        }
Example #15
0
        private void OnMouseDrag()
        {
            dropTarget = null;
            if (selection == null)
            {
                return;
            }
            foreach (var node in tree.AllNodes)
            {
                if (node == selection)
                {
                    continue;
                }

                var bounds = cachedPositioning.GetBoundsFor(node);
                if (bounds.Contains(Event.current.mousePosition))
                {
                    dropTarget  = node;
                    dropIndex   = dropTarget.ChildCount;
                    isDropValid = node.CanBeParentOf(selection);
                    break;
                }
                var childrenBounds = cachedPositioning.GetDropBoundsFor(node);
                for (int i = 0; i < childrenBounds.Length; i++)
                {
                    if (childrenBounds[i].Contains(Event.current.mousePosition))
                    {
                        dropTarget  = node;
                        dropIndex   = i;
                        isDropValid = node.CanBeParentOf(selection);
                        break;
                    }
                }
            }
            Event.current.Use();
        }
Example #16
0
 public abstract void Accept(MusicNodeVisitor vis, CachedMusicTreeNode container);
Example #17
0
 private void Manager_SelectedCueChanged(CueMusicTreeNode node, CachedMusicTreeNode owner)
 {
     UpdateDrawer(node, owner);
 }
Example #18
0
 private void MoveNode(CachedMusicTreeNode selection, CachedMusicTreeNode dropTarget, int dropIndex)
 {
     selection.Asset.ChangeParentTo(dropTarget.Asset, dropIndex);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }
Example #19
0
 public override void Accept(MusicNodeVisitor vis, CachedMusicTreeNode container)
 {
     vis.Visit(this, container);
 }
Example #20
0
 private void AddChild <T>(CachedMusicTreeNode node) where T : MusicTreeNode
 {
     node.Tree.Asset.CreateChildFor <T>(node.Asset);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }
Example #21
0
 private void TryRemoveNode(CachedMusicTreeNode node)
 {
     node.Tree.Asset.DeleteNodeAndAllChildren(node.Asset);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }