diff --git a/NBTModel/Data/Nodes/NbtFileDataNode.cs b/NBTModel/Data/Nodes/NbtFileDataNode.cs index 866d812..4c7559d 100644 --- a/NBTModel/Data/Nodes/NbtFileDataNode.cs +++ b/NBTModel/Data/Nodes/NbtFileDataNode.cs @@ -59,6 +59,7 @@ namespace NBTExplorer.Model get { return NodeCapabilities.CreateTag + | NodeCapabilities.Copy | NodeCapabilities.PasteInto | NodeCapabilities.Search | NodeCapabilities.Refresh @@ -71,11 +72,17 @@ namespace NBTExplorer.Model get { return Path.GetFileName(_path); } } + public override string NodePathName { get { return Path.GetFileName(_path); } } + private string NodeNameWithoutExtension + { + get { return Path.GetFileNameWithoutExtension(_path); } + } + public override string NodeDisplay { get @@ -101,6 +108,27 @@ namespace NBTExplorer.Model get { return true; } } + private TagNodeCompound GetTagNode () + { + TagNode tag; + + if (_tree == null) { + try { + Expand(); + tag = _tree.Root.Copy(); + Release(); + } + catch { + Release(); + return null; + } + } + else { + tag = _tree.Root.Copy(); + } + return (TagNodeCompound) tag; + } + protected override void ExpandCore () { if (_tree == null) { @@ -203,6 +231,20 @@ namespace NBTExplorer.Model return false; } + public override bool CopyNode() + { + if (CanCopyNode) + { + // Need to create new compound tag, add all children of the nbt node into it, + // copy it and delete it. + + NbtClipboardController.CopyToClipboard(new NbtClipboardData(this.NodeNameWithoutExtension, this.GetTagNode())); + return true; + } + + return false; + } + public override bool PasteNode () { if (!CanPasteIntoNode)