private Bitmap RenderBackground(File GFXFile, File PalFile, File LayoutFile, int offs, int palOffs) { LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); PalFile = new LZFile(PalFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); Palette pal1 = new FilePalette(new InlineFile(PalFile, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFile, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, offs, palOffs); t.render(); return t.buffer; }
private void fileTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag is Directory) { e.Node.Expand(); return; } File f = e.Node.Tag as File; String filename = f.name; filename = filename.ToLowerInvariant(); try { if (filename == "banner.bin") { LevelChooser.showImgMgr(); File imgFile = new InlineFile(f, 0x20, 0x200, f.name); File palFile = new InlineFile(f, 0x220, 0x20, f.name); LevelChooser.imgMgr.m.addImage(new Image2D(imgFile, 32, true, false)); LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile)); } else if (filename.EndsWith(".enpg")) { LevelChooser.showImgMgr(); LZFile fileLz = new LZFile(f, LZFile.CompressionType.LZ); File imgFile = new InlineFile(fileLz, 0, 0x10000, f.name); File palFile = new InlineFile(fileLz, 0x10000, 0x200, f.name); LevelChooser.imgMgr.m.addImage(new EnpgImage2D(imgFile)); LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile)); } else if (filename.EndsWith(".bncd")) { new Bncd(f); } if (filename.EndsWith(".nsbtx") || filename.EndsWith(".nsbmd")) { new NSBTX(f); } else if (filename.EndsWith(".nscr") || filename.EndsWith(".ncgr") || filename.EndsWith(".nclr")) { SectionFileLoader.load(f); } else if (filename.EndsWith(".narc")) { new FilesystemBrowserDialog(new NarcFilesystem(f)).Show(); } else if (filename.EndsWith(".carc")) { new FilesystemBrowserDialog(new NarcFilesystem(f, true)).Show(); } else if (filename.Contains("_ncl.bin")) { new PaletteViewer(new LZFile(f, LZFile.CompressionType.MaybeLZ)).Show(); } else if (filename.Contains("_nsc.bin")) { if (LevelChooser.imgMgr == null) { return; } Image2D img = LevelChooser.imgMgr.m.getSelectedImage(); Palette[] pals = LevelChooser.imgMgr.m.getPalettes(); if (img == null) { return; } if (pals == null) { return; } if (pals.Length == 0) { return; } Tilemap t = new Tilemap(f, 32, img, pals, 0, 0); new TilemapEditorWindow(t).Show(); } else if (filename.Contains("_ncg.bin")) { LevelChooser.showImgMgr(); LevelChooser.imgMgr.m.addImage(new Image2D(f, 256, false)); } } catch (AlreadyEditingException ex) { MessageBox.Show(this, (LanguageManager.Get("Errors", "File"))); } }
private void fileTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag is Directory) { e.Node.Expand(); return; } File f = e.Node.Tag as File; String filename = f.name; filename = filename.ToLowerInvariant(); try { if (filename == "banner.bin") { LevelChooser.showImgMgr(); File imgFile = new InlineFile(f, 0x20, 0x200, f.name); File palFile = new InlineFile(f, 0x220, 0x20, f.name); LevelChooser.imgMgr.m.addImage(new Image2D(imgFile, 32, true, false)); LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile)); } else if (filename.EndsWith(".enpg")) { LevelChooser.showImgMgr(); LZFile fileLz = new LZFile(f, LZFile.CompressionType.LZ); File imgFile = new InlineFile(fileLz, 0, 0x10000, f.name); File palFile = new InlineFile(fileLz, 0x10000, 0x200, f.name); LevelChooser.imgMgr.m.addImage(new EnpgImage2D(imgFile)); LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile)); } else if (filename.EndsWith(".bncd")) new Bncd(f); if (filename.EndsWith(".nsbtx") || filename.EndsWith(".nsbmd")) new NSBTX(f); else if (filename.EndsWith(".nscr") || filename.EndsWith(".ncgr") || filename.EndsWith(".nclr")) SectionFileLoader.load(f); else if (filename.EndsWith(".narc")) new FilesystemBrowserDialog(new NarcFilesystem(f)).Show(); else if (filename.EndsWith(".carc")) new FilesystemBrowserDialog(new NarcFilesystem(f, true)).Show(); else if (filename.Contains("_ncl.bin")) new PaletteViewer(new LZFile(f, LZFile.CompressionType.MaybeLZ)).Show(); else if (filename.Contains("_nsc.bin")) { if (LevelChooser.imgMgr == null) return; Image2D img = LevelChooser.imgMgr.m.getSelectedImage(); Palette[] pals = LevelChooser.imgMgr.m.getPalettes(); if (img == null) return; if (pals == null) return; if (pals.Length == 0) return; Tilemap t = new Tilemap(f, 32, img, pals, 0, 0); new TilemapEditorWindow(t).Show(); } else if (filename.Contains("_ncg.bin")) { LevelChooser.showImgMgr(); LevelChooser.imgMgr.m.addImage(new Image2D(f, 256, false)); } } catch (AlreadyEditingException ex) { MessageBox.Show(this, (LanguageManager.Get("Errors", "File"))); } }
private Tilemap getTilemap() { getFiles(); if (GFXFile == null) return null; if (PalFile == null) return null; if (LayoutFile == null) return null; LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); LZFile PalFileLz = new LZFile(PalFile, LZFile.CompressionType.LZ); Palette pal1 = new FilePalette(new InlineFile(PalFileLz, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFileLz, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, bg.topLayer ? 256 : 576, bg.topLayer ? 8 : 10); return t; }
public void load() { //Palettes int palCount = ROM.LZ77_GetDecompressedSize(PalFile.getContents()) / 512; palettes = new Palette[palCount]; LZFile PalFileLz = new LZFile(PalFile, LZFile.CompressionType.LZ); for(int i = 0; i < palCount; i++) palettes[i] = new FilePalette(new InlineFile(PalFileLz, i*512, 512, "Palette "+i)); //Graphics graphics = new Image2D(GFXFile, 256, false); //Map16 map16 = new Map16Tilemap(Map16File, 32, graphics, palettes, Map16TileOffset, Map16PaletteOffset); Overrides = new short[map16.getMap16TileCount()]; Map16Buffer = map16.render(); /* TilemapEditorTest t = new TilemapEditorTest(); t.load(map16); t.Show(); */ //Tile Behaviors loadTileBehaviors(); //Objects loadObjects(); /* // Finally, load overrides if (overrideFlag) { UseOverrides = true; OverrideBitmap = Properties.Resources.tileoverrides; Overrides = new short[Map16.Length]; EditorOverrides = new short[Map16.Length]; for (int idx = 0; idx < Map16.Length; idx++) { Overrides[idx] = -1; EditorOverrides[idx] = -1; } }*/ }