public FindBlock (DataNode searchRoot) { InitializeComponent(); _searchRoot = searchRoot; _groupX = new CoordinateGroup() { RegionBox = _regionXTextBox, ChunkBox = _chunkXTextBox, BlockBox = _blockXTextBox, LocalChunkBox = _localChunkXTextBox, LocalBlockBox = _localBlockXTextBox, }; _groupZ = new CoordinateGroup() { RegionBox = _regionZTextBox, ChunkBox = _chunkZTextBox, BlockBox = _blockZTextBox, LocalChunkBox = _localChunkZTextBox, LocalBlockBox = _localBlockZTextBox, }; ApplyRegion(_groupX, "0", true); ApplyRegion(_groupZ, "0", true); Validate(); }
public override bool Process(DataNode dataNode, ConsoleOptions options) { string value = options.Values[0]; TagDataNode tagDataNode = dataNode as TagDataNode; return tagDataNode.Parse(value); }
public FindReplace (MainForm main, NodeTreeController controller, DataNode searchRoot) { InitializeComponent(); _main = main; _mainController = controller; _mainSearchRoot = searchRoot; _findController = new RuleTreeController(treeView1); treeView1.NodeMouseDoubleClick += (s, e) => { _findController.EditSelection(); }; //_findController.VirtualRootDisplay = "Find Rules"; _replaceController = new NodeTreeController(treeView2); treeView2.NodeMouseDoubleClick += (s, e) => { _replaceController.EditSelection(); }; _replaceController.VirtualRootDisplay = "Replacement Tags"; _explorerStrip.Renderer = new ToolStripExplorerRenderer(); _explorerStrip.ImageList = _mainController.IconList; _explorerManager = new ExplorerBarController(_explorerStrip, _mainController.IconRegistry, _mainController.IconList, searchRoot); _explorerManager.SearchRootChanged += (s, e) => { _mainSearchRoot = _explorerManager.SearchRoot; Reset(); }; }
public override bool Process (DataNode dataNode, ConsoleOptions options) { if (options.Values.Count == 0) return false; string jsonPath = options.Values[0]; using (FileStream stream = File.OpenWrite(jsonPath)) { using (StreamWriter writer = new StreamWriter(stream)) { if (dataNode is TagDataNode) { TagDataNode tagNode = dataNode as TagDataNode; WriteNbtTag(writer, tagNode.Tag); } else if (dataNode is NbtFileDataNode) { dataNode.Expand(); TagNodeCompound root = new TagNodeCompound(); foreach (DataNode child in dataNode.Nodes) { TagDataNode childTagNode = child as TagDataNode; if (childTagNode == null) continue; if (childTagNode.Tag != null) root.Add(childTagNode.NodeName, childTagNode.Tag); } WriteNbtTag(writer, root); } } } return true; }
public override bool CanProcess (DataNode dataNode) { if (!(dataNode is TagListDataNode)) return false; return true; }
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; }
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 ExplorerBarController (ToolStrip toolStrip, IconRegistry registry, ImageList iconList, DataNode rootNode) { _explorerStrip = toolStrip; _registry = registry; _iconList = iconList; _rootNode = rootNode; Initialize(); }
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; }
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; }
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); } }
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; }
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; }
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); } node.Nodes.Clear(); foreach (DataNode child in dataNode.Nodes) { if (!currentNodes.ContainsKey(child)) node.Nodes.Add(CreateUnexpandedNode(child)); else node.Nodes.Add(currentNodes[child]); } foreach (TreeNode child in node.Nodes) child.ContextMenuStrip = BuildNodeContextMenu(child.Tag as DataNode); if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) { ExpandNode(node); node.Expand(); } }
private bool PasteIntoNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = dataNode.PasteIntoNodeCapabilities; return (dataNode != null) && dataNode.CanPasteIntoNode; }
private TreeNode GetRootFromDataNodePath(DataNode node, out Stack<DataNode> hierarchy) { hierarchy = new Stack<DataNode>(); while (node != null) { hierarchy.Push(node); node = node.Parent; } DataNode rootDataNode = hierarchy.Pop(); TreeNode frontNode = null; foreach (TreeNode child in _nodeTree.Nodes) { if (child.Tag == rootDataNode) frontNode = child; } return frontNode; }
private TreeNode FindFrontNode(DataNode node) { Stack<DataNode> hierarchy; TreeNode frontNode = GetRootFromDataNodePath(node, out hierarchy); if (frontNode == null) return null; while (hierarchy.Count > 0) { if (!frontNode.IsExpanded) { frontNode.Nodes.Add(new TreeNode()); frontNode.Expand(); } DataNode childData = hierarchy.Pop(); foreach (TreeNode childFront in frontNode.Nodes) { if (childFront.Tag == childData) { frontNode = childFront; break; } } } return frontNode; }
private bool EditNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = dataNode.EditNodeCapabilities; return (dataNode != null) && dataNode.CanEditNode; }
private bool DeleteNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = dataNode.DeleteNodeCapabilities; return (dataNode != null) && dataNode.CanDeleteNode; }
protected Dictionary<string, object> BuildExpandSet(DataNode node) { if (node == null || !node.IsExpanded) return null; Dictionary<string, object> dict = new Dictionary<string, object>(); foreach (DataNode child in node.Nodes) { Dictionary<string, object> childDict = BuildExpandSet(child); if (childDict != null) { if (!String.IsNullOrEmpty(child.NodeName)) dict[child.NodeName] = childDict; else dict[child.NodeDisplay] = childDict; } } return dict; }
private void SearchDiscoveryCallback(DataNode node) { _nodeTree.SelectedNode = FindFrontNode(node); if (_searchForm != null) { _searchForm.DialogResult = DialogResult.OK; _searchForm = null; } }
private bool ReorderNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = dataNode.ReorderNodeCapabilities; return (dataNode != null) && dataNode.CanReoderNode; }
private void SearchCollapseCallback(DataNode node) { CollapseBelow(node); }
private bool CreateFloatNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = GroupCapabilities.Single; return (dataNode != null) && dataNode.CanCreateTag(TagType.TAG_FLOAT); }
private void SearchEndCallback(DataNode node) { _searchForm.DialogResult = DialogResult.OK; _searchForm = null; MessageBox.Show("End of results"); }
private bool CreateIntArrayNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = GroupCapabilities.Single; return (dataNode != null) && dataNode.CanCreateTag(TagType.TAG_INT_ARRAY); }
protected void RestoreExpandSet(DataNode node, Dictionary<string, object> expandSet) { node.Expand(); foreach (DataNode child in node.Nodes) { if (expandSet.ContainsKey(child.NodeName)) { Dictionary<string, object> childDict = (Dictionary<string, object>)expandSet[child.NodeName]; if (childDict != null) RestoreExpandSet(child, childDict); } else if (expandSet.ContainsKey(child.NodeDisplay)) { Dictionary<string, object> childDict = (Dictionary<string, object>)expandSet[child.NodeDisplay]; if (childDict != null) RestoreExpandSet(child, childDict); } } }
private bool CreateStringNodePred(DataNode dataNode, out GroupCapabilities caps) { caps = GroupCapabilities.Single; return (dataNode != null) && dataNode.CanCreateTag(TagType.TAG_STRING); }
public override bool CanProcess (DataNode dataNode) { return true; }
private TreeNode CreateUnexpandedNode(DataNode node) { TreeNode frontNode = new TreeNode(node.NodeDisplay); frontNode.ImageIndex = _iconRegistry.Lookup(node.GetType()); frontNode.SelectedImageIndex = frontNode.ImageIndex; frontNode.Tag = node; frontNode.ContextMenuStrip = BuildNodeContextMenu(node); if (node.HasUnexpandedChildren || node.Nodes.Count > 0) frontNode.Nodes.Add(new TreeNode()); return frontNode; }