Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 5
0
 private void OnCueSelected(CueMusicTreeNode cue, CachedMusicTreeNode owner)
 {
     if (SelectedCueChanged != null)
     {
         SelectedCueChanged(cue, owner);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
 public NoteSheetEditor(CueMusicTreeNode cue, CachedMusicTreeNode cueOwner)
 {
     this.cue      = cue;
     this.cueOwner = cueOwner;
     trackDrawers  = new List <NoteTrackEditor>();
     MusicTreeEditorManager.Instance.NoteTrackDefinitionsChanged += Instance_NoteTrackDefinitionsChanged;
     UpdateTrackDrawers();
 }
Ejemplo n.º 8
0
 private void OnMouseUp()
 {
     Event.current.Use();
     if (dropTarget != null && selection != null && isDropValid)
     {
         MoveNode(selection, dropTarget, dropIndex);
     }
     dropTarget = null;
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 11
0
 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;
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 13
0
        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;
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 16
0
 public abstract void Accept(MusicNodeVisitor vis, CachedMusicTreeNode container);
Ejemplo n.º 17
0
 private void Manager_SelectedCueChanged(CueMusicTreeNode node, CachedMusicTreeNode owner)
 {
     UpdateDrawer(node, owner);
 }
Ejemplo n.º 18
0
 private void MoveNode(CachedMusicTreeNode selection, CachedMusicTreeNode dropTarget, int dropIndex)
 {
     selection.Asset.ChangeParentTo(dropTarget.Asset, dropIndex);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }
Ejemplo n.º 19
0
 public override void Accept(MusicNodeVisitor vis, CachedMusicTreeNode container)
 {
     vis.Visit(this, container);
 }
Ejemplo n.º 20
0
 private void AddChild <T>(CachedMusicTreeNode node) where T : MusicTreeNode
 {
     node.Tree.Asset.CreateChildFor <T>(node.Asset);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }
Ejemplo n.º 21
0
 private void TryRemoveNode(CachedMusicTreeNode node)
 {
     node.Tree.Asset.DeleteNodeAndAllChildren(node.Asset);
     MusicTreeEditorManager.Instance.OnChangesToTreeHierarchy();
 }