public static PngInfo GetPngInfo(this Wz_Node wz_Node, Wz_Node baseNode) { var nodes = wz_Node.Nodes; var inLinkNode = nodes["_inlink"]; var outLinkNode = nodes["_outlink"]; PngInfo pngInfo; if (inLinkNode != null) { var link = inLinkNode.Value.ToString().Replace('/', '\\'); var node = wz_Node.GetNodeWzImage().Node.SearchNode(link); pngInfo = node.GetValue <Wz_Png>()?.ToPngInfo(); } else if (outLinkNode != null) { var link = outLinkNode.Value.ToString().Replace('/', '\\'); var node = baseNode.SearchNode(link); pngInfo = node.GetValue <Wz_Png>()?.ToPngInfo(); } else { pngInfo = wz_Node.GetValue <Wz_Png>()?.ToPngInfo(); } return(pngInfo); }
private void AppendContext(Wz_Node node) { Wz_Image wzImg = node.GetNodeWzImage(); if (wzImg != null) { _currentWzImg.Add(wzImg); } }
public static Wz_Node GetLinkedSourceNode(this Wz_Node node, GlobalFindNodeFunction findNode) { string path; if (!string.IsNullOrEmpty(path = node.Nodes["source"].GetValueEx <string>(null))) { return(findNode?.Invoke(path)); } else if (!string.IsNullOrEmpty(path = node.Nodes["_inlink"].GetValueEx <string>(null))) { var img = node.GetNodeWzImage(); return(img?.Node.FindNodeByPath(true, path.Split('/'))); } else if (!string.IsNullOrEmpty(path = node.Nodes["_outlink"].GetValueEx <string>(null))) { return(findNode?.Invoke(path)); } else { return(node); } }
/// <summary> /// Search for specified map Img starting from Base.wz root. /// </summary> /// <param name="root">The root of Base.wz.</param> /// <param name="imgText">The node text to search. E.g. "450007010.img" </param> /// <returns>The Wz img containing desired map.</returns> /// <exception cref="WzImgNotFoundException">If not found.</exception> public static Wz_Image SearchForMap(Wz_Node root, string imgText) { if (!imgText.Contains(".img")) { throw new ArgumentException("Supplied imgText is not legal.", nameof(imgText)); } // Filter map nodes, and find string wz file. IEnumerable <Wz_Node> mapNodes = root.Nodes .Where(n => n.GetNodeWzFile().Type == Wz_Type.Map); // Do search on each map node foreach (var mapRoot in mapNodes) { Wz_Node result = GenericBfsSearcher(mapRoot, (node) => node.Text == imgText); if (result != null) { return(result.GetNodeWzImage()); } } // Throw if not found. throw new WzImgNotFoundException(string.Format("Target Img {0} cannot be found.", imgText)); }
public static CharacterConfig GetCharacterConfig(this Wz_Node wz_Node, Wz_Node baseNode) { if (wz_Node.Value != null && wz_Node.Value is Wz_Uol) { wz_Node = wz_Node.GetValue <Wz_Uol>().HandleUol(wz_Node); } var nodes = wz_Node.Nodes; var config = new CharacterConfig { Name = wz_Node.Text, Origin = nodes["origin"]?.GetValue <Wz_Vector>(), PngInfo = wz_Node.GetPngInfo(baseNode), Group = nodes["group"]?.Value?.ToString(), Hash = nodes["_hash"]?.Value?.ToString(), Map = wz_Node.GetMap(), Z = nodes["z"]?.Value?.ToString(), Action = nodes["action"]?.Value?.ToString(), Delay = nodes["delay"]?.Value?.ToString(), Frame = nodes["frame"]?.Value?.ToString(), Move = nodes["move"]?.GetValue <Wz_Vector>(), Rotate = nodes["rotate"]?.Value?.ToString(), Vector = nodes["vector"]?.GetValue <Wz_Vector>(), Flip = nodes["flip"]?.Value?.ToString() }; if (config.Action != null) { var link = $"{config.Action}\\{config.Frame}"; var node = wz_Node.GetNodeWzImage().Node.SearchNode(link); var baseConfig = node.GetCharacterConfig(baseNode); config.Origin = baseConfig.Origin; config.Map = baseConfig.Map; config.Z = baseConfig.Z; config.Group = baseConfig.Group; config.Hash = baseConfig.Hash; config.PngInfo = baseConfig.PngInfo; } return(config); }
public static string ImgID(this Wz_Node Node) { return(Node.GetNodeWzImage().Name.Replace(".img", "")); }
public static string ImgName(this Wz_Node Node) { return(Node.GetNodeWzImage().Name); }
public static Bitmap ExtractPng2(this Wz_Node Node) { if (Node.HasNode("_outlink")) { var LinkData = Node.GetNode("_outlink").Value.ToString(); string[] Split = LinkData.Split('/'); string DestPath = ""; switch (Split[0]) { case "Mob": DestPath = Regex.Replace(LinkData, "Mob/", ""); if (Arc.MobWz != null && Arc.MobWz.HasNode(Split[1])) { return((Arc.MobWz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else if (Arc.Mob001Wz != null && Arc.Mob001Wz.HasNode(Split[1])) { return((Arc.Mob001Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else { return((Arc.Mob2Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } break; case "Map": if (Split[1] == "Map") { DestPath = LinkData.Remove(0, 4); } else { DestPath = Regex.Replace(LinkData, "Map/", ""); } if (Arc.MapWz != null && Arc.MapWz.HasNode(Split[1] + "/" + Split[2])) { return((Arc.MapWz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else if (Arc.Map001Wz != null && Arc.Map001Wz.HasNode(Split[1] + "/" + Split[2])) { return((Arc.Map001Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else if (Arc.Map002Wz != null && Arc.Map002Wz.HasNode(Split[1] + '/' + Split[2])) { return((Arc.Map002Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else { return((Arc.Map2Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } break; case "Skill": DestPath = Regex.Replace(LinkData, "Skill/", ""); if (Arc.SkillWz != null && Arc.SkillWz.HasNode(Split[1])) { return((Arc.SkillWz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else if (Arc.Skill001Wz != null && Arc.Skill001Wz.HasNode(Split[1])) { return((Arc.Skill001Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } else { return((Arc.Skill002Wz.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } break; default: DestPath = Regex.Replace(LinkData, Node.GetNodeWzFile().Type.ToString() + "/", ""); return((Node.GetNodeWzFile().WzStructure.GetNode(DestPath).Value as Wz_Png).ExtractPng()); break; } ; } else if (Node.HasNode("_inlink")) { var LinkData = Node.GetNode("_inlink").Value.ToString(); return((Node.GetNodeWzImage().Node.GetNode(LinkData).Value as Wz_Png).ExtractPng()); } else if (Node.HasNode("source")) { var LinkData = Node.GetNode("source").Value.ToString(); var DestPath = Regex.Replace(LinkData, Node.GetNodeWzFile().Type.ToString() + "/", ""); if (Node.GetNodeWzFile().WzStructure.GetNode(DestPath) != null) { return((Node.GetNodeWzFile().WzStructure.GetNode(DestPath).Value as Wz_Png).ExtractPng()); } } else { if (Node.Value is Wz_Uol) { return((Node.ResolveUol().Value as Wz_Png).ExtractPng()); } else { return((Node.Value as Wz_Png).ExtractPng()); } } return(null); }