示例#1
0
        private void importClipboard_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show((LanguageManager.Get("LevelChooser", "replaceclipboard")), (LanguageManager.Get("LevelChooser", "replaceclipboardtitle")), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            try
            {
                string leveltxt = Clipboard.GetText();
                if (!(leveltxt.StartsWith("NSMBeLevel|") && leveltxt.EndsWith("|")))
                {
                    throw new Exception();
                }
                leveltxt = leveltxt.Substring(11, leveltxt.Length - 12);
                byte[] levelfile          = ROM.LZ77_Decompress(Convert.FromBase64String(leveltxt));
                ByteArrayInputStream strm = new ByteArrayInputStream(levelfile);
                BinaryReader         br   = new BinaryReader(strm);

                string LevelFilename = (string)levelTreeView.SelectedNode.Tag;
                NSMBe4.DSFileSystem.File LevelFile = ROM.FS.getFileByName(LevelFilename + ".bin");
                NSMBe4.DSFileSystem.File BGFile    = ROM.FS.getFileByName(LevelFilename + "_bgdat.bin");
                new ExportedLevel(br).Import(LevelFile, BGFile);
                br.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show((LanguageManager.Get("LevelChooser", "clipinvalidlevel")));
            }
        }
示例#2
0
 public void reload()
 {
     rawdata = f.getContents();
     if (isLZCompressed)
     {
         rawdata = ROM.LZ77_Decompress(rawdata);
     }
     loadImageData();
 }
示例#3
0
 public PaletteViewer(File f)
 {
     InitializeComponent();
     this.MdiParent = MdiParentForm.instance;
     this.f         = f;
     fileLz         = new LZFile(f, LZFile.CompressionType.LZ);
     this.pal       = FilePalette.arrayToPalette(ROM.LZ77_Decompress(f.getContents()));
     if (pal.Length < 256)
     {
         is4bpp.Checked = true;
     }
     updatePalettes();
     pictureBox1.Invalidate();
     this.Icon = Properties.Resources.nsmbe;
 }
示例#4
0
        private void openClipboard_Click(object sender, EventArgs e)
        {
            try
            {
                string leveltxt = Clipboard.GetText();
                if (!(leveltxt.StartsWith("NSMBeLevel|") && leveltxt.EndsWith("|")))
                {
                    throw new Exception();
                }
                leveltxt = leveltxt.Substring(11, leveltxt.Length - 12);
                byte[] leveldata          = ROM.LZ77_Decompress(Convert.FromBase64String(leveltxt));
                ByteArrayInputStream strm = new ByteArrayInputStream(leveldata);
                BinaryReader         br   = new BinaryReader(strm);

                ExportedLevel exlvl     = new ExportedLevel(br);
                LevelEditor   newEditor = new LevelEditor("", "", exlvl.LevelFile, exlvl.BGFile, exlvl.LevelFileID, exlvl.BGFileID);
                newEditor.Show();
                br.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show((LanguageManager.Get("LevelChooser", "clipinvalidlevel")));
            }
        }
示例#5
0
        public ClipboardLevelSource(string loadFileName)
        {
            BinaryReader br;

            if (loadFileName == "")
            {
                string leveltxt = Clipboard.GetText();
                if (!(leveltxt.StartsWith(clipboardHeader) && leveltxt.EndsWith(clipboardFooter)))
                {
                    throw new Exception();
                }
                leveltxt = leveltxt.Substring(11, leveltxt.Length - 12);
                byte[] leveldata          = ROM.LZ77_Decompress(Convert.FromBase64String(leveltxt));
                ByteArrayInputStream strm = new ByteArrayInputStream(leveldata);
                br = new BinaryReader(strm);
            }
            else
            {
                FileStream fs = new FileStream(loadFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                br = new BinaryReader(fs);
            }
            level = new ExportedLevel(br);
            br.Close();
        }