Example #1
0
        private IEnumerator GetRatingForSong(IBeatmapLevel level)
        {
            UnityWebRequest www = UnityWebRequest.Get($"{PluginConfig.beatsaverURL}/api/songs/search/hash/{level.levelID.Substring(0, 32)}");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Logger.Error($"Unable to connect to {PluginConfig.beatsaverURL}! " + (www.isNetworkError ? $"Network error: {www.error}" : (www.isHttpError ? $"HTTP error: {www.error}" : "Unknown error")));
            }
            else
            {
                try
                {
                    _firstVote = true;

                    JSONNode node = JSON.Parse(www.downloadHandler.text);

                    _lastBeatSaverSong = Song.FromSearchNode(node["songs"][0]);

                    _ratingText.text = (int.Parse(_lastBeatSaverSong.upvotes) - int.Parse(_lastBeatSaverSong.downvotes)).ToString();

                    _upvoteButton.interactable   = (PluginConfig.apiAccessToken != PluginConfig.apiTokenPlaceholder);
                    _downvoteButton.interactable = (PluginConfig.apiAccessToken != PluginConfig.apiTokenPlaceholder);
                }
                catch (Exception e)
                {
                    Logger.Exception("Unable to get song rating! Excpetion: " + e);
                }
            }
        }
Example #2
0
        public async void SetSong(IBeatmapLevel level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty)
        {
            selectedLevel = level;
            selectedBeatmapCharacteristic = characteristic;
            selectedDifficulty            = difficulty;

            songNameText.text = selectedLevel.songName;

            _playerDataModel.playerData.SetLastSelectedBeatmapCharacteristic(selectedBeatmapCharacteristic);

            var diffBeatmaps = selectedLevel.beatmapLevelData.GetDifficultyBeatmapSet(selectedBeatmapCharacteristic).difficultyBeatmaps;

            int diffIndex = CustomExtensions.GetClosestDifficultyIndex(diffBeatmaps, selectedDifficulty);

            difficultyControlRect.gameObject.SetActive(perPlayerDifficulty);
            difficultyControl.SetTexts(diffBeatmaps.Select(x => x.difficulty.ToString().Replace("Plus", "+")).ToArray());
            difficultyControl.SelectCellWithNumber(diffIndex);

            playNowButton.SetButtonText("PLAY NOW");
            playNowButtonGlow.SetGlow("#5DADE2");

            SetProgressBarState(false, 0f);

            levelCoverImage.texture = await selectedLevel.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token);
        }
Example #3
0
 static void Postfix(StandardLevelDetailViewController __instance, ref LevelParamsPanel ____levelParamsPanel, ref TextMeshProUGUI ____highScoreText, ref IDifficultyBeatmap ____selectedDifficultyBeatmap, ref PlayerData ____playerData)
 {
     try
     {
         IBeatmapLevel level       = ____selectedDifficultyBeatmap.level;
         PlayerData    localPlayer = ____playerData;
         if (localPlayer != null)
         {
             PlayerLevelStatsData playerLevelStats = localPlayer.GetPlayerLevelStatsData(level.levelID, ____selectedDifficultyBeatmap.difficulty, ____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
             if (playerLevelStats != null)
             {
                 if (playerLevelStats.validScore)
                 {
                     int   highScore = int.Parse(____highScoreText.text);
                     int   maxScore  = ScoreController.MaxRawScoreForNumberOfNotes(____selectedDifficultyBeatmap.beatmapData.notesCount);
                     float percent   = (float)highScore / maxScore;
                     percent *= 100;
                     ____highScoreText.overflowMode       = TextOverflowModes.Overflow;
                     ____highScoreText.enableWordWrapping = false;
                     ____highScoreText.richText           = true;
                     ____highScoreText.text += "<size=75%> <#FFFFFF> (" + "<#FFD42A>" + percent.ToString("F2") + "%" + "<#FFFFFF>)";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Plugin.Log("Exception in DetailView Postfix: \n " + ex);
     }
 }
Example #4
0
        public void SubmitRecommendation(IBeatmapLevel level, string listId = "")
        {
            Logger.log.Debug("Submitting Level");
            try
            {
                if (level.IsWip())
                {
                    Logger.log.Debug("WIP so not sending recommendation.");
                    return;
                }

                var recommendation = new Recommendation();

                recommendation.Hash            = SongCore.Utilities.Hashing.GetCustomLevelHash(level as CustomPreviewBeatmapLevel);
                recommendation.SongName        = level.songName;
                recommendation.SongSubName     = level.songSubName;
                recommendation.SongAuthorName  = level.songAuthorName;
                recommendation.LevelAuthorName = level.levelAuthorName;

                string json = JsonConvert.SerializeObject(recommendation);

                SharedCoroutineStarter.instance.StartCoroutine(_requestService.Post("recommendation/" + listId, json));
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
            }
        }
Example #5
0
        public void SetSelectedSong(SongInfo info)
        {
            SetLoadingState(false);

            _selectedSong = null;

            _selectedSongCell.SetText(info.songName);
            _selectedSongCell.SetSubText("Loading info...");

            _playButton.SetButtonText("PLAY");
            _playBtnGlow.color = new Color(0f, 0.7058824f, 1f, 0.7843137f);

            SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
            {
                _selectedSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                _selectedSongCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _selectedSongCell.SetIcon(cover); }));
            });

            _timeParamText.transform.parent.gameObject.SetActive(false);
            _bpmParamText.transform.parent.gameObject.SetActive(false);
            _blocksParamText.transform.parent.gameObject.SetActive(false);
            _obstaclesParamText.transform.parent.gameObject.SetActive(false);
            _starsParamText.transform.parent.gameObject.SetActive(false);
            _ratingParamText.transform.parent.gameObject.SetActive(false);

            _rankedText.gameObject.SetActive(false);

            _characteristicControl.SetTexts(new string[] { "None" });
            _characteristicControl.SelectCellWithNumber(0);
            _difficultyControl.SetTexts(new string[] { "None" });
            _difficultyControl.SelectCellWithNumber(0);
        }
        private VideoData LoadVideo(string jsonPath, IBeatmapLevel level)
        {
            var       infoText = File.ReadAllText(jsonPath);
            VideoData vid;

            try
            {
                vid = JsonUtility.FromJson <VideoData>(infoText);
            }
            catch (Exception)
            {
                Console.WriteLine("Error parsing video json: " + jsonPath);
                return(null);
            }

            vid.level = level;

            if (!File.Exists(GetVideoPath(vid)))
            {
                Console.WriteLine("Couldn't find Video: " + vid.videoPath + " queueing for download...");
                YouTubeDownloader.Instance.EnqueueVideo(vid);
            }
            else
            {
                vid.downloadState = DownloadState.Downloaded;
            }

            return(vid);
        }
            private void OnConfirmDeleteButton()
            {
                IBeatmapLevel l_LevelToDelete = standardLevelDetailView.GetField <IBeatmapLevel>("_level");

                if (l_LevelToDelete != null)
                {
                    TableView l_TableView = Resources.FindObjectsOfTypeAll <LevelCollectionViewController>().FirstOrDefault().GetComponentInChildren <TableView>();

                    int l_IndexOfTopCell = 0;
                    if (l_TableView != null)
                    {
                        if (l_TableView.visibleCells.Count() > 0)
                        {
                            l_IndexOfTopCell = l_TableView.visibleCells.Min(x => x.idx);
                        }
                    }

                    Loader.Instance.DeleteSong((l_LevelToDelete as CustomBeatmapLevel).customLevelPath);

                    /// Scroll back to where we were
                    if (l_TableView != null)
                    {
                        l_TableView.ScrollToCellWithIdx(l_IndexOfTopCell, TableViewScroller.ScrollPositionType.Beginning, false);
                    }
                }

                m_ParserParams.EmitEvent("hide-delete-confirmation-modal");
            }
        public void SetQuickButtons(IBeatmapLevel level)
        {
            if (_titleButton == null)
            {
                _titleButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(-35, 35), new Vector2(30f, 6f));
            }
            _titleButton.SetButtonText(level.songName);
            _titleButton.SetButtonTextSize(3);
            _titleButton.onClick.RemoveAllListeners();
            _titleButton.onClick.AddListener(delegate() { _inputString += level.songName + " "; UpdateInputText(); });

            if (_subtitleButton == null)
            {
                _subtitleButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(0, 35), new Vector2(30f, 6f));
            }
            _subtitleButton.SetButtonText(level.songSubName);
            _subtitleButton.SetButtonTextSize(3);
            _subtitleButton.onClick.RemoveAllListeners();
            _subtitleButton.onClick.AddListener(delegate() { _inputString += level.songSubName + " "; UpdateInputText(); });

            if (_artistButton == null)
            {
                _artistButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(35, 35), new Vector2(30f, 6f));
            }
            _artistButton.SetButtonText(level.songAuthorName);
            _artistButton.SetButtonTextSize(3);
            _artistButton.onClick.RemoveAllListeners();
            _artistButton.onClick.AddListener(delegate() { _inputString += level.songAuthorName + " "; UpdateInputText(); });
        }
Example #9
0
        /// <summary>
        ///   Fetches the lyrics of the given song online asynchronously and, if they're found,
        ///   populates the given list.
        /// </summary>
        public static IEnumerator GetOnlineLyrics(IBeatmapLevel level, List <Subtitle> subtitles)
        {
            // Perform request
            UnityWebRequest req = UnityWebRequest.Get($"https://beatsinger.herokuapp.com/{level.GetLyricsHash()}");

            yield return(req.SendWebRequest());

            if (req.isNetworkError || req.isHttpError)
            {
                Debug.Log(req.error);
            }
            else if (req.responseCode == 200)
            {
                // Request done, process result
                try
                {
                    if (req.GetResponseHeader("Content-Type") == "application/json")
                    {
                        PopulateFromJson(req.downloadHandler.text, subtitles);
                    }
                    else
                    {
                        using (StringReader reader = new StringReader(req.downloadHandler.text))
                            PopulateFromSrt(reader, subtitles);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            req.Dispose();
        }
Example #10
0
        private void _standardLevelResultsViewController_didActivateEvent(bool firstActivation, VRUI.VRUIViewController.ActivationType activationType)
        {
            IDifficultyBeatmap diffBeatmap = _standardLevelResultsViewController.GetPrivateField <IDifficultyBeatmap>("_difficultyBeatmap");

            _lastLevel = diffBeatmap.level;

            if (!(_lastLevel is CustomPreviewBeatmapLevel))
            {
                _upvoteButton.gameObject.SetActive(false);
                _downvoteButton.gameObject.SetActive(false);
                _ratingText.gameObject.SetActive(false);
                //         _reviewButton.gameObject.SetActive(false);
            }
            else
            {
                _upvoteButton.gameObject.SetActive(true);
                _downvoteButton.gameObject.SetActive(true);
                _ratingText.gameObject.SetActive(true);
                _ratingText.alignment = TextAlignmentOptions.Center;
                //      _reviewButton.gameObject.SetActive(true);

                _upvoteButton.interactable   = false;
                _downvoteButton.interactable = false;
                //         _reviewButton.interactable = false;
                _ratingText.text = "LOADING...";

                StartCoroutine(GetRatingForSong(_lastLevel));
            }
        }
Example #11
0
        private async void SetContent(IBeatmapLevel level)
        {
            if (level.beatmapLevelData.difficultyBeatmapSets.Any(x => x.beatmapCharacteristic == _playerDataModel.playerData.lastSelectedBeatmapCharacteristic))
            {
                _selectedDifficultyBeatmap = level.GetDifficultyBeatmap(_playerDataModel.playerData.lastSelectedBeatmapCharacteristic, _playerDataModel.playerData.lastSelectedBeatmapDifficulty);
            }
            else if (level.beatmapLevelData.difficultyBeatmapSets.Length > 0)
            {
                _selectedDifficultyBeatmap = level.GetDifficultyBeatmap(level.beatmapLevelData.difficultyBeatmapSets[0].beatmapCharacteristic, _playerDataModel.playerData.lastSelectedBeatmapDifficulty);
            }
            else
            {
                Plugin.log.Critical("Unable to set level! No beatmap characteristics found!");
            }

            UpdateContent();

            _playerDataModel.playerData.SetLastSelectedBeatmapCharacteristic(_selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            _playerDataModel.playerData.SetLastSelectedBeatmapDifficulty(_selectedDifficultyBeatmap.difficulty);

            SetControlData(_selectedLevel.beatmapLevelData.difficultyBeatmapSets, _playerDataModel.playerData.lastSelectedBeatmapCharacteristic);

            levelCoverImage.texture = await level.GetCoverImageTexture2DAsync(cancellationToken.Token);

            SetLoadingState(false);
        }
Example #12
0
        private static void ReadyUp(IBeatmapLevel song)
        {
            if (queuedSong != null || (queuedSong == null && song == null))
            {
                return;
            }
            if (queuedSong == null && song != null)
            {
                queuedSong = song;
                if (autoReady)
                {
                    PracticeSettings pSettings = null;
                    if (SteamAPI.GetSongOffset() > 0f)
                    {
                        pSettings = new PracticeSettings();
                        float offsetTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds() - timeRequestedToLaunch;
                        // add 5 seconds to it because that's about how long it takes to launch a song
                        pSettings.startSongTime = SteamAPI.GetSongOffset() + offsetTime + 5f;
                        timeRequestedToLaunch   = 0;
                    }

                    SongListUtils.StartSong(song, SteamAPI.GetSongDifficulty(), SteamAPI.GetGameplayModifiers(), pSettings);
                }
                else
                {
                    SteamAPI.SetReady();
                    PreviewPlayer.CrossfadeTo(song.previewAudioClip, song.previewStartTime, song.previewDuration);
                }
            }
        }
        public static async void TryDownloadSong(string levelId, TaskCompletionSource <BeatmapLevelsModel.GetBeatmapLevelResult> tcs, CancellationToken cancellationToken, BeatmapLevelsModel beatmapLevelsModel)
        {
            try
            {
                IPreviewBeatmapLevel beatmap = await Downloader.DownloadSong(levelId, cancellationToken);

                if (beatmap is CustomPreviewBeatmapLevel customLevel)
                {
                    Plugin.Log?.Debug($"Download was successful.");
                    IBeatmapLevel beatmapLevel = await CustomLevelLoader(ref beatmapLevelsModel).LoadCustomBeatmapLevelAsync(customLevel, cancellationToken);

                    UIHelper.RefreshUI();
                    tcs.TrySetResult(new BeatmapLevelsModel.GetBeatmapLevelResult(false, beatmapLevel));
                }
                else
                {
                    Plugin.Log?.Error($"beatmap:{beatmap?.GetType().Name} is not an CustomPreviewBeatmapLevel");
                }
            }
            catch (OperationCanceledException)
            {
                Plugin.Log?.Debug($"Download was canceled.");
                tcs.TrySetCanceled(cancellationToken);
                return;
            }
            catch (Exception ex)
            {
                Plugin.Log?.Error($"Error downloading beatmap '{levelId}': {ex.Message}");
                Plugin.Log?.Debug(ex);
            }
            tcs.TrySetResult(new BeatmapLevelsModel.GetBeatmapLevelResult(true, null));
            Plugin.Log?.Debug($"Download was unsuccessful.");
        }
        public void HandleDidSelectLevel(LevelPackLevelsViewController sender, IPreviewBeatmapLevel level)
        {
            selectedLevel = Resources.FindObjectsOfTypeAll <BeatmapLevelSO>().First(x => x.levelID == level.levelID);

            selectedLevelVideo = VideoLoader.Instance.GetVideo(selectedLevel);
            ScreenManager.Instance.PrepareVideo(selectedLevelVideo);
        }
Example #15
0
        private static void StartLevel(IBeatmapLevel level, BeatmapCharacteristicSO characteristic,
                                       BeatmapDifficulty difficulty, GameplayModifiers modifiers, float startTime = 0f)
        {
            var menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault();


            if (menuSceneSetupData != null)
            {
                var playerData = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData;

                var playerSettings = playerData.playerSpecificSettings;
                var environmentOverrideSettings = playerData.overrideEnvironmentSettings;

                var colorSchemesSettings = playerData.colorSchemesSettings.overrideDefaultColors
                    ? playerData.colorSchemesSettings.GetColorSchemeForId(playerData.colorSchemesSettings
                                                                          .selectedColorSchemeId)
                    : null;


                var difficultyBeatmap = level.GetDifficultyBeatmap(characteristic, difficulty, false);

                try
                {
                    BS_Utils.Gameplay.Gamemode.NextLevelIsIsolated("TestMod");
                }
                catch
                {
                }

                PracticeSettings practiceSettings = null;
                if (startTime > 1f)
                {
                    practiceSettings = new PracticeSettings(PracticeSettings.defaultPracticeSettings);
                    if (startTime > 1f)
                    {
                        practiceSettings.startSongTime = startTime + 1.5f;
                        practiceSettings.startInAdvanceAndClearNotes = true;
                    }

                    practiceSettings.songSpeedMul = modifiers.songSpeedMul;
                }

                menuSceneSetupData.StartStandardLevel(
                    difficultyBeatmap,
                    environmentOverrideSettings,
                    colorSchemesSettings,
                    modifiers,
                    playerSettings,
                    practiceSettings,
                    "Menu",
                    false,
                    () => { },
                    (manager, result) => { });
            }
            else
            {
                Plugin.log.Error("SceneSetupData is null!");
            }
        }
 public static void Search(string query, IBeatmapLevel level, Action callback)
 {
     if (searchInProgress)
     {
         SharedCoroutineStarter.instance.StopCoroutine("SearchYoutubeCoroutine");
     }
     SharedCoroutineStarter.instance.StartCoroutine(SearchYoutubeCoroutine(query, level, callback));
 }
Example #17
0
 private void standardLevelListViewController_didSelectLevelEvent(LevelListViewController sender, IBeatmapLevel level)
 {
     if (Config.AutoUpdateSongs && level != _lastLevel && level is CustomLevel)
     {
         _lastLevel = level;
         StartCoroutine(HandleDidSelectLevelEvent(level.levelID));
     }
 }
Example #18
0
 static void Postfix(ref IBeatmapLevel ____level, ref IDifficultyBeatmap ____selectedDifficultyBeatmap)
 {
     Quest_SpectatorController.instance.readyToSpectate = true;
     if (!Quest_SpectatorController.instance.once)
     {
         Quest_SpectatorController.instance.StartClient();
     }
 }
 public void RemoveSong(IBeatmapLevel level)
 {
     if (level == null)
     {
         return;
     }
     RemoveSong(level as CustomLevel);
 }
Example #20
0
        private void DeletePressed()
        {
            IBeatmapLevel level = _detailViewController.difficultyBeatmap.level;

            _simpleDialog.Init("Delete song", $"Do you really want to delete \"{ level.songName} {level.songSubName}\"?", "Delete", "Cancel");
            _simpleDialog.didFinishEvent -= _simpleDialog_didFinishEvent;
            _simpleDialog.didFinishEvent += _simpleDialog_didFinishEvent;
            _freePlayFlowCoordinator.InvokePrivateMethod("PresentViewController", new object[] { _simpleDialog, null, false });
        }
Example #21
0
        private static void StartLevel(IBeatmapLevel beatmapLevel, SongInfo songInfo)
        {
            MenuTransitionsHelper menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault();
            PlayerData            playerSettings     = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First().playerData;

            playerSettings.playerSpecificSettings.leftHanded = songInfo.leftHanded;
            playerSettings.practiceSettings.songSpeedMul     = 1.0f;
            songInfo.modifiers.noFail = true;
            IBeatmapLevel level = beatmapLevel;

            PreviewDifficultyBeatmapSet[] sets            = songInfo.beatmap.previewDifficultyBeatmapSets;
            BeatmapCharacteristicSO       characteristics = null;

            foreach (PreviewDifficultyBeatmapSet set in sets)
            {
                if (("Mode" + set.beatmapCharacteristic.compoundIdPartName) == Convert.ToString(songInfo.mode))
                {
                    characteristics = set.beatmapCharacteristic;
                }
            }
            //BeatmapCharacteristicSO characteristics = songInfo.beatmap.previewDifficultyBeatmapSets[0].beatmapCharacteristic;
            IDifficultyBeatmap levelDifficulty = BeatmapLevelDataExtensions.GetDifficultyBeatmap(level.beatmapLevelData, characteristics, songInfo.difficulty);

            menuSceneSetupData.StartStandardLevel(levelDifficulty,
                                                  playerSettings.overrideEnvironmentSettings.overrideEnvironments ? playerSettings.overrideEnvironmentSettings : null,
                                                  playerSettings.colorSchemesSettings.overrideDefaultColors ? playerSettings.colorSchemesSettings.GetSelectedColorScheme() : null,
                                                  songInfo.modifiers,
                                                  playerSettings.playerSpecificSettings,
                                                  null, "Exit", false, () => { }, (StandardLevelScenesTransitionSetupDataSO sceneTransition, LevelCompletionResults results) =>
            {
                bool newHighScore = false;

                var mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                if (results.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
                {
                    return;
                }

                switch (results.levelEndStateType)
                {
                case LevelCompletionResults.LevelEndStateType.None:
                    break;

                case LevelCompletionResults.LevelEndStateType.Cleared:
                    Logger.log.Info("Showing menu");
                    break;

                case LevelCompletionResults.LevelEndStateType.Failed:
                    Logger.log.Info("Showing menu");
                    break;

                default:
                    break;
                }
            });
        }
        public BeatmapDetails(IBeatmapLevel level)
        {
            if (level == null)
            {
                throw new ArgumentNullException(nameof(level), "IBeatmapLevel parameter 'level' cannot be null");
            }
            else if (level.beatmapLevelData == null)
            {
                throw new ArgumentException("Provided IBeatmapLevel object cannot have the 'beatmapLevelData' property be null", nameof(level));
            }

            // remove the directory part of a custom level ID
            LevelID = BeatmapDetailsLoader.GetSimplifiedLevelID(level);

            SongName       = level.songName;
            BeatsPerMinute = level.beatsPerMinute;

            if (level.beatmapLevelData.audioClip != null)
            {
                SongDuration = level.beatmapLevelData.audioClip.length;
            }
            else
            {
                SongDuration = level.songDuration;
                if (level is CustomBeatmapLevel)
                {
                    Logger.log.Debug("Using stored song duration for custom song (might not work)");
                }
            }

            var levelDifficultyBeatmapSets = level.beatmapLevelData.difficultyBeatmapSets;

            DifficultyBeatmapSets = new SimplifiedDifficultyBeatmapSet[levelDifficultyBeatmapSets.Count()];
            for (int i = 0; i < levelDifficultyBeatmapSets.Count(); ++i)
            {
                SimplifiedDifficultyBeatmapSet newSet = new SimplifiedDifficultyBeatmapSet();
                DifficultyBeatmapSets[i] = newSet;

                newSet.CharacteristicName = levelDifficultyBeatmapSets[i].beatmapCharacteristic.serializedName;

                var levelDifficultyBeatmaps = levelDifficultyBeatmapSets[i].difficultyBeatmaps;
                newSet.DifficultyBeatmaps = new SimplifiedDifficultyBeatmap[levelDifficultyBeatmaps.Length];
                for (int j = 0; j < levelDifficultyBeatmaps.Length; ++j)
                {
                    SimplifiedDifficultyBeatmap newDiff = new SimplifiedDifficultyBeatmap();
                    newSet.DifficultyBeatmaps[j] = newDiff;

                    newDiff.Difficulty               = levelDifficultyBeatmaps[j].difficulty;
                    newDiff.NoteJumpMovementSpeed    = levelDifficultyBeatmaps[j].noteJumpMovementSpeed;
                    newDiff.NotesCount               = levelDifficultyBeatmaps[j].beatmapData.notesCount;
                    newDiff.BombsCount               = levelDifficultyBeatmaps[j].beatmapData.bombsCount;
                    newDiff.ObstaclesCount           = levelDifficultyBeatmaps[j].beatmapData.obstaclesCount;
                    newDiff.SpawnRotationEventsCount = levelDifficultyBeatmaps[j].beatmapData.spawnRotationEventsCount;
                }
            }
        }
Example #23
0
        public void SetSelectedSong(IBeatmapLevel selectedLevel)
        {
            buttonsRect.gameObject.SetActive(isHost);

            _selectedLevel = selectedLevel;
            controlsRect.gameObject.SetActive(true);
            charactertisticControlBlocker.gameObject.SetActive(!isHost);
            difficultyControlBlocker.gameObject.SetActive(!isHost);
            SetBeatmapLevel(_selectedLevel);
        }
        public VideoData GetVideo(IBeatmapLevel level)
        {
            VideoData vid;

            if (videos.TryGetValue(level, out vid))
            {
                return(vid);
            }
            return(null);
        }
            private void OnDeleteButton()
            {
                IBeatmapLevel l_LevelToDelete = standardLevelDetailView.GetField <IBeatmapLevel>("_level");

                if (l_LevelToDelete != null && l_LevelToDelete is CustomBeatmapLevel customLevel)
                {
                    m_DeleteConfirmationText.text = $"Are you sure you would like to delete '<color=#FFFFCC>{Utils.GameUI.EscapeTextMeshProTags(customLevel.songName)}</color>' by {Utils.GameUI.EscapeTextMeshProTags(customLevel.levelAuthorName)}?";
                    m_ParserParams.EmitEvent("show-delete-confirmation-modal");
                }
            }
Example #26
0
        public void SetSelectedSong(IBeatmapLevel selectedLevel)
        {
            buttonsRect.gameObject.SetActive(!DisablePlayButton);

            _selectedLevel = selectedLevel;
            controlsRect.gameObject.SetActive(true);
            charactertisticControlBlocker.gameObject.SetActive(DisableCharacteristicControl);
            difficultyControlBlocker.gameObject.SetActive(DisableDifficultyControl);
            SetBeatmapLevel(_selectedLevel);
        }
Example #27
0
        public string GetVideoPath(IBeatmapLevel level)
        {
            VideoData vid;

            if (videos.TryGetValue(level, out vid))
            {
                return(GetVideoPath(vid));
            }
            return(null);
        }
Example #28
0
        private static void StartLevel(IBeatmapLevel beatmapLevel, CustomPreviewBeatmapLevel beatmap, BeatmapDifficulty difficulty)
        {
            Logger.log.Info("Starting level");

            MenuTransitionsHelper menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault();
            PlayerData            playerSettings     = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData;

            var gamePlayModifiers = new GameplayModifiers();

            gamePlayModifiers.IsWithoutModifiers();

            IBeatmapLevel           level           = beatmapLevel;
            BeatmapCharacteristicSO characteristics = beatmap.previewDifficultyBeatmapSets[0].beatmapCharacteristic;
            IDifficultyBeatmap      levelDifficulty = BeatmapLevelDataExtensions.GetDifficultyBeatmap(level.beatmapLevelData, characteristics, difficulty);

            menuSceneSetupData.StartStandardLevel(levelDifficulty,
                                                  playerSettings.overrideEnvironmentSettings.overrideEnvironments ? playerSettings.overrideEnvironmentSettings : null,
                                                  playerSettings.colorSchemesSettings.overrideDefaultColors ? playerSettings.colorSchemesSettings.GetSelectedColorScheme() : null,
                                                  gamePlayModifiers,
                                                  playerSettings.playerSpecificSettings,
                                                  playerSettings.practiceSettings, "Exit", false, () => { }, (StandardLevelScenesTransitionSetupDataSO sceneTransition, LevelCompletionResults results) =>
            {
                bool newHighScore = false;

                var mainFlowCoordinator       = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();
                RandomSongMenu randomSongMenu = BeatSaberUI.CreateFlowCoordinator <RandomSongMenu>();

                if (results.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
                {
                    Logger.log.Info("Restarting level");
                    return;
                }

                switch (results.levelEndStateType)
                {
                case LevelCompletionResults.LevelEndStateType.None:
                    break;

                case LevelCompletionResults.LevelEndStateType.Cleared:
                    UploadScore(levelDifficulty, results, out newHighScore);
                    randomSongMenu.Show(beatmap, difficulty, levelDifficulty, results, newHighScore);
                    Logger.log.Info("Showing menu");
                    break;

                case LevelCompletionResults.LevelEndStateType.Failed:
                    Logger.log.Info("Showing menu");
                    randomSongMenu.Show(beatmap, difficulty, levelDifficulty, results, newHighScore);
                    break;

                default:
                    break;
                }
            });
        }
        /// <summary>
        /// Remove Song from editing playlist
        /// </summary>
        /// <param name="levelId"></param>
        public void RemoveSongFromEditingPlaylist(IBeatmapLevel songInfo)
        {
            if (this.CurrentEditingPlaylist == null)
            {
                return;
            }

            this.CurrentEditingPlaylist.songs.RemoveAll(x => x.level != null && x.level.levelID == songInfo.levelID);
            this.CurrentEditingPlaylistLevelIds.RemoveWhere(x => x == songInfo.levelID);

            this.CurrentEditingPlaylist.SavePlaylist();
        }
Example #30
0
        public void StartLevel(IBeatmapLevel level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, GameplayModifiers modifiers, float startTime = 0f)
        {
            Client.Instance.playerInfo.updateInfo.playerComboBlocks  = 0;
            Client.Instance.playerInfo.updateInfo.playerCutBlocks    = 0;
            Client.Instance.playerInfo.updateInfo.playerTotalBlocks  = 0;
            Client.Instance.playerInfo.updateInfo.playerEnergy       = 0f;
            Client.Instance.playerInfo.updateInfo.playerScore        = 0;
            Client.Instance.playerInfo.updateInfo.playerLevelOptions = new LevelOptionsInfo(difficulty, modifiers, characteristic.serializedName);

            MenuTransitionsHelperSO menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelperSO>().FirstOrDefault();

            if (_playerManagementViewController != null)
            {
                _playerManagementViewController.SetGameplayModifiers(modifiers);
            }

            if (menuSceneSetupData != null)
            {
                Client.Instance.playerInfo.updateInfo.playerState = Config.Instance.SpectatorMode ? PlayerState.Spectating : PlayerState.Game;

                PlayerSpecificSettings playerSettings = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault().playerData.playerSpecificSettings;

                roomInfo.roomState = RoomState.InGame;

                IDifficultyBeatmap difficultyBeatmap = level.GetDifficultyBeatmap(characteristic, difficulty, false);

                Plugin.log.Debug($"Starting song: name={level.songName}, levelId={level.levelID}, difficulty={difficulty}");

                Client.Instance.MessageReceived -= PacketReceived;

                try
                {
                    BS_Utils.Gameplay.Gamemode.NextLevelIsIsolated("Beat Saber Multiplayer");
                }
                catch
                {
                }

                PracticeSettings practiceSettings = new PracticeSettings(PracticeSettings.defaultPracticeSettings);
                practiceSettings.startSongTime = startTime + 1.5f;
                practiceSettings.songSpeedMul  = modifiers.songSpeedMul;
                practiceSettings.startInAdvanceAndClearNotes = true;

                menuSceneSetupData.StartStandardLevel(difficultyBeatmap, new OverrideEnvironmentSettings()
                {
                    overrideEnvironments = false
                }, null, modifiers, playerSettings, (startTime > 1f ? practiceSettings : null), "Lobby", false, () => { }, (StandardLevelScenesTransitionSetupDataSO sender, LevelCompletionResults levelCompletionResults) => { InGameOnlineController.Instance.SongFinished(levelCompletionResults, difficultyBeatmap, modifiers, startTime > 1f); });
            }
            else
            {
                Plugin.log.Error("SceneSetupData is null!");
            }
        }