Exemple #1
0
    protected override void RenameEnded(RenameEndedArgs args)
    {
        base.RenameEnded(args);

        if (args.acceptedRename)
        {
            PackTreeItem itm = FindItem(args.itemID, rootItem) as PackTreeItem;
            itm.nodeEntry.name = args.newName;
            itm.displayName    = args.newName;
        }
    }
Exemple #2
0
    protected override bool CanRename(TreeViewItem item)
    {
        PackTreeItem packItem = item as PackTreeItem;

        if (packItem.nodeEntry.obj != null)
        {
            return(false);
        }

        return(true);
    }
Exemple #3
0
    void CreateFolderInsideItem(object item)
    {
        PackTreeItem packItem = item as PackTreeItem;

        //TODO : check if a New Folder already exist under that parent to don't have 2 folder named the same
        PackSettings.Node n = new PackSettings.Node()
        {
            name = "New Folder", parent = packItem.nodeEntry
        };

        ArrayUtility.Add(ref packItem.nodeEntry.children, n);

        Reload();
    }
Exemple #4
0
    TreeViewItem RecursiveAddItem(PackSettings.Node node, int level)
    {
        //hashcode is not unique but that should be enough her, hopefully. Need to have consistent ID across reload
        //as otherwise selected thing get lost.
        TreeViewItem ret = new PackTreeItem()
        {
            id = node.id, displayName = node.name, nodeEntry = node, icon = s_Icons[node.obj == null ? 0 : 1]
        };

        currentTopID += 1;

        for (int i = 0; i < node.children.Length; ++i)
        {
            ret.AddChild(RecursiveAddItem(node.children[i], level + 1));
        }

        return(ret);
    }
Exemple #5
0
    protected override void KeyEvent()
    {
        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete)
        {
            Undo.RecordObject(m_EditedPack, "Removing Files from pack");
            foreach (int index in GetSelection())
            {
                PackTreeItem itm = FindItem(index, rootItem) as PackTreeItem;

                if (itm != null)
                {
                    ArrayUtility.Remove(ref itm.nodeEntry.parent.children, itm.nodeEntry);
                    itm.parent.children.Remove(itm);
                }
            }

            Reload();
        }

        base.KeyEvent();
    }
Exemple #6
0
    protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
    {
        if (args.dragAndDropPosition == DragAndDropPosition.OutsideItems)
        {
            var data = DragAndDrop.GetGenericData(ROW_DRAG_OP);

            if (data == null)
            {//we're dropping from outside, adding asset
                if (args.performDrop)
                {
                    AddDraggedAssetToPack(m_EditedPack.root);
                }

                return(DragAndDropVisualMode.Link);
            }
            else
            {// dropping Tree view item, just move them to root
                if (args.performDrop)
                {
                    MoveDraggedObject(m_EditedPack.root);
                }

                return(DragAndDropVisualMode.Move);
            }
        }

        if (args.dragAndDropPosition == DragAndDropPosition.UponItem || args.dragAndDropPosition == DragAndDropPosition.BetweenItems)
        {
            PackTreeItem itm = args.parentItem as PackTreeItem;

            var data = DragAndDrop.GetGenericData(ROW_DRAG_OP);

            if (data == null)
            {
                //we're dropping from outside, adding asset

                if (args.performDrop)
                {
                    AddDraggedAssetToPack(itm.nodeEntry);
                }

                return(DragAndDropVisualMode.Link);
            }
            else
            {
                //you can't drag'n drop on something your dragging...
                if (m_DraggedItem.Contains(itm) || itm == null)
                {
                    return(DragAndDropVisualMode.None);
                }

                if (itm.nodeEntry.obj != null)
                {
                    //this is a file, you can't drag stuff on a file
                    return(DragAndDropVisualMode.None);
                }
                else
                {
                    if (args.performDrop)
                    {
                        //ok move node to that new parent


                        MoveDraggedObject(itm.nodeEntry);
                        IsDragging = false;
                    }

                    return(DragAndDropVisualMode.Move);
                }
            }
        }

        return(DragAndDropVisualMode.None);;
    }