forked from mirrors/NBTExplorer
Allow deleting chunks from region files.
This commit is contained in:
parent
5d456cf743
commit
27110539a8
3 changed files with 44 additions and 9 deletions
|
@ -229,14 +229,14 @@ namespace NBTExplorer.Controllers
|
||||||
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
||||||
if (item.Value.NamePatternTest(path))
|
if (item.Value.NamePatternTest(path))
|
||||||
node = item.Value.NodeCreate(path);
|
node = item.Value.NodeCreate(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node == null)
|
if (node == null)
|
||||||
node = NbtFileDataNode.TryCreateFrom(path);
|
node = NbtFileDataNode.TryCreateFrom(path);
|
||||||
if (node != null)
|
if (node != null)
|
||||||
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
||||||
else
|
else
|
||||||
failCount++;
|
failCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,19 @@ namespace NBTExplorer.Model
|
||||||
get { return _z; }
|
get { return _z; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RegionFileDataNode RegionParent
|
||||||
|
{
|
||||||
|
get { return Parent as RegionFileDataNode; }
|
||||||
|
}
|
||||||
|
|
||||||
protected override NodeCapabilities Capabilities
|
protected override NodeCapabilities Capabilities
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return NodeCapabilities.CreateTag
|
return NodeCapabilities.CreateTag
|
||||||
| NodeCapabilities.PasteInto
|
| NodeCapabilities.PasteInto
|
||||||
| NodeCapabilities.Search;
|
| NodeCapabilities.Search
|
||||||
|
| NodeCapabilities.Delete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +105,17 @@ namespace NBTExplorer.Model
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool DeleteNode ()
|
||||||
|
{
|
||||||
|
if (CanDeleteNode && _regionFile.HasChunk(_x, _z)) {
|
||||||
|
RegionParent.QueueDeleteChunk(_x, _z);
|
||||||
|
IsParentModified = true;
|
||||||
|
return Parent.Nodes.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsNamedContainer
|
public bool IsNamedContainer
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace NBTExplorer.Model
|
||||||
{
|
{
|
||||||
private string _path;
|
private string _path;
|
||||||
private RegionFile _region;
|
private RegionFile _region;
|
||||||
|
private List<RegionKey> _deleteQueue = new List<RegionKey>();
|
||||||
|
|
||||||
private static Regex _namePattern = new Regex(@"^r\.(-?\d+)\.(-?\d+)\.(mcr|mca)$");
|
private static Regex _namePattern = new Regex(@"^r\.(-?\d+)\.(-?\d+)\.(mcr|mca)$");
|
||||||
|
|
||||||
|
@ -100,6 +101,16 @@ namespace NBTExplorer.Model
|
||||||
Nodes.Clear();
|
Nodes.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SaveCore ()
|
||||||
|
{
|
||||||
|
foreach (RegionKey key in _deleteQueue) {
|
||||||
|
if (_region.HasChunk(key.X, key.Z))
|
||||||
|
_region.DeleteChunk(key.X, key.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
_deleteQueue.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public override bool RefreshNode ()
|
public override bool RefreshNode ()
|
||||||
{
|
{
|
||||||
Dictionary<string, object> expandSet = BuildExpandSet(this);
|
Dictionary<string, object> expandSet = BuildExpandSet(this);
|
||||||
|
@ -108,5 +119,12 @@ namespace NBTExplorer.Model
|
||||||
|
|
||||||
return expandSet != null;
|
return expandSet != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void QueueDeleteChunk (int rx, int rz)
|
||||||
|
{
|
||||||
|
RegionKey key = new RegionKey(rx, rz);
|
||||||
|
if (!_deleteQueue.Contains(key))
|
||||||
|
_deleteQueue.Add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue