/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonSaveScript_Click(object sender, EventArgs e) { if (scriptArrayEditor.SelectedObject is SEMScript sound) { byte[] d; if (SEM.CompileSEMScript(scriptBox.Text, out d) == -1) { sound.CommandData = d; } scriptBox.Text = SEM.DecompileSEMScript(sound.CommandData); } }
/// <summary> /// /// </summary> /// <param name="pack"></param> /// <param name="fighter"></param> /// <param name="editor"></param> /// <returns>Dictionary to maps old sound id values to new values</returns> private void ImportSoundData(ZipFile pack, MEXFighterEntry fighter, string semFile) { Console.WriteLine($"Importing Sound Data..."); var root = Path.GetDirectoryName(MainForm.Instance.FilePath); // Load SEM File SemEntries = SEM.ReadSEMFile(semFile, true, editor._data); // narrator call----------------------------------------------- var narratorScript = @".SFXID : (id) .REVERB : 48 .PRIORITY : 15 .UNKNOWN06 : 229 .END : 0"; var narr = pack["Sound/narrator.dsp"]; var nameBank = SemEntries.Find(e => e.SoundBank?.Name == "nr_name.ssm"); if (narr != null && nameBank != null) { var narsound = new DSP(); narsound.FromFormat(GetBytes(narr), "dsp"); var index = nameBank.SoundBank.Sounds.Length; nameBank.SoundBank.AddSound(narsound); var script = new SEMScript(); SEM.CompileSEMScript(narratorScript.Replace("(id)", index.ToString()), out script.CommandData); var scriptIndex = nameBank.Scripts.Length; nameBank.AddScript(script); fighter.AnnouncerCall = scriptIndex + SemEntries.IndexOf(nameBank) * 10000; Console.WriteLine("Imported Announcer Call"); } // Create and import SSM----------------------------------------------- var semYAML = pack["Sound/sem.yaml"]; var ssmFile = pack["Sound/sound.ssm"]; if (semYAML != null) { using (MemoryStream zos = new MemoryStream()) { semYAML.Extract(zos); zos.Position = 0; using (StreamReader r = new StreamReader(zos)) { var semEntry = SEMEntry.Deserialize(r.ReadToEnd()); if (ssmFile != null) { var ssmName = fighter.NameText.ToLower() + ".ssm"; semEntry.SoundBank = new SSM(); using (MemoryStream ssmStream = new MemoryStream()) { ssmFile.Extract(ssmStream); ssmStream.Position = 0; semEntry.SoundBank.Open(ssmName, ssmStream); } var ssmFilePath = Path.Combine(root, "audio\\us\\" + ssmName); File.WriteAllBytes(ssmFilePath, GetBytes(ssmFile)); } fighter.SSMIndex = SemEntries.Count; SemEntries.Add(semEntry); } } } // Import Victory Theme var victory = pack["Sound/victory.hps"]; if (victory != null) { var ffname = $"ff_{fighter.NameText.ToLower()}.hps"; fighter.VictoryThemeID = editor.MusicControl.AddMusic(new HSD_String() { Value = ffname }); var fffilePath = Path.Combine(root, "audio\\" + ffname); File.WriteAllBytes(fffilePath, GetBytes(victory)); } }