private void importLevelButton_Click(object sender, EventArgs e) { if (levelTreeView.SelectedNode == null) { return; } // Figure out what file to import if (importLevelDialog.ShowDialog() == DialogResult.Cancel) { return; } // Get the files string LevelFilename = (string)levelTreeView.SelectedNode.Tag; DSFileSystem.File LevelFile = ROM.getLevelFile(LevelFilename); DSFileSystem.File BGFile = ROM.getBGDatFile(LevelFilename); // Load it try { ExternalLevelSource level = new ExternalLevelSource(importLevelDialog.FileName); level.level.Import(LevelFile, BGFile); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void exportLevelButton_Click(object sender, EventArgs e) { if (levelTreeView.SelectedNode == null) { return; } // Figure out what file to export to if (exportLevelDialog.ShowDialog() == DialogResult.Cancel) { return; } // Get the files string LevelFilename = (string)levelTreeView.SelectedNode.Tag; DSFileSystem.File LevelFile = ROM.getLevelFile(LevelFilename); DSFileSystem.File BGFile = ROM.getBGDatFile(LevelFilename); // Load it FileStream fs = new FileStream(exportLevelDialog.FileName, FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); new ExportedLevel(LevelFile, BGFile).Write(bw); bw.Close(); }
public InternalLevelSource(string filename, string levelname, string loadFileName) { //If load from NARC in FS if (filename.Contains("@")) { string fileName = filename.Split('@')[0]; string narcName = filename.Split('@')[1]; narcFs = new NarcFilesystem(ROM.FS.getFileByName(narcName + ".narc")); levelFile = narcFs.getFileByName(fileName + ".bin"); BGDatFile = narcFs.getFileByName(fileName + "_bgdat.bin"); } //If load from FS else { levelFile = ROM.getLevelFile(filename); BGDatFile = ROM.getBGDatFile(filename); } this.filename = filename; this.levelname = levelname; if (loadFileName == "") { levelData = levelFile.getContents(); BGDatData = BGDatFile.getContents(); } else { FileStream fs = new FileStream(loadFileName, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader br = new BinaryReader(fs); ExportedLevel level = new ExportedLevel(br); br.Close(); levelData = level.LevelFile; BGDatData = level.BGDatFile; } }
private void exportClipboard_Click(object sender, EventArgs e) { string LevelFilename = (string)levelTreeView.SelectedNode.Tag; DSFileSystem.File LevelFile = ROM.getLevelFile(LevelFilename); DSFileSystem.File BGFile = ROM.getBGDatFile(LevelFilename); ByteArrayInputStream strm = new ByteArrayInputStream(new byte[0]); BinaryWriter bw = new BinaryWriter(strm); new ExportedLevel(LevelFile, BGFile).Write(bw); ClipboardLevelSource.copyData(strm.getData()); bw.Close(); }
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 LevelFilename = (string)levelTreeView.SelectedNode.Tag; DSFileSystem.File LevelFile = ROM.getLevelFile(LevelFilename); DSFileSystem.File BGFile = ROM.getBGDatFile(LevelFilename); ClipboardLevelSource level = new ClipboardLevelSource(); level.level.Import(LevelFile, BGFile); } catch (Exception ex) { MessageBox.Show((LanguageManager.Get("LevelChooser", "clipinvalidlevel"))); } }