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 FaithfulForm()
 {
     mod  = null;
     pack = null;
     InitializeComponent();
     cbRescaleType.SelectedIndex = 0;
     ParseCommandLine();
 }
Ejemplo n.º 3
0
 private void DisposeMod()
 {
     if (mod != null)
     {
         tvMod.SetPack(null);
         SetInputImage(null);
         mod.Dispose();
         mod = null;
     }
 }
Ejemplo n.º 4
0
 private void DisposePack()
 {
     if (pack != null)
     {
         tvPack.SetPack(null);
         tvRecolorSource.SetPack(null);
         SetGuiImage(null);
         SetRecolorImage(null);
         pack.Dispose();
         pack = null;
     }
 }
Ejemplo n.º 5
0
 public TextureEntry(string path, Bitmap img = null)
 {
     if (string.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     FullPath  = path;
     ImageData = img;
     ImageSize = (img == null) ? Size.Empty : img.Size;
     // assets/MODNAME/textures/items/extras/
     LastDirectory = Path.GetPathRoot(FullPath);
     PathElements  = new HashSet <string>(TexturePack.SplitPath(path));
 }
Ejemplo n.º 6
0
        public static TexturePack GetModTextures(string path, ZipArchive file)
        {
            var mod = new TexturePack(path);
            // ani data needs to be held separately
            var aniData = new Dictionary <string, string>();

            foreach (var entry in file.Entries)
            {
                string name = entry.FullName;
                if (name.StartsWith(TextureEntry.ASSETS) && name.Contains(TEXTURES))
                {
                    if (name.EndsWith(TEXTURE_EXT))
                    {
                        try {
                            using (var stream = entry.Open()) {
                                // ignore exception if image data is invalid
                                mod.Add(new TextureEntry(name, LoadImageCached(stream)));
                            }
                        } catch (ArgumentException) { }
                    }
                    else if (name.EndsWith("." + ANI_EXT))
                    {
                        string pngName = name.Substring(0, name.Length - 1 - ANI_EXT.Length);
                        using (var reader = new StreamReader(entry.Open())) {
                            aniData.Add(pngName, reader.ReadToEnd());
                        }
                    }
                }
            }
            foreach (var texture in mod)
            {
                string animated;
                if (aniData.TryGetValue(texture.FullPath, out animated))
                {
                    texture.AnimationData = animated;
                }
            }
            mod.Sort();
            return(mod);
        }