forked from mirrors/NBTExplorer
Restructuring project to support separate command-line utility
This commit is contained in:
parent
a03537bb99
commit
d4ad1bd99a
61 changed files with 2186 additions and 162 deletions
|
@ -3,7 +3,7 @@
|
||||||
<Product Id="*"
|
<Product Id="*"
|
||||||
Name="NBTExplorer"
|
Name="NBTExplorer"
|
||||||
Language="1033"
|
Language="1033"
|
||||||
Version="2.6.1.0"
|
Version="2.7.0.0"
|
||||||
Manufacturer="Justin Aquadro"
|
Manufacturer="Justin Aquadro"
|
||||||
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
|
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
|
||||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
||||||
|
@ -81,6 +81,15 @@
|
||||||
<Component Id="C.NBTExplorer.visualelementsmanifest.xml" Guid="*">
|
<Component Id="C.NBTExplorer.visualelementsmanifest.xml" Guid="*">
|
||||||
<File Source="../Staging/Windows/NBTExplorer.visualelementsmanifest.xml" KeyPath="yes" />
|
<File Source="../Staging/Windows/NBTExplorer.visualelementsmanifest.xml" KeyPath="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component Id="C.NBTUtil.exe" Guid="*">
|
||||||
|
<File Source="../Staging/NBTUtil.exe" KeyPath="yes" />
|
||||||
|
</Component>
|
||||||
|
<Component Id="C.NBTUtil.exe.config" Guid="*">
|
||||||
|
<File Source="../Staging/NBTUtil.exe.config" KeyPath="yes" />
|
||||||
|
</Component>
|
||||||
|
<Component Id="C.NBTModel.dll" Guid="*">
|
||||||
|
<File Source="../Staging/NBTModel.dll" KeyPath="yes" />
|
||||||
|
</Component>
|
||||||
<Component Id="C.Substrate.dll" Guid="*">
|
<Component Id="C.Substrate.dll" Guid="*">
|
||||||
<File Source="../Staging/Substrate.dll" KeyPath="yes" />
|
<File Source="../Staging/Substrate.dll" KeyPath="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBTExplorerMac", "NBTExplor
|
||||||
EndProject
|
EndProject
|
||||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "NBTExplorer.Installer", "NBTExplorer.Installer\NBTExplorer.Installer.wixproj", "{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}"
|
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "NBTExplorer.Installer", "NBTExplorer.Installer\NBTExplorer.Installer.wixproj", "{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBTUtil", "NBTUtil\NBTUtil.csproj", "{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBTModel", "NBTModel\NBTModel.csproj", "{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
AppStore|Any CPU = AppStore|Any CPU
|
AppStore|Any CPU = AppStore|Any CPU
|
||||||
|
@ -71,6 +75,36 @@ Global
|
||||||
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|Mixed Platforms.Build.0 = Release|x86
|
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|x86.ActiveCfg = Release|x86
|
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|x86.ActiveCfg = Release|x86
|
||||||
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|x86.Build.0 = Release|x86
|
{A1566071-7CBB-4C54-AAE1-4B81B7715DB3}.Release|x86.Build.0 = Release|x86
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.AppStore|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.AppStore|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.AppStore|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.AppStore|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.AppStore|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.AppStore|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.AppStore|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.AppStore|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Substrate.Nbt;
|
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
|
||||||
{
|
|
||||||
public class TagDoubleDataNode : TagDataNode
|
|
||||||
{
|
|
||||||
public TagDoubleDataNode (TagNodeDouble tag)
|
|
||||||
: base(tag)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override bool EditNode ()
|
|
||||||
{
|
|
||||||
return EditScalarValue(Tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Substrate.Nbt;
|
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
|
||||||
{
|
|
||||||
public class TagFloatDataNode : TagDataNode
|
|
||||||
{
|
|
||||||
public TagFloatDataNode (TagNodeFloat tag)
|
|
||||||
: base(tag)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override bool EditNode ()
|
|
||||||
{
|
|
||||||
return EditScalarValue(Tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Substrate.Nbt;
|
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
|
||||||
{
|
|
||||||
public class TagIntDataNode : TagDataNode
|
|
||||||
{
|
|
||||||
public TagIntDataNode (TagNodeInt tag)
|
|
||||||
: base(tag)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override bool EditNode ()
|
|
||||||
{
|
|
||||||
return EditScalarValue(Tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Substrate.Nbt;
|
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
|
||||||
{
|
|
||||||
public class TagLongDataNode : TagDataNode
|
|
||||||
{
|
|
||||||
public TagLongDataNode (TagNodeLong tag)
|
|
||||||
: base(tag)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override bool EditNode ()
|
|
||||||
{
|
|
||||||
return EditScalarValue(Tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Substrate.Nbt;
|
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
|
||||||
{
|
|
||||||
public class TagShortDataNode : TagDataNode
|
|
||||||
{
|
|
||||||
public TagShortDataNode (TagNodeShort tag)
|
|
||||||
: base(tag)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override bool EditNode ()
|
|
||||||
{
|
|
||||||
return EditScalarValue(Tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -84,6 +84,9 @@
|
||||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Substrate, Version=1.3.8.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Substrate, Version=1.3.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
@ -98,12 +101,8 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controllers\ExplorerBarController.cs" />
|
<Compile Include="Controllers\ExplorerBarController.cs" />
|
||||||
<Compile Include="Controllers\NodeTreeController.cs" />
|
<Compile Include="Controllers\NodeTreeController.cs" />
|
||||||
<Compile Include="FormRegistry.cs" />
|
|
||||||
<Compile Include="Controllers\RuleTreeController.cs" />
|
<Compile Include="Controllers\RuleTreeController.cs" />
|
||||||
<Compile Include="Interop.cs" />
|
<Compile Include="Interop.cs" />
|
||||||
<Compile Include="Model\Search\SearchRule.cs" />
|
|
||||||
<Compile Include="NbtClipboardController.cs" />
|
|
||||||
<Compile Include="SnapshotList.cs" />
|
|
||||||
<Compile Include="Vendor\MultiSelectTreeView\MultiSelectTreeview.cs">
|
<Compile Include="Vendor\MultiSelectTreeView\MultiSelectTreeview.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -174,32 +173,6 @@
|
||||||
<Compile Include="Windows\EditHex.Designer.cs">
|
<Compile Include="Windows\EditHex.Designer.cs">
|
||||||
<DependentUpon>EditHex.cs</DependentUpon>
|
<DependentUpon>EditHex.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Model\CompoundTagContainer.cs" />
|
|
||||||
<Compile Include="Model\CubicRegionDataNode.cs" />
|
|
||||||
<Compile Include="Model\CubicRegionFile.cs" />
|
|
||||||
<Compile Include="Model\DataNode.cs" />
|
|
||||||
<Compile Include="Model\DataNodeCollection.cs" />
|
|
||||||
<Compile Include="Model\DirectoryDataNode.cs" />
|
|
||||||
<Compile Include="Model\FileTypeRegistry.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\TagByteArrayDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagByteDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagCompoundDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagContainerInterface.cs" />
|
|
||||||
<Compile Include="Model\TagDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagDoubleDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagFloatDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagIntArrayDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagIntDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagListDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagLongDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagShortDataNode.cs" />
|
|
||||||
<Compile Include="Model\TagStringDataNode.cs" />
|
|
||||||
<Compile Include="NbtClipboardData.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
@ -208,7 +181,6 @@
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SearchWorker.cs" />
|
<Compile Include="SearchWorker.cs" />
|
||||||
<Compile Include="Model\TagKey.cs" />
|
|
||||||
<Compile Include="Vendor\Be.Windows.Forms.HexBox\BuiltInContextMenu.cs">
|
<Compile Include="Vendor\Be.Windows.Forms.HexBox\BuiltInContextMenu.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -337,6 +309,12 @@
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NBTModel\NBTModel.csproj">
|
||||||
|
<Project>{20d7cba3-5b6d-40b0-8d28-4c9a58e4ffbc}</Project>
|
||||||
|
<Name>NBTModel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace NBTExplorer
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main ()
|
static void Main (string[] args)
|
||||||
{
|
{
|
||||||
Application.ThreadException += AppThreadFailureHandler;
|
Application.ThreadException += AppThreadFailureHandler;
|
||||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("NBTExplorer")]
|
[assembly: AssemblyProduct("NBTExplorer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Justin Aquadro 2011-2012")]
|
[assembly: AssemblyCopyright("Copyright © Justin Aquadro 2011-2014")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.6.2.0")]
|
[assembly: AssemblyVersion("2.7.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2.6.2.0")]
|
[assembly: AssemblyFileVersion("2.7.0.0")]
|
||||||
|
|
2
NBTExplorer/Windows/About.Designer.cs
generated
2
NBTExplorer/Windows/About.Designer.cs
generated
|
@ -43,7 +43,7 @@
|
||||||
this.linkLabel1.Size = new System.Drawing.Size(256, 133);
|
this.linkLabel1.Size = new System.Drawing.Size(256, 133);
|
||||||
this.linkLabel1.TabIndex = 0;
|
this.linkLabel1.TabIndex = 0;
|
||||||
this.linkLabel1.TabStop = true;
|
this.linkLabel1.TabStop = true;
|
||||||
this.linkLabel1.Text = "NBTExplorer\r\nCopyright ©2011-2013 Justin Aquadro\r\n\r\nNBTExplorer is based on NBTEd" +
|
this.linkLabel1.Text = "NBTExplorer\r\nCopyright ©2011-2014 Justin Aquadro\r\n\r\nNBTExplorer is based on NBTEd" +
|
||||||
"it by copyboy\r\nFugue icon set: p.yusukekamiyamane.com\r\n\r\nEmail: jaquadro@gmail.c" +
|
"it by copyboy\r\nFugue icon set: p.yusukekamiyamane.com\r\n\r\nEmail: jaquadro@gmail.c" +
|
||||||
"om\r\nNBTExplorer Github Project Page";
|
"om\r\nNBTExplorer Github Project Page";
|
||||||
this.linkLabel1.UseCompatibleTextRendering = true;
|
this.linkLabel1.UseCompatibleTextRendering = true;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using NBTModel.Interop;
|
||||||
|
|
||||||
namespace NBTExplorer.Windows
|
namespace NBTExplorer.Windows
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@ using NBTExplorer.Controllers;
|
||||||
namespace NBTExplorer.Windows
|
namespace NBTExplorer.Windows
|
||||||
{
|
{
|
||||||
using Predicates = NodeTreeController.Predicates;
|
using Predicates = NodeTreeController.Predicates;
|
||||||
|
using NBTModel.Interop;
|
||||||
|
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using NBTModel.Interop;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer.Windows
|
namespace NBTExplorer.Windows
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NBTModel.Interop;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
{
|
{
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NBTExplorer.Utility;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer
|
namespace NBTModel.Interop
|
||||||
{
|
{
|
||||||
public static class FormRegistry
|
public static class FormRegistry
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NBTExplorer
|
namespace NBTModel.Interop
|
||||||
{
|
{
|
||||||
public static class NbtClipboardController
|
public static class NbtClipboardController
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer
|
namespace NBTModel.Interop
|
||||||
{
|
{
|
||||||
public class NbtClipboardData
|
public class NbtClipboardData
|
||||||
{
|
{
|
66
NBTModel/ListTagContainer.cs
Normal file
66
NBTModel/ListTagContainer.cs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
using System;
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class ListTagContainer : IOrderedTagContainer
|
||||||
|
{
|
||||||
|
private TagNodeList _tag;
|
||||||
|
private Action<bool> _modifyHandler;
|
||||||
|
|
||||||
|
public ListTagContainer (TagNodeList tag, Action<bool> modifyHandler)
|
||||||
|
{
|
||||||
|
_tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TagCount
|
||||||
|
{
|
||||||
|
get { return _tag.Count; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteTag (TagNode tag)
|
||||||
|
{
|
||||||
|
bool result = _tag.Remove(tag);
|
||||||
|
if (result)
|
||||||
|
SetModified();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetTagIndex (TagNode tag)
|
||||||
|
{
|
||||||
|
return _tag.IndexOf(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool InsertTag (TagNode tag, int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index > _tag.Count)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_tag.ValueType != tag.GetTagType())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_tag.Insert(index, tag);
|
||||||
|
|
||||||
|
SetModified();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AppendTag (TagNode tag)
|
||||||
|
{
|
||||||
|
if (_tag.ValueType != tag.GetTagType())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_tag.Add(tag);
|
||||||
|
|
||||||
|
SetModified();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetModified ()
|
||||||
|
{
|
||||||
|
if (_modifyHandler != null)
|
||||||
|
_modifyHandler(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
NBTModel/NBTModel.csproj
Normal file
83
NBTModel/NBTModel.csproj
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{20D7CBA3-5B6D-40B0-8D28-4C9A58E4FFBC}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NBTExplorer.Model</RootNamespace>
|
||||||
|
<AssemblyName>NBTModel</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Substrate">
|
||||||
|
<HintPath>..\References\Substrate.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CompoundTagContainer.cs" />
|
||||||
|
<Compile Include="CubicRegionDataNode.cs" />
|
||||||
|
<Compile Include="CubicRegionFile.cs" />
|
||||||
|
<Compile Include="DataNode.cs" />
|
||||||
|
<Compile Include="DataNodeCollection.cs" />
|
||||||
|
<Compile Include="DirectoryDataNode.cs" />
|
||||||
|
<Compile Include="FileTypeRegistry.cs" />
|
||||||
|
<Compile Include="Interop\FormRegistry.cs" />
|
||||||
|
<Compile Include="Interop\NbtClipboardController.cs" />
|
||||||
|
<Compile Include="Interop\NbtClipboardData.cs" />
|
||||||
|
<Compile Include="ListTagContainer.cs" />
|
||||||
|
<Compile Include="NbtFileDataNode.cs" />
|
||||||
|
<Compile Include="NodeCapabilities.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="RegionChunkDataNode.cs" />
|
||||||
|
<Compile Include="RegionFileDataNode.cs" />
|
||||||
|
<Compile Include="Search\SearchRule.cs" />
|
||||||
|
<Compile Include="TagByteArrayDataNode.cs" />
|
||||||
|
<Compile Include="TagByteDataNode.cs" />
|
||||||
|
<Compile Include="TagCompoundDataNode.cs" />
|
||||||
|
<Compile Include="TagContainerInterface.cs" />
|
||||||
|
<Compile Include="TagDataNode.cs" />
|
||||||
|
<Compile Include="TagDoubleDataNode.cs" />
|
||||||
|
<Compile Include="TagFloatDataNode.cs" />
|
||||||
|
<Compile Include="TagIntArrayDataNode.cs" />
|
||||||
|
<Compile Include="TagIntDataNode.cs" />
|
||||||
|
<Compile Include="TagKey.cs" />
|
||||||
|
<Compile Include="TagListDataNode.cs" />
|
||||||
|
<Compile Include="TagLongDataNode.cs" />
|
||||||
|
<Compile Include="TagShortDataNode.cs" />
|
||||||
|
<Compile Include="TagStringDataNode.cs" />
|
||||||
|
<Compile Include="Utility\SnapshotList.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -4,6 +4,7 @@ using Substrate.Core;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
using NBTModel.Interop;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
{
|
{
|
36
NBTModel/Properties/AssemblyInfo.cs
Normal file
36
NBTModel/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("NBTModel")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("NBTModel")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("0dd78c98-e4af-4898-a0f5-4ea5675933c8")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Substrate.Core;
|
using Substrate.Core;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NBTModel.Interop;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
{
|
{
|
|
@ -13,6 +13,18 @@ namespace NBTExplorer.Model
|
||||||
get { return base.Tag as TagNodeByte; }
|
get { return base.Tag as TagNodeByte; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
byte data;
|
||||||
|
if (!byte.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool EditNode ()
|
public override bool EditNode ()
|
||||||
{
|
{
|
||||||
return EditScalarValue(Tag);
|
return EditScalarValue(Tag);
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NBTModel.Interop;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
|
@ -36,5 +36,6 @@ namespace NBTExplorer.Model
|
||||||
{
|
{
|
||||||
int GetTagIndex (TagNode tag);
|
int GetTagIndex (TagNode tag);
|
||||||
bool InsertTag (TagNode tag, int index);
|
bool InsertTag (TagNode tag, int index);
|
||||||
|
bool AppendTag (TagNode tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NBTModel.Interop;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
|
@ -44,6 +45,9 @@ namespace NBTExplorer.Model
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void Clear ()
|
||||||
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected override NodeCapabilities Capabilities
|
protected override NodeCapabilities Capabilities
|
||||||
|
@ -155,6 +159,11 @@ namespace NBTExplorer.Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool Parse (string value)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected override NodeCapabilities Capabilities
|
protected override NodeCapabilities Capabilities
|
||||||
{
|
{
|
||||||
get
|
get
|
33
NBTModel/TagDoubleDataNode.cs
Normal file
33
NBTModel/TagDoubleDataNode.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class TagDoubleDataNode : TagDataNode
|
||||||
|
{
|
||||||
|
public TagDoubleDataNode (TagNodeDouble tag)
|
||||||
|
: base(tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeDouble Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeDouble; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
double data;
|
||||||
|
if (!double.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EditNode ()
|
||||||
|
{
|
||||||
|
return EditScalarValue(Tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
NBTModel/TagFloatDataNode.cs
Normal file
33
NBTModel/TagFloatDataNode.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class TagFloatDataNode : TagDataNode
|
||||||
|
{
|
||||||
|
public TagFloatDataNode (TagNodeFloat tag)
|
||||||
|
: base(tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeFloat Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeFloat; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
float data;
|
||||||
|
if (!float.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EditNode ()
|
||||||
|
{
|
||||||
|
return EditScalarValue(Tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
NBTModel/TagIntDataNode.cs
Normal file
33
NBTModel/TagIntDataNode.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class TagIntDataNode : TagDataNode
|
||||||
|
{
|
||||||
|
public TagIntDataNode (TagNodeInt tag)
|
||||||
|
: base(tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeInt Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeInt; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
if (!int.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EditNode ()
|
||||||
|
{
|
||||||
|
return EditScalarValue(Tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using NBTModel.Interop;
|
||||||
using Substrate.Nbt;
|
using Substrate.Nbt;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
|
@ -10,10 +11,10 @@ namespace NBTExplorer.Model
|
||||||
public TagListDataNode (TagNodeList tag)
|
public TagListDataNode (TagNodeList tag)
|
||||||
: base(tag)
|
: base(tag)
|
||||||
{
|
{
|
||||||
_container = new ListTagContainer(tag);
|
_container = new ListTagContainer(tag, res => IsDataModified = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected new TagNodeList Tag
|
public new TagNodeList Tag
|
||||||
{
|
{
|
||||||
get { return base.Tag as TagNodeList; }
|
get { return base.Tag as TagNodeList; }
|
||||||
set { base.Tag = value; }
|
set { base.Tag = value; }
|
||||||
|
@ -99,8 +100,22 @@ namespace NBTExplorer.Model
|
||||||
return _container.DeleteTag(tag);
|
return _container.DeleteTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendTag (TagNode tag)
|
public override void Clear ()
|
||||||
{
|
{
|
||||||
|
if (TagCount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Nodes.Clear();
|
||||||
|
Tag.Clear();
|
||||||
|
|
||||||
|
IsDataModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AppendTag (TagNode tag)
|
||||||
|
{
|
||||||
|
if (tag == null || !CanCreateTag(tag.GetTagType()))
|
||||||
|
return false;
|
||||||
|
|
||||||
_container.InsertTag(tag, _container.TagCount);
|
_container.InsertTag(tag, _container.TagCount);
|
||||||
IsDataModified = true;
|
IsDataModified = true;
|
||||||
|
|
||||||
|
@ -109,6 +124,8 @@ namespace NBTExplorer.Model
|
||||||
if (node != null)
|
if (node != null)
|
||||||
Nodes.Add(node);
|
Nodes.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
33
NBTModel/TagLongDataNode.cs
Normal file
33
NBTModel/TagLongDataNode.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class TagLongDataNode : TagDataNode
|
||||||
|
{
|
||||||
|
public TagLongDataNode (TagNodeLong tag)
|
||||||
|
: base(tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeLong Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeLong; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
long data;
|
||||||
|
if (!long.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EditNode ()
|
||||||
|
{
|
||||||
|
return EditScalarValue(Tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
NBTModel/TagShortDataNode.cs
Normal file
33
NBTModel/TagShortDataNode.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
public class TagShortDataNode : TagDataNode
|
||||||
|
{
|
||||||
|
public TagShortDataNode (TagNodeShort tag)
|
||||||
|
: base(tag)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeShort Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeShort; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
short data;
|
||||||
|
if (!short.TryParse(value, out data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Tag.Data = data;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EditNode ()
|
||||||
|
{
|
||||||
|
return EditScalarValue(Tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,19 @@ namespace NBTExplorer.Model
|
||||||
: base(tag)
|
: base(tag)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
protected new TagNodeString Tag
|
||||||
|
{
|
||||||
|
get { return base.Tag as TagNodeString; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Parse (string value)
|
||||||
|
{
|
||||||
|
Tag.Data = value;
|
||||||
|
IsDataModified = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool EditNode ()
|
public override bool EditNode ()
|
||||||
{
|
{
|
||||||
return EditStringValue(Tag);
|
return EditStringValue(Tag);
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace NBTExplorer
|
namespace NBTExplorer.Utility
|
||||||
{
|
{
|
||||||
public class SnapshotState<T> : IDisposable
|
public class SnapshotState<T> : IDisposable
|
||||||
{
|
{
|
6
NBTUtil/App.config
Normal file
6
NBTUtil/App.config
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
|
||||||
|
<supportedRuntime version="v2.0.50727"/></startup>
|
||||||
|
</configuration>
|
76
NBTUtil/ConsoleOptions.cs
Normal file
76
NBTUtil/ConsoleOptions.cs
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NDesk.Options;
|
||||||
|
|
||||||
|
namespace NBTUtil
|
||||||
|
{
|
||||||
|
public enum ConsoleCommand
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Print,
|
||||||
|
PrintTree,
|
||||||
|
SetValue,
|
||||||
|
SetList,
|
||||||
|
Help,
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConsoleOptions
|
||||||
|
{
|
||||||
|
private OptionSet _options;
|
||||||
|
private string _currentKey;
|
||||||
|
|
||||||
|
//public string FilePath { get; private set; }
|
||||||
|
//public string TagPath { get; private set; }
|
||||||
|
public string Path { get; private set; }
|
||||||
|
|
||||||
|
public ConsoleCommand Command { get; private set; }
|
||||||
|
public List<string> Values { get; private set; }
|
||||||
|
public bool ShowTypes { get; private set; }
|
||||||
|
|
||||||
|
public ConsoleOptions ()
|
||||||
|
{
|
||||||
|
Command = ConsoleCommand.None;
|
||||||
|
Values = new List<string>();
|
||||||
|
|
||||||
|
_options = new OptionSet() {
|
||||||
|
{ "path=", "Path to NBT tag from current directory", v => Path = v },
|
||||||
|
{ "print", "Print the value(s) of a tag", v => Command = ConsoleCommand.Print },
|
||||||
|
{ "printtree", "Print the NBT tree rooted at a tag", v => Command = ConsoleCommand.PrintTree },
|
||||||
|
{ "types", "Show data types when printing tags", v => ShowTypes = true },
|
||||||
|
{ "setvalue=", "Set a single tag value", v => {
|
||||||
|
Command = ConsoleCommand.SetValue;
|
||||||
|
_currentKey = "setvalue";
|
||||||
|
if (!string.IsNullOrEmpty(v))
|
||||||
|
Values.Add(v);
|
||||||
|
}},
|
||||||
|
{ "setlist=", "Replace a list tag's contents with one or more values.", v => {
|
||||||
|
Command = ConsoleCommand.SetList;
|
||||||
|
_currentKey = "setlist";
|
||||||
|
if (!string.IsNullOrEmpty(v))
|
||||||
|
Values.Add(v);
|
||||||
|
}},
|
||||||
|
{ "help", "Print this help message", v => Command = ConsoleCommand.Help },
|
||||||
|
{ "<>", v => {
|
||||||
|
switch (_currentKey) {
|
||||||
|
case "setvalue":
|
||||||
|
case "setlist":
|
||||||
|
Values.Add(v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Parse (string[] args)
|
||||||
|
{
|
||||||
|
_options.Parse(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrintUsage ()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Program Options:");
|
||||||
|
_options.WriteOptionDescriptions(Console.Out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
181
NBTUtil/ConsoleRunner.cs
Normal file
181
NBTUtil/ConsoleRunner.cs
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
using NBTUtil.Ops;
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTUtil
|
||||||
|
{
|
||||||
|
class ConsoleRunner
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<ConsoleCommand, ConsoleOperation> _commandTable = new Dictionary<ConsoleCommand, ConsoleOperation>() {
|
||||||
|
{ ConsoleCommand.SetValue, new EditOperation() },
|
||||||
|
{ ConsoleCommand.SetList, new SetListOperation() },
|
||||||
|
{ ConsoleCommand.Print, new PrintOperation() },
|
||||||
|
{ ConsoleCommand.PrintTree, new PrintTreeOperation() },
|
||||||
|
};
|
||||||
|
|
||||||
|
private ConsoleOptions _options;
|
||||||
|
|
||||||
|
public ConsoleRunner ()
|
||||||
|
{
|
||||||
|
_options = new ConsoleOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Run (string[] args)
|
||||||
|
{
|
||||||
|
_options.Parse(args);
|
||||||
|
|
||||||
|
if (_options.Command == ConsoleCommand.Help)
|
||||||
|
return PrintHelp();
|
||||||
|
|
||||||
|
if (_options.Path == null)
|
||||||
|
return PrintUsage("Error: You must specify a path");
|
||||||
|
if (!_commandTable.ContainsKey(_options.Command))
|
||||||
|
return PrintUsage("Error: No command specified");
|
||||||
|
|
||||||
|
NbtPath path = new NbtPath(_options.Path);
|
||||||
|
DataNode targetNode = path.Open();
|
||||||
|
|
||||||
|
if (targetNode == null)
|
||||||
|
return PrintError("Error: Invalid path");
|
||||||
|
|
||||||
|
ConsoleOperation op = _commandTable[_options.Command];
|
||||||
|
if (!op.OptionsValid(_options))
|
||||||
|
return PrintError("Error: Invalid options specified for the given command");
|
||||||
|
if (!op.CanProcess(targetNode))
|
||||||
|
return PrintError("Error: The given command can't be applied to the given tag");
|
||||||
|
if (!op.Process(targetNode, _options))
|
||||||
|
return PrintError("Error: Problem encountered applying the given command");
|
||||||
|
|
||||||
|
path.RootNode.Save();
|
||||||
|
|
||||||
|
Console.WriteLine("The operation completed successfully");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataNode OpenFile (string path)
|
||||||
|
{
|
||||||
|
DataNode node = null;
|
||||||
|
foreach (var item in FileTypeRegistry.RegisteredTypes) {
|
||||||
|
if (item.Value.NamePatternTest(path))
|
||||||
|
node = item.Value.NodeCreate(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataNode ExpandDataNode (DataNode dataNode, string tagPath)
|
||||||
|
{
|
||||||
|
string[] pathParts = tagPath.Split('/');
|
||||||
|
|
||||||
|
DataNode curTag = dataNode;
|
||||||
|
curTag.Expand();
|
||||||
|
|
||||||
|
foreach (var part in pathParts) {
|
||||||
|
TagDataNode.Container container = curTag as TagDataNode.Container;
|
||||||
|
if (curTag == null)
|
||||||
|
throw new Exception("Invalid tag path");
|
||||||
|
|
||||||
|
DataNode childTag = null;
|
||||||
|
foreach (var child in curTag.Nodes) {
|
||||||
|
if (child.NodePathName == part)
|
||||||
|
childTag = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childTag == null)
|
||||||
|
throw new Exception("Invalid tag path");
|
||||||
|
|
||||||
|
curTag.Expand();
|
||||||
|
}
|
||||||
|
|
||||||
|
return curTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool PrintHelp ()
|
||||||
|
{
|
||||||
|
Console.WriteLine("NBTUtil - Copyright 2014 Justin Aquadro");
|
||||||
|
_options.PrintUsage();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool PrintUsage (string error)
|
||||||
|
{
|
||||||
|
Console.WriteLine(error);
|
||||||
|
_options.PrintUsage();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool PrintError (string error)
|
||||||
|
{
|
||||||
|
Console.WriteLine(error);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NbtPath
|
||||||
|
{
|
||||||
|
private class PathPart
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public DataNode Node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PathPart> _pathParts = new List<PathPart>();
|
||||||
|
|
||||||
|
public NbtPath (string path)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
|
||||||
|
string[] parts = path.Split('/', '\\');
|
||||||
|
foreach (var p in parts) {
|
||||||
|
_pathParts.Add(new PathPart() {
|
||||||
|
Name = p,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Path { get; private set; }
|
||||||
|
|
||||||
|
public DataNode RootNode
|
||||||
|
{
|
||||||
|
get { return (_pathParts.Count == 0) ? null : _pathParts[0].Node; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataNode TargetNode
|
||||||
|
{
|
||||||
|
get { return (_pathParts.Count == 0) ? null : _pathParts[_pathParts.Count - 1].Node; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataNode Open ()
|
||||||
|
{
|
||||||
|
DataNode dataNode = new DirectoryDataNode(Directory.GetCurrentDirectory());
|
||||||
|
dataNode.Expand();
|
||||||
|
|
||||||
|
foreach (var part in _pathParts) {
|
||||||
|
DataNode match = null;
|
||||||
|
foreach (var child in dataNode.Nodes) {
|
||||||
|
if (child.NodePathName == part.Name)
|
||||||
|
match = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
part.Node = match;
|
||||||
|
|
||||||
|
dataNode = match;
|
||||||
|
dataNode.Expand();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
NBTUtil/NBTUtil.csproj
Normal file
81
NBTUtil/NBTUtil.csproj
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{BD90EED5-97B9-47D5-AFEA-C2C0D0E59FCF}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NBTUtil</RootNamespace>
|
||||||
|
<AssemblyName>NBTUtil</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Substrate">
|
||||||
|
<HintPath>..\References\Substrate.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ConsoleOptions.cs" />
|
||||||
|
<Compile Include="ConsoleRunner.cs" />
|
||||||
|
<Compile Include="NDesk\Options.cs" />
|
||||||
|
<Compile Include="Ops\ConsoleOperation.cs" />
|
||||||
|
<Compile Include="Ops\EditOperation.cs" />
|
||||||
|
<Compile Include="Ops\PrintOperation.cs" />
|
||||||
|
<Compile Include="Ops\PrintTreeOperation.cs" />
|
||||||
|
<Compile Include="Ops\SetListOperation.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TypePrinter.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NBTModel\NBTModel.csproj">
|
||||||
|
<Project>{20d7cba3-5b6d-40b0-8d28-4c9a58e4ffbc}</Project>
|
||||||
|
<Name>NBTModel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
<ItemGroup>
|
||||||
|
<Staging Include="$(OutputPath)\**\*.dll" />
|
||||||
|
<Staging Include="$(OutputPath)\**\*.exe" />
|
||||||
|
<Staging Include="$(OutputPath)\**\*.exe.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Copy SourceFiles="@(Staging)" DestinationFolder="..\Staging\%(RecursiveDir)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
1123
NBTUtil/NDesk/Options.cs
Normal file
1123
NBTUtil/NDesk/Options.cs
Normal file
File diff suppressed because it is too large
Load diff
18
NBTUtil/Ops/ConsoleOperation.cs
Normal file
18
NBTUtil/Ops/ConsoleOperation.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
|
||||||
|
namespace NBTUtil.Ops
|
||||||
|
{
|
||||||
|
abstract class ConsoleOperation
|
||||||
|
{
|
||||||
|
public virtual bool OptionsValid (ConsoleOptions options)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract bool CanProcess (DataNode dataNode);
|
||||||
|
public abstract bool Process (DataNode dataNode, ConsoleOptions options);
|
||||||
|
}
|
||||||
|
}
|
35
NBTUtil/Ops/EditOperation.cs
Normal file
35
NBTUtil/Ops/EditOperation.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
|
||||||
|
namespace NBTUtil.Ops
|
||||||
|
{
|
||||||
|
class EditOperation : ConsoleOperation
|
||||||
|
{
|
||||||
|
public override bool OptionsValid (ConsoleOptions options)
|
||||||
|
{
|
||||||
|
if (options.Values.Count == 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanProcess (DataNode dataNode)
|
||||||
|
{
|
||||||
|
if (!(dataNode is TagDataNode) || !dataNode.CanEditNode)
|
||||||
|
return false;
|
||||||
|
if (dataNode is TagByteArrayDataNode || dataNode is TagIntArrayDataNode)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
||||||
|
{
|
||||||
|
string value = options.Values[0];
|
||||||
|
|
||||||
|
TagDataNode tagDataNode = dataNode as TagDataNode;
|
||||||
|
return tagDataNode.Parse(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
NBTUtil/Ops/PrintOperation.cs
Normal file
27
NBTUtil/Ops/PrintOperation.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
|
||||||
|
namespace NBTUtil.Ops
|
||||||
|
{
|
||||||
|
class PrintOperation : ConsoleOperation
|
||||||
|
{
|
||||||
|
public override bool CanProcess (DataNode dataNode)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
||||||
|
{
|
||||||
|
Console.WriteLine(TypePrinter.Print(dataNode, options.ShowTypes));
|
||||||
|
|
||||||
|
if (dataNode.IsContainerType) {
|
||||||
|
foreach (var child in dataNode.Nodes)
|
||||||
|
Console.WriteLine(" | " + TypePrinter.Print(child, options.ShowTypes));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
NBTUtil/Ops/PrintTreeOperation.cs
Normal file
36
NBTUtil/Ops/PrintTreeOperation.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
|
||||||
|
namespace NBTUtil.Ops
|
||||||
|
{
|
||||||
|
class PrintTreeOperation : ConsoleOperation
|
||||||
|
{
|
||||||
|
public override bool CanProcess (DataNode dataNode)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
||||||
|
{
|
||||||
|
PrintSubTree(dataNode, options, "", true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrintSubTree (DataNode dataNode, ConsoleOptions options, string indent, bool last)
|
||||||
|
{
|
||||||
|
Console.WriteLine(indent + " + " + TypePrinter.Print(dataNode, options.ShowTypes));
|
||||||
|
|
||||||
|
indent += last ? " " : " |";
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
dataNode.Expand();
|
||||||
|
foreach (DataNode child in dataNode.Nodes) {
|
||||||
|
cnt++;
|
||||||
|
PrintSubTree(child, options, indent, cnt == dataNode.Nodes.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
NBTUtil/Ops/SetListOperation.cs
Normal file
37
NBTUtil/Ops/SetListOperation.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
using Substrate.Nbt;
|
||||||
|
|
||||||
|
namespace NBTUtil.Ops
|
||||||
|
{
|
||||||
|
class SetListOperation : ConsoleOperation
|
||||||
|
{
|
||||||
|
public override bool CanProcess (DataNode dataNode)
|
||||||
|
{
|
||||||
|
if (!(dataNode is TagListDataNode))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
||||||
|
{
|
||||||
|
TagListDataNode listNode = dataNode as TagListDataNode;
|
||||||
|
|
||||||
|
listNode.Clear();
|
||||||
|
foreach (string value in options.Values) {
|
||||||
|
TagNode tag = TagDataNode.DefaultTag(listNode.Tag.ValueType);
|
||||||
|
TagDataNode tagData = TagDataNode.CreateFromTag(tag);
|
||||||
|
if (!tagData.Parse(value))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!listNode.AppendTag(tagData.Tag))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
NBTUtil/Program.cs
Normal file
15
NBTUtil/Program.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NBTUtil
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main (string[] args)
|
||||||
|
{
|
||||||
|
ConsoleRunner runner = new ConsoleRunner();
|
||||||
|
runner.Run(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
NBTUtil/Properties/AssemblyInfo.cs
Normal file
36
NBTUtil/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("NBTUtil")]
|
||||||
|
[assembly: AssemblyDescription("A command-line utility to inspect and modify NBT data.")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("NBTUtil")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Justin Aquadro 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("14c36789-324a-4cbf-8cb4-1f2bd711a631")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
40
NBTUtil/TypePrinter.cs
Normal file
40
NBTUtil/TypePrinter.cs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using NBTExplorer.Model;
|
||||||
|
|
||||||
|
namespace NBTUtil
|
||||||
|
{
|
||||||
|
static class TypePrinter
|
||||||
|
{
|
||||||
|
private static Dictionary<Type, string> _key = new Dictionary<Type, string>() {
|
||||||
|
{ typeof(TagByteDataNode), "b" },
|
||||||
|
{ typeof(TagShortDataNode), "s" },
|
||||||
|
{ typeof(TagIntDataNode), "i" },
|
||||||
|
{ typeof(TagLongDataNode), "l" },
|
||||||
|
{ typeof(TagFloatDataNode), "f" },
|
||||||
|
{ typeof(TagDoubleDataNode), "d" },
|
||||||
|
{ typeof(TagStringDataNode), "T" },
|
||||||
|
{ typeof(TagByteArrayDataNode), "a" },
|
||||||
|
{ typeof(TagIntArrayDataNode), "A" },
|
||||||
|
{ typeof(TagListDataNode), "L" },
|
||||||
|
{ typeof(TagCompoundDataNode), "C" },
|
||||||
|
{ typeof(NbtFileDataNode), "N" },
|
||||||
|
{ typeof(RegionFileDataNode), "R" },
|
||||||
|
{ typeof(RegionChunkDataNode), "r" },
|
||||||
|
{ typeof(CubicRegionDataNode), "R" },
|
||||||
|
{ typeof(DirectoryDataNode), "/" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public static string Print (DataNode node, bool showType)
|
||||||
|
{
|
||||||
|
if (!_key.ContainsKey(node.GetType()))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (showType)
|
||||||
|
return "<" + _key[node.GetType()] + "> " + node.NodeDisplay;
|
||||||
|
else
|
||||||
|
return node.NodeDisplay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue