Ejemplo n.º 1
0
        public static TexturePack GetPackTextures(string path, string[] files)
        {
            var pack = new TexturePack(path);

            foreach (string imgFile in files)
            {
                if (imgFile.Contains(TEXTURES))
                {
                    try {
                        TextureEntry entry;
                        using (var stream = OpenFile(imgFile)) {
                            // ignore exception if image data is invalid
                            entry = new TextureEntry(imgFile, LoadImageCached(stream));
                        }
                        string ani = imgFile + "." + ANI_EXT;
                        if (File.Exists(ani))
                        {
                            entry.AnimationData = File.ReadAllText(ani);
                        }
                        pack.Add(entry);
                    } catch (ArgumentException) { }
                }
            }
            pack.Sort();
            return(pack);
        }
Ejemplo n.º 2
0
 public void FindEntry(TextureEntry entry)
 {
     if (entry != null && tree != null)
     {
         FindPackNode(tree, entry, new LinkedList <TextureTree>());
     }
 }
Ejemplo n.º 3
0
        private bool FindPackNode(TextureTree root, TextureEntry entry, LinkedList <TextureTree> path)
        {
            var  value = root.Value;
            bool found = false;

            if (value != null && value.PathElements.IsSupersetOf(entry.PathElements))
            {
                BeginUpdate();
                try {
                    var lastChild = ExpandUpTo(path);
                    if (lastChild != null)
                    {
                        int count = lastChild.Count;
                        for (int i = 0; i < count; i++)
                        {
                            var node = lastChild[i];
                            if (GetEntry(node) == value)
                            {
                                SelectedNode = node;
                                node.EnsureVisible();
                                break;
                            }
                        }
                    }
                } finally {
                    EndUpdate();
                }
                found = true;
            }
            else if (!root.IsLeaf)
            {
                path.AddLast(root);
                foreach (var child in root.Children)
                {
                    if (FindPackNode(child, entry, path))
                    {
                        found = true;
                        break;
                    }
                }
                path.RemoveLast();
            }
            return(found);
        }