private void editLevelButton_Click(object sender, EventArgs e)
        {
            // Make a caption
            string EditorCaption = "";

            if (levelTreeView.SelectedNode.Parent.Parent == null)
            {
                EditorCaption += levelTreeView.SelectedNode.Text;
            }
            else
            {
                EditorCaption += levelTreeView.SelectedNode.Parent.Text + ", " + levelTreeView.SelectedNode.Text;
            }

            // Open it
            try
            {
                LevelEditor NewEditor = new LevelEditor((string)levelTreeView.SelectedNode.Tag, EditorCaption);
                NewEditor.Show();
            }
            catch (AlreadyEditingException)
            {
                MessageBox.Show(LanguageManager.Get("Errors", "Level"));
            }
        }
Beispiel #2
0
 public void Initialise(NSMBGraphics GFX, NSMBLevel Level, LevelEditor editor)
 {
     this.GFX           = GFX;
     this.Level         = Level;
     this.editor        = editor;
     Ready              = true;
     hScrollBar.Visible = true;
     vScrollBar.Visible = true;
     ViewablePixels     = new Rectangle();
     ViewableBlocks     = new Rectangle();
     UpdateScrollbars();
     remakeTileCache();
     DrawingArea.Invalidate();
 }
        public void Initialise(NSMBGraphics GFX, NSMBLevel Level, LevelEditor editor) {
            this.GFX = GFX;
            this.Level = Level;
            this.editor = editor;
            Ready = true;
            hScrollBar.Visible = true;
            vScrollBar.Visible = true;
            ViewablePixels = new Rectangle();
            ViewableBlocks = new Rectangle();
            UpdateScrollbars();
            remakeTileCache();
            DrawingArea.Invalidate();

        }
        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")));
            }
        }
Beispiel #5
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")));
            }
        }
Beispiel #6
0
        private void editLevelButton_Click(object sender, EventArgs e)
        {
            // Make a caption
            string EditorCaption = "";

            if (levelTreeView.SelectedNode.Parent.Parent == null) {
                EditorCaption += levelTreeView.SelectedNode.Text;
            } else {
                EditorCaption += levelTreeView.SelectedNode.Parent.Text + ", " + levelTreeView.SelectedNode.Text;
            }

            // Open it
            try
            {
                LevelEditor NewEditor = new LevelEditor((string)levelTreeView.SelectedNode.Tag, EditorCaption);
                NewEditor.Show();
            }
            catch (AlreadyEditingException)
            {
                MessageBox.Show(LanguageManager.Get("Errors", "Level"));
            }
        }
Beispiel #7
0
        private void LevelChooser_Load(object sender, EventArgs e)
        {
            importLevelButton.Enabled = false;
            exportLevelButton.Enabled = false;
            editLevelButton.Enabled = false;
            hexEditLevelButton.Enabled = false;
            useMDI.Checked = Properties.Settings.Default.mdi;
            autoUpdate.Checked = Properties.Settings.Default.AutoUpdateSD;
            chkAutoBackup.Checked = Properties.Settings.Default.AutoBackup > 0;
            if (chkAutoBackup.Checked)
                autoBackupTime.Value = Properties.Settings.Default.AutoBackup;
            init = true;

            filesystemBrowser1.Load(ROM.FS);

            LoadLevelNames();
            if (ROM.UserInfo != null)
                musicList.Items.AddRange(ROM.UserInfo.getFullList("Music").ToArray());

            LanguageManager.ApplyToContainer(this, "LevelChooser");
            importLevelDialog.Filter = LanguageManager.Get("LevelChooser", "LevelFilter");
            exportLevelDialog.Filter = LanguageManager.Get("LevelChooser", "LevelFilter");
            openPatchDialog.Filter = LanguageManager.Get("LevelChooser", "PatchFilter");
            savePatchDialog.Filter = LanguageManager.Get("LevelChooser", "PatchFilter");
            this.Activate();
            //Get Language Files
            string langDir = System.IO.Path.Combine(Application.StartupPath, "Languages");
            if (System.IO.Directory.Exists(langDir)) {
                string[] files = System.IO.Directory.GetFiles(langDir);
                for (int l = 0; l < files.Length; l++) {
                    if (files[l].EndsWith(".ini")) {
                        int startPos = files[l].LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1;
                        languageListBox.Items.Add(files[l].Substring(startPos, files[l].LastIndexOf('.') - startPos));
                    }
                }
            }

            // Load filebackups from crash
            string backupPath = Path.Combine(Application.StartupPath, "Backup");
            if (ROM.fileBackups.Count > 0)
                foreach (string filename in ROM.fileBackups)
                    try
                    {
                        byte[] levelFile; byte[] bgFile; string[] error;
                        FileStream fs = new System.IO.FileStream(Path.Combine(backupPath, filename + ".nml"), FileMode.Open);
                        BinaryReader br = new BinaryReader(fs);
                        NSMBLevel.getImportLevel(out levelFile, out bgFile, out error, br);
                        br.Close();
                        if (error == null)
                        {
                            LevelEditor newEditor = new LevelEditor(filename, filename + " - Recovered Level", levelFile, bgFile);
                            newEditor.Show();
                        }
                    }
                    catch (Exception) { }

            this.Text = "NSMB Editor 5.2 Beta";
            label3.Text = "NSMB Editor 5.2 " + Properties.Resources.version.Trim();
            this.Icon = Properties.Resources.nsmbe;

            if (!ROM.isNSMBRom)
            {
                tabControl1.TabPages.Remove(tabPage2);
                tabControl1.TabPages.Remove(tabPage5);
                tabControl1.TabPages.Remove(tabPage6);
                nsmbToolsGroupbox.Enabled = false;
                musicSlotsGrp.Enabled = false;
            }

            //            new LevelEditor("A01_1", "LOL").Show();
        }