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 NarcReplace(string NarcName, string f1) { NarcFilesystem fs = new NarcFilesystem(ROM.FS.getFileByName(NarcName)); NSMBe5.DSFileSystem.File f = fs.getFileByName(f1); f.beginEdit(this); f.replace(ROM.FS.getFileByName(f1).getContents(), this); f.endEdit(this); fs.close(); }
//WTF was this for?! //private void NarcReplace(string NarcName, string f1, string f2) { } private void NarcReplace(string NarcName, string f1, ushort f2) { NarcFilesystem fs = new NarcFilesystem(ROM.FS.getFileByName(NarcName)); NSMBe5.DSFileSystem.File f = fs.getFileByName(f1); if (f == null) { Console.Out.WriteLine("No File: " + NarcName + "/" + f1); } else { f.beginEdit(this); f.replace(ROM.FS.getFileById(f2).getContents(), this); f.endEdit(this); } fs.close(); }