/// <summary> /// Constructor. Acquire all necessary BeatSaberUi elements. /// </summary> /// <param name="flowCoordinator"></param> public BeatSaberUIController(LevelSelectionFlowCoordinator flowCoordinator) { Logger.Debug("Collecting all BeatSaberUI Elements..."); LevelSelectionFlowCoordinator = flowCoordinator; // gather flow coordinator elements LevelSelectionNavigationController = LevelSelectionFlowCoordinator.GetField <LevelSelectionNavigationController, LevelSelectionFlowCoordinator>("levelSelectionNavigationController"); Logger.Debug("Acquired LevelSelectionNavigationController [{0}]", LevelSelectionNavigationController.GetInstanceID()); LevelFilteringNavigationController = LevelSelectionNavigationController.GetField <LevelFilteringNavigationController, LevelSelectionNavigationController>("_levelFilteringNavigationController"); Logger.Debug("Acquired LevelFilteringNavigationController [{0}]", LevelFilteringNavigationController.GetInstanceID()); LevelCollectionNavigationController = LevelSelectionNavigationController.GetField <LevelCollectionNavigationController, LevelSelectionNavigationController>("_levelCollectionNavigationController"); Logger.Debug("Acquired LevelCollectionNavigationController [{0}]", LevelCollectionNavigationController.GetInstanceID()); LevelCollectionViewController = LevelCollectionNavigationController.GetField <LevelCollectionViewController, LevelCollectionNavigationController>("_levelCollectionViewController"); Logger.Debug("Acquired LevelPackLevelsViewController [{0}]", LevelCollectionViewController.GetInstanceID()); LevelDetailViewController = LevelCollectionNavigationController.GetField <StandardLevelDetailViewController, LevelCollectionNavigationController>("_levelDetailViewController"); Logger.Debug("Acquired StandardLevelDetailViewController [{0}]", LevelDetailViewController.GetInstanceID()); LevelCollectionTableView = this.LevelCollectionViewController.GetField <LevelCollectionTableView, LevelCollectionViewController>("_levelCollectionTableView"); Logger.Debug("Acquired LevelPackLevelsTableView [{0}]", LevelCollectionTableView.GetInstanceID()); StandardLevelDetailView = LevelDetailViewController.GetField <StandardLevelDetailView, StandardLevelDetailViewController>("_standardLevelDetailView"); Logger.Debug("Acquired StandardLevelDetailView [{0}]", StandardLevelDetailView.GetInstanceID()); BeatmapCharacteristicSelectionViewController = StandardLevelDetailView.GetField <BeatmapCharacteristicSegmentedControlController, StandardLevelDetailView>("_beatmapCharacteristicSegmentedControlController"); Logger.Debug("Acquired BeatmapCharacteristicSegmentedControlController [{0}]", BeatmapCharacteristicSelectionViewController.GetInstanceID()); LevelDifficultyViewController = StandardLevelDetailView.GetField <BeatmapDifficultySegmentedControlController, StandardLevelDetailView>("_beatmapDifficultySegmentedControlController"); Logger.Debug("Acquired BeatmapDifficultySegmentedControlController [{0}]", LevelDifficultyViewController.GetInstanceID()); LevelCollectionTableViewTransform = LevelCollectionTableView.transform as RectTransform; Logger.Debug("Acquired TableViewRectTransform from LevelPackLevelsTableView [{0}]", LevelCollectionTableViewTransform.GetInstanceID()); AnnotatedBeatmapLevelCollectionsViewController = LevelFilteringNavigationController.GetField <AnnotatedBeatmapLevelCollectionsViewController, LevelFilteringNavigationController>("_annotatedBeatmapLevelCollectionsViewController"); Logger.Debug("Acquired AnnotatedBeatmapLevelCollectionsViewController from LevelFilteringNavigationController [{0}]", AnnotatedBeatmapLevelCollectionsViewController.GetInstanceID()); TableView tableView = LevelCollectionTableView.GetField <TableView, LevelCollectionTableView>("_tableView"); ScrollView scrollView = tableView.GetField <ScrollView, TableView>("_scrollView"); TableViewPageUpButton = scrollView.GetField <Button, ScrollView>("_pageUpButton"); TableViewPageDownButton = scrollView.GetField <Button, ScrollView>("_pageDownButton"); Logger.Debug("Acquired Page Up and Down buttons..."); ActionButtons = StandardLevelDetailView.GetComponentsInChildren <RectTransform>().First(x => x.name == "ActionButtons"); Logger.Debug("Acquired ActionButtons [{0}]", ActionButtons.GetInstanceID()); ScreenSystem = Resources.FindObjectsOfTypeAll <ScreenSystem>().Last(); Logger.Debug("Acquired ScreenSystem [{0}]", ScreenSystem.GetInstanceID()); SimpleDialogPromptViewControllerPrefab = Resources.FindObjectsOfTypeAll <SimpleDialogPromptViewController>().Last(); Logger.Debug("Acquired SimpleDialogPromptViewControllerPrefab [{0}]", SimpleDialogPromptViewControllerPrefab.GetInstanceID()); BeatmapLevelsModel = Resources.FindObjectsOfTypeAll <BeatmapLevelsModel>().Last(); Logger.Debug("Acquired BeatmapLevelsModel [{0}]", BeatmapLevelsModel); }
public LevelDetailButtonsViewController(StandardLevelDetailViewController standardLevelDetailViewController, LevelCollectionViewController levelCollectionViewController, LevelCollectionNavigationController levelCollectionNavigationController, AddPlaylistModalController addPlaylistController, PopupModalsController popupModalsController, DifficultyHighlighter difficultyHighlighter) { this.standardLevelDetailViewController = standardLevelDetailViewController; levelCollectionTableView = Accessors.LevelCollectionTableViewAccessor(ref levelCollectionViewController); this.levelCollectionNavigationController = levelCollectionNavigationController; this.addPlaylistController = addPlaylistController; this.popupModalsController = popupModalsController; this.difficultyHighlighter = difficultyHighlighter; }
static bool Prefix(SinglePlayerLevelSelectionFlowCoordinator __instance, ref Action beforeSceneSwitchCallback, ref bool practice, LevelSelectionNavigationController ___levelSelectionNavigationController) { if (RecordingController.instance == null) { Logger.log?.Warn($"RecordingController is null, unable to start recording."); return(true); } if (!(OBSController.instance?.IsConnected ?? false)) { Logger.log?.Warn($"Not connected to OBS, skipping StartLevel override."); return(true); } if (Plugin.config.LevelStartDelay == 0) { RecordingController.instance.StartRecordingLevel(); SharedCoroutineStarter.instance.StartCoroutine(RecordingController.instance.GameStatusSetup()); return(true); } if (DelayedStartActive && WaitingToStart) { return(false); // Ignore this call to StartLevel } if (!WaitingToStart && DelayedStartActive) // Done waiting, start the level { DelayedStartActive = false; return(true); } DelayedStartActive = true; WaitingToStart = true; Logger.log?.Debug("LevelSelectionNavigationController_StartLevel"); LevelCollectionNavigationController navigationController = AccessNavigationController(ref ___levelSelectionNavigationController); StandardLevelDetailViewController detailViewController = AccessDetailViewController(ref navigationController); StandardLevelDetailView levelView = AccessDetailView(ref detailViewController); if (levelView != null) { levelView.actionButton.interactable = false; } SharedCoroutineStarter.instance.StartCoroutine(DelayedLevelStart(__instance, beforeSceneSwitchCallback, practice, levelView?.actionButton)); return(false); }
private void Levelnav_didChangeLevelDetailContentEvent(LevelCollectionNavigationController arg1, StandardLevelDetailViewController.ContentType arg2) { }
/// <summary> /// Sort the song list based on the settings. /// </summary> public void ProcessSongList(IAnnotatedBeatmapLevelCollection selectedBeatmapCollection, LevelSelectionNavigationController navController) { Logger.Trace("ProcessSongList()"); List <IPreviewBeatmapLevel> unsortedSongs = null; List <IPreviewBeatmapLevel> filteredSongs = null; List <IPreviewBeatmapLevel> sortedSongs = null; // Abort if (selectedBeatmapCollection == null) { Logger.Debug("Cannot process songs yet, no level collection selected..."); return; } Logger.Debug($"Using songs from level collection: {selectedBeatmapCollection.collectionName} [num={selectedBeatmapCollection.beatmapLevelCollection.beatmapLevels.Length}"); unsortedSongs = selectedBeatmapCollection.beatmapLevelCollection.beatmapLevels.ToList(); // filter Logger.Debug($"Starting filtering songs by {_settings.filterMode}"); Stopwatch stopwatch = Stopwatch.StartNew(); switch (_settings.filterMode) { case SongFilterMode.Favorites: filteredSongs = FilterFavorites(unsortedSongs); break; case SongFilterMode.Search: filteredSongs = FilterSearch(unsortedSongs); break; case SongFilterMode.Ranked: filteredSongs = FilterRanked(unsortedSongs, true, false); break; case SongFilterMode.Unranked: filteredSongs = FilterRanked(unsortedSongs, false, true); break; case SongFilterMode.Custom: Logger.Info("Song filter mode set to custom. Deferring filter behaviour to another mod."); filteredSongs = CustomFilterHandler != null?CustomFilterHandler.Invoke(selectedBeatmapCollection) : unsortedSongs; break; case SongFilterMode.None: default: Logger.Info("No song filter selected..."); filteredSongs = unsortedSongs; break; } stopwatch.Stop(); Logger.Info("Filtering songs took {0}ms", stopwatch.ElapsedMilliseconds); // sort Logger.Debug($"Starting to sort songs by {_settings.sortMode}"); stopwatch = Stopwatch.StartNew(); SortWasMissingData = false; switch (_settings.sortMode) { case SongSortMode.Original: sortedSongs = SortOriginal(filteredSongs); break; case SongSortMode.Newest: sortedSongs = SortNewest(filteredSongs); break; case SongSortMode.Author: sortedSongs = SortAuthor(filteredSongs); break; case SongSortMode.UpVotes: sortedSongs = SortUpVotes(filteredSongs); break; case SongSortMode.PlayCount: sortedSongs = SortBeatSaverPlayCount(filteredSongs); break; case SongSortMode.Rating: sortedSongs = SortBeatSaverRating(filteredSongs); break; case SongSortMode.Heat: sortedSongs = SortBeatSaverHeat(filteredSongs); break; case SongSortMode.YourPlayCount: sortedSongs = SortPlayCount(filteredSongs); break; case SongSortMode.PP: sortedSongs = SortPerformancePoints(filteredSongs); break; case SongSortMode.Stars: sortedSongs = SortStars(filteredSongs); break; case SongSortMode.Random: sortedSongs = SortRandom(filteredSongs); break; case SongSortMode.Custom: sortedSongs = CustomSortHandler != null?CustomSortHandler.Invoke(filteredSongs) : filteredSongs; break; case SongSortMode.Default: default: sortedSongs = SortSongName(filteredSongs); break; } if (this.Settings.invertSortResults && _settings.sortMode != SongSortMode.Random) { sortedSongs.Reverse(); } stopwatch.Stop(); Logger.Info("Sorting songs took {0}ms", stopwatch.ElapsedMilliseconds); // Still hacking in a custom level pack // Asterisk the pack name so it is identifable as filtered. var packName = selectedBeatmapCollection.collectionName; if (packName == null) { packName = ""; } if (!packName.EndsWith("*") && _settings.filterMode != SongFilterMode.None) { packName += "*"; } // Some level categories have a null cover image, supply something, it won't show it anyway var coverImage = selectedBeatmapCollection.coverImage; if (coverImage == null) { coverImage = BeatSaberMarkupLanguage.Utilities.ImageResources.BlankSprite; } Logger.Debug("Creating filtered level pack..."); BeatmapLevelPack levelPack = new BeatmapLevelPack(SongBrowserModel.FilteredSongsCollectionName, packName, selectedBeatmapCollection.collectionName, coverImage, new BeatmapLevelCollection(sortedSongs.ToArray())); /* * public virtual void SetData( * IAnnotatedBeatmapLevelCollection annotatedBeatmapLevelCollection, * bool showPackHeader, bool showPlayerStats, bool showPracticeButton, * string actionButtonText, * GameObject noDataInfoPrefab, BeatmapDifficultyMask allowedBeatmapDifficultyMask, BeatmapCharacteristicSO[] notAllowedCharacteristics); */ Logger.Debug("Acquiring necessary fields to call SetData(pack)..."); LevelCollectionNavigationController lcnvc = navController.GetField <LevelCollectionNavigationController, LevelSelectionNavigationController>("_levelCollectionNavigationController"); var _showPlayerStatsInDetailView = navController.GetField <bool, LevelSelectionNavigationController>("_showPlayerStatsInDetailView"); var _hidePracticeButton = navController.GetField <bool, LevelSelectionNavigationController>("_hidePracticeButton"); var _actionButtonText = navController.GetField <string, LevelSelectionNavigationController>("_actionButtonText"); var _allowedBeatmapDifficultyMask = navController.GetField <BeatmapDifficultyMask, LevelSelectionNavigationController>("_allowedBeatmapDifficultyMask"); var _notAllowedCharacteristics = navController.GetField <BeatmapCharacteristicSO[], LevelSelectionNavigationController>("_notAllowedCharacteristics"); Logger.Debug("Calling lcnvc.SetData..."); lcnvc.SetData(levelPack, true, _showPlayerStatsInDetailView, !_hidePracticeButton, _actionButtonText, null, _allowedBeatmapDifficultyMask, _notAllowedCharacteristics); //_sortedSongs.ForEach(x => Logger.Debug(x.levelID)); }
public CoverImageUpdater(LevelPackDetailViewController levelPackDetailViewController, LevelCollectionNavigationController levelCollectionNavigationController) { this.levelPackDetailViewController = levelPackDetailViewController; this.levelCollectionNavigationController = levelCollectionNavigationController; }