mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-25 00:36:26 +00:00
- display whole file path for the root element (if applicable)
This commit is contained in:
parent
15b1b2891f
commit
d74e34e2da
5 changed files with 57 additions and 59 deletions
45
NBTModel/Data/Nodes/AbstractFileDataNode.cs
Normal file
45
NBTModel/Data/Nodes/AbstractFileDataNode.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Common functionality for a few nodes that represent files.
|
||||
/// </summary>
|
||||
public class AbstractFileDataNode : DataNode
|
||||
{
|
||||
protected string _path;
|
||||
|
||||
protected AbstractFileDataNode(string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not only the name of the node but also (in some cases, but not all) the value (or part of the value) that is displayed to the user.
|
||||
/// Return the full path if this node is the root, otherwise return only the file/folder name
|
||||
/// </summary>
|
||||
public override string NodeName
|
||||
{
|
||||
get => Parent == null ? _path : Path.GetFileName(_path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Just return NodeName, since that is where the display name is build.
|
||||
/// Side note: I believe NodeName and NodeDisplay should be separated, this would then allow to replace NodePathName with NodeName, but that
|
||||
/// would require changing a lot of unfamiliar (to me) code.
|
||||
/// </summary>
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get => NodeName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual name of the node in a path. Return only the name of the file or folder, not the whole path.
|
||||
/// </summary>
|
||||
public override string NodePathName
|
||||
{
|
||||
get => Path.GetFileName(_path);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,17 +5,14 @@ using NBTModel.Interop;
|
|||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class CubicRegionDataNode : DataNode
|
||||
{
|
||||
private string _path;
|
||||
public class CubicRegionDataNode : AbstractFileDataNode
|
||||
{
|
||||
private CubicRegionFile _region;
|
||||
|
||||
private static Regex _namePattern = new Regex(@"^r2(\.-?\d+){3}\.(mcr|mca)$");
|
||||
|
||||
private CubicRegionDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
private CubicRegionDataNode (string path) : base(path)
|
||||
{}
|
||||
|
||||
public static CubicRegionDataNode TryCreateFrom (string path)
|
||||
{
|
||||
|
@ -47,16 +44,6 @@ namespace NBTExplorer.Model
|
|||
get { return true; }
|
||||
}
|
||||
|
||||
public override string NodePathName
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -4,14 +4,10 @@ using System;
|
|||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class DirectoryDataNode : DataNode
|
||||
public class DirectoryDataNode : AbstractFileDataNode
|
||||
{
|
||||
private string _path;
|
||||
|
||||
public DirectoryDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
public DirectoryDataNode (string path) : base(path)
|
||||
{}
|
||||
|
||||
protected override NodeCapabilities Capabilities
|
||||
{
|
||||
|
@ -40,11 +36,6 @@ namespace NBTExplorer.Model
|
|||
}
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override bool HasUnexpandedChildren
|
||||
{
|
||||
get { return !IsExpanded; }
|
||||
|
|
|
@ -8,19 +8,17 @@ using NBTModel.Interop;
|
|||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class NbtFileDataNode : DataNode, IMetaTagContainer
|
||||
public class NbtFileDataNode : AbstractFileDataNode, IMetaTagContainer
|
||||
{
|
||||
private NbtTree _tree;
|
||||
private string _path;
|
||||
private CompressionType _compressionType;
|
||||
|
||||
private CompoundTagContainer _container;
|
||||
|
||||
private static Regex _namePattern = new Regex(@"\.(dat|nbt|schematic|dat_mcr|dat_old|bpt|rc)$");
|
||||
|
||||
private NbtFileDataNode (string path, CompressionType compressionType)
|
||||
private NbtFileDataNode (string path, CompressionType compressionType) : base(path)
|
||||
{
|
||||
_path = path;
|
||||
_compressionType = compressionType;
|
||||
_container = new CompoundTagContainer(new TagNodeCompound());
|
||||
}
|
||||
|
@ -66,16 +64,6 @@ namespace NBTExplorer.Model
|
|||
}
|
||||
}
|
||||
|
||||
public override string NodeName
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override string NodePathName
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get
|
||||
|
|
|
@ -7,18 +7,15 @@ using System;
|
|||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
public class RegionFileDataNode : DataNode
|
||||
public class RegionFileDataNode : AbstractFileDataNode
|
||||
{
|
||||
private string _path;
|
||||
private RegionFile _region;
|
||||
private List<RegionKey> _deleteQueue = new List<RegionKey>();
|
||||
|
||||
private static Regex _namePattern = new Regex(@"^r\.(-?\d+)\.(-?\d+)\.(mcr|mca)$");
|
||||
|
||||
private RegionFileDataNode (string path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
private RegionFileDataNode (string path) : base(path)
|
||||
{}
|
||||
|
||||
public static RegionFileDataNode TryCreateFrom (string path)
|
||||
{
|
||||
|
@ -64,16 +61,6 @@ namespace NBTExplorer.Model
|
|||
get { return true; }
|
||||
}
|
||||
|
||||
public override string NodePathName
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
public override string NodeDisplay
|
||||
{
|
||||
get { return Path.GetFileName(_path); }
|
||||
}
|
||||
|
||||
protected override void ExpandCore ()
|
||||
{
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue