public static ScriptNode FindAnimateableProp(ScriptNode prop) { if (prop.GetCanvas() != null) { return(prop); } string[] names = new[] { "move", "fly", "die", "stand", "iconRaw", "icon" , "effect/default" , "effect" }; // Find any node that is usable for rendering foreach (var name in names) { var x = prop.GetNode(name); if (x == null) { continue; } return(x); } if (prop.HasChild("0")) { return(prop); } return(null); }
public SpriteSource(ScriptNode canvas, Point position, string category, string islot, string baseVslot, int job = 0) { if (islot == "" && baseVslot != "") { throw new Exception("Empty islot for non-empty vslot"); } Canvas = canvas.GetCanvas(); Position = position; Category = category; ISlot = islot; BaseVSlot = baseVslot; VSlot = ""; { // Figure out which inventory slot number it is // Basically just traverse the zmap, and the highest ID = inventory slot...? var tmp = ISlot; while (tmp.Length > 0) { var chunk = tmp.Substring(0, 2); tmp = tmp.Substring(2); var slot = FindStringIndex(zmap, chunk); if (slot == -1) { throw new Exception("Unknown islot specified"); } if (slot > InventorySlotNumber) { InventorySlotNumber = slot; } } } var vslot = ""; if (BaseVSlot == "Ae" && (job / 100 == 23 || job == 2002) && Canvas.GetString("z") != "backAccessoryEar" ) { Z = QueryZ(canvas, BaseVSlot, ref vslot, "accessoryEarOverHair"); } else { Z = QueryZ(canvas, BaseVSlot, ref vslot, null); } VSlot = vslot; }
private static List <FrameInfo> TryRenderNode(ScriptNode node, out string filename) { filename = "??"; resolveAgain: { // Try to resolve UOL while (node.Get() is WzUOL) { var uol = node.Get() as WzUOL; var path = uol.ActualPath(); var newNode = node.GetNode(path); if (newNode == null) { return(null); } node = newNode; } } { // If its a single canvas, render that var canvas = node.GetCanvas(); if (canvas != null) { filename = GetFilenameForNode(node); return(new List <FrameInfo>(RenderFrame(canvas))); } } { // If its a prop, figure out if we can render it var animateableProp = FindAnimateableProp(node); if (animateableProp == null) { var info = node.GetNode("info"); if (info == null) { return(null); } // Maybe we can find a link node var link = node.GetString("info/link"); if (link != null) { var path = "../" + link + ".img"; Console.WriteLine("Trying to get node @ {0}", path); var tmp = node.GetNode(path); if (tmp != null) { node = tmp; goto resolveAgain; } } // Figure out if the info node is any good animateableProp = FindAnimateableProp(info); if (animateableProp != null && animateableProp is ScriptNode) { node = animateableProp; goto resolveAgain; } } else { node = animateableProp; } } { // Try to render elements var frames = new List <FrameInfo>(); bool indexesAreImageOrUOL = true; bool foundAny = false; for (var i = 0; ; i++) { var p = node.Get(i.ToString()); if (p == null) { break; } foundAny = true; if (!(p is WzCanvas || p is WzUOL)) { if (i == 0) { continue; } indexesAreImageOrUOL = false; break; } frames.AddRange(RenderFrame(p)); } if (foundAny && indexesAreImageOrUOL) { if (node.GetInt32("zigzag", 0) == 1) { // Apply a zigzag if (frames.Count > 2) { // Zigzag var tmp = new List <FrameInfo>(frames); tmp.RemoveAt(0); tmp.RemoveAt(tmp.Count - 1); tmp.Reverse(); frames.AddRange(tmp); } } } filename = GetFilenameForNode(node); return(frames); } }