private CustomLevel LoadSong(CustomSongInfo song) { try { var newLevel = _customLevelPool.Get(); newLevel.Init(song); newLevel.SetAudioClip(TemporaryAudioClip); var difficultyBeatmaps = new List <LevelSO.DifficultyBeatmap>(); foreach (var diffBeatmap in song.difficultyLevels) { try { var difficulty = diffBeatmap.difficulty.ToEnum(BeatmapDifficulty.Normal); if (string.IsNullOrEmpty(diffBeatmap.json)) { Log("Couldn't find or parse difficulty json " + song.path + "/" + diffBeatmap.jsonPath, LogSeverity.Warn); continue; } var newBeatmapData = _beatmapDataPool.Get(); newBeatmapData.SetJsonData(diffBeatmap.json); var newDiffBeatmap = new CustomLevel.CustomDifficultyBeatmap(newLevel, difficulty, diffBeatmap.difficultyRank, diffBeatmap.noteJumpMovementSpeed, diffBeatmap.noteJumpStartBeatOffset, newBeatmapData); difficultyBeatmaps.Add(newDiffBeatmap); } catch (Exception e) { Log("Error parsing difficulty level in song: " + song.path, LogSeverity.Warn); Log(e.Message, LogSeverity.Warn); } } if (difficultyBeatmaps.Count == 0) { return(null); } newLevel.SetDifficultyBeatmaps(difficultyBeatmaps.ToArray()); newLevel.InitData(); LoadSprite(song.path + "/" + song.coverImagePath, newLevel); return(newLevel); } catch (Exception e) { Log("Failed to load song: " + song.path, LogSeverity.Warn); Log(e.ToString(), LogSeverity.Warn); } return(null); }
public void Init(String relativePath, String name, Sprite coverImage) { _songName = name; _songSubName = ""; _songAuthorName = "Folder"; _levelAuthorName = "Halsafar"; _levelID = $"Folder_{relativePath}"; var beatmapData = new FolderBeatMapDataSO(); var difficultyBeatmaps = new List <CustomLevel.CustomDifficultyBeatmap>(); var newDiffBeatmap = new CustomLevel.CustomDifficultyBeatmap(this, BeatmapDifficulty.Easy, 0, 0, 0, beatmapData); difficultyBeatmaps.Add(newDiffBeatmap); var sceneInfo = Resources.Load <SceneInfo>("SceneInfo/" + "DefaultEnvironment" + "SceneInfo"); this.InitFull(_levelID, _songName, _songSubName, _songAuthorName, _levelAuthorName, SongLoaderPlugin.SongLoader.TemporaryAudioClip, 1, 1, 1, 1, 1, 1, coverImage, difficultyBeatmaps.ToArray(), sceneInfo, null); this.InitData(); }
static void Postfix(ref LevelParamsPanel ____levelParamsPanel, ref IDifficultyBeatmap ____difficultyBeatmap, ref IPlayer ____player, ref TextMeshProUGUI ____songNameText, ref UnityEngine.UI.Button ____playButton, ref UnityEngine.UI.Button ____practiceButton) { IBeatmapLevel level = ____difficultyBeatmap?.level; ____playButton.interactable = true; ____practiceButton.interactable = true; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = new Color(0, 0.706f, 1.000f, 0.784f); ____songNameText.overflowMode = TextOverflowModes.Overflow; ____songNameText.enableWordWrapping = false; ____songNameText.richText = true; if (level != null) { CustomLevel.CustomDifficultyBeatmap beatmap = ____difficultyBeatmap as CustomLevel.CustomDifficultyBeatmap; if (SongLoader.infoButton == null) { SongLoader.infoButton = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PlayButton")), (RectTransform)____playButton.transform.parent.transform, false); SongLoader.infoButton.SetButtonText("?"); // SongLoader.infoButton = CustomUI.BeatSaber.BeatSaberUI.CreateUIButton((RectTransform)____playButton.transform.parent.transform, "PlayButton", null, "?"); SongLoader.infoButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0); (SongLoader.infoButton.transform as RectTransform).sizeDelta = new Vector2(0.1f, 0.1f); } if (beatmap != null) { SongLoader.infoButton.onClick.RemoveAllListeners(); SongLoader.infoButton.onClick.AddListener(delegate() { if (beatmap != null) { SongLoader.showSongRequirements(beatmap); } }); if (beatmap.requirements.Count == 0 && beatmap.suggestions.Count == 0 && beatmap.warnings.Count == 0) { SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; SongLoader.infoButton.interactable = false; } else if (beatmap.warnings.Count == 0) { SongLoader.infoButton.interactable = true; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; } else if (beatmap.warnings.Count > 0) { SongLoader.infoButton.interactable = true; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; if (beatmap.warnings.Contains("WIP")) { ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; } } SongLoader.currentRequirements = beatmap.requirements; SongLoader.currentSuggestions = beatmap.suggestions; for (int i = 0; i < beatmap.requirements.Count; i++) { if (!SongLoader.capabilities.Contains(beatmap.requirements[i])) { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = new Color(0, 0.706f, 1.000f, 0.784f); } } } else { SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; SongLoader.infoButton.interactable = false; } } }
static void Postfix(ref LevelParamsPanel ____levelParamsPanel, ref IDifficultyBeatmap ____selectedDifficultyBeatmap, ref IPlayer ____player, ref TextMeshProUGUI ____songNameText, ref UnityEngine.UI.Button ____playButton, ref UnityEngine.UI.Button ____practiceButton, ref BeatmapDifficultySegmentedControlController ____beatmapDifficultySegmentedControlController) { IBeatmapLevel level = ____selectedDifficultyBeatmap?.level; ____playButton.interactable = true; ____practiceButton.interactable = true; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = new Color(0, 0.706f, 1.000f, 0.784f); ____songNameText.text = "<size=78%>" + ____songNameText.text; // ____songNameText.overflowMode = TextOverflowModes.Overflow; // ____songNameText.enableWordWrapping = false; ____songNameText.richText = true; if (level != null) { var customLevel = level as CustomLevel; CustomLevel.CustomDifficultyBeatmap beatmap = ____selectedDifficultyBeatmap as CustomLevel.CustomDifficultyBeatmap; if (SongLoader.infoButton == null) { Console.WriteLine("Creating Info Button"); SongLoader.infoButton = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PlayButton")), (RectTransform)____levelParamsPanel.transform.parent, false); SongLoader.infoButton.SetButtonText("?"); (SongLoader.infoButton.transform as RectTransform).anchorMax = new Vector2(1, 1); (SongLoader.infoButton.transform as RectTransform).anchorMin = new Vector2(1, 1); (SongLoader.infoButton.transform as RectTransform).pivot = new Vector2(1, 1); (SongLoader.infoButton.transform as RectTransform).anchoredPosition = new Vector2(-1f, -1f); // SongLoader.infoButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0); // (SongLoader.infoButton.transform as RectTransform).sizeDelta = new Vector2(0.11f, 0.1f); SongLoader.infoButton.transform.localScale *= 0.5f; } if (beatmap != null) { SongLoader.infoButton.onClick.RemoveAllListeners(); SongLoader.infoButton.onClick.AddListener(delegate() { //Console.WriteLine("Click"); if (beatmap != null) { SongLoader.showSongRequirements(beatmap, customLevel.customSongInfo); } }); if (beatmap.requirements.Count == 0 && beatmap.suggestions.Count == 0 && beatmap.warnings.Count == 0 && customLevel?.customSongInfo?.mappers?.Length == 0 && customLevel?.customSongInfo?.lighters?.Length == 0 && beatmap.information.Count == 0 && customLevel.customSongInfo.contributors.Length == 0) { SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; SongLoader.infoButton.interactable = false; } else if (beatmap.warnings.Count == 0) { SongLoader.infoButton.interactable = true; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.blue; } else if (beatmap.warnings.Count > 0) { SongLoader.infoButton.interactable = true; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; if (beatmap.warnings.Contains("WIP")) { ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; } } SongLoader.currentRequirements = beatmap.requirements; SongLoader.currentSuggestions = beatmap.suggestions; for (int i = 0; i < beatmap.requirements.Count; i++) { if (!SongLoader.capabilities.Contains(beatmap.requirements[i])) { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; } } //Difficulty Label Handling bool overrideLabels = false; foreach (CustomSongInfo.DifficultyLevel diffLevel in customLevel.customSongInfo.difficultyLevels) { var difficulty = diffLevel.difficulty.ToEnum(BeatmapDifficulty.Normal); if (!string.IsNullOrWhiteSpace(diffLevel.difficultyLabel)) { // Console.WriteLine("Diff: " + difficulty + " Label: " + diffLevel.difficultyLabel); overrideLabels = true; switch (difficulty) { case BeatmapDifficulty.Easy: EasyOverride = diffLevel.difficultyLabel; break; case BeatmapDifficulty.Normal: NormalOverride = diffLevel.difficultyLabel; break; case BeatmapDifficulty.Hard: HardOverride = diffLevel.difficultyLabel; break; case BeatmapDifficulty.Expert: ExpertOverride = diffLevel.difficultyLabel; break; case BeatmapDifficulty.ExpertPlus: ExpertPlusOverride = diffLevel.difficultyLabel; break; } } } if (overrideLabels) { // Console.WriteLine("Overriding"); ____beatmapDifficultySegmentedControlController.SetData(____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.difficultyBeatmaps, ____beatmapDifficultySegmentedControlController.selectedDifficulty); clearOverrideLabels(); } } else { SongLoader.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; SongLoader.infoButton.interactable = false; } } }
internal static void showSongRequirements(CustomLevel.CustomDifficultyBeatmap beatmap) { if (reqDialog == null) { InitRequirementsMenu(); } // suggestionsList.text = ""; reqViewController.Data.Clear(); if (beatmap.warnings.Count > 0) { foreach (string req in beatmap.warnings) { // Console.WriteLine(req); reqViewController.Data.Add(new CustomCellInfo("<size=75%>" + req, "Warning", WarningIcon)); } } if (beatmap.requirements.Count > 0) { foreach (string req in beatmap.requirements) { // Console.WriteLine(req); if (!capabilities.Contains(req)) { reqViewController.Data.Add(new CustomCellInfo("<size=75%>" + req, "Missing Requirement", MissingReqIcon)); } else { reqViewController.Data.Add(new CustomCellInfo("<size=75%>" + req, "Requirement", HaveReqIcon)); } } } if (beatmap.suggestions.Count > 0) { foreach (string req in beatmap.suggestions) { // Console.WriteLine(req); if (!capabilities.Contains(req)) { reqViewController.Data.Add(new CustomCellInfo("<size=75%>" + req, "Missing Suggestion", MissingSuggestionIcon)); } else { reqViewController.Data.Add(new CustomCellInfo("<size=75%>" + req, "Suggestion", HaveSuggestionIcon)); } } } /* * if (!SongLoader.capabilities.Contains(req)) * { * reqString += "<#FF0000>" + req + "<#FFD42A> | "; * ____playButton.interactable = false; * ____practiceButton.interactable = false; * ____playButton.gameObject.GetComponentInChildren<UnityEngine.UI.Image>().color = Color.red; * * } * else * {//(0.000, 0.706, 1.000, 0.784) * reqString += "<#FFD42A>" + req + " | "; * } * * */ reqDialog.Present(); reqViewController._customListTableView.ReloadData(); }
private void OnSceneTransitioned(Scene activeScene) { GameObject.Destroy(GameObject.Find("SongLoader Color Setter")); customSongColors = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongColors", true, true); customSongPlatforms = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongPlatforms", true, true); if (AreSongsLoading) { //Scene changing while songs are loading. Since we are using a separate thread while loading, this is bad and could cause a crash. //So we have to stop loading. if (_loadingTask != null) { _loadingTask.Cancel(); _loadingCancelled = true; AreSongsLoading = false; LoadingProgress = 0; StopAllCoroutines(); _progressBar.ShowMessage("Loading cancelled\n<size=80%>Press Ctrl+R to refresh</size>"); Log("Loading was cancelled by player since they loaded another scene."); } } StartCoroutine(WaitRemoveScores()); if (activeScene.name == MenuSceneName) { CurrentLevelPlaying = null; if (CustomLevelCollectionSO == null) { var levelCollectionSO = Resources.FindObjectsOfTypeAll <LevelCollectionSO>().FirstOrDefault(); CustomLevelCollectionSO = CustomLevelCollectionSO.ReplaceOriginal(levelCollectionSO); } else { CustomLevelCollectionSO.ReplaceReferences(); } if (_standardLevelDetailViewController == null) { _standardLevelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault(); if (_standardLevelDetailViewController == null) { return; } _standardLevelDetailViewController.didPressPlayButtonEvent += StandardLevelDetailControllerOnDidPressPlayButtonEvent; } if (_LevelListViewController == null) { _LevelListViewController = Resources.FindObjectsOfTypeAll <LevelListViewController>().FirstOrDefault(); if (_LevelListViewController == null) { return; } _LevelListViewController.didSelectLevelEvent += StandardLevelListViewControllerOnDidSelectLevelEvent; } if (_characteristicViewController == null) { _characteristicViewController = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSelectionViewController>().FirstOrDefault(); if (_characteristicViewController == null) { return; } _characteristicViewController.didSelectBeatmapCharacteristicEvent += OnDidSelectBeatmapCharacteristicEvent; } if (CustomPlatformsPresent) { CheckForPreviousPlatform(); } } else if (activeScene.name == GameSceneName) { _standardLevelSceneSetupData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault(); if (_standardLevelSceneSetupData == null) { return; } var level = _standardLevelSceneSetupData.difficultyBeatmap; var beatmap = level as CustomLevel.CustomDifficultyBeatmap; if (beatmap != null) { CurrentLevelPlaying = beatmap; //The note jump movement speed now gets set in the Start method, so we're too early here. We have to wait a bit before overriding. Invoke(nameof(DelayedNoteJumpMovementSpeedFix), 0.1f); } if (NoteHitVolumeChanger.PrefabFound) { return; } var song = CustomLevels.FirstOrDefault(x => x.levelID == level.level.levelID); if (song == null) { return; } NoteHitVolumeChanger.SetVolume(song.customSongInfo.noteHitVolume, song.customSongInfo.noteMissVolume); //Set environment if the song has customEnvironment if (CustomPlatformsPresent) { CheckCustomSongEnvironment(song); } //Set enviroment colors for the song if it has song specific colors if (customSongColors) { song.SetSongColors(CurrentLevelPlaying.colorLeft, CurrentLevelPlaying.colorRight, CurrentLevelPlaying.hasCustomColors); } } }