Most of the 2.0 work.

This commit is contained in:
Justin Aquadro 2012-08-31 01:29:32 -04:00
parent 1c63f48dea
commit 2250139349
27 changed files with 3961 additions and 45 deletions

View file

@ -1,20 +1,23 @@
using Substrate.Core;
using Substrate.Nbt;
using System.Collections.Generic;
using System;
using System.Windows.Forms;
namespace NBTExplorer
{
public class DataNode
public class DataNodeOld
{
public DataNode ()
public DataNodeOld ()
{
}
public DataNode (DataNode parent)
public DataNodeOld (DataNodeOld parent)
{
Parent = parent;
}
public DataNode Parent { get; set; }
public DataNodeOld Parent { get; set; }
private bool _modified;
public bool Modified
@ -32,13 +35,13 @@ namespace NBTExplorer
public bool Expanded { get; set; }
}
public class NbtDataNode : DataNode
public class NbtDataNode : DataNodeOld
{
public NbtDataNode ()
{
}
public NbtDataNode (DataNode parent)
public NbtDataNode (DataNodeOld parent)
: base(parent)
{
}
@ -53,7 +56,7 @@ namespace NBTExplorer
{
}
public RegionChunkData (DataNode parent, RegionFile file, int x, int z)
public RegionChunkData (DataNodeOld parent, RegionFile file, int x, int z)
: base(parent)
{
Region = file;
@ -66,14 +69,14 @@ namespace NBTExplorer
public int Z { get; private set; }
}
public class RegionData : DataNode
public class RegionData : DataNodeOld
{
public RegionData (string path)
: this(null, path)
{
}
public RegionData (DataNode parent, string path)
public RegionData (DataNodeOld parent, string path)
: base(parent)
{
Path = path;
@ -89,7 +92,7 @@ namespace NBTExplorer
{
}
public NbtFileData (DataNode parent, string path, CompressionType cztype)
public NbtFileData (DataNodeOld parent, string path, CompressionType cztype)
: base(parent)
{
Path = path;
@ -100,14 +103,14 @@ namespace NBTExplorer
public CompressionType CompressionType { get; private set; }
}
public class DirectoryData : DataNode
public class DirectoryData : DataNodeOld
{
public DirectoryData (string path)
: this(null, path)
{
}
public DirectoryData (DataNode parent, string path)
public DirectoryData (DataNodeOld parent, string path)
: base(parent)
{
Path = path;

View file

@ -264,8 +264,8 @@ namespace NBTExplorer
private void LinkDataNodeParent (TreeNode node, TreeNode parent)
{
if (node != null && parent != null && node.Tag != null && parent.Tag != null) {
DataNode nodeDn = node.Tag as DataNode;
DataNode parentDn = parent.Tag as DataNode;
DataNodeOld nodeDn = node.Tag as DataNodeOld;
DataNodeOld parentDn = parent.Tag as DataNodeOld;
if (nodeDn != null && parentDn != null) {
nodeDn.Parent = parentDn;
@ -332,7 +332,7 @@ namespace NBTExplorer
public void UnloadLazyDataNode (TreeNode node)
{
DataNode data = node.Tag as DataNode;
DataNodeOld data = node.Tag as DataNodeOld;
if (data == null || data.Modified)
return;
@ -347,8 +347,8 @@ namespace NBTExplorer
if (node.Tag == null)
return;
if (node.Tag is DataNode) {
if ((node.Tag as DataNode).Expanded)
if (node.Tag is DataNodeOld) {
if ((node.Tag as DataNodeOld).Expanded)
return;
}
@ -371,7 +371,7 @@ namespace NBTExplorer
if (node.Tag == null)
return;
if (node.Tag is DataNode) {
if (node.Tag is DataNodeOld) {
UnloadLazyDataNode(node);
}
}
@ -664,7 +664,7 @@ namespace NBTExplorer
private void SaveNode (TreeNode node)
{
foreach (TreeNode sub in node.Nodes) {
if (sub.Tag != null && sub.Tag is DataNode) {
if (sub.Tag != null && sub.Tag is DataNodeOld) {
SaveNode(sub);
}
}
@ -728,7 +728,7 @@ namespace NBTExplorer
return null;
TreeNode baseNode = node;
while (baseNode.Tag == null || !(baseNode.Tag is DataNode)) {
while (baseNode.Tag == null || !(baseNode.Tag is DataNodeOld)) {
baseNode = baseNode.Parent;
}
@ -745,7 +745,7 @@ namespace NBTExplorer
if (baseNode == null || baseNode == node)
return;
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
DeleteNodeNbtTag(node);
@ -912,7 +912,7 @@ namespace NBTExplorer
if (form.ShowDialog() == DialogResult.OK) {
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
tag.ToTagString().Data = form.StringValue;
@ -924,7 +924,7 @@ namespace NBTExplorer
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
Array.Copy(form.Data, tag.ToTagByteArray().Data, tag.ToTagByteArray().Length);
@ -942,7 +942,7 @@ namespace NBTExplorer
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
for (int i = 0; i < iatag.Length; i++) {
@ -955,7 +955,7 @@ namespace NBTExplorer
if (form.ShowDialog() == DialogResult.OK) {
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
node.Text = GetNodeText(node);
@ -997,7 +997,7 @@ namespace NBTExplorer
if (form.ShowDialog() == DialogResult.OK) {
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
SetTagNodeName(node, form.TagName);
@ -1033,7 +1033,7 @@ namespace NBTExplorer
if (tag is TagNodeCompound) {
TagNodeCompound ctag = tag as TagNodeCompound;
CreateNode form = new CreateNode(type);
CreateNodeForm form = new CreateNodeForm(type);
foreach (string key in ctag.Keys) {
form.InvalidNames.Add(key);
}
@ -1052,7 +1052,7 @@ namespace NBTExplorer
else if (tag is TagNodeList) {
TagNode newNode;
if (TagIsSizedType(type)) {
CreateNode form = new CreateNode(type, false);
CreateNodeForm form = new CreateNodeForm(type, false);
if (form.ShowDialog() != DialogResult.OK)
return;
@ -1079,7 +1079,7 @@ namespace NBTExplorer
TreeNode baseNode = BaseNode(node);
if (baseNode != null) {
(baseNode.Tag as DataNode).Modified = true;
(baseNode.Tag as DataNodeOld).Modified = true;
}
}
@ -1219,8 +1219,8 @@ namespace NBTExplorer
if (!_search.MoveNext()) {
_nodeTree.SelectedNode = _rootSearchNode;
if (_rootSearchNode != null && _rootSearchNode.Tag is DataNode) {
if (_rootSearchNode.IsExpanded && !(_rootSearchNode.Tag as DataNode).Expanded) {
if (_rootSearchNode != null && _rootSearchNode.Tag is DataNodeOld) {
if (_rootSearchNode.IsExpanded && !(_rootSearchNode.Tag as DataNodeOld).Expanded) {
_rootSearchNode.Collapse();
}
}
@ -1241,8 +1241,8 @@ namespace NBTExplorer
bool expand = false;
if (node.Tag is DataNode) {
DataNode data = node.Tag as DataNode;
if (node.Tag is DataNodeOld) {
DataNodeOld data = node.Tag as DataNodeOld;
if (!data.Expanded) {
ExpandNode(node);
expand = true;
@ -1277,7 +1277,7 @@ namespace NBTExplorer
}
if (expand) {
DataNode data = node.Tag as DataNode;
DataNodeOld data = node.Tag as DataNodeOld;
if (!data.Modified)
CollapseNode(node);
}

30
IconRegistry.cs Normal file
View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
namespace NBTExplorer
{
public class IconRegistry
{
private static Dictionary<Type, int> _iconRegistry;
public IconRegistry ()
{
_iconRegistry = new Dictionary<Type, int>();
}
public int DefaultIcon { get; set; }
public int Lookup (Type type)
{
if (_iconRegistry.ContainsKey(type))
return _iconRegistry[type];
else
return DefaultIcon;
}
public void Register (Type type, int iconIndex)
{
_iconRegistry[type] = iconIndex;
}
}
}

698
MainForm.Designer.cs generated Normal file
View file

@ -0,0 +1,698 @@
namespace NBTExplorer
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose (bool disposing)
{
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openMinecraftSaveFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this._menuItemExit = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemCut = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemCopy = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemPaste = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this._menuItemRename = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemEditValue = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemDelete = new System.Windows.Forms.ToolStripMenuItem();
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemFind = new System.Windows.Forms.ToolStripMenuItem();
this.findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._menuItemAbout = new System.Windows.Forms.ToolStripMenuItem();
this._nodeTree = new System.Windows.Forms.TreeView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this._buttonOpen = new System.Windows.Forms.ToolStripButton();
this._buttonOpenFolder = new System.Windows.Forms.ToolStripButton();
this._buttonSave = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this._buttonCut = new System.Windows.Forms.ToolStripButton();
this._buttonCopy = new System.Windows.Forms.ToolStripButton();
this._buttonPaste = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this._buttonRename = new System.Windows.Forms.ToolStripButton();
this._buttonEdit = new System.Windows.Forms.ToolStripButton();
this._buttonDelete = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this._buttonAddTagByte = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagShort = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagInt = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagLong = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagFloat = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagDouble = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagByteArray = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagIntArray = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagString = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagList = new System.Windows.Forms.ToolStripButton();
this._buttonAddTagCompound = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this._buttonFindNext = new System.Windows.Forms.ToolStripButton();
this.BottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.TopToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem,
this.searchToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(619, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.openFolderToolStripMenuItem,
this.openMinecraftSaveFolderToolStripMenuItem,
this.toolStripSeparator3,
this.saveToolStripMenuItem,
this.toolStripSeparator4,
this._menuItemExit});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image")));
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
this.openToolStripMenuItem.Text = "&Open...";
//
// openFolderToolStripMenuItem
//
this.openFolderToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openFolderToolStripMenuItem.Image")));
this.openFolderToolStripMenuItem.Name = "openFolderToolStripMenuItem";
this.openFolderToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.O)));
this.openFolderToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
this.openFolderToolStripMenuItem.Text = "Open &Folder...";
//
// openMinecraftSaveFolderToolStripMenuItem
//
this.openMinecraftSaveFolderToolStripMenuItem.Name = "openMinecraftSaveFolderToolStripMenuItem";
this.openMinecraftSaveFolderToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
this.openMinecraftSaveFolderToolStripMenuItem.Text = "Open &Minecraft Save Folder";
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(220, 6);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image")));
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
this.saveToolStripMenuItem.Text = "&Save";
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(220, 6);
//
// exitToolStripMenuItem
//
this._menuItemExit.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem.Image")));
this._menuItemExit.Name = "exitToolStripMenuItem";
this._menuItemExit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
this._menuItemExit.Size = new System.Drawing.Size(223, 22);
this._menuItemExit.Text = "E&xit";
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._menuItemCut,
this._menuItemCopy,
this._menuItemPaste,
this.toolStripSeparator7,
this._menuItemRename,
this._menuItemEditValue,
this._menuItemDelete});
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "&Edit";
//
// cutToolStripMenuItem
//
this._menuItemCut.Image = ((System.Drawing.Image)(resources.GetObject("cutToolStripMenuItem.Image")));
this._menuItemCut.Name = "cutToolStripMenuItem";
this._menuItemCut.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
this._menuItemCut.Size = new System.Drawing.Size(166, 22);
this._menuItemCut.Text = "Cu&t";
//
// copyToolStripMenuItem
//
this._menuItemCopy.Image = ((System.Drawing.Image)(resources.GetObject("copyToolStripMenuItem.Image")));
this._menuItemCopy.Name = "copyToolStripMenuItem";
this._menuItemCopy.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this._menuItemCopy.Size = new System.Drawing.Size(166, 22);
this._menuItemCopy.Text = "&Copy";
//
// pasteToolStripMenuItem
//
this._menuItemPaste.Image = ((System.Drawing.Image)(resources.GetObject("pasteToolStripMenuItem.Image")));
this._menuItemPaste.Name = "pasteToolStripMenuItem";
this._menuItemPaste.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
this._menuItemPaste.Size = new System.Drawing.Size(166, 22);
this._menuItemPaste.Text = "&Paste";
//
// toolStripSeparator7
//
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(163, 6);
//
// renameToolStripMenuItem
//
this._menuItemRename.Image = ((System.Drawing.Image)(resources.GetObject("renameToolStripMenuItem.Image")));
this._menuItemRename.Name = "renameToolStripMenuItem";
this._menuItemRename.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R)));
this._menuItemRename.Size = new System.Drawing.Size(166, 22);
this._menuItemRename.Text = "&Rename";
//
// editValueToolStripMenuItem
//
this._menuItemEditValue.Image = ((System.Drawing.Image)(resources.GetObject("editValueToolStripMenuItem.Image")));
this._menuItemEditValue.Name = "editValueToolStripMenuItem";
this._menuItemEditValue.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this._menuItemEditValue.Size = new System.Drawing.Size(166, 22);
this._menuItemEditValue.Text = "&Edit Value";
//
// deleteToolStripMenuItem
//
this._menuItemDelete.Image = ((System.Drawing.Image)(resources.GetObject("deleteToolStripMenuItem.Image")));
this._menuItemDelete.Name = "deleteToolStripMenuItem";
this._menuItemDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete;
this._menuItemDelete.Size = new System.Drawing.Size(166, 22);
this._menuItemDelete.Text = "&Delete";
//
// searchToolStripMenuItem
//
this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._menuItemFind,
this.findNextToolStripMenuItem});
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.searchToolStripMenuItem.Text = "&Search";
//
// findToolStripMenuItem
//
this._menuItemFind.Image = ((System.Drawing.Image)(resources.GetObject("findToolStripMenuItem.Image")));
this._menuItemFind.Name = "findToolStripMenuItem";
this._menuItemFind.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
this._menuItemFind.Size = new System.Drawing.Size(146, 22);
this._menuItemFind.Text = "Find...";
//
// findNextToolStripMenuItem
//
this.findNextToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("findNextToolStripMenuItem.Image")));
this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem";
this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.findNextToolStripMenuItem.Text = "Find Next";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._menuItemAbout});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Text = "&Help";
//
// aboutToolStripMenuItem
//
this._menuItemAbout.Image = ((System.Drawing.Image)(resources.GetObject("aboutToolStripMenuItem.Image")));
this._menuItemAbout.Name = "aboutToolStripMenuItem";
this._menuItemAbout.ShortcutKeys = System.Windows.Forms.Keys.F1;
this._menuItemAbout.Size = new System.Drawing.Size(126, 22);
this._menuItemAbout.Text = "&About";
//
// _nodeTree
//
this._nodeTree.AllowDrop = true;
this._nodeTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this._nodeTree.ImageIndex = 0;
this._nodeTree.ImageList = this.imageList1;
this._nodeTree.ItemHeight = 18;
this._nodeTree.Location = new System.Drawing.Point(0, 49);
this._nodeTree.Margin = new System.Windows.Forms.Padding(0);
this._nodeTree.Name = "_nodeTree";
this._nodeTree.SelectedImageIndex = 0;
this._nodeTree.Size = new System.Drawing.Size(619, 350);
this._nodeTree.TabIndex = 0;
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(0, "document-attribute-b.png");
this.imageList1.Images.SetKeyName(1, "document-attribute-s.png");
this.imageList1.Images.SetKeyName(2, "document-attribute-i.png");
this.imageList1.Images.SetKeyName(3, "document-attribute-l.png");
this.imageList1.Images.SetKeyName(4, "document-attribute-f.png");
this.imageList1.Images.SetKeyName(5, "document-attribute-d.png");
this.imageList1.Images.SetKeyName(6, "edit-code.png");
this.imageList1.Images.SetKeyName(7, "edit-small-caps.png");
this.imageList1.Images.SetKeyName(8, "edit-list.png");
this.imageList1.Images.SetKeyName(9, "box.png");
this.imageList1.Images.SetKeyName(10, "folder.png");
this.imageList1.Images.SetKeyName(11, "block.png");
this.imageList1.Images.SetKeyName(12, "wooden-box.png");
this.imageList1.Images.SetKeyName(13, "map.png");
this.imageList1.Images.SetKeyName(14, "edit-code-i.png");
this.imageList1.Images.SetKeyName(15, "question-white.png");
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._buttonOpen,
this._buttonOpenFolder,
this._buttonSave,
this.toolStripSeparator1,
this._buttonCut,
this._buttonCopy,
this._buttonPaste,
this.toolStripSeparator6,
this._buttonRename,
this._buttonEdit,
this._buttonDelete,
this.toolStripSeparator2,
this._buttonAddTagByte,
this._buttonAddTagShort,
this._buttonAddTagInt,
this._buttonAddTagLong,
this._buttonAddTagFloat,
this._buttonAddTagDouble,
this._buttonAddTagByteArray,
this._buttonAddTagIntArray,
this._buttonAddTagString,
this._buttonAddTagList,
this._buttonAddTagCompound,
this.toolStripSeparator5,
this._buttonFindNext});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(619, 25);
this.toolStrip1.Stretch = true;
this.toolStrip1.TabIndex = 0;
//
// _buttonOpen
//
this._buttonOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonOpen.Image = ((System.Drawing.Image)(resources.GetObject("_buttonOpen.Image")));
this._buttonOpen.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonOpen.Name = "_buttonOpen";
this._buttonOpen.Size = new System.Drawing.Size(23, 22);
this._buttonOpen.Text = "Open NBT Data Source";
//
// _buttonOpenFolder
//
this._buttonOpenFolder.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonOpenFolder.Image = ((System.Drawing.Image)(resources.GetObject("_buttonOpenFolder.Image")));
this._buttonOpenFolder.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonOpenFolder.Name = "_buttonOpenFolder";
this._buttonOpenFolder.Size = new System.Drawing.Size(23, 22);
this._buttonOpenFolder.Text = "Open Folder";
//
// _buttonSave
//
this._buttonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonSave.Image = ((System.Drawing.Image)(resources.GetObject("_buttonSave.Image")));
this._buttonSave.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonSave.Name = "_buttonSave";
this._buttonSave.Size = new System.Drawing.Size(23, 22);
this._buttonSave.Text = "Save All Modified Tags";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// _buttonCut
//
this._buttonCut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonCut.Image = ((System.Drawing.Image)(resources.GetObject("_buttonCut.Image")));
this._buttonCut.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonCut.Name = "_buttonCut";
this._buttonCut.Size = new System.Drawing.Size(23, 22);
this._buttonCut.Text = "Cut";
//
// _buttonCopy
//
this._buttonCopy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonCopy.Image = ((System.Drawing.Image)(resources.GetObject("_buttonCopy.Image")));
this._buttonCopy.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonCopy.Name = "_buttonCopy";
this._buttonCopy.Size = new System.Drawing.Size(23, 22);
this._buttonCopy.Text = "Copy";
//
// _buttonPaste
//
this._buttonPaste.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonPaste.Image = ((System.Drawing.Image)(resources.GetObject("_buttonPaste.Image")));
this._buttonPaste.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonPaste.Name = "_buttonPaste";
this._buttonPaste.Size = new System.Drawing.Size(23, 22);
this._buttonPaste.Text = "Paste";
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(6, 25);
//
// _buttonRename
//
this._buttonRename.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonRename.Image = ((System.Drawing.Image)(resources.GetObject("_buttonRename.Image")));
this._buttonRename.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonRename.Name = "_buttonRename";
this._buttonRename.Size = new System.Drawing.Size(23, 22);
this._buttonRename.Text = "Rename Tag";
//
// _buttonEdit
//
this._buttonEdit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonEdit.Image = ((System.Drawing.Image)(resources.GetObject("_buttonEdit.Image")));
this._buttonEdit.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonEdit.Name = "_buttonEdit";
this._buttonEdit.Size = new System.Drawing.Size(23, 22);
this._buttonEdit.Text = "Edit Tag Value";
//
// _buttonDelete
//
this._buttonDelete.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonDelete.Image = ((System.Drawing.Image)(resources.GetObject("_buttonDelete.Image")));
this._buttonDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonDelete.Name = "_buttonDelete";
this._buttonDelete.Size = new System.Drawing.Size(23, 22);
this._buttonDelete.Text = "Delete Tag";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// _buttonAddTagByte
//
this._buttonAddTagByte.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagByte.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagByte.Image")));
this._buttonAddTagByte.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagByte.Name = "_buttonAddTagByte";
this._buttonAddTagByte.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagByte.Text = "Add Byte Tag";
//
// _buttonAddTagShort
//
this._buttonAddTagShort.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagShort.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagShort.Image")));
this._buttonAddTagShort.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagShort.Name = "_buttonAddTagShort";
this._buttonAddTagShort.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagShort.Text = "Add Short Tag";
//
// _buttonAddTagInt
//
this._buttonAddTagInt.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagInt.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagInt.Image")));
this._buttonAddTagInt.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagInt.Name = "_buttonAddTagInt";
this._buttonAddTagInt.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagInt.Text = "Add Int Tag";
//
// _buttonAddTagLong
//
this._buttonAddTagLong.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagLong.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagLong.Image")));
this._buttonAddTagLong.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagLong.Name = "_buttonAddTagLong";
this._buttonAddTagLong.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagLong.Text = "Add Long Tag";
//
// _buttonAddTagFloat
//
this._buttonAddTagFloat.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagFloat.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagFloat.Image")));
this._buttonAddTagFloat.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagFloat.Name = "_buttonAddTagFloat";
this._buttonAddTagFloat.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagFloat.Text = "Add Float Tag";
//
// _buttonAddTagDouble
//
this._buttonAddTagDouble.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagDouble.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagDouble.Image")));
this._buttonAddTagDouble.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagDouble.Name = "_buttonAddTagDouble";
this._buttonAddTagDouble.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagDouble.Text = "Add Double Tag";
//
// _buttonAddTagByteArray
//
this._buttonAddTagByteArray.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagByteArray.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagByteArray.Image")));
this._buttonAddTagByteArray.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagByteArray.Name = "_buttonAddTagByteArray";
this._buttonAddTagByteArray.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagByteArray.Text = "Add Byte Array Tag";
//
// _buttonAddTagIntArray
//
this._buttonAddTagIntArray.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagIntArray.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagIntArray.Image")));
this._buttonAddTagIntArray.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this._buttonAddTagIntArray.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagIntArray.Name = "_buttonAddTagIntArray";
this._buttonAddTagIntArray.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagIntArray.Text = "Add Int Array Tag";
//
// _buttonAddTagString
//
this._buttonAddTagString.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagString.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagString.Image")));
this._buttonAddTagString.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagString.Name = "_buttonAddTagString";
this._buttonAddTagString.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagString.Text = "Add String Tag";
//
// _buttonAddTagList
//
this._buttonAddTagList.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagList.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagList.Image")));
this._buttonAddTagList.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagList.Name = "_buttonAddTagList";
this._buttonAddTagList.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagList.Text = "Add List Tag";
//
// _buttonAddTagCompound
//
this._buttonAddTagCompound.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonAddTagCompound.Image = ((System.Drawing.Image)(resources.GetObject("_buttonAddTagCompound.Image")));
this._buttonAddTagCompound.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonAddTagCompound.Name = "_buttonAddTagCompound";
this._buttonAddTagCompound.Size = new System.Drawing.Size(23, 22);
this._buttonAddTagCompound.Text = "Add Compound Tag";
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
//
// _buttonFindNext
//
this._buttonFindNext.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this._buttonFindNext.Image = ((System.Drawing.Image)(resources.GetObject("_buttonFindNext.Image")));
this._buttonFindNext.ImageTransparentColor = System.Drawing.Color.Magenta;
this._buttonFindNext.Name = "_buttonFindNext";
this._buttonFindNext.Size = new System.Drawing.Size(23, 22);
this._buttonFindNext.Text = "Find / Find Next";
//
// BottomToolStripPanel
//
this.BottomToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.BottomToolStripPanel.Name = "BottomToolStripPanel";
this.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.BottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.BottomToolStripPanel.Size = new System.Drawing.Size(0, 0);
//
// TopToolStripPanel
//
this.TopToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.TopToolStripPanel.Name = "TopToolStripPanel";
this.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.TopToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.TopToolStripPanel.Size = new System.Drawing.Size(0, 0);
//
// RightToolStripPanel
//
this.RightToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.RightToolStripPanel.Name = "RightToolStripPanel";
this.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.RightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.RightToolStripPanel.Size = new System.Drawing.Size(0, 0);
//
// LeftToolStripPanel
//
this.LeftToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.LeftToolStripPanel.Name = "LeftToolStripPanel";
this.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.LeftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.LeftToolStripPanel.Size = new System.Drawing.Size(0, 0);
//
// ContentPanel
//
this.ContentPanel.Size = new System.Drawing.Size(562, 376);
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
this.statusStrip1.Location = new System.Drawing.Point(0, 401);
this.statusStrip1.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(619, 22);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(604, 17);
this.toolStripStatusLabel1.Spring = true;
//
// MainForm
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(619, 423);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this._nodeTree);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
this.Text = "NBTExplorer";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.TreeView _nodeTree;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton _buttonOpen;
private System.Windows.Forms.ToolStripButton _buttonSave;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton _buttonRename;
private System.Windows.Forms.ToolStripButton _buttonEdit;
private System.Windows.Forms.ToolStripButton _buttonDelete;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripButton _buttonAddTagByte;
private System.Windows.Forms.ToolStripButton _buttonAddTagShort;
private System.Windows.Forms.ToolStripButton _buttonAddTagInt;
private System.Windows.Forms.ToolStripButton _buttonAddTagLong;
private System.Windows.Forms.ToolStripButton _buttonAddTagFloat;
private System.Windows.Forms.ToolStripButton _buttonAddTagDouble;
private System.Windows.Forms.ToolStripButton _buttonAddTagByteArray;
private System.Windows.Forms.ToolStripButton _buttonAddTagList;
private System.Windows.Forms.ToolStripButton _buttonAddTagCompound;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolStripButton _buttonAddTagString;
private System.Windows.Forms.ToolStripMenuItem _menuItemAbout;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openFolderToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem _menuItemExit;
private System.Windows.Forms.ToolStripMenuItem _menuItemFind;
private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripButton _buttonFindNext;
private System.Windows.Forms.ToolStripButton _buttonOpenFolder;
private System.Windows.Forms.ToolStripMenuItem openMinecraftSaveFolderToolStripMenuItem;
private System.Windows.Forms.ToolStripPanel BottomToolStripPanel;
private System.Windows.Forms.ToolStripPanel TopToolStripPanel;
private System.Windows.Forms.ToolStripPanel RightToolStripPanel;
private System.Windows.Forms.ToolStripPanel LeftToolStripPanel;
private System.Windows.Forms.ToolStripContentPanel ContentPanel;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripButton _buttonAddTagIntArray;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _menuItemCut;
private System.Windows.Forms.ToolStripMenuItem _menuItemCopy;
private System.Windows.Forms.ToolStripMenuItem _menuItemPaste;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripMenuItem _menuItemRename;
private System.Windows.Forms.ToolStripMenuItem _menuItemEditValue;
private System.Windows.Forms.ToolStripMenuItem _menuItemDelete;
private System.Windows.Forms.ToolStripButton _buttonCut;
private System.Windows.Forms.ToolStripButton _buttonCopy;
private System.Windows.Forms.ToolStripButton _buttonPaste;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
}
}

523
MainForm.cs Normal file
View file

@ -0,0 +1,523 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using Substrate;
using Substrate.Core;
using Substrate.Nbt;
using NBTExplorer.Model;
namespace NBTExplorer
{
public partial class MainForm : Form
{
private static Dictionary<TagType, int> _tagIconIndex;
private IconRegistry _iconRegistry;
static MainForm ()
{
_tagIconIndex = new Dictionary<TagType, int>();
_tagIconIndex[TagType.TAG_BYTE] = 0;
_tagIconIndex[TagType.TAG_SHORT] = 1;
_tagIconIndex[TagType.TAG_INT] = 2;
_tagIconIndex[TagType.TAG_LONG] = 3;
_tagIconIndex[TagType.TAG_FLOAT] = 4;
_tagIconIndex[TagType.TAG_DOUBLE] = 5;
_tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6;
_tagIconIndex[TagType.TAG_STRING] = 7;
_tagIconIndex[TagType.TAG_LIST] = 8;
_tagIconIndex[TagType.TAG_COMPOUND] = 9;
_tagIconIndex[TagType.TAG_INT_ARRAY] = 14;
}
public MainForm ()
{
InitializeComponent();
InitializeIconRegistry();
_nodeTree.BeforeExpand += _nodeTree_BeforeExpand;
_nodeTree.AfterSelect += _nodeTree_AfterSelect;
_nodeTree.NodeMouseDoubleClick += _nodeTree_NodeMouseDoubleClick;
_buttonEdit.Click += _buttonEdit_Click;
_buttonRename.Click += _buttonRename_Click;
_buttonDelete.Click += _buttonDelete_Click;
_buttonCopy.Click += _buttonCopy_Click;
_buttonCut.Click += _buttonCut_Click;
_buttonPaste.Click += _buttonPaste_Click;
_buttonAddTagByte.Click += _buttonAddTagByte_Click;
_buttonAddTagByteArray.Click += _buttonAddTagByteArray_Click;
_buttonAddTagCompound.Click += _buttonAddTagCompound_Click;
_buttonAddTagDouble.Click += _buttonAddTagDouble_Click;
_buttonAddTagFloat.Click += _buttonAddTagFloat_Click;
_buttonAddTagInt.Click += _buttonAddTagInt_Click;
_buttonAddTagIntArray.Click += _buttonAddTagIntArray_Click;
_buttonAddTagList.Click += _buttonAddTagList_Click;
_buttonAddTagLong.Click += _buttonAddTagLong_Click;
_buttonAddTagShort.Click += _buttonAddTagShort_Click;
_buttonAddTagString.Click += _buttonAddTagString_Click;
_menuItemExit.Click += _menuItemExit_Click;
_menuItemEditValue.Click += _menuItemEditValue_Click;
_menuItemRename.Click += _menuItemRename_Click;
_menuItemDelete.Click += _menuItemDelete_Click;
_menuItemCopy.Click += _menuItemCopy_Click;
_menuItemCut.Click += _menuItemCut_Click;
_menuItemPaste.Click += _menuItemPaste_Click;
_menuItemAbout.Click += _menuItemAbout_Click;
/*_nodeTree.BeforeExpand += NodeExpand;
_nodeTree.AfterCollapse += NodeCollapse;
_nodeTree.AfterSelect += NodeSelected;
_nodeTree.NodeMouseClick += NodeClicked;
_nodeTree.NodeMouseDoubleClick += NodeDoubleClicked;
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1) {
OpenFile(args[1]);
}
else {
OpenMinecraftDir();
}*/
//OpenDirectory(@"F:\Minecraft\tps");
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1) {
OpenFile(args[1]);
}
else {
OpenMinecraftDirectory();
}
}
private void InitializeIconRegistry ()
{
_iconRegistry = new IconRegistry();
_iconRegistry.DefaultIcon = 15;
_iconRegistry.Register(typeof(TagByteDataNode), 0);
_iconRegistry.Register(typeof(TagShortDataNode), 1);
_iconRegistry.Register(typeof(TagIntDataNode), 2);
_iconRegistry.Register(typeof(TagLongDataNode), 3);
_iconRegistry.Register(typeof(TagFloatDataNode), 4);
_iconRegistry.Register(typeof(TagDoubleDataNode), 5);
_iconRegistry.Register(typeof(TagByteArrayDataNode), 6);
_iconRegistry.Register(typeof(TagStringDataNode), 7);
_iconRegistry.Register(typeof(TagListDataNode), 8);
_iconRegistry.Register(typeof(TagCompoundDataNode), 9);
_iconRegistry.Register(typeof(RegionChunkDataNode), 9);
_iconRegistry.Register(typeof(DirectoryDataNode), 10);
_iconRegistry.Register(typeof(RegionFileDataNode), 11);
_iconRegistry.Register(typeof(NbtFileDataNode), 12);
_iconRegistry.Register(typeof(TagIntArrayDataNode), 14);
}
private void OpenFile (string path)
{
_nodeTree.Nodes.Clear();
NbtFileDataNode node = NbtFileDataNode.TryCreateFrom(path);
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
}
private void OpenDirectory (string path)
{
_nodeTree.Nodes.Clear();
DirectoryDataNode node = new DirectoryDataNode(path);
TreeNode frontNode = CreateUnexpandedNode(node);
_nodeTree.Nodes.Add(frontNode);
ExpandNode(frontNode);
frontNode.Expand();
}
private void OpenMinecraftDirectory ()
{
try {
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
path = Path.Combine(path, ".minecraft");
path = Path.Combine(path, "saves");
if (!Directory.Exists(path)) {
path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
}
OpenDirectory(path);
}
catch (Exception) {
MessageBox.Show("Could not open default Minecraft save directory");
try {
OpenDirectory(Directory.GetCurrentDirectory());
}
catch (Exception) {
MessageBox.Show("Could not open current directory, this tool is probably not compatible with your platform.");
Application.Exit();
}
}
}
private TreeNode CreateUnexpandedNode (DataNode node)
{
TreeNode frontNode = new TreeNode(node.NodeDisplay);
frontNode.ImageIndex = _iconRegistry.Lookup(node.GetType());
frontNode.SelectedImageIndex = frontNode.ImageIndex;
frontNode.Tag = node;
if (node.HasUnexpandedChildren)
frontNode.Nodes.Add(new TreeNode());
return frontNode;
}
private void ExpandNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode backNode = node.Tag as DataNode;
if (!backNode.HasUnexpandedChildren)
return;
node.Nodes.Clear();
if (!backNode.IsExpanded)
backNode.Expand();
foreach (DataNode child in backNode.Nodes)
node.Nodes.Add(CreateUnexpandedNode(child));
}
private void CreateNode (TreeNode node, TagType type)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanCreateTag(type))
return;
if (dataNode.CreateNode(type)) {
node.Text = dataNode.NodeDisplay;
RefreshChildNodes(node, dataNode);
UpdateUI(dataNode);
}
}
private void RefreshChildNodes (TreeNode node, DataNode dataNode)
{
Dictionary<DataNode, TreeNode> currentNodes = new Dictionary<DataNode, TreeNode>();
foreach (TreeNode child in node.Nodes) {
if (child.Tag is DataNode)
currentNodes.Add(child.Tag as DataNode, child);
}
foreach (DataNode child in dataNode.Nodes) {
if (!currentNodes.ContainsKey(child))
node.Nodes.Add(CreateUnexpandedNode(child));
else
currentNodes.Remove(child);
}
foreach (TreeNode child in currentNodes.Values) {
node.Nodes.Remove(child);
}
if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) {
ExpandNode(node);
node.Expand();
}
}
private void EditNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanEditNode)
return;
if (dataNode.EditNode()) {
node.Text = dataNode.NodeDisplay;
}
}
private void RenameNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanRenameNode)
return;
if (dataNode.RenameNode()) {
node.Text = dataNode.NodeDisplay;
}
}
private void DeleteNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanDeleteNode)
return;
if (dataNode.DeleteNode()) {
UpdateUI(node.Parent.Tag as DataNode);
UpdateNodeText(node.Parent);
node.Remove();
}
}
private void CopyNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanCopyNode)
return;
dataNode.CopyNode();
}
private void CutNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanCutNode)
return;
if (dataNode.CutNode()) {
UpdateUI(node.Parent.Tag as DataNode);
UpdateNodeText(node.Parent);
node.Remove();
}
}
private void PasteNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanPasteIntoNode)
return;
if (dataNode.PasteNode()) {
node.Text = dataNode.NodeDisplay;
RefreshChildNodes(node, dataNode);
UpdateUI(dataNode);
}
}
private void UpdateNodeText (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
node.Text = dataNode.NodeDisplay;
}
private void UpdateUI (DataNode node)
{
if (node == null)
return;
_buttonAddTagByte.Enabled = node.CanCreateTag(TagType.TAG_BYTE);
_buttonAddTagByteArray.Enabled = node.CanCreateTag(TagType.TAG_BYTE_ARRAY);
_buttonAddTagCompound.Enabled = node.CanCreateTag(TagType.TAG_COMPOUND);
_buttonAddTagDouble.Enabled = node.CanCreateTag(TagType.TAG_DOUBLE);
_buttonAddTagFloat.Enabled = node.CanCreateTag(TagType.TAG_FLOAT);
_buttonAddTagInt.Enabled = node.CanCreateTag(TagType.TAG_INT);
_buttonAddTagIntArray.Enabled = node.CanCreateTag(TagType.TAG_INT_ARRAY);
_buttonAddTagList.Enabled = node.CanCreateTag(TagType.TAG_LIST);
_buttonAddTagLong.Enabled = node.CanCreateTag(TagType.TAG_LONG);
_buttonAddTagShort.Enabled = node.CanCreateTag(TagType.TAG_SHORT);
_buttonAddTagString.Enabled = node.CanCreateTag(TagType.TAG_STRING);
_buttonCopy.Enabled = node.CanCopyNode;
_buttonCut.Enabled = node.CanCutNode;
_buttonDelete.Enabled = node.CanDeleteNode;
_buttonEdit.Enabled = node.CanEditNode;
_buttonFindNext.Enabled = node.CanSearchNode; // Not entirely
_buttonPaste.Enabled = node.CanPasteIntoNode; // Not entirely
_buttonRename.Enabled = node.CanRenameNode;
_menuItemCopy.Enabled = node.CanCopyNode;
_menuItemCut.Enabled = node.CanCutNode;
_menuItemDelete.Enabled = node.CanDeleteNode;
_menuItemEditValue.Enabled = node.CanEditNode;
_menuItemFind.Enabled = node.CanSearchNode;
_menuItemPaste.Enabled = node.CanPasteIntoNode; // Not entirely
_menuItemRename.Enabled = node.CanRenameNode;
}
#region Event Handlers
#region TreeView Event Handlers
private void _nodeTree_BeforeExpand (object sender, TreeViewCancelEventArgs e)
{
ExpandNode(e.Node);
}
private void _nodeTree_AfterSelect (object sender, TreeViewEventArgs e)
{
UpdateUI(e.Node.Tag as DataNode);
}
private void _nodeTree_NodeMouseDoubleClick (object sender, TreeNodeMouseClickEventArgs e)
{
EditNode(e.Node);
}
#endregion
#region Toolstrip Event Handlers
private void _buttonEdit_Click (object sender, EventArgs e)
{
EditNode(_nodeTree.SelectedNode);
}
private void _buttonRename_Click (object sender, EventArgs e)
{
RenameNode(_nodeTree.SelectedNode);
}
private void _buttonDelete_Click (object sender, EventArgs e)
{
DeleteNode(_nodeTree.SelectedNode);
}
private void _buttonCopy_Click (object sernder, EventArgs e)
{
CopyNode(_nodeTree.SelectedNode);
}
private void _buttonCut_Click (object sernder, EventArgs e)
{
CutNode(_nodeTree.SelectedNode);
}
private void _buttonPaste_Click (object sernder, EventArgs e)
{
PasteNode(_nodeTree.SelectedNode);
}
private void _buttonAddTagByteArray_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_BYTE_ARRAY);
}
private void _buttonAddTagByte_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_BYTE);
}
private void _buttonAddTagCompound_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_COMPOUND);
}
private void _buttonAddTagDouble_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_DOUBLE);
}
private void _buttonAddTagFloat_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_FLOAT);
}
private void _buttonAddTagInt_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_INT);
}
private void _buttonAddTagIntArray_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_INT_ARRAY);
}
private void _buttonAddTagList_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_LIST);
}
private void _buttonAddTagLong_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_LONG);
}
private void _buttonAddTagShort_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_SHORT);
}
private void _buttonAddTagString_Click (object sender, EventArgs e)
{
CreateNode(_nodeTree.SelectedNode, TagType.TAG_STRING);
}
#endregion
#region Menu Event Handlers
private void _menuItemExit_Click (object sender, EventArgs e)
{
Close();
}
private void _menuItemEditValue_Click (object sender, EventArgs e)
{
EditNode(_nodeTree.SelectedNode);
}
private void _menuItemRename_Click (object sender, EventArgs e)
{
RenameNode(_nodeTree.SelectedNode);
}
private void _menuItemDelete_Click (object sender, EventArgs e)
{
DeleteNode(_nodeTree.SelectedNode);
}
private void _menuItemCopy_Click (object sender, EventArgs e)
{
CopyNode(_nodeTree.SelectedNode);
}
private void _menuItemCut_Click (object sender, EventArgs e)
{
CutNode(_nodeTree.SelectedNode);
}
private void _menuItemPaste_Click (object sender, EventArgs e)
{
PasteNode(_nodeTree.SelectedNode);
}
private void _menuItemAbout_Click (object sender, EventArgs e)
{
new About().ShowDialog();
}
#endregion
#endregion
}
}

1146
MainForm.resx Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class CompoundTagContainer : INamedTagContainer
{
private TagNodeCompound _tag;
public CompoundTagContainer (TagNodeCompound tag)
{
_tag = tag;
}
public int TagCount
{
get { return _tag.Count; }
}
public IEnumerable<string> TagNamesInUse
{
get { return _tag.Keys; }
}
public string GetTagName (TagNode tag)
{
foreach (String name in _tag.Keys)
if (_tag[name] == tag)
return name;
return null;
}
public bool AddTag (TagNode tag, string name)
{
if (_tag.ContainsKey(name))
return false;
_tag.Add(name, tag);
return true;
}
public bool RenameTag (TagNode tag, string name)
{
if (_tag.ContainsKey(name))
return false;
string oldName = GetTagName(tag);
_tag.Remove(oldName);
_tag.Add(name, tag);
return true;
}
public bool DeleteTag (TagNode tag)
{
foreach (String name in _tag.Keys)
if (_tag[name] == tag)
return _tag.Remove(name);
return false;
}
}
}

181
Model/DataNode.cs Normal file
View file

@ -0,0 +1,181 @@
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class DataNode
{
private DataNode _parent;
private DataNodeCollection _children;
private bool _expanded;
private bool _modified;
public DataNode ()
{
_children = new DataNodeCollection(this);
}
public DataNode Parent
{
get { return _parent; }
internal set { _parent = value; }
}
public DataNodeCollection Nodes
{
get { return _children; }
}
public bool IsModified
{
get { return _modified; }
set
{
if (value && Parent != null)
Parent.IsModified = value;
_modified = value;
}
}
public bool IsExpanded
{
get { return _expanded; }
private set { _expanded = value; }
}
public void Expand ()
{
if (!IsExpanded) {
ExpandCore();
IsExpanded = true;
}
}
protected virtual void ExpandCore () { }
public void Collapse ()
{
if (IsExpanded && !IsModified) {
Release();
IsExpanded = false;
}
}
public void Release ()
{
foreach (DataNode node in Nodes)
node.Release();
ReleaseCore();
IsExpanded = false;
}
protected virtual void ReleaseCore ()
{
Nodes.Clear();
}
public virtual string NodeName
{
get { return ""; }
}
public virtual string NodeDisplay
{
get { return ""; }
}
public virtual bool HasUnexpandedChildren
{
get { return false; }
}
#region Capabilities
protected virtual NodeCapabilities Capabilities
{
get { return NodeCapabilities.None; }
}
public virtual bool CanRenameNode
{
get { return (Capabilities & NodeCapabilities.Rename) != NodeCapabilities.None; }
}
public virtual bool CanEditNode
{
get { return (Capabilities & NodeCapabilities.Edit) != NodeCapabilities.None; }
}
public virtual bool CanDeleteNode
{
get { return (Capabilities & NodeCapabilities.Delete) != NodeCapabilities.None; }
}
public virtual bool CanCopyNode
{
get { return (Capabilities & NodeCapabilities.Copy) != NodeCapabilities.None; }
}
public virtual bool CanCutNode
{
get { return (Capabilities & NodeCapabilities.Cut) != NodeCapabilities.None; }
}
public virtual bool CanPasteIntoNode
{
get { return (Capabilities & NodeCapabilities.PasteInto) != NodeCapabilities.None; }
}
public virtual bool CanSearchNode
{
get { return (Capabilities & NodeCapabilities.Search) != NodeCapabilities.None; }
}
public virtual bool CanCreateTag (TagType type)
{
return false;
}
#endregion
#region Operations
public virtual bool CreateNode (TagType type)
{
return false;
}
public virtual bool RenameNode ()
{
return false;
}
public virtual bool EditNode ()
{
return false;
}
public virtual bool DeleteNode ()
{
return false;
}
public virtual bool CopyNode ()
{
return false;
}
public virtual bool CutNode ()
{
return false;
}
public virtual bool PasteNode ()
{
return false;
}
#endregion
}
}

121
Model/DataNodeCollection.cs Normal file
View file

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
namespace NBTExplorer.Model
{
public class DataNodeCollection : IList<DataNode>
{
private List<DataNode> _nodes;
private DataNode _parent;
internal DataNodeCollection (DataNode parent)
{
_parent = parent;
_nodes = new List<DataNode>();
}
public int IndexOf (DataNode item)
{
return _nodes.IndexOf(item);
}
public void Insert (int index, DataNode item)
{
if (item == null)
throw new ArgumentNullException("item");
if (item.Parent != null)
throw new ArgumentException("The item is already assigned to another DataNode.");
item.Parent = _parent;
_nodes.Insert(index, item);
}
public void RemoveAt (int index)
{
if (index < 0 || index >= _nodes.Count)
throw new ArgumentOutOfRangeException("index");
DataNode node = _nodes[index];
node.Parent = null;
_nodes.RemoveAt(index);
}
DataNode IList<DataNode>.this[int index]
{
get { return _nodes[index]; }
set
{
if (index < 0 || index > _nodes.Count)
throw new ArgumentOutOfRangeException("index");
if (value == null)
throw new ArgumentNullException("item");
if (value.Parent != null)
throw new ArgumentException("The item is already assigned to another DataNode.");
_nodes[index].Parent = null;
_nodes[index] = value;
_nodes[index].Parent = _parent;
}
}
public void Add (DataNode item)
{
if (item == null)
throw new ArgumentNullException("item");
if (item.Parent != null)
throw new ArgumentException("The item is already assigned to another DataNode.");
item.Parent = _parent;
_nodes.Add(item);
}
public void Clear ()
{
foreach (DataNode node in _nodes)
node.Parent = null;
_nodes.Clear();
}
public bool Contains (DataNode item)
{
return _nodes.Contains(item);
}
public void CopyTo (DataNode[] array, int arrayIndex)
{
_nodes.CopyTo(array, arrayIndex);
}
public int Count
{
get { return _nodes.Count; }
}
bool ICollection<DataNode>.IsReadOnly
{
get { return (_nodes as IList<DataNode>).IsReadOnly; }
}
public bool Remove (DataNode item)
{
if (_nodes.Contains(item))
item.Parent = null;
return _nodes.Remove(item);
}
public IEnumerator<DataNode> GetEnumerator ()
{
return _nodes.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
{
return _nodes.GetEnumerator();
}
}
}

View file

@ -0,0 +1,65 @@
using System.IO;
namespace NBTExplorer.Model
{
public class DirectoryDataNode : DataNode
{
private string _path;
public DirectoryDataNode (string path)
{
_path = path;
}
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.Search;
}
}
public override string NodeDisplay
{
get { return Path.GetFileName(_path); }
}
public override bool HasUnexpandedChildren
{
get { return !IsExpanded; }
}
protected override void ExpandCore ()
{
foreach (string dirpath in Directory.GetDirectories(_path)) {
Nodes.Add(new DirectoryDataNode(dirpath));
}
foreach (string filepath in Directory.GetFiles(_path)) {
string ext = Path.GetExtension(filepath);
DataNode node = null;
switch (ext) {
case ".mcr":
case ".mca":
node = RegionFileDataNode.TryCreateFrom(filepath);
break;
case ".dat":
case ".nbt":
case ".schematic":
node = NbtFileDataNode.TryCreateFrom(filepath);
break;
}
if (node != null)
Nodes.Add(node);
}
}
protected override void ReleaseCore ()
{
Nodes.Clear();
}
}
}

38
Model/ListTagContainer.cs Normal file
View file

@ -0,0 +1,38 @@
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class ListTagContainer : IOrderedTagContainer
{
private TagNodeList _tag;
public ListTagContainer (TagNodeList tag)
{
_tag = tag;
}
public int TagCount
{
get { return _tag.Count; }
}
public bool DeleteTag (TagNode tag)
{
return _tag.Remove(tag);
}
public int GetTagIndex (TagNode tag)
{
return _tag.IndexOf(tag);
}
public bool InsertTag (TagNode tag, int index)
{
if (index < 0 || index > _tag.Count)
return false;
_tag.Insert(index, tag);
return true;
}
}
}

124
Model/NbtFileDataNode.cs Normal file
View file

@ -0,0 +1,124 @@
using System.IO;
using Substrate.Core;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class NbtFileDataNode : DataNode, IMetaTagContainer
{
private NbtTree _tree;
private string _path;
private CompressionType _compressionType;
private CompoundTagContainer _container;
private NbtFileDataNode (string path, CompressionType compressionType)
{
_path = path;
_compressionType = compressionType;
_container = new CompoundTagContainer(new TagNodeCompound());
}
public static NbtFileDataNode TryCreateFrom (string path)
{
return TryCreateFrom(path, CompressionType.GZip)
?? TryCreateFrom(path, CompressionType.None);
}
private static NbtFileDataNode TryCreateFrom (string path, CompressionType compressionType)
{
try {
NBTFile file = new NBTFile(path);
NbtTree tree = new NbtTree();
tree.ReadFrom(file.GetDataInputStream(compressionType));
if (tree.Root == null)
return null;
return new NbtFileDataNode(path, compressionType);
}
catch {
return null;
}
}
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.CreateTag
| NodeCapabilities.PasteInto
| NodeCapabilities.Search;
}
}
public override string NodeName
{
get { return Path.GetFileName(_path); }
}
public override string NodeDisplay
{
get { return NodeName; }
}
public override bool HasUnexpandedChildren
{
get { return !IsExpanded; }
}
protected override void ExpandCore ()
{
if (_tree == null) {
NBTFile file = new NBTFile(_path);
_tree = new NbtTree();
_tree.ReadFrom(file.GetDataInputStream(_compressionType));
if (_tree.Root != null)
_container = new CompoundTagContainer(_tree.Root);
}
foreach (TagNode tag in _tree.Root.Values) {
TagDataNode node = TagDataNode.CreateFromTag(tag);
if (node != null)
Nodes.Add(node);
}
}
protected override void ReleaseCore ()
{
_tree = null;
Nodes.Clear();
}
public bool IsNamedContainer
{
get { return true; }
}
public bool IsOrderedContainer
{
get { return false; }
}
public INamedTagContainer NamedTagContainer
{
get { return _container; }
}
public IOrderedTagContainer OrderedTagContainer
{
get { return null; }
}
public int TagCount
{
get { return _container.TagCount; }
}
public bool DeleteTag (TagNode tag)
{
return _container.DeleteTag(tag);
}
}
}

18
Model/NodeCapabilities.cs Normal file
View file

@ -0,0 +1,18 @@
using System;
namespace NBTExplorer.Model
{
[Flags]
public enum NodeCapabilities
{
None = 0,
Cut = 0x1,
Copy = 0x2,
PasteInto = 0x4,
Rename = 0x8,
Edit = 0x10,
Delete = 0x20,
CreateTag = 0x40,
Search = 0x80,
}
}

View file

@ -0,0 +1,96 @@
using Substrate.Core;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class RegionChunkDataNode : DataNode, IMetaTagContainer
{
private RegionFile _regionFile;
private NbtTree _tree;
private int _x;
private int _z;
private CompoundTagContainer _container;
public RegionChunkDataNode (RegionFile regionFile, int x, int z)
{
_regionFile = regionFile;
_x = x;
_z = z;
_container = new CompoundTagContainer(new TagNodeCompound());
}
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.CreateTag
| NodeCapabilities.PasteInto
| NodeCapabilities.Search;
}
}
public override bool HasUnexpandedChildren
{
get { return !IsExpanded; }
}
public override string NodeDisplay
{
get { return "Chunk [" + _x + ", " + _z + "]"; }
}
protected override void ExpandCore ()
{
if (_tree == null) {
_tree = new NbtTree();
_tree.ReadFrom(_regionFile.GetChunkDataInputStream(_x, _z));
if (_tree.Root != null)
_container = new CompoundTagContainer(_tree.Root);
}
foreach (TagNode tag in _tree.Root.Values) {
TagDataNode node = TagDataNode.CreateFromTag(tag);
if (node != null)
Nodes.Add(node);
}
}
protected override void ReleaseCore ()
{
_tree = null;
Nodes.Clear();
}
public bool IsNamedContainer
{
get { return true; }
}
public bool IsOrderedContainer
{
get { return false; }
}
public INamedTagContainer NamedTagContainer
{
get { return _container; }
}
public IOrderedTagContainer OrderedTagContainer
{
get { return null; }
}
public int TagCount
{
get { return _container.TagCount; }
}
public bool DeleteTag (TagNode tag)
{
return _container.DeleteTag(tag);
}
}
}

View file

@ -0,0 +1,65 @@
using System.IO;
using System.Windows.Forms;
using Substrate.Core;
namespace NBTExplorer.Model
{
public class RegionFileDataNode : DataNode
{
private string _path;
private RegionFile _region;
private RegionFileDataNode (string path)
{
_path = path;
}
public static RegionFileDataNode TryCreateFrom (string path)
{
return new RegionFileDataNode(path);
}
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.Search;
}
}
public override bool HasUnexpandedChildren
{
get { return !IsExpanded; }
}
public override string NodeDisplay
{
get { return Path.GetFileName(_path); }
}
protected override void ExpandCore ()
{
try {
if (_region == null)
_region = new RegionFile(_path);
for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) {
if (_region.HasChunk(x, z)) {
Nodes.Add(new RegionChunkDataNode(_region, x, z));
}
}
}
}
catch {
MessageBox.Show("Not a valid region file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
protected override void ReleaseCore ()
{
_region = null;
Nodes.Clear();
}
}
}

View file

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class TagCompoundDataNode : TagDataNode.Container
{
private CompoundTagContainer _container;
public TagCompoundDataNode (TagNodeCompound tag)
: base(tag)
{
_container = new CompoundTagContainer(tag);
}
protected new TagNodeCompound Tag
{
get { return base.Tag as TagNodeCompound; }
}
protected override void ExpandCore ()
{
var list = new SortedList<TagKey, TagNode>();
foreach (var item in Tag) {
list.Add(new TagKey(item.Key, item.Value.GetTagType()), item.Value);
}
foreach (var item in list) {
TagDataNode node = TagDataNode.CreateFromTag(item.Value);
if (node != null)
Nodes.Add(node);
}
}
public override bool CanCreateTag (TagType type)
{
return Enum.IsDefined(typeof(TagType), type) && type != TagType.TAG_END;
}
public override bool CanPasteIntoNode
{
get { return NbtClipboardData.ContainsData; }
}
public override bool CreateNode (TagType type)
{
if (!CanCreateTag(type))
return false;
CreateNodeForm form = new CreateNodeForm(type, true);
form.InvalidNames.AddRange(_container.TagNamesInUse);
if (form.ShowDialog() == DialogResult.OK) {
AddTag(form.TagNode, form.TagName);
return true;
}
return false;
}
public override bool PasteNode ()
{
if (!CanPasteIntoNode)
return false;
NbtClipboardData clipboard = NbtClipboardData.CopyFromClipboard();
if (clipboard.Node == null)
return false;
string name = clipboard.Name;
if (String.IsNullOrEmpty(name))
name = "UNNAMED";
AddTag(clipboard.Node, MakeUniqueName(name));
return true;
}
public override bool IsNamedContainer
{
get { return true; }
}
public override INamedTagContainer NamedTagContainer
{
get { return _container; }
}
public override int TagCount
{
get { return _container.TagCount; }
}
public override bool DeleteTag (TagNode tag)
{
return _container.DeleteTag(tag);
}
private void AddTag (TagNode tag, string name)
{
_container.AddTag(tag, name);
if (IsExpanded) {
TagDataNode node = TagDataNode.CreateFromTag(tag);
if (node != null)
Nodes.Add(node);
}
}
private string MakeUniqueName (string name)
{
List<string> names = new List<string>(_container.TagNamesInUse);
if (!names.Contains(name))
return name;
int index = 1;
while (names.Contains(MakeCandidateName(name, index)))
index++;
return MakeCandidateName(name, index);
}
private string MakeCandidateName (string name, int index)
{
return name + " (Copy " + index + ")";
}
}
}

View file

@ -0,0 +1,36 @@
using System.Collections.Generic;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public interface ITagContainer
{
int TagCount { get; }
bool DeleteTag (TagNode tag);
}
public interface IMetaTagContainer : ITagContainer
{
bool IsNamedContainer { get; }
bool IsOrderedContainer { get; }
INamedTagContainer NamedTagContainer { get; }
IOrderedTagContainer OrderedTagContainer { get; }
}
public interface INamedTagContainer : ITagContainer
{
IEnumerable<string> TagNamesInUse { get; }
string GetTagName (TagNode tag);
bool AddTag (TagNode tag, string name);
bool RenameTag (TagNode tag, string name);
}
public interface IOrderedTagContainer : ITagContainer
{
int GetTagIndex (TagNode tag);
bool InsertTag (TagNode tag, int index);
}
}

433
Model/TagDataNode.cs Normal file
View file

@ -0,0 +1,433 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public abstract class TagDataNode : DataNode
{
public abstract class Container : TagDataNode, IMetaTagContainer
{
protected Container (TagNode tag)
: base(tag)
{ }
#region ITagContainer
public virtual int TagCount
{
get { return 0; }
}
public virtual bool IsNamedContainer
{
get { return false; }
}
public virtual bool IsOrderedContainer
{
get { return false; }
}
public virtual INamedTagContainer NamedTagContainer
{
get { return null; }
}
public virtual IOrderedTagContainer OrderedTagContainer
{
get { return null; }
}
public virtual bool DeleteTag (TagNode tag)
{
return false;
}
#endregion
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.Copy
| NodeCapabilities.CreateTag
| NodeCapabilities.Cut
| NodeCapabilities.Delete
| NodeCapabilities.PasteInto
| (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None)
| NodeCapabilities.Search;
}
}
public override bool HasUnexpandedChildren
{
get { return !IsExpanded && TagCount > 0; }
}
public override string NodeDisplay
{
get { return NodeDisplayPrefix + TagCount + ((TagCount == 1) ? " entry" : " entries"); }
}
}
private static Dictionary<TagType, Type> _tagRegistry;
static TagDataNode ()
{
_tagRegistry = new Dictionary<TagType, Type>();
_tagRegistry[TagType.TAG_BYTE] = typeof(TagByteDataNode);
_tagRegistry[TagType.TAG_BYTE_ARRAY] = typeof(TagByteArrayDataNode);
_tagRegistry[TagType.TAG_COMPOUND] = typeof(TagCompoundDataNode);
_tagRegistry[TagType.TAG_DOUBLE] = typeof(TagDoubleDataNode);
_tagRegistry[TagType.TAG_FLOAT] = typeof(TagFloatDataNode);
_tagRegistry[TagType.TAG_INT] = typeof(TagIntDataNode);
_tagRegistry[TagType.TAG_INT_ARRAY] = typeof(TagIntArrayDataNode);
_tagRegistry[TagType.TAG_LIST] = typeof(TagListDataNode);
_tagRegistry[TagType.TAG_LONG] = typeof(TagLongDataNode);
_tagRegistry[TagType.TAG_SHORT] = typeof(TagShortDataNode);
_tagRegistry[TagType.TAG_STRING] = typeof(TagStringDataNode);
}
static public TagDataNode CreateFromTag (TagNode tag)
{
if (tag == null || !_tagRegistry.ContainsKey(tag.GetTagType()))
return null;
return Activator.CreateInstance(_tagRegistry[tag.GetTagType()], tag) as TagDataNode;
}
static public TagNode DefaultTag (TagType type)
{
switch (type) {
case TagType.TAG_BYTE:
return new TagNodeByte(0);
case TagType.TAG_BYTE_ARRAY:
return new TagNodeByteArray(new byte[0]);
case TagType.TAG_COMPOUND:
return new TagNodeCompound();
case TagType.TAG_DOUBLE:
return new TagNodeDouble(0);
case TagType.TAG_FLOAT:
return new TagNodeFloat(0);
case TagType.TAG_INT:
return new TagNodeInt(0);
case TagType.TAG_INT_ARRAY:
return new TagNodeIntArray(new int[0]);
case TagType.TAG_LIST:
return new TagNodeList(TagType.TAG_BYTE);
case TagType.TAG_LONG:
return new TagNodeLong(0);
case TagType.TAG_SHORT:
return new TagNodeShort(0);
case TagType.TAG_STRING:
return new TagNodeString("");
default:
return new TagNodeByte(0);
}
}
private TagNode _tag;
protected TagDataNode (TagNode tag)
{
_tag = tag;
}
protected IMetaTagContainer TagParent
{
get { return base.Parent as IMetaTagContainer; }
}
protected TagNode Tag
{
get { return _tag; }
set
{
if (_tag.GetTagType() == value.GetTagType())
_tag = value;
}
}
protected override NodeCapabilities Capabilities
{
get
{
return NodeCapabilities.Copy
| NodeCapabilities.Cut
| NodeCapabilities.Delete
| NodeCapabilities.Edit
| (TagParent.IsNamedContainer ? NodeCapabilities.Rename : NodeCapabilities.None);
}
}
public override string NodeName
{
get
{
if (TagParent == null || !TagParent.IsNamedContainer)
return null;
return TagParent.NamedTagContainer.GetTagName(Tag);
}
}
protected string NodeDisplayPrefix
{
get
{
string name = NodeName;
return String.IsNullOrEmpty(name) ? "" : name + ": ";
}
}
public override string NodeDisplay
{
get { return NodeDisplayPrefix + Tag.ToString(); }
}
public override bool DeleteNode ()
{
if (CanDeleteNode) {
TagParent.DeleteTag(Tag);
return Parent.Nodes.Remove(this);
}
return false;
}
public override bool RenameNode ()
{
if (CanRenameNode && TagParent.IsNamedContainer) {
EditName form = new EditName(TagParent.NamedTagContainer.GetTagName(Tag));
form.InvalidNames.AddRange(TagParent.NamedTagContainer.TagNamesInUse);
if (form.ShowDialog() == DialogResult.OK && form.IsModified) {
if (TagParent.NamedTagContainer.RenameTag(Tag, form.TagName)) {
IsModified = true;
return true;
}
}
}
return false;
}
public override bool CopyNode ()
{
if (CanCopyNode) {
NbtClipboardData clip = new NbtClipboardData(NodeName, Tag);
clip.CopyToClipboard();
return true;
}
return false;
}
public override bool CutNode ()
{
if (CanCutNode) {
NbtClipboardData clip = new NbtClipboardData(NodeName, Tag);
clip.CopyToClipboard();
TagParent.DeleteTag(Tag);
Parent.Nodes.Remove(this);
return true;
}
return false;
}
protected bool EditScalarValue (TagNode tag)
{
EditValue form = new EditValue(tag);
if (form.ShowDialog() == DialogResult.OK) {
IsModified = true;
return true;
}
else
return false;
}
protected bool EditStringValue (TagNode tag)
{
EditString form = new EditString(tag.ToTagString().Data);
if (form.ShowDialog() == DialogResult.OK) {
tag.ToTagString().Data = form.StringValue;
IsModified = true;
return true;
}
else
return false;
}
protected bool EditByteHexValue (TagNode tag)
{
HexEditor form = new HexEditor(NodeName, tag.ToTagByteArray().Data, 1);
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
Array.Copy(form.Data, tag.ToTagByteArray().Data, tag.ToTagByteArray().Length);
IsModified = true;
return true;
}
else
return false;
}
protected bool EditIntHexValue (TagNode tag)
{
TagNodeIntArray iatag = tag.ToTagIntArray();
byte[] data = new byte[iatag.Length * 4];
for (int i = 0; i < iatag.Length; i++) {
byte[] buf = BitConverter.GetBytes(iatag.Data[i]);
Array.Copy(buf, 0, data, 4 * i, 4);
}
HexEditor form = new HexEditor(NodeName, data, 4);
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
for (int i = 0; i < iatag.Length; i++) {
iatag.Data[i] = BitConverter.ToInt32(form.Data, i * 4);
}
IsModified = true;
return true;
}
else
return false;
}
}
public class TagByteDataNode : TagDataNode
{
public TagByteDataNode (TagNodeByte tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagShortDataNode : TagDataNode
{
public TagShortDataNode (TagNodeShort tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagIntDataNode : TagDataNode
{
public TagIntDataNode (TagNodeInt tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagLongDataNode : TagDataNode
{
public TagLongDataNode (TagNodeLong tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagFloatDataNode : TagDataNode
{
public TagFloatDataNode (TagNodeFloat tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagDoubleDataNode : TagDataNode
{
public TagDoubleDataNode (TagNodeDouble tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditScalarValue(Tag);
}
}
public class TagStringDataNode : TagDataNode
{
public TagStringDataNode (TagNodeString tag)
: base(tag)
{ }
public override bool EditNode ()
{
return EditStringValue(Tag);
}
public override string NodeDisplay
{
get { return NodeDisplayPrefix + Tag.ToString().Replace('\n', (char)0x00B6); }
}
}
public class TagByteArrayDataNode : TagDataNode
{
public TagByteArrayDataNode (TagNodeByteArray tag)
: base(tag)
{ }
protected new TagNodeByteArray Tag
{
get { return base.Tag as TagNodeByteArray; }
}
public override bool EditNode ()
{
return EditByteHexValue(Tag);
}
public override string NodeDisplay
{
get { return NodeDisplayPrefix + Tag.Data.Length + " bytes"; }
}
}
public class TagIntArrayDataNode : TagDataNode
{
public TagIntArrayDataNode (TagNodeIntArray tag)
: base(tag)
{ }
protected new TagNodeIntArray Tag
{
get { return base.Tag as TagNodeIntArray; }
}
public override bool EditNode ()
{
return EditIntHexValue(Tag);
}
public override string NodeDisplay
{
get { return NodeDisplayPrefix + Tag.Data.Length + " integers"; }
}
}
}

111
Model/TagListDataNode.cs Normal file
View file

@ -0,0 +1,111 @@
using System;
using Substrate.Nbt;
namespace NBTExplorer.Model
{
public class TagListDataNode : TagDataNode.Container
{
private ListTagContainer _container;
public TagListDataNode (TagNodeList tag)
: base(tag)
{
_container = new ListTagContainer(tag);
}
protected new TagNodeList Tag
{
get { return base.Tag as TagNodeList; }
set { base.Tag = value; }
}
protected override void ExpandCore ()
{
foreach (TagNode tag in Tag) {
TagDataNode node = TagDataNode.CreateFromTag(tag);
if (node != null)
Nodes.Add(node);
}
}
public override bool CanCreateTag (TagType type)
{
if (Tag.Count > 0)
return Tag.ValueType == type;
else
return Enum.IsDefined(typeof(TagType), type) && type != TagType.TAG_END;
}
public override bool CanPasteIntoNode
{
get
{
if (NbtClipboardData.ContainsData) {
TagNode node = NbtClipboardData.CopyFromClipboard().Node;
if (node != null && node.GetTagType() == Tag.ValueType)
return true;
}
return false;
}
}
public override bool CreateNode (TagType type)
{
if (!CanCreateTag(type))
return false;
if (Tag.Count == 0) {
Tag = new TagNodeList(type);
_container = new ListTagContainer(Tag);
}
AppendTag(TagDataNode.DefaultTag(type));
return true;
}
public override bool PasteNode ()
{
if (!CanPasteIntoNode)
return false;
NbtClipboardData clipboard = NbtClipboardData.CopyFromClipboard();
if (clipboard.Node == null)
return false;
AppendTag(clipboard.Node);
return true;
}
public override bool IsOrderedContainer
{
get { return true; }
}
public override IOrderedTagContainer OrderedTagContainer
{
get { return _container; }
}
public override int TagCount
{
get { return _container.TagCount; }
}
public override bool DeleteTag (TagNode tag)
{
return _container.DeleteTag(tag);
}
private void AppendTag (TagNode tag)
{
_container.InsertTag(tag, _container.TagCount);
if (IsExpanded) {
TagDataNode node = TagDataNode.CreateFromTag(tag);
if (node != null)
Nodes.Add(node);
}
}
}
}

View file

@ -10,9 +10,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NBTExplorer</RootNamespace>
<AssemblyName>NBTExplorer</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@ -49,6 +48,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IconRegistry.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="DataNode.cs" />
<Compile Include="Forms\About.cs">
<SubType>Form</SubType>
@ -98,6 +104,19 @@
<Compile Include="Forms\EditHex.Designer.cs">
<DependentUpon>EditHex.cs</DependentUpon>
</Compile>
<Compile Include="Model\CompoundTagContainer.cs" />
<Compile Include="Model\DataNode.cs" />
<Compile Include="Model\DataNodeCollection.cs" />
<Compile Include="Model\DirectoryDataNode.cs" />
<Compile Include="Model\ListTagContainer.cs" />
<Compile Include="Model\NbtFileDataNode.cs" />
<Compile Include="Model\NodeCapabilities.cs" />
<Compile Include="Model\RegionChunkDataNode.cs" />
<Compile Include="Model\RegionFileDataNode.cs" />
<Compile Include="Model\TagCompoundDataNode.cs" />
<Compile Include="Model\TagContainerInterface.cs" />
<Compile Include="Model\TagDataNode.cs" />
<Compile Include="Model\TagListDataNode.cs" />
<Compile Include="NbtClipboardData.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -122,6 +141,10 @@
<Compile Include="Vendor\Be.Windows.Forms.HexBox\MemoryDataBlock.cs" />
<Compile Include="Vendor\Be.Windows.Forms.HexBox\NativeMethods.cs" />
<Compile Include="Vendor\Be.Windows.Forms.HexBox\Util.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\About.resx">
<DependentUpon>About.cs</DependentUpon>
</EmbeddedResource>

View file

@ -14,7 +14,7 @@ namespace NBTExplorer
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new MainForm());
}
}
}

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.239
// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

View file

@ -1,3 +1,7 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
<startup>
<supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>

View file

@ -1,6 +1,6 @@
namespace NBTExplorer
{
partial class CreateNode
partial class CreateNodeForm
{
/// <summary>
/// Required designer variable.

View file

@ -9,7 +9,7 @@ using Substrate.Nbt;
namespace NBTExplorer
{
public partial class CreateNode : Form
public partial class CreateNodeForm : Form
{
private string _name;
private int _size;
@ -20,11 +20,11 @@ namespace NBTExplorer
private List<string> _invalidNames = new List<string>();
public CreateNode (TagType tagType)
public CreateNodeForm (TagType tagType)
: this(tagType, true)
{ }
public CreateNode (TagType tagType, bool hasName)
public CreateNodeForm (TagType tagType, bool hasName)
{
InitializeComponent();

View file

@ -10,6 +10,7 @@ namespace NBTExplorer
{
public partial class EditName : Form
{
private string _originalName;
private string _name;
private List<string> _invalidNames = new List<string>();
@ -18,6 +19,7 @@ namespace NBTExplorer
{
InitializeComponent();
_originalName = name;
_name = name;
_nameField.Text = _name;
@ -33,6 +35,11 @@ namespace NBTExplorer
get { return _invalidNames; }
}
public bool IsModified
{
get { return _name != _originalName; }
}
private void Apply ()
{
if (ValidateInput()) {
@ -54,7 +61,7 @@ namespace NBTExplorer
return false;
}
if (_invalidNames.Contains(text)) {
if (text != _originalName && _invalidNames.Contains(text)) {
MessageBox.Show("Duplicate name provided.");
return false;
}