Example #1
0
        //Everything else.
        #region everythingElse

        //New
        private void newBetaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            file      = new swarFile();
            file.data = new swarFile.swarData[0];
            file.fixOffsets();
            updateNodes();
        }
Example #2
0
        //Open
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog f = new OpenFileDialog();

            f.Filter = "Swarchive|*.swar";
            f.Title  = "Import the file";
            f.ShowDialog();

            if (f.FileName != "")
            {
                file = new swarFile();
                file.load(File.ReadAllBytes(f.FileName));

                file.fixOffsets();
                updateNodes();
            }
        }
Example #3
0
        public SwarEditor(MainWindow parent, byte[] b, string name, int index)
        {
            InitializeComponent();

            //Load swar.
            file = new swarFile();
            file.load(b);

            //Change nodes.
            this.Text          = name;
            tree.Nodes[0].Text = name;

            //Update nodes.
            updateNodes();

            this.parent = parent;
            parentIndex = index;
        }
Example #4
0
        public void FixInstrumentIndexStuffOther(ref sbnkFile.basicInstrumentStuff u, ref Dictionary <int, Dictionary <int, int> > newSwavs, ref UInt16 swavId, ref List <byte[]> files, BankData bankData)
        {
            //See if wave has been loaded.
            try
            {
                int index = newSwavs[(int)GetRealSwarFileId(u.swarNumber, bankData)][u.swavNumber];
                u.swarNumber = 0;
                u.swavNumber = (UInt16)index;
            }

            //Not loaded.
            catch
            {
                //Add to loaded things.
                Dictionary <int, int> swavThing = new Dictionary <int, int>();
                swavThing.Add(u.swavNumber, swavId);

                try
                {
                    newSwavs[(int)GetRealSwarFileId(u.swarNumber, bankData)].Add(u.swavNumber, swavId);
                }

                catch
                {
                    newSwavs.Add((int)GetRealSwarFileId(u.swarNumber, bankData), swavThing);
                }

                //Add that swav file.
                swarFile sf = new swarFile();
                sf.load(parent.sdat.files.files[(int)GetRealSwarFileId(u.swarNumber, bankData)]);
                files.Add(sf.data[0].files[u.swavNumber]);

                u.swarNumber = 0;
                u.swavNumber = swavId;
                swavId      += 1;
            }
        }
Example #5
0
        /// <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();
        }