/// <summary> /// When a song is selected /// </summary> /// <param name="p_TableView">Source table</param> /// <param name="p_Row">Selected row</param> private void OnSongSelected(TableView p_TableView, int p_Row) { /// Fetch song entry var l_SongEntry = m_SongList.Data[p_Row]; /// Hide if invalid song if (l_SongEntry == null) { /// Hide song info panel UnselectSong(); return; } /// Show UIs m_SongInfoPanel.SetActive(true); FlowCoordinator.DetailView.SetVisible(true); /// Update UIs m_SongInfo_Detail.FromBeatSaver(l_SongEntry.BeatMap, l_SongEntry.Cover); m_SongInfo_Detail.SetFavoriteToggleValue(m_TypeSegmentControl.selectedCellNumber == 2 /* Blacklist */); FlowCoordinator.DetailView.SetDetail(l_SongEntry.BeatMap); /// Set selected song m_SelectedSong = l_SongEntry; /// Launch preview music if local map var l_LocalSong = SongCore.Loader.GetLevelByHash(m_SelectedSong.BeatMap.Hash); if (l_LocalSong != null && SongCore.Loader.CustomLevels.ContainsKey(l_LocalSong.customLevelPath)) { m_SongInfo_Detail.SetPlayButtonText("Play"); /// Load the song clip to get duration if (Config.ChatRequest.PlayPreviewMusic) { l_LocalSong.GetPreviewAudioClipAsync(CancellationToken.None).ContinueWith(x => { if (x.IsCompleted && x.Status == TaskStatus.RanToCompletion) { HMMainThreadDispatcher.instance.Enqueue(() => { /// Start preview song m_SongPreviewPlayer.CrossfadeTo(x.Result, l_LocalSong.previewStartTime, l_LocalSong.previewDuration, 1f); }); } }); } } /// Stop preview music if any else { m_SongInfo_Detail.SetPlayButtonText("Download"); m_SongPreviewPlayer.CrossfadeToDefault(); } }
/// <summary> /// When a song is selected /// </summary> /// <param name="p_TableView">Source table</param> /// <param name="p_Row">Selected row</param> private void OnSongSelected(TableView p_TableView, int p_Row) { /// Fetch song entry BeatSaverCustomSongCellInfo l_SongRow = m_SongList.data[p_Row] as BeatSaverCustomSongCellInfo; /// Get song entry var l_SongEntry = m_SongsProvider.Where(x => x.BeatMap.Hash == l_SongRow.SongHash).FirstOrDefault(); /// Hide if invalid song if (l_SongEntry == null) { /// Hide song info panel UnselectSong(); return; } /// Show UIs m_SongInfoPanel.SetActive(true); /// Update UIs m_SongInfo_Detail.FromBeatSaver(l_SongEntry.BeatMap, l_SongEntry.Cover); /// Set selected song m_SelectedSong = l_SongEntry; /// Launch preview music if local map var l_LocalSong = SongCore.Loader.GetLevelByHash(m_SelectedSong.BeatMap.Hash); if (l_LocalSong != null) { m_SongInfo_Detail.SetPlayButtonText("Play"); /// Load the song clip to get duration if (Config.ChatRequest.PlayPreviewMusic) { l_LocalSong.GetPreviewAudioClipAsync(CancellationToken.None).ContinueWith(x => { if (x.IsCompleted && x.Status == TaskStatus.RanToCompletion) { HMMainThreadDispatcher.instance.Enqueue(() => { /// Start preview song m_SongPreviewPlayer.CrossfadeTo(x.Result, l_LocalSong.previewStartTime, l_LocalSong.previewDuration, 1f); }); } }); } } /// Stop preview music if any else { m_SongInfo_Detail.SetPlayButtonText("Download"); m_SongPreviewPlayer.CrossfadeToDefault(); } }