protected override void DidActivate(bool firstActivation, ActivationType activationType) { _beatmapCharacteristics = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSO>(); _beatmapLevelsModel = Resources.FindObjectsOfTypeAll <BeatmapLevelsModelSO>().FirstOrDefault(); _contentModelSO = Resources.FindObjectsOfTypeAll <AdditionalContentModelSO>().FirstOrDefault(); if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _playerManagementViewController = BeatSaberUI.CreateViewController <PlayerManagementViewController>(); _playerManagementViewController.gameplayModifiersChanged += UpdateLevelOptions; _playerManagementViewController.transferHostButtonPressed += TransferHostConfirmation; var dialogOrig = ReflectionUtil.GetPrivateField <SimpleDialogPromptViewController>(FindObjectOfType <MainFlowCoordinator>(), "_simpleDialogPromptViewController"); _passHostDialog = Instantiate(dialogOrig.gameObject).GetComponent <SimpleDialogPromptViewController>(); _hostLeaveDialog = Instantiate(dialogOrig.gameObject).GetComponent <SimpleDialogPromptViewController>(); _quickSettingsViewController = BeatSaberUI.CreateViewController <QuickSettingsViewController>(); _roomNavigationController = BeatSaberUI.CreateViewController <RoomNavigationController>(); _roomNavigationController.didFinishEvent += () => { LeaveRoom(); }; _searchKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _searchKeyboard.enterButtonPressed += SearchPressed; _searchKeyboard.backButtonPressed += () => { DismissViewController(_searchKeyboard); }; _searchKeyboard.allowEmptyInput = true; } ProvideInitialViewControllers(_roomNavigationController, _playerManagementViewController, _quickSettingsViewController); }
public void RefreshLevelPacks() { CustomLevelsCollection.UpdatePreviewLevels(CustomLevels.Values.OrderBy(l => l.songName).ToArray()); WIPLevelsCollection.UpdatePreviewLevels(CustomWIPLevels.Values.OrderBy(l => l.songName).ToArray()); BeatmapLevelsModelSO.SetField("_loadedBeatmapLevelPackCollection", CustomBeatmapLevelPackCollectionSO); BeatmapLevelsModelSO.SetField("_allLoadedBeatmapLevelPackCollection", CustomBeatmapLevelPackCollectionSO); BeatmapLevelsModelSO.UpdateLoadedPreviewLevels(); OnLevelPacksRefreshed?.Invoke(); }
private void initMapVariables() { if (soloFreePlayFlowCoordinator == null) { // has a start function soloFreePlayFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().FirstOrDefault(); // has a set level function levelPackLevelsViewController = Resources.FindObjectsOfTypeAll <LevelPackLevelsViewController>().FirstOrDefault(); // has an event, that is called, when a level finished loading standardLevelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault(); standardLevelDetailViewController.didPresentContentEvent += new Action <StandardLevelDetailViewController, StandardLevelDetailViewController.ContentType> (this.HandleLevelDetailViewControllerDidPresentContent); // all the beat saber levels beatmapLevelsModelSO = Resources.FindObjectsOfTypeAll <BeatmapLevelsModelSO>().FirstOrDefault(); levelPackCollection = beatmapLevelsModelSO.allLoadedBeatmapLevelPackCollection; } }
public void RefreshLevelPacks() { CustomLevelsCollection.UpdatePreviewLevels(CustomLevels.Values.OrderBy(l => l.songName).ToArray()); WIPLevelsCollection.UpdatePreviewLevels(CustomWIPLevels.Values.OrderBy(l => l.songName).ToArray()); CachedWIPLevelCollection?.UpdatePreviewLevels(CachedWIPLevels?.Values?.OrderBy(l => l.songName).ToArray()); if (CachedWIPLevels.Count > 0) { if (CachedWIPLevelsPack != null && !CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Contains(CachedWIPLevelsPack)) { CustomBeatmapLevelPackCollectionSO.AddLevelPack(CachedWIPLevelsPack); } } // else if (CachedWIPLevelsPack != null && CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Contains(CachedWIPLevelsPack)) // CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Remove(CachedWIPLevelsPack); foreach (var folderEntry in SeperateSongFolders) { if (folderEntry.SongFolderEntry.Pack == FolderLevelPack.NewPack) { folderEntry.LevelCollection.UpdatePreviewLevels(folderEntry.Levels.Values.OrderBy(l => l.songName).ToArray()); if (folderEntry.Levels.Count > 0 || folderEntry is ModSeperateSongFolder) { if (!CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Contains(folderEntry.LevelPack)) { CustomBeatmapLevelPackCollectionSO.AddLevelPack(folderEntry.LevelPack); } } // else if (CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Contains(folderEntry.LevelPack)) // CustomBeatmapLevelPackCollectionSO._customBeatmapLevelPacks.Remove(folderEntry.LevelPack); } } BeatmapLevelsModelSO.SetField("_customLevelPackCollection", CustomBeatmapLevelPackCollectionSO); BeatmapLevelsModelSO.UpdateAllLoadedBeatmapLevelPacks(); BeatmapLevelsModelSO.UpdateLoadedPreviewLevels(); var filterNav = Resources.FindObjectsOfTypeAll <LevelFilteringNavigationController>().FirstOrDefault(); filterNav.InitPlaylists(); filterNav.UpdatePlaylistsData(); AttemptReselectCurrentLevelPack(filterNav); OnLevelPacksRefreshed?.Invoke(); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { _beatmapCharacteristics = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSO>(); _beatmapLevelsModel = Resources.FindObjectsOfTypeAll <BeatmapLevelsModelSO>().FirstOrDefault(); if (firstActivation) { _radioNavController = BeatSaberUI.CreateViewController <RoomNavigationController>(); _radioNavController.didFinishEvent += () => { LeaveChannel(); }; _inGameViewController = BeatSaberUI.CreateViewController <InGameScreenViewController>(); _inGameViewController.playPressedEvent += PlayNow_Pressed; _nextSongScreenViewController = BeatSaberUI.CreateViewController <NextSongScreenViewController>(); _nextSongScreenViewController.skipPressedEvent += SkipSong_Pressed; _resultsScreenViewController = BeatSaberUI.CreateViewController <ResultsScreenViewController>(); } ProvideInitialViewControllers(_radioNavController, null, null); }
public static async Task <BeatmapLevelsModelSO.GetBeatmapLevelResult?> GetLevelFromPreview(IPreviewBeatmapLevel level, BeatmapLevelsModelSO beatmapLevelsModel = null) { beatmapLevelsModel = beatmapLevelsModel ?? Resources.FindObjectsOfTypeAll <BeatmapLevelsModelSO>().FirstOrDefault(); if (beatmapLevelsModel != null) { getLevelCancellationTokenSource?.Cancel(); getLevelCancellationTokenSource = new CancellationTokenSource(); var token = getLevelCancellationTokenSource.Token; BeatmapLevelsModelSO.GetBeatmapLevelResult?result = null; try { result = await beatmapLevelsModel.GetBeatmapLevelAsync(level.levelID, token); } catch (OperationCanceledException) { } if (result?.isError == true || result?.beatmapLevel == null) { return(null); //Null out entirely in case of error } return(result); } return(null); }