public override void CopyValues(ScrObjLibraryEntry other) { base.CopyValues(other); MusicEntry ce = (MusicEntry)other; clip = ce.clip; }
public void ChangeTo(string songName) { songName = songName.Trim(); var song = songs.Find(item => item.name == songName); if (song != null && song == currentSong) { Debug.Log("Play current song -> abort!"); return; } if (songName.Length == 0) { Debug.Log("Stopping music."); audioSource.Stop(); currentSong = null; return; } Debug.Assert(song != null, "Unknown song with name " + songName); Debug.Log("Changing music to: " + songName); if (currentSong == null) { Debug.Log("play new song"); audioSource.clip = song.song; audioSource.Play(); currentSong = song; } else { Debug.Log("Set fadeinto"); fadeIntoSong = song; } }
void Update() { if (currentSong != null) { if (fadeIntoSong == null) { if (currentSong != null) { var volume = audioSource.volume + Time.deltaTime / fadeInTime; audioSource.volume = Mathf.Min(1f, volume); } } else { var volume = audioSource.volume - Time.deltaTime / fadeOutTime; audioSource.volume = Mathf.Max(0f, volume); if (volume < 0) { audioSource.Stop(); audioSource.clip = fadeIntoSong.song; audioSource.Play(); currentSong = fadeIntoSong; fadeIntoSong = null; } } } }
void InstansiateMusic() { GUI.FocusControl(null); if (musicLibrary.ContainsID(uuid)) { Debug.Log("uuid already exists!"); return; } MusicEntry me = Editor.CreateInstance <MusicEntry>(); me.name = uuid; me.uuid = uuid; me.entryName = uuid; me.repColor = repColor; string path = "Assets/LibraryData/Music/" + uuid + ".asset"; AssetDatabase.CreateAsset(me, path); musicLibrary.InsertEntry(me, 0); Undo.RecordObject(musicLibrary, "Added music"); EditorUtility.SetDirty(musicLibrary); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); uuid = ""; selMusic = 0; SelectMusic(); }
void SelectMusic() { if (selMusic == -1) { // Nothing selected if (soundType == 0) { musicValues.ResetValues(); } else { sfxValues.ResetValues(); } } else { // Something selected selMusic = Mathf.Min(currentEntryList.Length - 1, selMusic); if (soundType == 0) { MusicEntry me = (MusicEntry)musicLibrary.GetEntryByIndex(selMusic); musicValues.CopyValues(me); } else { SfxEntry se = (SfxEntry)sfxLibrary.GetEntryByIndex(selMusic); sfxValues.CopyValues(se); } } }
public MusicEntryController(EntryChunkController entrychunkcontroller, MusicEntry musicentry) : base(entrychunkcontroller, musicentry) { this.musicentry = musicentry; Node.Text = string.Format("Music Entry ({0})", musicentry.EIDString); Node.ImageKey = "musicentry"; Node.SelectedImageKey = "musicentry"; if (musicentry.VH != null) { AddNode(new VHController(this, musicentry.VH)); } foreach (SEQ seq in musicentry.SEP.SEQs) { AddNode(new SEQController(this, seq)); } AddMenuSeparator(); AddMenu("Import VH", Menu_Import_VH); AddMenu("Import SEQ", Menu_Import_SEQ); AddMenuSeparator(); AddMenu("Export SEP", Menu_Export_SEP); AddMenuSeparator(); AddMenu("Export Linked VH", Menu_Export_Linked_VH); AddMenu("Export Linked VB", Menu_Export_Linked_VB); AddMenu("Export Linked VAB", Menu_Export_Linked_VAB); AddMenu("Export Linked VAB as DLS", Menu_Export_Linked_VAB_DLS); }
public override void ResetValues() { base.ResetValues(); playerTheme = null; enemyTheme = null; battleTheme = null; healTheme = null; }
void SaveSelectedMusic() { MusicEntry me = (MusicEntry)musicLibrary.GetEntryByIndex(selMusic); me.CopyValues(musicValues); Undo.RecordObject(me, "Updated music"); EditorUtility.SetDirty(me); }
/// <summary> /// Constructor for the editor window. /// </summary> /// <param name="entries"></param> /// <param name="container"></param> public MusicEditorWindow(ScrObjLibraryVariable entries, MusicEntry container, ScrObjLibraryVariable entries2, SfxEntry container2) { musicLibrary = entries; musicValues = container; sfxLibrary = entries2; sfxValues = container2; LoadLibrary(); }
public override void CopyValues(ScrObjLibraryEntry other) { base.CopyValues(other); MusicEntry me = (MusicEntry)other; clip = me.clip; identifier = me.identifier; }
public override bool Act(DialogueScene scene, DialogueJsonItem data) { MusicEntry me = (MusicEntry)data.entry; scene.bkgMusic.value = me.clip; return(true); }
public SoundManager(TabPage tabPage) { SplitContainer splitContainerSound = tabPage.Controls["splitContainerSound"] as SplitContainer; SplitContainer splitContainerSoundMusic = splitContainerSound.Panel1.Controls["splitContainerSoundMusic"] as SplitContainer; ListBox listBoxSoundMusic = splitContainerSoundMusic.Panel1.Controls["listBoxSoundMusic"] as ListBox; TextBox textBoxSoundMusic = splitContainerSoundMusic.Panel2.Controls["textBoxSoundMusic"] as TextBox; Button buttonSoundPlayMusic = splitContainerSoundMusic.Panel2.Controls["buttonSoundPlayMusic"] as Button; SplitContainer splitContainerSoundSoundEffect = splitContainerSound.Panel2.Controls["splitContainerSoundSoundEffect"] as SplitContainer; ListBox listBoxSoundSoundEffect = splitContainerSoundSoundEffect.Panel1.Controls["listBoxSoundSoundEffect"] as ListBox; TextBox textBoxSoundSoundEffect = splitContainerSoundSoundEffect.Panel2.Controls["textBoxSoundSoundEffect"] as TextBox; Button buttonSoundPlaySoundEffect = splitContainerSoundSoundEffect.Panel2.Controls["buttonSoundPlaySoundEffect"] as Button; TableConfig.MusicData.GetMusicEntryList().ForEach(musicEntry => listBoxSoundMusic.Items.Add(musicEntry)); listBoxSoundMusic.Click += (sender, e) => { MusicEntry musicEntry = listBoxSoundMusic.SelectedItem as MusicEntry; textBoxSoundMusic.Text = musicEntry.Index.ToString(); }; buttonSoundPlayMusic.Click += (sender, e) => { int?musicIndexNullable = ParsingUtilities.ParseIntNullable(textBoxSoundMusic.Text); if (musicIndexNullable == null) { return; } int musicIndex = musicIndexNullable.Value; if (musicIndex < 0 || musicIndex > 34) { return; } uint setMusic = RomVersionConfig.SwitchMap(0x80320544, 0x8031F690); InGameFunctionCall.WriteInGameFunctionCall(setMusic, 0, (uint)musicIndex, 0); }; foreach (uint soundEffect in _soundEffects) { string soundEffectString = HexUtilities.FormatValue(soundEffect, 4); listBoxSoundSoundEffect.Items.Add(soundEffectString); } listBoxSoundSoundEffect.Click += (sender, e) => { textBoxSoundSoundEffect.Text = listBoxSoundSoundEffect.SelectedItem.ToString() + "FF81"; }; buttonSoundPlaySoundEffect.Click += (sender, e) => { uint setSound = RomVersionConfig.SwitchMap(0x8031EB00, 0x8031DC78); uint soundArg = RomVersionConfig.SwitchMap(0x803331F0, 0x803320E0); uint?soundEffectNullable = ParsingUtilities.ParseHexNullable(textBoxSoundSoundEffect.Text); if (!soundEffectNullable.HasValue) { return; } uint soundEffect = soundEffectNullable.Value; InGameFunctionCall.WriteInGameFunctionCall(setSound, soundEffect, soundArg); }; }
public override void CopyValues(ScrObjLibraryEntry other) { base.CopyValues(other); MusicSetEntry ms = (MusicSetEntry)other; playerTheme = ms.playerTheme; enemyTheme = ms.enemyTheme; battleTheme = ms.battleTheme; healTheme = ms.healTheme; }
private String EntryText(MusicEntry entry) { String annot = ""; if (!entry.Enable) { annot += "[Disabled]"; } String music = entry.BaseName; return(String.Format("{0} {1}", annot, music)); }
private VH FindLinkedVH() { MusicEntry vhentry = FindEID <MusicEntry>(musicentry.VHEID); if (vhentry == null) { throw new GUIException("The linked music entry could not be found."); } if (vhentry.VH == null) { throw new GUIException("The linked music entry was found but does not contain a VH file."); } return(vhentry.VH); }
void SelectMusic() { if (selMusic == -1) { // Nothing selected musicValues.ResetValues(); } else { // Something selected MusicEntry me = (MusicEntry)musicLibrary.GetEntryByIndex(selMusic); musicValues.CopyValues(me); } }
public override void InitializeTab() { base.InitializeTab(); TableConfig.MusicData = XmlConfigParser.OpenMusicTable(@"Config/MusicData.xml"); TableConfig.MusicData.GetMusicEntryList().ForEach(musicEntry => listBoxSoundMusic.Items.Add(musicEntry)); listBoxSoundMusic.Click += (sender, e) => { MusicEntry musicEntry = listBoxSoundMusic.SelectedItem as MusicEntry; textBoxSoundMusic.Text = musicEntry.Index.ToString(); }; buttonSoundPlayMusic.Click += (sender, e) => { int?musicIndexNullable = ParsingUtilities.ParseIntNullable(textBoxSoundMusic.Text); if (musicIndexNullable == null) { return; } int musicIndex = musicIndexNullable.Value; if (musicIndex < 0 || musicIndex > 34) { return; } uint setMusic = RomVersionConfig.SwitchMap(0x80320544, 0x8031F690); InGameFunctionCall.WriteInGameFunctionCall(setMusic, 0, (uint)musicIndex, 0); }; foreach (uint soundEffect in _soundEffects) { string soundEffectString = HexUtilities.FormatValue(soundEffect, 4); listBoxSoundSoundEffect.Items.Add(soundEffectString); } listBoxSoundSoundEffect.Click += (sender, e) => { textBoxSoundSoundEffect.Text = listBoxSoundSoundEffect.SelectedItem.ToString() + "FF81"; }; buttonSoundPlaySoundEffect.Click += (sender, e) => { uint setSound = RomVersionConfig.SwitchMap(0x8031EB00, 0x8031DC78); uint soundArg = RomVersionConfig.SwitchMap(0x803331F0, 0x803320E0); uint?soundEffectNullable = ParsingUtilities.ParseHexNullable(textBoxSoundSoundEffect.Text); if (!soundEffectNullable.HasValue) { return; } uint soundEffect = soundEffectNullable.Value; InGameFunctionCall.WriteInGameFunctionCall(setSound, soundEffect, soundArg); }; }
public void CopyValues(Frame other) { background = other.background; characters = new CharacterEntry[Constants.DIALOGUE_PLAYERS_COUNT]; poses = new int[Constants.DIALOGUE_PLAYERS_COUNT]; for (int i = 0; i < Constants.DIALOGUE_PLAYERS_COUNT; i++) { characters[i] = other.characters[i]; poses[i] = other.poses[i]; } talkingIndex = other.talkingIndex; talkingName = other.talkingName; dialogueText = other.dialogueText; bkgMusic = other.bkgMusic; }
public override bool Act(DialogueScene scene, DialogueActionData data) { MusicEntry me = (MusicEntry)data.entries[0]; if (me == null) { return(false); } scene.bkgMusic.value = me.clip; scene.musicFocusSource.value = false; scene.effectStartDuration.value = 0; scene.effectEndDuration.value = 0; return(true); }
public override bool Act(DialogueScene scene, DialogueActionData data) { MusicEntry me = (MusicEntry)data.entries[0]; if (me == null) { Debug.LogWarning("Empty Music action!"); return(true); } scene.bkgMusic.value = me.clip; scene.effectStartDuration.value = 0; scene.effectEndDuration.value = 0; return(true); }
public void PlayMusic(string name, bool randomizeTime, float maxVolume = 1.0f) { if (m_playingMusic != null && m_playingMusic.key == name) { return; } var music = m_music.FirstOrDefault(a => a.key == name); if (music != null) { m_queuedMusic = music; m_randomizeTime = randomizeTime; m_maxVolume = maxVolume; } }
void SaveSelectedMusic() { if (soundType == 0) { MusicEntry me = (MusicEntry)musicLibrary.GetEntryByIndex(selMusic); me.CopyValues(musicValues); Undo.RecordObject(me, "Updated music"); EditorUtility.SetDirty(me); } else { SfxEntry se = (SfxEntry)sfxLibrary.GetEntryByIndex(selMusic); se.CopyValues(sfxValues); Undo.RecordObject(se, "Updated sfx"); EditorUtility.SetDirty(se); } }
public void CopyValues(Frame other) { background = other.background; characters = new CharacterEntry[Constants.DIALOGUE_PLAYERS_COUNT]; poses = new int[Constants.DIALOGUE_PLAYERS_COUNT]; for (int i = 0; i < Constants.DIALOGUE_PLAYERS_COUNT; i++) { characters[i] = other.characters[i]; poses[i] = other.poses[i]; } talkingIndex = other.talkingIndex; talkingName = other.talkingName; dialogueText = other.dialogueText; bkgMusic = other.bkgMusic; movements = new List <DialogueMoveTuple>(); for (int i = 0; i < other.movements.Count; i++) { movements.Add(other.movements[i]); } }
void DeleteMusic() { GUI.FocusControl(null); MusicEntry me = (MusicEntry)musicLibrary.GetEntryByIndex(selMusic); string path = "Assets/LibraryData/Music/" + me.uuid + ".asset"; musicLibrary.RemoveEntryByIndex(selMusic); Undo.RecordObject(musicLibrary, "Deleted music"); EditorUtility.SetDirty(musicLibrary); bool res = AssetDatabase.MoveAssetToTrash(path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); if (res) { Debug.Log("Removed music: " + me.uuid); selMusic = -1; } }
IEnumerator MusicRoutine() { while (true) { // Wait for queued music while (m_queuedMusic == null) { yield return(null); } // Fade out if (m_playingMusic != null) { while (m_musicSource.volume > 0) { m_musicSource.volume -= Time.deltaTime * 2; yield return(null); } m_musicSource.Stop(); } // Switch music m_musicSource.clip = m_queuedMusic.clip; if (m_randomizeTime) { m_musicSource.time = UnityEngine.Random.Range(0, m_musicSource.clip.length); } m_musicSource.Play(); m_playingMusic = m_queuedMusic; m_queuedMusic = null; // Fade in while (m_musicSource.volume < m_maxVolume) { m_musicSource.volume += Time.deltaTime * 2; yield return(null); } m_musicSource.volume = m_maxVolume; } }
public override bool Act(DialogueScene scene, DialogueActionData data) { scene.background.value = data.entries[0]; MusicEntry me = (MusicEntry)data.entries[1]; if (me != null) { scene.bkgMusic.value = me.clip; } else { Debug.LogWarning("No music set for the scene"); } for (int i = 0; i < Utility.DIALOGUE_PLAYERS_COUNT; i++) { scene.characters[i].value = data.entries[i + 2]; } return(true); }
public MusicListEntry(int index, MusicEntry entry) { this.index = index; this.entry = entry; }
private void InitializeMusicList() { var panel = _musicList = AddUIComponent <UIListBox>(); panel.width = width - 34; panel.height = height - 80 - 20; panel.relativePosition = new Vector3(10, 80 + 10); panel.textColor = new Color32(150, 150, 150, 255); panel.itemHover = "SubcategoriesPanel"; panel.itemHeight = 32; panel.itemPadding = new RectOffset(0, 0, 4, 4); panel.tooltip = "Click on an item to play the song.\nDouble click to enable/disable it.\nDrag to resort the list."; panel.Show(); /** * Not working -.- * */ //Update 3.3 scrollbar //if (CSLMusicModSettings.MusicListEnableScrollbar) { var scroller = panel.AddUIComponent <UIScrollbar>(); scroller.width = 15; scroller.height = panel.height; scroller.relativePosition = new Vector3(width - 15 - 15f, 0); scroller.orientation = UIOrientation.Vertical; //All credits to https://github.com/justacid/Skylines-ExtendedPublicTransport { var track = scroller.AddUIComponent <UISlicedSprite>(); track.relativePosition = Vector2.zero; track.autoSize = true; track.size = track.parent.size; track.fillDirection = UIFillDirection.Vertical; track.spriteName = "ScrollbarTrack"; scroller.trackObject = track; { UISlicedSprite thumbSprite = track.AddUIComponent <UISlicedSprite>(); thumbSprite.relativePosition = Vector2.zero; thumbSprite.fillDirection = UIFillDirection.Vertical; thumbSprite.autoSize = true; thumbSprite.width = thumbSprite.parent.width; thumbSprite.spriteName = "ChirpScrollbarThumb"; thumbSprite.color = new Color32(255, 255, 255, 128); //thumbSprite.color = new Color32(0, 100, 180, 255); scroller.thumbObject = thumbSprite; } } _musicList.scrollbar = scroller; scroller.isVisible = true; } //UpdateMusicList(); panel.eventItemClicked += delegate(UIComponent component, int value) { if (AudioWatcher != null) { //+ Only if not resorted, switch to track if (!_resort_resorted && value >= 0 && _filtered_MusicEntryList.Count > value) { //AudioWatcher.RequestSwitchMusic(MusicManager.MusicEntries[value]); AudioWatcher.RequestSwitchMusic(_filtered_MusicEntryList[value]); //use filtered list } } }; panel.eventItemDoubleClicked += delegate(UIComponent component, int value) { if (value >= 0 && _filtered_MusicEntryList.Count > value) { //Store old entry MusicEntry current = AudioWatcher.CurrentMusicEntry; //MusicEntry entry = MusicManager.MusicEntries[value]; var entry = _filtered_MusicEntryList[value]; entry.Enable = !entry.Enable; UpdateMusicListPreserveScroll(); //Restore the current entry AudioWatcher.RequestSwitchMusic(current); } }; //Add feature to resort the music list panel.eventItemMouseDown += delegate(UIComponent component, int value) { if (AudioWatcher != null) { //Disable resort while filtering if (Filtered) { return; } if (value >= 0 && MusicManager.MusicEntries.Count > value) { _resort_CurrentItem = MusicManager.MusicEntries[value]; _resort_currentPivotIndex = value; _resort_resorted = false; } } }; panel.eventItemMouseUp += delegate(UIComponent component, int value) { _resort_CurrentItem = null; if (_resort_resorted) { MusicManager.SaveMusicFileSettings(); } }; panel.eventItemMouseHover += delegate(UIComponent component, int value) { if (value >= 0 && _filtered_MusicEntryList.Count > value) { if (_resort_CurrentItem != null && value != _resort_currentPivotIndex) { //Disable resort while filtering if (Filtered) { return; } MusicManager.MusicEntries.Remove(_resort_CurrentItem); MusicManager.MusicEntries.Insert(value, _resort_CurrentItem); _resort_currentPivotIndex = value; UpdateMusicListPreserveScroll(); _resort_resorted = true; } else { var entry = _filtered_MusicEntryList[value]; String tooltip = entry.BaseName + "\n----\n"; tooltip += "Supported tags:\n"; foreach (var tag in entry.TagSongs.Keys) { if (tag == "") { tooltip += "Default music\n"; } else { tooltip += MusicManager.TagIndicator + tag + "\n"; } } tooltip += "\n\nClick on an item to play the song.\nDouble click to enable/disable it.\nDrag to resort the list."; _musicList.tooltip = tooltip; } } }; }
/// <summary> /// Constructor /// </summary> /// <param name="entries"></param> /// <param name="container"></param> public MusicEditorWindow(ScrObjLibraryVariable entries, MusicEntry container) { musicLibrary = entries; musicValues = container; LoadLibrary(); }
protected override void DrawContentWindow() { MusicEntry musicValues = (MusicEntry)entryValues; musicValues.clip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", musicValues.clip, typeof(AudioClip), false); }