Exemple #1
0
        private void decompressFileButton_Click(object sender, EventArgs e)
        {
            File f = fileTreeView.SelectedNode.Tag as File;

            try
            {
                try
                {
                    f.beginEdit(this);
                }
                catch (AlreadyEditingException)
                {
                    MessageBox.Show(LanguageManager.Get("Errors", "File"));
                    return;
                }

                CompressedFile RawFile = new CompressedFile(f, CompressedFile.CompressionType.MaybeCompressed);

                f.replace(RawFile.getContents(), this);
                UpdateFileInfo();
                f.endEdit(this);
            }
            catch (Exception)
            {
                MessageBox.Show(LanguageManager.Get("FilesystemBrowser", "DecompressionFail"));
                if (f.beingEditedBy(this))
                {
                    f.endEdit(this);
                }
            }
        }
Exemple #2
0
        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;

            try
            {
                if (!(f.id < 0))
                {
                    f = new CompressedFile(f, CompressedFile.CompressionType.MaybeCompressed);
                }

                switch (getFileTypeForFile(f))
                {
                case "BANNER":
                {
                    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));
                    LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile));
                }
                break;

                case "ENPG":
                {
                    LevelChooser.showImgMgr();
                    File imgFile = new InlineFile(f, 0, 0x10000, f.name);
                    File palFile = new InlineFile(f, 0x10000, 0x200, f.name);
                    LevelChooser.imgMgr.m.addImage(new EnpgImage2D(imgFile));
                    LevelChooser.imgMgr.m.addPalette(new FilePalette(palFile));
                }
                break;

                case "BNCD":
                {
                    DialogResult result = MessageBox.Show("Is this a 256 colors BNCD?\n(No by default, Yes if using the 256 worldmap icons ASM hack)", LanguageManager.Get("General", "Question"), MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Yes)
                    {
                        new Bncd256(f);
                    }
                    else if (result == DialogResult.No)
                    {
                        new Bncd(f);
                    }
                }
                break;

                case "BTX0":
                case "BMD0":
                {
                    new NSBTX(f);
                }
                break;

                case "NSCR":
                case "NCGR":
                case "NCLR":
                {
                    SectionFileLoader.load(f);
                }
                break;

                case "NARC":
                {
                    //CARC is just the LZ compressed form of the NARC and because
                    //NSMBe can now detect the LZ form it won't be needed anymore
                    new FilesystemBrowserDialog(new NarcFilesystem(f)).Show();
                }
                break;

                case "NCL":
                {
                    new PaletteViewer(f).Show();
                }
                break;

                case "NSC":
                {
                    if (LevelChooser.imgMgr != null)
                    {
                        Image2D   img  = LevelChooser.imgMgr.m.getSelectedImage();
                        Palette[] pals = LevelChooser.imgMgr.m.getPalettes();
                        if (img != null && pals != null && pals.Length > 0)
                        {
                            NSCPrompt nscPrompt = new NSCPrompt(f.getContents().Length);
                            if (!nscPrompt.canceled)
                            {
                                Tilemap t = new Tilemap(f, nscPrompt.tileWidth, img, pals, nscPrompt.imgOffs, nscPrompt.palOffs);
                                new TilemapEditorWindow(t).Show();
                            }
                            break;
                        }
                    }

                    MessageBox.Show("Please make sure you have at least a bitmap and a palette opened in the 2D Viewer before opening an NSC file.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

                case "NCG":
                {
                    LevelChooser.showImgMgr();
                    LevelChooser.imgMgr.m.addImage(new Image2D(f, 256, false));
                }
                break;

                case "BNBL":
                {
                    new BNBL(f);
                }
                break;

                case "BNCL":
                {
                    new BNCL(f);
                }
                break;
                }
            }
            catch (AlreadyEditingException ex)
            {
                MessageBox.Show(this, (LanguageManager.Get("Errors", "File")));
            }
        }