public NSCR(MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR NSCR, NCGR NCGR, MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR NCLR) { this.file = NSCR; this.NCGR = NCGR; this.NCLR = NCLR; this.InitializeComponent(); }
public AnimationRunner(NANR.Animation animation, NCGR ncgr, NCLR nclr, NCER ncer) { this.animation = animation; this.ncgr = ncgr; this.nclr = nclr; this.ncer = ncer; }
private Image UpdateImage() { Image image; if (this.stopUpdating) { return(null); } if (this.tile.order != NCGR.TileOrder.NoTiled) { this.tile.rahc.nTilesX = (ushort)(this.numericWidth.Value / 8M); this.tile.rahc.nTilesY = (ushort)(this.numericHeight.Value / 8M); } else { this.tile.rahc.nTilesX = (ushort)this.numericWidth.Value; this.tile.rahc.nTilesY = (ushort)this.numericHeight.Value; } if (this.isMap) { NCGR.NCGR_s tile = this.tile; tile.rahc.tileData.tiles = Convertir.BytesToTiles(Convertir.TilesToBytes(tile.rahc.tileData.tiles, (int)this.tile.other)); image = NCGR.Get_Image(tile, this.paleta, 0, this.trackZoom.Value); } else { image = NCGR.Get_Image(this.tile, this.paleta, (int)this.tile.other, this.trackZoom.Value); } this.pic.Image = image; return(image); }
public void SetNCGR(NCGR Graphic) { this.Graphic = Graphic; if (this.Palette == null || Graphic == null || this.Cell == null) { return; } this.UploadCells(); }
public AnimationPlayer_WinForms(NANR.Animation animation, NCGR ncgr, NCLR nclr, NCER ncer, PictureBox pb) : base(animation, ncgr, nclr, ncer) { PictureBox = pb; generateBitmaps(); Timer = new Timer(); Timer.Interval = 1000 / 60; Timer.Tick += Timer_Tick; }
private void toolStripButton3_Click(object sender, EventArgs e) { if (this.saveFileDialog2.ShowDialog() != DialogResult.OK || this.saveFileDialog2.FileName.Length <= 0) { return; } NCGR ncgr = new NCGR(this.ImageData, 80, 88, Graphic.GXTexFmt.GX_TEXFMT_PLTT16); File.Create(this.saveFileDialog2.FileName).Close(); File.WriteAllBytes(this.saveFileDialog2.FileName, ncgr.Write()); }
public GraphicsTestForm(string[] args) { InitializeComponent(); nds = new NDS(File.OpenRead(args[0])); nclr = new NCLR(nds.FileSystem.OpenFile(@"data/data0/BG1.NCLR")); ncgr = new NCGR(nds.FileSystem.OpenFile(@"data/data0/BG1.NCGR")); nscr = new NSCR(nds.FileSystem.OpenFile(@"data/data0/BG1.NSCR")); Bitmap bitmap = nscr.ToBitmap(ncgr, nclr.Palette); ImgDisp.Image = bitmap; }
public void SetNCGR(NCGR Graphic, int ID) { this.Graphic = Graphic; if (this.GraphicId != -1) { FileHandler.CloseFile(this.GraphicId); this.GraphicId = ID - 1; } else { this.GraphicId = ID; } if (this.Palette == null || Graphic == null) { return; } this.LoadCells(); }
private void Add_TransparencyColor() { int index = Convertir.Remove_DuplicatedColors(ref this.paleta.pltt.palettes[0], ref this.tile.rahc.tileData.tiles); if (index == -1) { index = Convertir.Remove_NotUsedColors(ref this.paleta.pltt.palettes[0], ref this.tile.rahc.tileData.tiles); } this.paleta.pltt.palettes[0].colors[index] = this.paleta.pltt.palettes[0].colors[0]; this.paleta.pltt.palettes[0].colors[0] = Color.FromArgb(0xf8, 0, 0xf8); Convertir.Change_Color(ref this.tile.rahc.tileData.tiles, index, 0); string tempFileName = Path.GetTempFileName(); NCLR.Escribir(this.paleta, tempFileName); string fileout = Path.GetTempFileName(); NCGR.Write(this.tile, fileout); this.UpdateImage(); this.checkTransparency.Checked = true; }
public TestForm(string[] args) { InitializeComponent(); nds = new NDS(File.OpenRead(args[0])); MainArchive mainArchive = new MainArchive(nds.FileSystem.OpenFile(args[1])); NCLR nclr = new NCLR(mainArchive.OpenFile(int.Parse(args[2]))); SubArchive subArchive = new SubArchive(mainArchive.OpenFile(int.Parse(args[3]))); NCGR ncgr = new NCGR(subArchive.OpenFile(2)); NANR nanr = new NANR(subArchive.OpenFile(1)); NCER ncer = new NCER(subArchive.OpenFile(0)); NANR.Animation anim = nanr.animations[int.Parse(args[4])]; //imgDisp.Image = cell.DrawOamBoxes(Color.Red); player = new AnimationPlayer_WinForms(anim, ncgr, nclr, ncer, imgDisp); player.Start(); }
public TileView(NCGR.NCGR_s tile, NCLR.NCLR_s paleta) { this.components = null; this.InitializeComponent(); this.isMap = false; this.paleta = paleta; this.tile = tile; if (!(this.tile.other is int)) { this.tile.other = 0; } this.pic.Image = NCGR.Get_Image(tile, paleta, (int)this.tile.other); this.numericWidth.Value = this.pic.Image.Width; this.numericHeight.Value = this.pic.Image.Height; this.comboDepth.Text = (tile.rahc.depth == ColorDepth.Depth4Bit) ? "4 bpp" : "8 bpp"; this.oldDepth = this.comboDepth.Text; switch (tile.order) { case NCGR.TileOrder.NoTiled: this.oldTiles = 0; this.comboBox1.SelectedIndex = 0; break; case NCGR.TileOrder.Horizontal: this.oldTiles = 1; this.comboBox1.SelectedIndex = 1; break; } this.comboDepth.SelectedIndexChanged += new EventHandler(this.comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(this.numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(this.numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(this.numericStart_ValueChanged); this.Info(); if ((new string(paleta.header.id) != "NCLR.NCLR_s") && (new string(paleta.header.id) != "RLCN")) { this.btnSetTrans.Enabled = false; } }
private void Change_TransparencyColor(Color color) { int oldIndex = 0; for (int i = 0; i < this.paleta.pltt.palettes[0].colors.Length; i++) { if (this.paleta.pltt.palettes[0].colors[i] == color) { this.paleta.pltt.palettes[0].colors[i] = this.paleta.pltt.palettes[0].colors[0]; this.paleta.pltt.palettes[0].colors[0] = color; oldIndex = i; break; } } string tempFileName = Path.GetTempFileName(); NCLR.Escribir(this.paleta, tempFileName); Convertir.Change_Color(ref this.tile.rahc.tileData.tiles, oldIndex, 0); string fileout = Path.GetTempFileName(); NCGR.Write(this.tile, fileout); this.UpdateImage(); this.checkTransparency.Checked = true; }
private static void Main(string[] args) { if (args != null && args.Length > 0) { if (!Program.AttachConsole(-1)) { Program.AllocConsole(); } switch (args[0].ToLower()) { case "asm": if (args.Length > 2) { switch (args[1].ToLower()) { case "patch": ARM9 arM9 = new ARM9(System.IO.File.ReadAllBytes(args[2])); arM9.AddCustomCode(Path.GetDirectoryName(args[2])); System.IO.File.WriteAllBytes(Path.GetDirectoryName(args[2]) + "\\" + Path.GetFileNameWithoutExtension(args[2]) + "_new.bin", arM9.Write()); break; default: Program.PrintUsage(); break; } } else { Program.PrintUsage(); break; } break; case "g2d": if (args.Length > 4) { switch (args[1].ToLower()) { case "pal": switch (args[2].ToLower()) { case "4bpp": Bitmap b1 = (Bitmap)Image.FromFile(args[3]); NCLR nclr1 = new NCLR(Graphic.ToABGR1555(Graphic.GeneratePalette(b1, 16, false, false)), Graphic.GXTexFmt.GX_TEXFMT_PLTT16); System.IO.File.Create(args[4]).Close(); System.IO.File.WriteAllBytes(args[4], nclr1.Write()); b1.Dispose(); break; case "8bpp": Bitmap b2 = (Bitmap)Image.FromFile(args[4]); NCLR nclr2 = new NCLR(Graphic.ToABGR1555(Graphic.GeneratePalette(b2, 256, false, false)), Graphic.GXTexFmt.GX_TEXFMT_PLTT256); System.IO.File.Create(args[5]).Close(); System.IO.File.WriteAllBytes(args[5], nclr2.Write()); b2.Dispose(); break; default: Program.PrintUsage(); break; } break; case "grp": bool firstTransparent; if (args.Length > 5) { switch (args[2].ToLower()) { case "4bpp": Bitmap b3 = (Bitmap)Image.FromFile(args[3]); byte[] Data1; byte[] Palette1; Graphic.ConvertBitmap(b3, out Data1, out Palette1, Graphic.GXTexFmt.GX_TEXFMT_PLTT16, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR, out firstTransparent, false); NCLR nclr3 = new NCLR(Palette1, Graphic.GXTexFmt.GX_TEXFMT_PLTT16); NCGR ncgr1 = new NCGR(Data1, b3.Width / 8, b3.Height / 8, Graphic.GXTexFmt.GX_TEXFMT_PLTT16); System.IO.File.Create(args[4]).Close(); System.IO.File.WriteAllBytes(args[4], nclr3.Write()); System.IO.File.Create(args[5]).Close(); System.IO.File.WriteAllBytes(args[5], ncgr1.Write()); b3.Dispose(); break; case "8bpp": Bitmap b4 = (Bitmap)Image.FromFile(args[3]); byte[] Data2; byte[] Palette2; Graphic.ConvertBitmap(b4, out Data2, out Palette2, Graphic.GXTexFmt.GX_TEXFMT_PLTT256, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR, out firstTransparent, false); NCLR nclr4 = new NCLR(Palette2, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NCGR ncgr2 = new NCGR(Data2, b4.Width / 8, b4.Height / 8, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); System.IO.File.Create(args[4]).Close(); System.IO.File.WriteAllBytes(args[4], nclr4.Write()); System.IO.File.Create(args[5]).Close(); System.IO.File.WriteAllBytes(args[5], ncgr2.Write()); b4.Dispose(); break; default: Program.PrintUsage(); break; } } else { Program.PrintUsage(); break; } break; case "map": if (args.Length > 7) { switch (args[2].ToLower()) { case "8bpp": switch (args[3].ToLower()) { case "single": Bitmap b5 = (Bitmap)Image.FromFile(args[4]); byte[] Palette3; byte[] Tilemap1; byte[] Screendata; Graphic.ConvertBitmap(b5, out Palette3, out Tilemap1, out Screendata, Graphic.GXTexFmt.GX_TEXFMT_PLTT256, true); NCLR nclr5 = new NCLR(Palette3, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NCGR ncgr3 = new NCGR(Tilemap1, Tilemap1.Length / 64 * 8, 8, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NSCR nscr1 = new NSCR(Screendata, b5.Width, b5.Height, Graphic.NNSG2dColorMode.NNS_G2D_SCREENCOLORMODE_16x16); System.IO.File.Create(args[5]).Close(); System.IO.File.WriteAllBytes(args[5], nclr5.Write()); System.IO.File.Create(args[6]).Close(); System.IO.File.WriteAllBytes(args[6], ncgr3.Write()); System.IO.File.Create(args[7]).Close(); System.IO.File.WriteAllBytes(args[7], nscr1.Write()); b5.Dispose(); break; case "duo": if (args.Length > 9) { Bitmap a = (Bitmap)Image.FromFile(args[4]); Bitmap b6 = (Bitmap)Image.FromFile(args[5]); byte[] Palette4; byte[] Tilemap2; byte[] ScreendataA; byte[] ScreendataB; Graphic.ConvertBitmap(a, b6, out Palette4, out Tilemap2, out ScreendataA, out ScreendataB, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NCLR nclr6 = new NCLR(Palette4, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NCGR ncgr4 = new NCGR(Tilemap2, Tilemap2.Length / 64 * 8, 8, Graphic.GXTexFmt.GX_TEXFMT_PLTT256); NSCR nscr2 = new NSCR(ScreendataA, b6.Width, b6.Height, Graphic.NNSG2dColorMode.NNS_G2D_SCREENCOLORMODE_16x16); NSCR nscr3 = new NSCR(ScreendataB, b6.Width, b6.Height, Graphic.NNSG2dColorMode.NNS_G2D_SCREENCOLORMODE_16x16); System.IO.File.Create(args[6]).Close(); System.IO.File.WriteAllBytes(args[6], nclr6.Write()); System.IO.File.Create(args[7]).Close(); System.IO.File.WriteAllBytes(args[7], ncgr4.Write()); System.IO.File.Create(args[8]).Close(); System.IO.File.WriteAllBytes(args[8], nscr2.Write()); System.IO.File.Create(args[9]).Close(); System.IO.File.WriteAllBytes(args[9], nscr3.Write()); a.Dispose(); b6.Dispose(); break; } Program.PrintUsage(); break; default: Program.PrintUsage(); break; } break; default: Program.PrintUsage(); break; } } else { Program.PrintUsage(); break; } break; default: Program.PrintUsage(); break; } } else { Program.PrintUsage(); break; } break; case "help": Program.PrintUsage(); break; case "mkds": if (args.Length > 1) { switch (args[1]) { case "kcl": if (args.Length > 3) { Obj2Kcl.ConvertToKcl(args[2], args[3]); break; } Program.PrintUsage(); break; } } else { Program.PrintUsage(); break; } break; default: Program.PrintUsage(); break; } Program.FreeConsole(); SendKeys.SendWait("{ENTER}"); } else { Program.Run((string)null); } }
public static Bitmap Get_Image(Bank banco, uint blockSize, NCGR.NCGR_s tile, NCLR.NCLR_s paleta, bool entorno, bool celda, bool numero, bool transparencia, bool image, int maxWidth, int maxHeight, int zoom = 1) { int num; if (banco.cells.Length == 0) { return(new Bitmap(1, 1)); } Size size = new Size(maxWidth * zoom, maxHeight * zoom); Bitmap bitmap = new Bitmap(size.Width, size.Height); Graphics graphics = Graphics.FromImage(bitmap); if (entorno) { for (num = -size.Width; num < size.Width; num += 8) { graphics.DrawLine(Pens.LightBlue, (num + (size.Width / 2)) * zoom, 0, (num + (size.Width / 2)) * zoom, size.Height * zoom); graphics.DrawLine(Pens.LightBlue, 0, (num + (size.Height / 2)) * zoom, size.Width * zoom, (num + (size.Height / 2)) * zoom); } graphics.DrawLine(Pens.Blue, (maxWidth / 2) * zoom, 0, (maxWidth / 2) * zoom, maxHeight * zoom); graphics.DrawLine(Pens.Blue, 0, (maxHeight / 2) * zoom, maxWidth * zoom, (maxHeight / 2) * zoom); } Image[] imageArray = new Image[banco.nCells]; for (num = 0; num < banco.nCells; num++) { if ((banco.cells[num].width != 0) && (banco.cells[num].height != 0)) { uint tileOffset = banco.cells[num].obj2.tileOffset; if (blockSize > 4) { blockSize = 4; } if (tile.rahc.depth == ColorDepth.Depth4Bit) { tileOffset = tileOffset << ((byte)blockSize); } else { tileOffset = (tileOffset << ((byte)blockSize)) / 2; } if (image) { for (int i = 0; i < tile.rahc.tileData.nPalette.Length; i++) { tile.rahc.tileData.nPalette[i] = banco.cells[num].obj2.index_palette; } if (blockSize < 4) { if (tile.order == NCGR.TileOrder.NoTiled) { imageArray[num] = NCGR.Get_Image(tile, paleta, (int)(tileOffset * 0x40), banco.cells[num].width, banco.cells[num].height, zoom); } else { imageArray[num] = NCGR.Get_Image(tile, paleta, (int)(tileOffset * 0x40), banco.cells[num].width / 8, banco.cells[num].height / 8, zoom); } } else { tileOffset /= blockSize / 2; int nTilesX = tile.rahc.nTilesX; int nTilesY = tile.rahc.nTilesY; if (tile.order == NCGR.TileOrder.Horizontal) { nTilesX *= 8; nTilesY *= 8; } int num6 = (int)(((long)tileOffset) % ((long)nTilesX)); int num7 = (int)(((long)tileOffset) / ((long)nTilesX)); if (tile.rahc.depth == ColorDepth.Depth4Bit) { num7 = (int)(num7 * (blockSize * 2)); } else { num7 = (int)(num7 * blockSize); } if (num7 >= nTilesY) { num7 = num7 % nTilesY; } imageArray[num] = NCGR.Get_Image(tile, paleta, zoom).Clone(new Rectangle(num6 * zoom, num7 * zoom, banco.cells[num].width * zoom, banco.cells[num].height * zoom), PixelFormat.Undefined); } if ((banco.cells[num].obj1.flipX == 1) && (banco.cells[num].obj1.flipY == 1)) { imageArray[num].RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (banco.cells[num].obj1.flipX == 1) { imageArray[num].RotateFlip(RotateFlipType.RotateNoneFlipX); } else if (banco.cells[num].obj1.flipY == 1) { imageArray[num].RotateFlip(RotateFlipType.Rotate180FlipX); } if (transparencia) { ((Bitmap)imageArray[num]).MakeTransparent(paleta.pltt.palettes[tile.rahc.tileData.nPalette[0]].colors[0]); } graphics.DrawImageUnscaled(imageArray[num], (size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom), (size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom)); } if (celda) { graphics.DrawRectangle(Pens.Black, (int)((size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom)), (int)((size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom)), (int)(banco.cells[num].width * zoom), (int)(banco.cells[num].height * zoom)); } if (numero) { graphics.DrawString(num.ToString(), SystemFonts.CaptionFont, Brushes.Black, (float)((size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom)), (float)((size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom))); } } } return(bitmap); }
public static Bitmap GetPreview(ByteFileInfo file) { switch (FileHandler.GetType(file)) { case "NCGR": NCGR ncgr = new NCGR(file.Data); FileHandler.LastGraphic = ncgr; if (FileHandler.LastPal == null) { return((Bitmap)null); } try { return(ncgr.CharacterData.ToBitmap(FileHandler.LastPal, 0)); } catch { return((Bitmap)null); } case "NCLR": MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR nclr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR(file.Data); System.Drawing.Color[] colorArray1 = nclr.PaletteData.ToColorArray(); Bitmap bitmap1 = new Bitmap(128, (int)Math.Round((double)colorArray1.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap1)) { graphics.Clear(System.Drawing.Color.Transparent); int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray1.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { if (num < colorArray1.Length) { graphics.FillRectangle((Brush) new SolidBrush(colorArray1[num++]), x, y, 8, 8); } } } } FileHandler.LastPal = nclr; return(bitmap1); case "NCL": System.Drawing.Color[] colorArray2 = new NCL(file.Data).PaletteData.ToColorArray(); Bitmap bitmap2 = new Bitmap(128, (int)Math.Round((double)colorArray2.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap2)) { graphics.Clear(System.Drawing.Color.Transparent); int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray2.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { if (num < colorArray2.Length) { graphics.FillRectangle((Brush) new SolidBrush(colorArray2[num++]), x, y, 8, 8); } } } } return(bitmap2); case "NSCR": MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR nscr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR(file.Data); if (FileHandler.LastPal == null || FileHandler.LastGraphic == null) { return((Bitmap)null); } try { return(nscr.ScreenData.ToBitmap(FileHandler.LastGraphic, FileHandler.LastPal)); } catch { return((Bitmap)null); } case "NCER": MKDS_Course_Modifier.G2D_Binary_File_Format.NCER ncer = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCER(file.Data); if (FileHandler.LastPal == null || FileHandler.LastGraphic == null) { return((Bitmap)null); } try { return(ncer.CellBankBlock.CellDataBank.GetBitmap(0, FileHandler.LastGraphic, FileHandler.LastPal)); } catch { return((Bitmap)null); } case "ICG.BIN": case "NCG.BIN": FileHandler.LastRawGraphic = file.Data; return(FileHandler.LastRawPal != null?Graphic.ConvertData(FileHandler.LastRawGraphic, FileHandler.LastRawPal, 0, (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), FileHandler.LastRawPal.Length / 2 >= 256?Graphic.GXTexFmt.GX_TEXFMT_PLTT256 : Graphic.GXTexFmt.GX_TEXFMT_PLTT16, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR, true, false) : (Bitmap)null); case "ICL.BIN": case "NCL.BIN": System.Drawing.Color[] colorArray3 = Graphic.ConvertABGR1555(file.Data); Bitmap bitmap3 = new Bitmap(128, (int)Math.Round((double)colorArray3.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap3)) { int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray3.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { graphics.FillRectangle((Brush) new SolidBrush(colorArray3[num++]), x, y, 8, 8); } } } FileHandler.LastRawPal = file.Data; return(bitmap3); case "ISC.BIN": case "NSC.BIN": if (FileHandler.LastRawPal != null && FileHandler.LastRawGraphic != null) { try { return(Graphic.ConvertData(FileHandler.LastRawGraphic, (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), FileHandler.LastRawPal, file.Data, (int)Math.Sqrt((double)(file.Data.Length / 2)) * 8, (int)Math.Sqrt((double)(file.Data.Length / 2)) * 8, FileHandler.LastRawPal.Length / 2 >= 256 ? Graphic.GXTexFmt.GX_TEXFMT_PLTT256 : Graphic.GXTexFmt.GX_TEXFMT_PLTT16, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR)); } catch { } } return((Bitmap)null); case "ENPG": try { return(Graphic.ConvertData(((IEnumerable <byte>)file.Data).ToList <byte>().GetRange(0, file.Data.Length - 512).ToArray(), ((IEnumerable <byte>)file.Data).ToList <byte>().GetRange(file.Data.Length - 512, 512).ToArray(), 0, (int)Math.Sqrt((double)(file.Data.Length - 512)), (int)Math.Sqrt((double)(file.Data.Length - 512)), Graphic.GXTexFmt.GX_TEXFMT_PLTT256, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_BMP, true, false)); } catch { return((Bitmap)null); } case "BMP": return((Bitmap)Image.FromStream((Stream) new MemoryStream(file.Data))); case "TEX": return(new TEX(file.Data).GetBitmap(0)); default: return((Bitmap)null); } }
public AnimationPlayer_WinForms(NANR.Animation animation, NCGR ncgr, NCLR nclr, NCER ncer) : this(animation, ncgr, nclr, ncer, new PictureBox()) { }
private static bool Open(ByteFileInfo file, Form1 Owner, object Parameter = null, bool filedialog = false) { switch (FileHandler.GetType(file)) { case "NARC": NARC.DirectoryEntry Root = NARC.Unpack(file.Data); if (FileHandler.OpenedArchives.Count != 0 && !FileHandler.OpenedArchives[0].FileName.EndsWith(".nds")) { FileHandler.OpenedArchives.RemoveAt(FileHandler.OpenedArchives.Count - 1); } Owner.OpenNarc(Root); return(true); case "NCGR": NCGR Graphic = new NCGR(file.Data); switch (FileHandler.OpenDialog) { case MKDS_Course_Modifier.UI.BNCL _: ((MKDS_Course_Modifier.UI.BNCL)FileHandler.OpenDialog).SetNCGR(Graphic); break; case MKDS_Course_Modifier.UI.NCER _: ((MKDS_Course_Modifier.UI.NCER)FileHandler.OpenDialog).SetNCGR(Graphic, FileHandler.OpenedFiles.Count); return(true); } return(false); case "NCLR": MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR nclr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR(file.Data); switch (FileHandler.OpenDialog) { case null: FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.NCLR(nclr); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case MKDS_Course_Modifier.UI.BNCL _: ((MKDS_Course_Modifier.UI.BNCL)FileHandler.OpenDialog).SetNCLR(nclr); break; case MKDS_Course_Modifier.UI.NCER _: ((MKDS_Course_Modifier.UI.NCER)FileHandler.OpenDialog).SetNCLR(nclr); break; } return(false); case "NSCR": MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR nscr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR(file.Data); return(false); case "NSBMD": MKDS_Course_Modifier.G3D_Binary_File_Format.NSBMD nsbmd = new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBMD(file.Data); if (FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD) { FileHandler.OpenedFiles.RemoveAt(FileHandler.OpenedFiles.Count - 1); ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBMD(nsbmd); return(true); } if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.NSBMD(nsbmd); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "NSBTX": MKDS_Course_Modifier.G3D_Binary_File_Format.NSBTX Btx = new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBTX(file.Data); if (FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD) { ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBTX(Btx); return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.NSBTX(Btx); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "NSBCA": NSBCA Bca1 = new NSBCA(file.Data); if (!(FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD)) { return(false); } ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBCA(Bca1); return(false); case "NSBTA": MKDS_Course_Modifier.G3D_Binary_File_Format.NSBTA nsbta = new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBTA(file.Data); int num = (int)MessageBox.Show("Due to problems with texture matrices, is nsbta temporary disabled."); return(false); case "NSBMA": NSBMA Bma = new NSBMA(file.Data); if (!(FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD)) { return(false); } ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBMA(Bma); return(false); case "NSBVA": NSBVA Bva = new NSBVA(file.Data); if (!(FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD)) { return(false); } ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBVA(Bva); return(false); case "NSBTP": NSBTP Btp = new NSBTP(file.Data); if (!(FileHandler.OpenDialog is MKDS_Course_Modifier.UI.NSBMD)) { return(false); } ((MKDS_Course_Modifier.UI.NSBMD)FileHandler.OpenDialog).SetNSBTP(Btp); return(false); case "KCL": KCL KCL = new KCL(file.Data); if (FileHandler.OpenDialog is MKDS_Course_Modifier.UI.MKDS.NKM) { ((MKDS_Course_Modifier.UI.MKDS.NKM)FileHandler.OpenDialog).SetKCL(KCL); } return(false); case "MR": MKDS_Course_Modifier.MKDS.MR Mission = new MKDS_Course_Modifier.MKDS.MR(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.MKDS.MR(Mission); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "NKM": MKDS_Course_Modifier.MKDS.NKM File1 = new MKDS_Course_Modifier.MKDS.NKM(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.MKDS.NKM(File1); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "NCG.BIN": return(false); case "NCL.BIN": return(false); case "NSC.BIN": return(false); case "SPA": MKDS_Course_Modifier.Particles.SPA Spa = new MKDS_Course_Modifier.Particles.SPA(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.SPA(Spa); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "SSEQ": MKDS_Course_Modifier.Sound.SSEQ file1 = new MKDS_Course_Modifier.Sound.SSEQ(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.SSEQ(file1, FileHandler.m); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "SBNK": SBNK k = new SBNK(file.Data); if (FileHandler.OpenDialog != null && FileHandler.OpenDialog is MKDS_Course_Modifier.UI.SSEQ) { SBNK s = SBNK.InitDLS(k, (SWAR[])Parameter); ((MKDS_Course_Modifier.UI.SSEQ)FileHandler.OpenDialog).SetDLS(SBNK.ToDLS(s)); } return(false); case "SDAT": SDAT SDAT = new SDAT(file.Data); Owner.OpenSDAT(SDAT); return(true); case "SSAR": MKDS_Course_Modifier.Sound.SSEQ file2 = new MKDS_Course_Modifier.Sound.SSEQ(file.Data, (int)Parameter); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.SSEQ(file2, FileHandler.m); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "NDS": NDS Rom = new NDS(file.Data); FileHandler.OpenedArchives.Clear(); Owner.OpenNDS(Rom); return(true); case "NCER": MKDS_Course_Modifier.G2D_Binary_File_Format.NCER Cell = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCER(file.Data); if (FileHandler.OpenDialog == null) { FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.NCER(Cell); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); } if (FileHandler.OpenDialog is MKDS_Course_Modifier.UI.BNCL) { ((MKDS_Course_Modifier.UI.BNCL)FileHandler.OpenDialog).SetNCER(Cell); } return(false); case "BMG": MKDS_Course_Modifier.Misc.BMG File2 = new MKDS_Course_Modifier.Misc.BMG(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.BMG(File2); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "SM64BMD": MKDS_Course_Modifier.SM64DS.BMD bmd = new MKDS_Course_Modifier.SM64DS.BMD(file.Data); if (FileHandler.OpenDialog is MKDS_Course_Modifier.UI.BMD) { ((MKDS_Course_Modifier.UI.BMD)FileHandler.OpenDialog).SetBMD(bmd); return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.BMD(bmd); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "SM64BCA": MKDS_Course_Modifier.SM64DS.BCA Bca2 = new MKDS_Course_Modifier.SM64DS.BCA(file.Data); if (!(FileHandler.OpenDialog is MKDS_Course_Modifier.UI.BMD)) { return(false); } ((MKDS_Course_Modifier.UI.BMD)FileHandler.OpenDialog).SetBCA(Bca2); return(true); case "BNCL": MKDS_Course_Modifier.Misc.BNCL Bncl = new MKDS_Course_Modifier.Misc.BNCL(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.BNCL(Bncl); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "GCNBMD": MKDS_Course_Modifier.GCN.BMD file3 = new MKDS_Course_Modifier.GCN.BMD(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new J3D1(file3); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "HBDF": HBDF hbdf = new HBDF(file.Data); if (hbdf.MDLFBlocks.Length > 0) { if (FileHandler.OpenDialog is MDLF) { ((MDLF)FileHandler.OpenDialog).SetHBDF(hbdf); } else { FileHandler.OpenDialog = (Form) new MDLF(hbdf); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); } } return(false); case "GCNBOL": BOL bol = new BOL(file.Data); return(false); case "PAZ": PAZ Arc = new PAZ(file.Data); Owner.OpenPAZ(Arc); return(true); case "TEX": TEX tex = new TEX(file.Data); return(false); case "GRPCONF": Grpconf grpconf = new Grpconf(file.Data); return(false); case "OBJ": MKDS_Course_Modifier._3D_Formats.OBJ obj = new MKDS_Course_Modifier._3D_Formats.OBJ(file.Path); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.OBJ(obj, obj.MLTName == null ? (MLT)null : new MLT(obj.MLTName)); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "GCNBLO": MKDS_Course_Modifier.GCN.BLO Layout = new MKDS_Course_Modifier.GCN.BLO(file.Data, file.Path); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.BLO(Layout); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "3DSCGFX": MKDS_Course_Modifier._3DS.CGFX cgfx = new MKDS_Course_Modifier._3DS.CGFX(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.CGFX(cgfx); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); case "FMVVideo": MKDS_Course_Modifier.Misc.FMV Video = new MKDS_Course_Modifier.Misc.FMV(file.Data); if (FileHandler.OpenDialog != null) { return(false); } FileHandler.OpenDialog = (Form) new MKDS_Course_Modifier.UI.FMV(Video); FileHandler.OpenDialog.Show((IWin32Window)Owner); FileHandler.OpenDialog.FormClosed += new FormClosedEventHandler(FileHandler.OpenDialog_FormClosed); return(true); default: return(false); } }
public Bitmap ToBitmap(NCGR Image, NCLR Palette) { return(Graphic.ConvertData(Image.CharacterData.Data, (int)Image.CharacterData.W * 8, (int)Image.CharacterData.H * 8, Palette.PaletteData.Data, this.Data, (int)this.screenWidth, (int)this.screenHeight, Image.CharacterData.pixelFmt, Image.CharacterData.characterFmt)); }