NBT files (i.e .dat or .schematic files) can now have their data copied into the clipboard.

This commit is contained in:
Desktop 2023-07-28 18:06:13 +03:00
parent 15b1b2891f
commit 09f7112164

View file

@ -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)