private static int QueryZ(ScriptNode canvas, string baseSlot, ref string vSlot, string modifiedZ)
            {
                var zKeyName = modifiedZ != null ? modifiedZ : canvas.GetString("z");
                var zIndex   = 0;

                if (!string.IsNullOrEmpty(baseSlot) && vSlot != null)
                {
                    if (!int.TryParse(zKeyName, out zIndex))
                    {
                        zIndex = FindStringIndex(zmap, zKeyName);
                        var tmp = "";
                        if (smap.TryGetValue(zKeyName, out tmp))
                        {
                            vSlot = CommonSlot(tmp, baseSlot);
                        }
                    }
                }


                return(zIndex);
            }
Beispiel #2
0
        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);
            }
        }