mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
NBT files (i.e .dat or .schematic files) can now have their data copied into the clipboard.
This commit is contained in:
parent
15b1b2891f
commit
09f7112164
1 changed files with 42 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue