//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// Stop preview music if any /// </summary> public void StopPreviewMusic() { if (m_SongPreviewPlayer != null && m_SongPreviewPlayer) { m_SongPreviewPlayer.CrossfadeToDefault(); } }
/// <summary> /// On deactivate /// </summary> /// <param name="p_RemovedFromHierarchy">Desactivation type</param> /// <param name="p_ScreenSystemEnabling">Is screen system enabled</param> protected override void DidDeactivate(bool p_RemovedFromHierarchy, bool p_ScreenSystemDisabling) { /// Forward event base.DidDeactivate(p_RemovedFromHierarchy, p_ScreenSystemDisabling); /// Close all remaining modals m_ParserParams.EmitEvent("CloseAllModals"); /// Stop preview music if any m_SongPreviewPlayer.CrossfadeToDefault(); }
IEnumerator LoadAudioClip() { GetNewSong(); Logger.Log("Loading file @ " + musicPath); WWW data = new WWW(Environment.CurrentDirectory + "\\" + musicPath); yield return(data); try { _menuMusic = data.GetAudioClipCompressed(false, AudioType.OGGVORBIS) as AudioClip; if (_menuMusic != null) { _menuMusic.name = Path.GetFileName(musicPath); } else { Logger.Log("No audio found!"); } } catch (Exception e) { Logger.Log("Can't load audio! Exception: " + e); } if (_previewPlayer != null && _menuMusic != null) { Logger.Log("Applying custom menu music..."); _previewPlayer.SetField("_defaultAudioClip", _menuMusic); _previewPlayer.CrossfadeToDefault(); } }
/// <summary> /// Stop playing level preview audio. /// </summary> public void CrossfadeAudioToDefault() { if (_cancellationTokenSource != null) { _cancellationTokenSource.Cancel(); _cancellationTokenSource = null; } _songPreviewPlayer.CrossfadeToDefault(); _songPreviewPlayerCrossfadingLevelID = null; }
private void DidSelectRow(TableView table, int row) { _selectedRow = row; if (_selectedRow != _lastSelection) { CustomLevel level = CustomLevelForRow(row); if (level) { SongLoader.Instance.LoadAudioClipForLevel(level, (customLevel) => { PlayPreview(customLevel); }); } else { _songPreviewPlayer.CrossfadeToDefault(); } } _lastSelection = _selectedRow; }
protected override void DidActivate() { ui = BSMultiplayerUI._instance; _songLoader = FindObjectOfType <SongLoader>(); localPlayerInfo = new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID()); if (_songPreviewPlayer == null) { ObjectProvider[] providers = Resources.FindObjectsOfTypeAll <ObjectProvider>().Where(x => x.name == "SongPreviewPlayerProvider").ToArray(); if (providers.Length > 0) { _songPreviewPlayer = providers[0].GetProvidedObject <SongPreviewPlayer>(); } } if (_backButton == null) { _backButton = ui.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { BSMultiplayerClient._instance.DataReceived -= DataReceived; BSMultiplayerClient._instance.DisconnectFromServer(); _songPreviewPlayer.CrossfadeToDefault(); try { transform.parent.GetComponent <MultiplayerServerHubViewController>().UpdatePage(); } catch (Exception e) { Console.WriteLine($"ServerHub exception: {e}"); } foreach (AvatarController avatar in _avatars) { Destroy(avatar.gameObject); } DismissModalViewController(null, false); }); } if (_timerText == null) { _timerText = ui.CreateText(rectTransform, "", new Vector2(0f, -5f)); _timerText.fontSize = 8f; _timerText.alignment = TextAlignmentOptions.Center; _timerText.rectTransform.sizeDelta = new Vector2(20f, 6f); } if (_selectText == null) { _selectText = ui.CreateText(rectTransform, "", new Vector2(0f, -36f)); _selectText.fontSize = 7f; _selectText.alignment = TextAlignmentOptions.Center; _selectText.rectTransform.sizeDelta = new Vector2(120f, 6f); } if (_loadingIndicator == null) { try { _loadingIndicator = ui.CreateLoadingIndicator(rectTransform); (_loadingIndicator.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_loadingIndicator.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f); _loadingIndicator.SetActive(true); } catch (Exception e) { Console.WriteLine("EXCEPTION: " + e); } } if (_selectedSongCell == null) { _selectedSongCell = Instantiate(Resources.FindObjectsOfTypeAll <SongListTableCell>().First(x => x.name == "SongListTableCell"), rectTransform, false); (_selectedSongCell.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchoredPosition = new Vector2(-25f, 0); _selectedSongCell.gameObject.SetActive(false); } else { _selectedSongCell.gameObject.SetActive(false); } if (_multiplayerLeaderboard == null) { _multiplayerLeaderboard = ui.CreateViewController <MultiplayerLeaderboardViewController>(); _multiplayerLeaderboard.rectTransform.anchorMin = new Vector2(0.3f, 0f); _multiplayerLeaderboard.rectTransform.anchorMax = new Vector2(0.7f, 1f); PushViewController(_multiplayerLeaderboard, true); } else { if (_viewControllers.IndexOf(_multiplayerLeaderboard) < 0) { PushViewController(_multiplayerLeaderboard, true); } } Console.WriteLine($"Connecting to {selectedServerIP}:{selectedServerPort}"); if (BSMultiplayerClient._instance.ConnectToServer(selectedServerIP, selectedServerPort)) { BSMultiplayerClient._instance.SendString(JsonUtility.ToJson(new ClientCommand(ClientCommandType.GetServerState))); BSMultiplayerClient._instance.SendString(JsonUtility.ToJson(new ClientCommand(ClientCommandType.GetAvailableSongs))); StartCoroutine(BSMultiplayerClient._instance.ReceiveFromServerCoroutine()); BSMultiplayerClient._instance.DataReceived += DataReceived; } else { _loading = false; TextMeshProUGUI _errorText = ui.CreateText(rectTransform, String.Format("Can't connect to server!"), new Vector2(0f, -48f)); _errorText.alignment = TextAlignmentOptions.Center; Destroy(_errorText.gameObject, 5f); } }
protected override void DidActivate() { ui = BeatSaverUI._instance; _songLoader = FindObjectOfType <SongLoader>(); UpdateAlreadyDownloadedSongs(); if (_songPreviewPlayer == null) { ObjectProvider[] providers = Resources.FindObjectsOfTypeAll <ObjectProvider>().Where(x => x.name == "SongPreviewPlayerProvider").ToArray(); if (providers.Length > 0) { _songPreviewPlayer = providers[0].GetProvidedObject <SongPreviewPlayer>(); } } if (_songListViewController == null) { _songListViewController = ui.CreateViewController <BeatSaverSongListViewController>(); _songListViewController.rectTransform.anchorMin = new Vector2(0.3f, 0f); _songListViewController.rectTransform.anchorMax = new Vector2(0.7f, 1f); PushViewController(_songListViewController, true); } else { if (_viewControllers.IndexOf(_songListViewController) < 0) { PushViewController(_songListViewController, true); } } _songListViewController.SelectTopButtons(TopButtonsState.Select); if (_backButton == null) { _backButton = ui.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { if (!_loading) { if (_songPreviewPlayer != null) { _songPreviewPlayer.CrossfadeToDefault(); } try { _songLoader.RefreshSongs(); _notUpdatedSongs.Clear(); } catch (Exception e) { log.Exception("Can't refresh songs! EXCEPTION: " + e); } DismissModalViewController(null, false); } }); } GetPage(_songListViewController._currentPage); base.DidActivate(); }
protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (addedToHierarchy) { showBackButton = true; SetTitle("Counters+"); persistentScenes = GSMPersistentScenes(ref gameScenesManager); // Get our hashset of persistent scenes mainSettings = SFCMainSettingsModel(ref settingsFlowCoordinator); persistentScenes.Add("MenuViewControllers"); // Make sure our menu persists through the transition persistentScenes.Add("MenuCore"); persistentScenes.Add("Menu"); var tutorialSceneSetup = MTHTutorialScenesSetup(ref menuTransitionsHelper); // Grab the scene transition setup data tutorialSceneSetup.Init(); // We're actually transitioning to the Tutorial sequence, but disabling the tutorial itself from starting. gameScenesManager.PushScenes(tutorialSceneSetup, 0.25f, null, (_) => { // god this makes me want to retire from beat saber modding void DisableAllNonImportantObjects(Transform original, Transform source, IEnumerable <string> importantObjects) { foreach (Transform child in source) { if (importantObjects.Contains(child.name)) { Transform loopback = child; while (loopback != original) { loopback.gameObject.SetActive(true); loopback = loopback.parent; } } else { child.gameObject.SetActive(false); DisableAllNonImportantObjects(original, child, importantObjects); } } } // Disable the tutorial from actually starting. I dont think there's a better way to do this... Transform tutorial = GameObject.Find("TutorialGameplay").transform; if (mainSettings.screenDisplacementEffectsEnabled) { // Disable menu shockwave to forget about rendering order problems menuShockwave.gameObject.SetActive(false); } // Reset menu audio to original state. songPreviewPlayer.CrossfadeToDefault(); // When not in FPFC, disable the Menu input, and re-enable the Tutorial menu input if (!Environment.GetCommandLineArgs().Any(x => x.ToLower() == "fpfc")) { vrInputModule.gameObject.SetActive(false); DisableAllNonImportantObjects(tutorial, tutorial, new string[] { "EventSystem", "ControllerLeft", "ControllerRight" }); } else // If we're in FPFC, just disable everything as usual. { DisableAllNonImportantObjects(tutorial, tutorial, Array.Empty <string>()); } }); } //fadeInOutController.FadeIn(1f, () => FadeInCallback(MenuEnvironmentManager.MenuEnvironmentType.Lobby)); PushViewControllerToNavigationController(mainScreenNavigation, blank); PushViewControllerToNavigationController(settingsSelection, horizontalSettingsList); ProvideInitialViewControllers(mainScreenNavigation, credits, null, settingsSelection); RefreshAllMockCounters(); }