public Portal(NXNode node, byte idx) { ID = idx; Type = node["pt"].ValueByte(); X = node["x"].ValueInt16(); Y = node["y"].ValueInt16(); Name = node["pn"].ValueString(); ToMapID = node["tm"].ValueInt32(); ToName = node["tn"].ValueString(); string script = null; if (node.ContainsChild("script")) { script = node["script"].ValueString(); } if (script == "") { script = null; } Script = script; if (Type != 0) { Y -= 40; } Enabled = true; }
private void RecurseHelper(NXNode n) { foreach (NXNode m in n) { RecurseHelper(m); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _disposed = true; if (_pointerWrapper != null) { _pointerWrapper.Dispose(); } _pointerWrapper = null; _baseNode = null; _strings = null; GC.SuppressFinalize(this); }
private void IterateNodes(TreeNode parentTreeNode, NXNode parentNXNode) { foreach (NXNode nxNode in parentNXNode) { TreeNode treeNode = new TreeNode(nxNode.Name); treeNode.Tag = nxNode; parentTreeNode.Nodes.Add(treeNode); IterateNodes(treeNode, nxNode); } }
public NXNode ResolvePath(string path) { string[] elements = (path.StartsWith("/") ? path.Substring(1) : path).Split(new[] { '/', '\\' }); NXNode node = BaseNode; foreach (string element in elements) { if (element != ".") { node = node[element]; } } return(node); }
private static void IterateNodes(NXNode n, string path, StringBuilder sb) { if (n.Name == "tile" || n.Name == "obj" || n.Name == "bS" || n.Name == "tS" || n.Name == "hs" || n.Name == "action" || n.Name == "id" || n.Name == "type" || n.Name == "tn" || n.Name == "pn" || n.Name == "interact" || n.Name == "speak" || n.Name == "delay" || n.Name == "elemAttr" || n.Name == "link" || n.Name == "foothold" || n.Name == "a0" || n.Name == "a1" || n.Name == "ladderRope") { return; } if (path.Contains("life")) { return; } var curPath = path + '/' + n.Name; if (n is NXValuedNode <string> ) { sb.AppendLine(curPath + "\tstring\t" + n.ValueString()); } //else if (n is NXValuedNode<Int64>) // sb.AppendLine(curPath + "\tint\t" + n.ValueInt64()); //else if (n is NXValuedNode<Double>) // sb.AppendLine(curPath + "\tdouble\t" + n.ValueDouble()); else { foreach (var subNode in n) { IterateNodes(subNode, curPath, sb); } } }
public CreateCharacterInfo(NXNode node) { int[] getIds(NXNode subNode) { return(subNode.Select(x => x.ValueInt32()).ToArray()); } Face = getIds(node["0"]); Hair = getIds(node["1"]); HairColor = getIds(node["2"]); Skin = getIds(node["3"]); Coat = getIds(node["4"]); Pants = getIds(node["5"]); Shoes = getIds(node["6"]); Weapon = getIds(node["7"]); }
private static void ProcessNames(NXNode listNode, Action <int, string> handleName) { foreach (var item in listNode) { if (int.TryParse(item.Name, out var itemId)) { if (item.ContainsChild("name")) { handleName(itemId, item["name"].ValueString()); } else { Trace.WriteLine($"Item {itemId} does not contain 'name' node."); } } else { Trace.WriteLine($"Node {item.Name} does not have a valid itemid as name!?"); } } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { NXNode node = e.Node.Tag as NXNode; pictureBoxCanvas.Image = null; if (node != null) { string info = string.Empty; if (node is NXValuedNode <Point> ) { info = node.ValueOrDie <Point>().ToString(); } else if (node is NXValuedNode <string> ) { info = node.ValueOrDie <string>(); } else if (node is NXValuedNode <double> ) { info = node.ValueOrDie <double>().ToString(); } else if (node is NXValuedNode <long> ) { info = node.ValueOrDie <long>().ToString(); } else if (node is NXBitmapNode) { var bitmap = node.ValueOrDie <Bitmap>(); info = string.Concat("Width = ", bitmap.Width, ", Height = ", bitmap.Height); pictureBoxCanvas.Image = bitmap; } textBoxInfo.Text = info; } toolStripStatusLabel.Text = string.Concat("Selection Type : ", e.Node.Tag.GetType().Name); }
public static void Init(NXNode mainNode) { Female = new CreateCharacterInfo(mainNode["CharFemale"]); Male = new CreateCharacterInfo(mainNode["CharMale"]); }
private void RecurseHelper(NXNode n) { foreach (NXNode m in n) RecurseHelper(m); }
private void LoadFoothold(NXNode node) { List<Foothold> footholds = new List<Foothold>(); foreach (NXNode sub in node["foothold"]) { foreach (NXNode sub2 in sub) { foreach (NXNode sub3 in sub2) { Foothold fh = new Foothold(); fh.ID = int.Parse(sub3.Name); fh.Next = sub3["next"].GetInt(); fh.Previous = sub3["prev"].GetInt(); fh.X1 = sub3["x1"].GetInt(); fh.X2 = sub3["x2"].GetInt(); fh.Y1 = sub3["y1"].GetInt(); fh.Y2 = sub3["y2"].GetInt(); footholds.Add(fh); } } } Foothold = footholds.ToArray(); }
private static string GetStringFromChild(NXNode node, string get) { if (!node.ContainsChild(get)) return ""; return node.GetChild(get).ValueOrDie<string>(); }
private static Point GetPointFromChild(NXNode node, string get) { if (!node.ContainsChild(get)) return new Point(); return node.GetChild(get).ValueOrDie<Point>(); }
private void LoadObjs(NXNode node) { for (int i = 0; i < 7; i++) { var objProp = node[i.ToString()]["obj"]; var list = new List<Obj>(); foreach (NXNode prop in objProp) { Obj obj = new Obj(); obj.ImgName = prop["oS"].ValueOrDie<string>() + ".img"; obj.l0 = prop["l0"].ValueOrDie<string>(); obj.l1 = prop["l1"].ValueOrDie<string>(); obj.l2 = prop["l2"].ValueOrDie<string>(); obj.X = prop["x"].GetInt(); obj.Y = prop["y"].GetInt(); list.Add(obj); } Objs[i] = list.ToArray(); } }
private static float GetFloatFromChild(NXNode node, string get) { if (!node.ContainsChild(get)) return 0; return (float) node.GetChild(get).ValueOrDie<double>(); }
private NXNode LoadNode(uint id) { Interlocked.CompareExchange(ref _nodes[id], NXNode.ParseNode(_nodeBlock + id, this), null); return(_nodes[id]); }
private bool Import(NXNode parentOwnNode, NXNode ownNode, NXNode otherNode, string path, bool insideImg) { if (insideImg) { // Either node does not exist if (ownNode == null || otherNode == null) { Console.WriteLine("[" + path + "] " + "Missing node"); return(true); } // Child count does not match if (ownNode.ChildCount != otherNode.ChildCount) { Console.WriteLine("[" + path + "] " + "Child count mismatch {0} != {1}", ownNode.ChildCount, otherNode.ChildCount); return(true); } // No children? Maybe the type/value changed if (ownNode.ChildCount == 0 && otherNode.ChildCount == 0) { var isSame = ownNode.IsSameAs(otherNode); if (!isSame) { Console.WriteLine("[" + path + "] " + "Found different node {0}: {1} != {2}", ownNode.Name, ownNode.ValueString(), otherNode.ValueString()); } return(!isSame); } // Iterate next nodes var ownNodeNames = new List <string>(ownNode.Select(x => x.Name)); var otherNodeNames = new List <string>(otherNode.Select(x => x.Name)); var nodeNames = ownNodeNames.Union(otherNodeNames).Distinct(); const bool show_all_edits = false; bool edits = false; foreach (var nodeName in nodeNames) { var own = ownNodeNames.Contains(nodeName) ? ownNode[nodeName] : null; var other = otherNodeNames.Contains(nodeName) ? otherNode[nodeName] : null; if (Import(ownNode, own, other, path + "/" + nodeName, true)) { edits = true; // Coalesce down if (!show_all_edits) { return(true); } } } return(edits); } if (otherNode == null) { return(true); } if (ownNode == null) { // New node. Add. parentOwnNode[otherNode.Name] = otherNode; parentOwnNode.IsExternallyLoaded = true; Console.WriteLine($"Adding {path}"); return(false); } var isImg = otherNode.Name.EndsWith(".img"); if (otherNode.ChildCount > 0) { // End of the node var ownNodeNames = new List <string>(ownNode.Select(x => x.Name)); var otherNodeNames = new List <string>(otherNode.Select(x => x.Name)); var nodeNames = ownNodeNames.Union(otherNodeNames).Distinct(); bool edits = false; foreach (var nodeName in nodeNames) { var own = ownNodeNames.Contains(nodeName) ? ownNode[nodeName] : null; var other = otherNodeNames.Contains(nodeName) ? otherNode[nodeName] : null; var curNodePath = path + "/" + nodeName; if (Import(ownNode, own, other, curNodePath, isImg) && isImg) { edits = true; break; } } if (edits) { parentOwnNode[otherNode.Name] = otherNode; parentOwnNode.IsExternallyLoaded = true; Console.WriteLine($"Replacing {path}"); } ownNode.Unload(true); otherNode.Unload(true); } // Don't care about regular nodes return(false); }
private void LoadTiles(NXNode node) { for (int i = 0; i < 7; i++) { var numProp = node[i.ToString()]; var infoProp = numProp["info"]; if (infoProp.ChildCount == 0) { Tiles[i] = new Tile[0]; continue; } var tileProp = numProp["tile"]; if (tileProp.ChildCount == 0) { Tiles[i] = new Tile[0]; continue; } string tileSetName = infoProp["tS"].ValueOrDie<string>(); var list = new List<Tile>(); foreach (NXNode prop in tileProp) { Tile tile = new Tile(); tile.ImgName = tileSetName + ".img"; tile.X = prop["x"].GetInt(); tile.Y = prop["y"].GetInt(); tile.TilePackName = prop["u"].ValueOrDie<string>(); tile.TileId = prop["no"].GetInt().ToString(); list.Add(tile); } Tiles[i] = list.ToArray(); } }
private void LoadProperties(NXNode node) { Properties = new MapProperties(); Properties.Bgm = node["info"]["bgm"].ValueOrDie<string>(); Properties.ReturnMap = (int)node["info"]["returnMap"].GetInt(); Properties.ForcedReturnMap = node["info"]["forcedReturn"].GetInt(); if (node["miniMap"] == null) return; Properties.Width = node["miniMap"]["width"].GetInt(); Properties.Height = node["miniMap"]["height"].GetInt(); Properties.CenterX = node["miniMap"]["centerX"].GetInt(); Properties.CenterY = node["miniMap"]["centerY"].GetInt(); //Properties.Botton = node["info"]["VRBottom"].GetInt(); //Properties.Left = node["info"]["VRLeft"].GetInt(); //Properties.Right = node["info"]["VRRight"].GetInt(); //Properties.Top = node["info"]["VRTop"].GetInt(); }
private void LoadPortal(NXNode node) { List<Portal> portals = new List<Portal>(); foreach (NXNode sub in node["portal"]) { Portal portal = new Portal(); portal.ID = int.Parse(sub.Name); portal.PortalName = sub["pn"].ValueOrDie<string>(); portal.PortalType = sub["pt"].GetInt(); portal.DestinationMapID = sub["tm"].GetInt(); portal.DestinationPortalName = sub["tn"].ValueOrDie<string>(); portal.X = sub["x"].GetInt(); portal.Y = sub["y"].GetInt(); portals.Add(portal); } Portals = portals.ToArray(); }
private static int GetIntFromChild(NXNode node, string get) { if (!node.ContainsChild(get)) return 0; try { return node.GetChild(get).ValueOrDie<int>(); } catch (InvalidCastException) // see Character.wz/Weapon/01482146.img/info/incSTR for more details T_T { return int.Parse(node.GetChild(get).ValueOrDie<string>()); } }
private void LoadLadderRope(NXNode node) { List<LadderRope> ladderropes = new List<LadderRope>(); foreach (NXNode sub in node["ladderRope"]) { LadderRope ladderrope = new LadderRope(); ladderrope.ID = int.Parse(sub.Name); ladderrope.L = sub["l"].GetInt(); ladderrope.X = sub["x"].GetInt(); ladderrope.YBoundaryBottom = sub["y1"].GetInt(); ladderrope.YBoundaryTop = sub["y2"].GetInt(); ladderropes.Add(ladderrope); } LadderRope = ladderropes.ToArray(); }