/// <summary> /// Generate a new bank. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void genButton_Click(object sender, EventArgs e) { for (int f**k = 0; f**k <= 356; f**k++) { swarFile s = new swarFile(); sbnkFile b = new sbnkFile(); s.data = new swarFile.swarData[1]; b.data = new sbnkFile.sbnkData[1]; s.data[0].files = new byte[0][]; b.data[0].records = new sbnkFile.sbnkInstrumentRecord[0]; List <byte[]> files = new List <byte[]>(); List <sbnkFile.sbnkInstrumentRecord> records = new List <sbnkFile.sbnkInstrumentRecord>(); UInt16 swavId = 0; foreach (GenEntry g in gens) { int fileStart = files.Count(); Dictionary <int, Dictionary <int, int> > newSwavs = new Dictionary <int, Dictionary <int, int> >(); sbnkFile currInstrument = new sbnkFile(); if (!parent.sdat.infoFile.bankData[g.index].isPlaceHolder) { currInstrument.load(parent.sdat.files.files[(int)parent.sdat.infoFile.bankData[g.index].fileId]); foreach (int instrument in g.instruments) { try { sbnkFile.sbnkInstrumentRecord currentRecord = currInstrument.data[0].records[instrument]; //Set universal wave data. if (currentRecord.fRecord == 1) { FixInstrumentIndexStuffUniversal(ref currentRecord.instrumentA, ref newSwavs, ref swavId, ref files, parent.sdat.infoFile.bankData[g.index]); } //Set ranged wave data. else if (currentRecord.fRecord == 16) { for (int i = 0; i < currentRecord.instrumentB.stuff.Count; i++) { sbnkFile.basicInstrumentStuff bcd = currentRecord.instrumentB.stuff[i]; FixInstrumentIndexStuffOther(ref bcd, ref newSwavs, ref swavId, ref files, parent.sdat.infoFile.bankData[g.index]); currentRecord.instrumentB.stuff[i] = bcd; } } //Set regional wave data. else if (currentRecord.fRecord > 16) { for (int i = 0; i < currentRecord.instrumentC.stuff.Count; i++) { sbnkFile.basicInstrumentStuff bcd = currentRecord.instrumentC.stuff[i]; FixInstrumentIndexStuffOther(ref bcd, ref newSwavs, ref swavId, ref files, parent.sdat.infoFile.bankData[g.index]); currentRecord.instrumentC.stuff[i] = bcd; } } //Add instrument. records.Add(currentRecord); } catch { MessageBox.Show("Couldn't add instrument " + instrument + " from bank " + g.index + ".", "Notice:"); } } } } s.data[0].files = files.ToArray(); b.data[0].records = records.ToArray(); parent.sdat.files.bankFiles.Add(b.toBytes()); parent.sdat.files.waveFiles.Add(s.toBytes()); parent.sdat.fixOffsets(); parent.sdat.infoFile.bankData.Add(new BankData { fileId = (UInt32)(parent.sdat.files.bankFiles.Count + parent.sdat.files.seqArcFiles.Count + parent.sdat.files.sseqFiles.Count - 1), isPlaceHolder = false, wave0 = (UInt16)(parent.sdat.infoFile.waveData.Count), wave1 = 0xFFFF, wave2 = 0xFFFF, wave3 = 0xFFFF }); parent.sdat.symbFile.bankStrings.Add(new symbStringName { isPlaceHolder = false, name = "BANK_PV" + (544 + Globals.monindex).ToString() }); parent.sdat.infoFile.waveData.Add(new WaveData { isPlaceHolder = false, fileId = (UInt32)(parent.sdat.files.waveFiles.Count + parent.sdat.files.bankFiles.Count + parent.sdat.files.seqArcFiles.Count + parent.sdat.files.sseqFiles.Count - 1) }); parent.sdat.symbFile.waveStrings.Add(new symbStringName { isPlaceHolder = false, name = "WAVE_ARC_PV" + (544 + Globals.monindex).ToString() }); Globals.monindex++; //Fix file ids. for (int i = 0; i < parent.sdat.infoFile.waveData.Count - 1; i++) { parent.sdat.infoFile.waveData[i].fileId += 1; } for (int i = 0; i < parent.sdat.infoFile.strmData.Count; i++) { parent.sdat.infoFile.strmData[i].fileId += 2; } parent.sdat.fixOffsets(); parent.updateNodes(); } MessageBox.Show("Done! It's recommended that you re-open all open banks and streams!", "Notice:"); this.Close(); }
//Save #region save private void saveToolStripMenuItem_Click(object sender, EventArgs e) { file.fixOffsets(); parent.sdat.files.waveFiles[parentIndex] = file.toBytes(); }