예제 #1
0
        private static void run(EnumResourcePackType packType, string packPath, string outputZipPath, IGraphicFilter filter)
        {
            using var tempDir = new TemporaryDirectory();
            Debug.WriteLine($"tempDir: {tempDir.Path}");
            var resourcePack = ResourcePackLoaders.Load(packType, packPath);

            foreach (var texture in resourcePack.EnumerateTextures())
            {
                texture.LoadPngFileToMemory();
                texture.ApplyFilter(filter);
                texture.WriteToResourcePack(tempDir.Path);
                texture.Dispose();
            }

            ZipFile.CreateFromDirectory(tempDir.Path, outputZipPath, CompressionLevel.Fastest, false, Encoding.UTF8);
            using (var ar = ZipFile.Open(outputZipPath, ZipArchiveMode.Update)) {
                var entry = ar.CreateEntry("pack.mcmeta");
                using (var writer = new StreamWriter(entry.Open(), Encoding.UTF8)) {
                    writer.WriteLine(
                        "{\n" +
                        "  \"pack\": {\n" +
                        "    \"pack_format\": 2,\n" +
                        "    \"description\": \"Made by MCResourcePackUtil (dev: yuma140902)\"\n" +
                        "  }\n" +
                        "}");
                }
            }
        }
        public static IResourcePack Load(EnumResourcePackType packType, string packPath)
        {
            switch (packType)
            {
            case EnumResourcePackType.PlainFolder:
                return(plainFolderLoader.Load(packPath));

            case EnumResourcePackType.Mod:
                return(modFileLoader.Load(packPath));

            case EnumResourcePackType.Zip:
                return(zipLoader.Load(packPath));

            case EnumResourcePackType.Folder:
                return(folderLoader.Load(packPath));

            default:
                throw new NotImplementedException($"{packType} のローダーがありません。");
            }
        }
예제 #3
0
 private ResourcePackType(EnumResourcePackType value) => this.value = value;