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; } }
public override void save(ExportedLevel level) { ByteArrayInputStream strm = new ByteArrayInputStream(new byte[0]); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(strm); level.Write(bw); copyData(strm.getData()); }
public override void save(ExportedLevel level) { FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); BinaryWriter bw = new BinaryWriter(fs); level.Write(bw); bw.Close(); }
public ExternalLevelSource(string filename, string loadFileName) { this.filename = filename; FileStream fs = new FileStream(loadFileName, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader br = new BinaryReader(fs); level = new ExportedLevel(br); br.Close(); }
private void levelSaver_DoWork(object sender, DoWorkEventArgs e) { try { Console.Out.WriteLine("Backing up level " + Level.source.getBackupText()); ExportedLevel exlvl = Level.getExport(); string backupPath = System.IO.Path.Combine(Application.StartupPath, "Backup"); if (!System.IO.Directory.Exists(backupPath)) { System.IO.Directory.CreateDirectory(backupPath); } string filename = Level.source.getBackupFileName(); System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(backupPath, filename), System.IO.FileMode.Create); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs); exlvl.Write(bw); bw.Close(); } catch (Exception ex) { } }
public InternalLevelSource(int LevelID, string levelname, string loadFileName) { levelFile = ROM.FS.getFileById(LevelID); BGDatFile = ROM.FS.getFileById(LevelID + 1); 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; } }
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), false); 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(); }
public void Save() { ExportedLevel exlvl = getExport(); source.save(exlvl); }
public abstract void save(ExportedLevel level);
public override void save(ExportedLevel level) { levelFile.replace(level.LevelFile, this); BGDatFile.replace(level.BGDatFile, this); }