void ProcessZipEntry_Classic(string path, byte[] data, ZipEntry entry) { if (!Utils.CaselessEnds(path, ".png")) { return; } entry.Path = Utils.GetFilename(path); if (entry.Path != "terrain.png") { if (entry.Path == "gui.png") { entry.Path = "gui_classic.png"; } if (!filenames.Contains(entry.Path)) { writer.WriteZipEntry(entry, data); } } else if (!filenames.Contains("terrain.png")) { terrainBmp = Platform.ReadBmp(drawer, data); using (Bitmap mask = Platform.ReadBmp(drawer, pngTerrainPatch)) { CopyTile(0, 0, 3 * 16, 3 * 16, mask, terrainBmp); CopyTile(16, 0, 6 * 16, 3 * 16, mask, terrainBmp); CopyTile(32, 0, 6 * 16, 2 * 16, mask, terrainBmp); CopyTile(0, 16, 5 * 16, 3 * 16, mask, terrainBmp); CopyTile(16, 16, 6 * 16, 5 * 16, mask, terrainBmp); CopyTile(32, 16, 11 * 16, 0 * 16, mask, terrainBmp); patchedTerrain = true; } } }
void ProcessZipEntry_Classic(string filename, byte[] data, ZipEntry entry) { if (!filename.EndsWith(".png", comp)) { return; } entry.Filename = ResourceList.GetFile(filename); if (entry.Filename != "terrain.png") { if (entry.Filename == "gui.png") { entry.Filename = "gui_classic.png"; } if (!existing.Contains(entry.Filename)) { writer.WriteZipEntry(entry, data); } } else if (!existing.Contains("terrain.png")) { terrainBmp = Platform.ReadBmp32Bpp(drawer, data); using (Bitmap mask = Platform.ReadBmp32Bpp(drawer, pngTerrainPatch)) { CopyTile(0, 0, 3 * 16, 3 * 16, mask, terrainBmp); CopyTile(16, 0, 6 * 16, 3 * 16, mask, terrainBmp); CopyTile(32, 0, 6 * 16, 2 * 16, mask, terrainBmp); CopyTile(0, 16, 5 * 16, 3 * 16, mask, terrainBmp); CopyTile(16, 16, 6 * 16, 5 * 16, mask, terrainBmp); CopyTile(32, 16, 11 * 16, 0 * 16, mask, terrainBmp); patchedTerrain = true; } } }
void ProcessZipEntry_Classic(string filename, byte[] data, ZipEntry entry) { if (!filename.EndsWith(".png", comp)) { return; } entry.Filename = ResourceList.GetFile(filename); if (entry.Filename != "terrain.png") { if (entry.Filename == "gui.png") { entry.Filename = "gui_classic.png"; } if (!existing.Contains(entry.Filename)) { writer.WriteZipEntry(entry, data); } return; } else if (!existing.Contains("terrain.png")) { using (Bitmap dstBitmap = new Bitmap(new MemoryStream(data)), maskBitmap = new Bitmap(new MemoryStream(pngTerrainPatch))) { PatchImage(dstBitmap, maskBitmap); writer.WriteNewImage(dstBitmap, "terrain.png"); } } }
void ProcessZipEntry_Classic(string filename, byte[] data, ZipEntry entry) { if (!filename.EndsWith(".png", comp)) { return; } entry.Filename = ResourceList.GetFile(filename); if (entry.Filename != "terrain.png") { if (entry.Filename == "gui.png") { entry.Filename = "gui_classic.png"; } if (!existing.Contains(entry.Filename)) { writer.WriteZipEntry(entry, data); } return; } else if (!existing.Contains("terrain.png")) { using (Bitmap dst = Platform.ReadBmp32Bpp(drawer, data), mask = Platform.ReadBmp32Bpp(drawer, pngTerrainPatch)) { PatchImage(dst, mask); writer.WriteNewImage(dst, "terrain.png"); } } }
public void Run() { reader = new ZipReader(); reader.SelectZipEntry = SelectZipEntry_Classic; reader.ProcessZipEntry = ProcessZipEntry_Classic; string texDir = Path.Combine(Program.AppDirectory, "texpacks"); string path = Path.Combine(texDir, "default.zip"); ExtractExisting(path); using (Stream dst = new FileStream(path, FileMode.Create, FileAccess.Write)) { writer = new ZipWriter(dst); writer.entries = new ZipEntry[100]; for (int i = 0; i < entries.Count; i++) { writer.WriteZipEntry(entries[i], datas[i]); } ExtractClassic(); ExtractModern(); if (pngGuiPatch != null) { using (Bitmap gui = Platform.ReadBmp32Bpp(drawer, pngGuiPatch)) writer.WriteNewImage(gui, "gui.png"); } if (patchedTerrain) { writer.WriteNewImage(terrainBmp, "terrain.png"); } writer.WriteCentralDirectoryRecords(); } }
public void Run() { reader = new ZipReader(); reader.SelectZipEntry = SelectZipEntry_Classic; reader.ProcessZipEntry = ProcessZipEntry_Classic; string defPath = Path.Combine("texpacks", "default.zip"); if (Platform.FileExists(defPath)) { using (Stream src = Platform.FileOpen(defPath)) { reader.ProcessZipEntry = ExtractExisting; reader.Extract(src); } } using (Stream dst = Platform.FileCreate(defPath)) { writer = new ZipWriter(dst); writer.entries = new ZipEntry[100]; for (int i = 0; i < entries.Count; i++) { writer.WriteZipEntry(entries[i], datas[i]); } ExtractClassic(); ExtractModern(); if (pngGuiPatch != null) { using (Bitmap gui = Platform.ReadBmp(drawer, pngGuiPatch)) writer.WriteNewImage(gui, "gui.png"); } if (patchedTerrain) { writer.WriteNewImage(terrainBmp, "terrain.png"); } writer.WriteCentralDirectoryRecords(); } }
public void Run() { reader = new ZipReader(); reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic; reader.ProcessZipEntry = ProcessZipEntry_Classic; string texDir = Path.Combine( Program.AppDirectory, "texpacks" ); string path = Path.Combine( texDir, "default.zip" ); ExtractExisting( path ); using( Stream dst = new FileStream( path, FileMode.Create, FileAccess.Write ) ) { writer = new ZipWriter( dst ); writer.entries = new ZipEntry[100]; for( int i = 0; i < entries.Count; i++ ) writer.WriteZipEntry( entries[i], datas[i] ); ExtractClassic(); ExtractModern(); if( pngGuiPatch != null ) { using( Bitmap guiBitmap = new Bitmap( new MemoryStream( pngGuiPatch ) ) ) writer.WriteNewImage( guiBitmap, "gui.png" ); } writer.WriteCentralDirectoryRecords(); } }