コード例 #1
0
ファイル: FindHeavy.cs プロジェクト: Xenation/NBTExplorer
        private void GatherAllRegions(DataNode rootNode, List <RegionFileDataNode> regions)
        {
            if (rootNode is DirectoryDataNode)
            {
                DirectoryDataNode dirNode = (DirectoryDataNode)rootNode;
                if (!dirNode.IsExpanded)
                {
                    dirNode.Expand();
                }

                foreach (DataNode subNode in dirNode.Nodes)
                {
                    if (subNode is RegionFileDataNode)
                    {
                        regions.Add((RegionFileDataNode)subNode);
                    }
                    else
                    {
                        GatherAllRegions(subNode, regions);
                    }
                }
            }
            else if (rootNode is RegionFileDataNode)
            {
                regions.Add((RegionFileDataNode)rootNode);
            }
        }
コード例 #2
0
 private static void ExitIfDirEmpty(DirectoryDataNode dir)
 {
     if (!dir.IsExpanded)
     {
         dir.Expand();
     }
     if (dir.Nodes.Count == 0)
     {
         Exit("Directory " + dir.NodeDirPath + " is empty.");
     }
 }
コード例 #3
0
 void _menuItemOpenInExplorer_Click(object sender, EventArgs e)
 {
     if (_nodeTree.SelectedNode.Tag is DirectoryDataNode)
     {
         DirectoryDataNode ddNode = _nodeTree.SelectedNode.Tag as DirectoryDataNode;
         try {
             string path = (!Interop.IsWindows ? "file://" : "") + ddNode.NodeDirPath;
             System.Diagnostics.Process.Start(path);
         } catch (Win32Exception ex) {
             MessageBox.Show(ex.Message, "そのディレクトリは開けません!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #4
0
 private void _contextOpenInExplorer_Click(object sender, EventArgs e)
 {
     if (_multiTree.SelectedNode != null && _multiTree.SelectedNode.Tag is DirectoryDataNode)
     {
         DirectoryDataNode ddNode = _multiTree.SelectedNode.Tag as DirectoryDataNode;
         try {
             string path = (!Interop.IsWindows ? "file://" : "") + ddNode.NodeDirPath;
             System.Diagnostics.Process.Start(path);
         }
         catch (Exception ex) {
             MessageBox.Show(ex.Message, "Can't open directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #5
0
        public int OpenPaths(string[] paths)
        {
            _nodeTree.Nodes.Clear();

            int failCount = 0;

            foreach (string path in paths)
            {
                if (Directory.Exists(path))
                {
                    DirectoryDataNode node = new DirectoryDataNode(path);
                    _nodeTree.Nodes.Add(CreateUnexpandedNode(node));
                }
                else if (File.Exists(path))
                {
                    DataNode node = null;
                    foreach (var item in FileTypeRegistry.RegisteredTypes)
                    {
                        if (item.Value.NamePatternTest(path))
                        {
                            node = item.Value.NodeCreate(path);
                        }
                    }

                    if (node == null)
                    {
                        node = NbtFileDataNode.TryCreateFrom(path);
                    }
                    if (node != null)
                    {
                        _nodeTree.Nodes.Add(CreateUnexpandedNode(node));
                    }
                    else
                    {
                        failCount++;
                    }
                }
            }

            if (_nodeTree.Nodes.Count > 0)
            {
                _nodeTree.Nodes[0].Expand();
            }

            OnSelectionInvalidated();

            return(failCount);
        }
コード例 #6
0
        private static DirectoryDataNode GetRegionDir(DirectoryDataNode worldDir)
        {
            var regionDir = worldDir.Nodes.FirstOrDefault(node => (node as DirectoryDataNode)?.NodePathName == "region") as DirectoryDataNode;

            if (regionDir is null)
            {
                Exit("Directory 'region' doesn't exist.");
            }
            else
            {
                Console.WriteLine("Found 'region' directory.");
            }

            ExitIfDirEmpty(regionDir);

            return(regionDir);
        }
コード例 #7
0
        private void OpenPaths(IEnumerable <string> paths)
        {
            _dataSource.Nodes.Clear();
            _mainOutlineView.ReloadData();

            foreach (string path in paths)
            {
                if (Directory.Exists(path))
                {
                    DirectoryDataNode node = new DirectoryDataNode(path);
                    _dataSource.Nodes.Add(new TreeDataNode(node));

                    // AddPathToHistory(Settings.Default.RecentDirectories, path);
                }
                else if (File.Exists(path))
                {
                    DataNode node = null;

                    foreach (var item in FileTypeRegistry.RegisteredTypes)
                    {
                        if (item.Value.NamePatternTest(path))
                        {
                            node = item.Value.NodeCreate(path);
                        }
                    }

                    if (node != null)
                    {
                        _dataSource.Nodes.Add(new TreeDataNode(node));
                        //AddPathToHistory(Settings.Default.RecentFiles, path);
                    }
                }
            }

            if (_dataSource.Nodes.Count > 0)
            {
                _mainOutlineView.ExpandItem(_dataSource.Nodes[0]);
            }

            _mainOutlineView.ReloadData();

            UpdateUI();
        }
コード例 #8
0
        private static DirectoryDataNode GetWorldDir()
        {
            bool isWin = (int)Environment.OSVersion.Platform < 4;

            Console.Write("Path to the world directory" + (isWin ? " (you can use environment variables)" : "") + ": ");
#if DEBUG
            string path = @"%appdata%\.minecraft\saves\New World-";
            Console.WriteLine(path);
#else
            string path = Console.ReadLine();
#endif
            if (isWin)
            {
                path = Environment.ExpandEnvironmentVariables(path);
            }

            var dir = new DirectoryDataNode(path);
            ExitIfDirEmpty(dir);

            return(dir);
        }
コード例 #9
0
ファイル: FindBlock.cs プロジェクト: phit/NBTExplorer
        private DataNode Search(DataNode node)
        {
            if (node is DirectoryDataNode)
            {
                DirectoryDataNode dirNode = node as DirectoryDataNode;
                if (!dirNode.IsExpanded)
                {
                    dirNode.Expand();
                }

                foreach (var subNode in dirNode.Nodes)
                {
                    DataNode resultNode = Search(subNode);
                    if (resultNode != null)
                    {
                        return(resultNode);
                    }
                }

                return(null);
            }
            else if (node is RegionFileDataNode)
            {
                RegionFileDataNode regionNode = node as RegionFileDataNode;

                int rx, rz;
                if (!RegionFileDataNode.RegionCoordinates(regionNode.NodePathName, out rx, out rz))
                {
                    return(null);
                }
                if (rx != _groupX.Region.Value || rz != _groupZ.Region.Value)
                {
                    return(null);
                }

                if (!regionNode.IsExpanded)
                {
                    regionNode.Expand();
                }

                foreach (var subNode in regionNode.Nodes)
                {
                    DataNode resultNode = Search(subNode);
                    if (resultNode != null)
                    {
                        return(resultNode);
                    }
                }

                return(null);
            }
            else if (node is RegionChunkDataNode)
            {
                RegionChunkDataNode chunkNode = node as RegionChunkDataNode;
                if (chunkNode.X != _groupX.LocalChunk.Value || chunkNode.Z != _groupZ.LocalChunk.Value)
                {
                    return(null);
                }

                return(chunkNode);
            }

            return(null);
        }
コード例 #10
0
 internal WorldManagerV8(DirectoryDataNode worldDirectory) : base(worldDirectory, DataVersion.V8) => LoadChunkManagers <ChunkManagerV8>();
コード例 #11
0
 public WorldManagerV14(DirectoryDataNode worldDirectory) : base(worldDirectory, DataVersion.V14) => LoadChunkManagers <ChunkManagerV14>();
コード例 #12
0
 internal WorldManager(DirectoryDataNode worldDirectory, DataVersion version)
 {
     Node        = worldDirectory;
     Version     = version;
     RegionFiles = Node.Get("region").Expanded().Nodes.Cast <RegionFileDataNode>().ToList();
 }
コード例 #13
0
 internal static WorldManager FromWorldDir(DirectoryDataNode worldDirectory)
 {
     var versionTag = worldDirectory.Get("level.dat")
                      .Get("Data")
                      .Get <TagCompoundDataNode>("Version");
     DataVersion v = versionTag is null ? (default) : (DataVersion)versionTag?.GetInt("Id");