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); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { this.name = "SongDetailsViewController"; var referenceViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(); StandardLevelDetailView reference = referenceViewController.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView"); RectTransform referenceParent = reference.transform.parent as RectTransform; this.rectTransform.anchorMin = referenceParent.anchorMin; this.rectTransform.anchorMax = referenceParent.anchorMax; this.rectTransform.anchoredPosition = Vector2.zero; this.rectTransform.sizeDelta = new Vector2(80f, 0f); if (Tweaks.SongBrowserTweaks.ModLoaded) { Logger.log.Notice("SongBrowser detected. Instantiating StandardLevelDetailView with SongBrowser's modifications. This may result in various NullReferenceExceptions being thrown (and caught) by UnityEngine. These exceptions appear to have no effect on regular operation and can be ignored."); } _standardLevelDetailView = Instantiate(reference, this.transform, false); _standardLevelDetailView.gameObject.SetActive(true); _standardLevelDetailView.name = "SearchResultLevelDetail"; if (Tweaks.SongBrowserTweaks.ModLoaded) { Logger.log.Notice("Finished instantiating StandardLevelDetailView"); } _levelParamsPanel = _standardLevelDetailView.GetPrivateField <LevelParamsPanel>("_levelParamsPanel"); _songNameText = _standardLevelDetailView.GetPrivateField <TextMeshProUGUI>("_songNameText"); _checkmarkSprite = BSUtilsUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.checkmark.png"); _crossSprite = BSUtilsUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.cross.png"); _blankSprite = Sprite.Create(Texture2D.blackTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero); RemoveCustomUIElements(this.rectTransform); ModifyPanelElements(); ModifyTextElements(); ModifySelectionElements(); } else { // stats panel gets disabled when in party mode, so re-enable it here just in case RectTransform statsPanel = _standardLevelDetailView.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "Stats"); statsPanel.gameObject.SetActive(true); _compactKeyboardButton.gameObject.SetActive(PluginConfig.CompactSearchMode); // strings get reset, so they have to be reapplied foreach (var str in _difficultyStrings) { _difficultyElements[str].Item1.text = str; } } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { var referenceViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(); StandardLevelDetailView reference = referenceViewController.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView"); RectTransform referenceParent = reference.transform.parent as RectTransform; this.rectTransform.anchorMin = referenceParent.anchorMin; this.rectTransform.anchorMax = referenceParent.anchorMax; this.rectTransform.anchoredPosition = Vector2.zero; this.rectTransform.sizeDelta = new Vector2(80f, 0f); _standardLevelDetailView = Instantiate(reference, this.transform, false); _standardLevelDetailView.gameObject.SetActive(true); _standardLevelDetailView.name = "SearchResultLevelDetail"; _levelParamsPanel = _standardLevelDetailView.GetPrivateField <LevelParamsPanel>("_levelParamsPanel"); _songNameText = _standardLevelDetailView.GetPrivateField <TextMeshProUGUI>("_songNameText"); _checkmarkSprite = UIUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.checkmark.png"); _crossSprite = UIUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.cross.png"); _blankSprite = Sprite.Create(Texture2D.blackTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero); RemoveCustomUIElements(this.rectTransform); RemoveSongRequirementsButton(); ModifyPanelElements(); ModifyTextElements(); ModifySelectionElements(); } else { // stats panel gets disabled when in party mode, so re-enable it here just in case RectTransform statsPanel = _standardLevelDetailView.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "Stats"); statsPanel.gameObject.SetActive(true); _compactKeyboardButton.gameObject.SetActive(PluginConfig.CompactSearchMode); // strings get reset, so they have to be reapplied foreach (var str in _difficultyStrings) { _difficultyElements[str].Item1.text = str; } } }
static void Postfix(ref LevelParamsPanel ____levelParamsPanel, ref IDifficultyBeatmap ____selectedDifficultyBeatmap, ref PlayerData ____playerData, ref TextMeshProUGUI ____songNameText, ref UnityEngine.UI.Button ____playButton, ref UnityEngine.UI.Button ____practiceButton, ref BeatmapDifficultySegmentedControlController ____beatmapDifficultySegmentedControlController, ref BeatmapCharacteristicSegmentedControlController ____beatmapCharacteristicSegmentedControlController) { bool firstSelection = false; var level = ____selectedDifficultyBeatmap.level is CustomBeatmapLevel ? ____selectedDifficultyBeatmap.level as CustomPreviewBeatmapLevel : null; if (level != lastLevel) { firstSelection = true; lastLevel = level; } ____playButton.interactable = true; ____practiceButton.interactable = true; ____playButton.gameObject.GetComponentInChildren <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; RequirementsUI.instance.ButtonGlowColor = "none"; RequirementsUI.instance.ButtonInteractable = false; if (level != null) { Data.ExtraSongData songData = Collections.RetrieveExtraSongData(Utilities.Hashing.GetCustomLevelHash(level), level.customLevelPath); if (songData == null) { RequirementsUI.instance.ButtonGlowColor = "none"; RequirementsUI.instance.ButtonInteractable = false; return; } bool wipFolderSong = false; IDifficultyBeatmap selectedDiff = ____selectedDifficultyBeatmap; Data.ExtraSongData.DifficultyData diffData = Collections.RetrieveDifficultyData(selectedDiff); //songData._difficulties?.FirstOrDefault(x => x._difficulty == selectedDiff.difficulty //&& (x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.characteristicName || x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)); if (diffData != null) { //If no additional information is present if (diffData.additionalDifficultyData._requirements.Count() == 0 && diffData.additionalDifficultyData._suggestions.Count() == 0 && diffData.additionalDifficultyData._warnings.Count() == 0 && diffData.additionalDifficultyData._information.Count() == 0 && songData.contributors.Count() == 0) { RequirementsUI.instance.ButtonGlowColor = "none"; RequirementsUI.instance.ButtonInteractable = false; } else if (diffData.additionalDifficultyData._warnings.Count() == 0) { RequirementsUI.instance.ButtonGlowColor = "#0000FF"; RequirementsUI.instance.ButtonInteractable = true; } else if (diffData.additionalDifficultyData._warnings.Count() > 0) { RequirementsUI.instance.ButtonGlowColor = "#FFFF00"; RequirementsUI.instance.ButtonInteractable = true; if (diffData.additionalDifficultyData._warnings.Contains("WIP")) { ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; } } } if (level.levelID.EndsWith(" WIP")) { RequirementsUI.instance.ButtonGlowColor = "#FFFF00"; RequirementsUI.instance.ButtonInteractable = true; ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; wipFolderSong = true; } if (diffData != null) { for (int i = 0; i < diffData.additionalDifficultyData._requirements.Count(); i++) { if (!Collections.capabilities.Contains(diffData.additionalDifficultyData._requirements[i])) { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; RequirementsUI.instance.ButtonGlowColor = "#FF0000"; } } } if (selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName == "MissingCharacteristic") { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; RequirementsUI.instance.ButtonGlowColor = "#FF0000"; } RequirementsUI.instance.level = level; RequirementsUI.instance.songData = songData; RequirementsUI.instance.diffData = diffData; RequirementsUI.instance.wipFolder = wipFolderSong; //Difficulty Label Handling levelLabels.Clear(); string currentCharacteristic = ""; foreach (Data.ExtraSongData.DifficultyData diffLevel in songData._difficulties) { var difficulty = diffLevel._difficulty; string characteristic = diffLevel._beatmapCharacteristicName; if (characteristic == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName) { currentCharacteristic = characteristic; } if (!levelLabels.ContainsKey(characteristic)) { levelLabels.Add(characteristic, new OverrideLabels()); } OverrideLabels charLabels = levelLabels[characteristic]; if (!string.IsNullOrWhiteSpace(diffLevel._difficultyLabel)) { switch (difficulty) { case BeatmapDifficulty.Easy: charLabels.EasyOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Normal: charLabels.NormalOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Hard: charLabels.HardOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Expert: charLabels.ExpertOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.ExpertPlus: charLabels.ExpertPlusOverride = diffLevel._difficultyLabel; break; } } } if (!string.IsNullOrWhiteSpace(currentCharacteristic)) { SetCurrentLabels(levelLabels[currentCharacteristic]); } else { clearOverrideLabels(); } ____beatmapDifficultySegmentedControlController.SetData(____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.difficultyBeatmaps, ____beatmapDifficultySegmentedControlController.selectedDifficulty); clearOverrideLabels(); if (songData._defaultCharacteristic != null && firstSelection) { if (____beatmapCharacteristicSegmentedControlController.selectedBeatmapCharacteristic.serializedName != songData._defaultCharacteristic) { var chars = ____beatmapCharacteristicSegmentedControlController.GetField <List <BeatmapCharacteristicSO> >("_beatmapCharacteristics"); int index = 0; foreach (var characteristic in chars) { if (songData._defaultCharacteristic == characteristic.serializedName) { break; } index++; } if (index != chars.Count) { ____beatmapCharacteristicSegmentedControlController.GetField <HMUI.IconSegmentedControl>("_segmentedControl").SelectCellWithNumber(index); } ____beatmapCharacteristicSegmentedControlController.HandleDifficultySegmentedControlDidSelectCell( ____beatmapCharacteristicSegmentedControlController.GetField <HMUI.IconSegmentedControl>("_segmentedControl"), index); } } } }
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; } } }
//Time - Downloads //BPM - Plays //Notes - BPM //Obstacles - Upvotes //Bombs - Downvotes protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation) { gameObject.SetActive(true); _levelDetails = GetComponentsInChildren <StandardLevelDetailView>(true).First(x => x.name == "LevelDetail"); _levelDetails.gameObject.SetActive(true); RemoveCustomUIElements(rectTransform); _levelParams = GetComponentsInChildren <LevelParamsPanel>().First(x => x.name == "LevelParamsPanel"); foreach (HoverHint hint in _levelParams.transform.GetComponentsInChildren <HoverHint>()) { switch (hint.name) { case "Time": { hint.GetComponentInChildren <Image>().sprite = Sprites.DownloadIcon; }; break; case "BPM": { hint.GetComponentInChildren <Image>().sprite = Sprites.PlayIcon; }; break; case "NotesCount": { hint.GetComponentInChildren <Image>().sprite = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "MetronomeIcon"); }; break; case "ObstaclesCount": { hint.GetComponentInChildren <Image>().sprite = Sprites.ThumbUp; }; break; case "BombsCount": { hint.GetComponentInChildren <Image>().sprite = Sprites.ThumbDown; }; break; } Destroy(hint); } RectTransform yourStats = GetComponentsInChildren <RectTransform>().First(x => x.name == "Stats"); yourStats.gameObject.SetActive(true); TextMeshProUGUI[] _textComponents = GetComponentsInChildren <TextMeshProUGUI>(); try { songNameText = _textComponents.First(x => x.name == "SongNameText"); downloadsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "Time"); downloadsText.fontSize = 3f; playsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "BPM"); playsText.fontSize = 3f; _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxRank").text = "Expert/+"; difficulty1Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxRank"); _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "Highscore").text = "Hard"; difficulty2Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "Highscore"); _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxCombo").text = "Easy/Normal"; difficulty3Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxCombo"); } catch (Exception e) { Logger.Exception("Unable to convert detail view controller! Exception: " + e); } _downloadButton = _levelDetails.playButton; _downloadButton.SetButtonText("DOWNLOAD"); _downloadButton.ToggleWordWrapping(false); _downloadButton.onClick.RemoveAllListeners(); _downloadButton.onClick.AddListener(() => { downloadButtonPressed?.Invoke(_currentSong); }); (_downloadButton.transform as RectTransform).sizeDelta = new Vector2(26f, 8.8f); _favoriteButton = _levelDetails.practiceButton; _favoriteButton.SetButtonIcon(Sprites.AddToFavorites); _favoriteButton.onClick.RemoveAllListeners(); _favoriteButton.onClick.AddListener(() => { favoriteButtonPressed?.Invoke(_currentSong); }); coverImage = _levelDetails.GetPrivateField <Image>("_coverImage"); } }
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) { var level = ____selectedDifficultyBeatmap.level is CustomBeatmapLevel ? ____selectedDifficultyBeatmap.level as CustomPreviewBeatmapLevel : null; ____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) { Data.ExtraSongData songData = Collections.RetrieveExtraSongData(Utilities.Hashing.GetCustomLevelHash(level), level.customLevelPath); if (MenuUI.infoButton == null) { Console.WriteLine("Creating Info Button"); MenuUI.infoButton = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PlayButton")), (RectTransform)____levelParamsPanel.transform.parent, false); MenuUI.infoButton.SetButtonText("?"); (MenuUI.infoButton.transform as RectTransform).anchorMax = new Vector2(1, 1); (MenuUI.infoButton.transform as RectTransform).anchorMin = new Vector2(1, 1); (MenuUI.infoButton.transform as RectTransform).pivot = new Vector2(1, 1); (MenuUI.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); MenuUI.infoButton.transform.localScale *= 0.5f; } if (songData == null) { MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; MenuUI.infoButton.interactable = false; return; } bool wipFolderSong = false; IDifficultyBeatmap selectedDiff = ____selectedDifficultyBeatmap; Data.ExtraSongData.DifficultyData diffData = Collections.RetrieveDifficultyData(selectedDiff); //songData._difficulties?.FirstOrDefault(x => x._difficulty == selectedDiff.difficulty //&& (x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.characteristicName || x._beatmapCharacteristicName == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)); if (diffData != null) { //If no additional information is present if (diffData.additionalDifficultyData._requirements.Count() == 0 && diffData.additionalDifficultyData._suggestions.Count() == 0 && diffData.additionalDifficultyData._warnings.Count() == 0 && diffData.additionalDifficultyData._information.Count() == 0 && songData.contributors.Count() == 0) { MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.black; MenuUI.infoButton.interactable = false; } else if (diffData.additionalDifficultyData._warnings.Count() == 0) { MenuUI.infoButton.interactable = true; MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.blue; } else if (diffData.additionalDifficultyData._warnings.Count() > 0) { MenuUI.infoButton.interactable = true; MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; if (diffData.additionalDifficultyData._warnings.Contains("WIP")) { ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; } } } if (level.customLevelPath.Contains("CustomWIPLevels")) { MenuUI.infoButton.interactable = true; MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; ____playButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.yellow; wipFolderSong = true; } if (diffData != null) { for (int i = 0; i < diffData.additionalDifficultyData._requirements.Count(); i++) { if (!Collections.capabilities.Contains(diffData.additionalDifficultyData._requirements[i])) { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; } } } if (selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.characteristicName == "Missing Characteristic") { ____playButton.interactable = false; ____practiceButton.interactable = false; ____playButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; MenuUI.infoButton.gameObject.GetComponentInChildren <UnityEngine.UI.Image>().color = Color.red; } MenuUI.infoButton.onClick.RemoveAllListeners(); MenuUI.infoButton.onClick.AddListener(delegate() { //Console.WriteLine("Click"); MenuUI.showSongRequirements(level, songData, diffData, wipFolderSong); }); //Difficulty Label Handling levelLabels.Clear(); string currentCharacteristic = ""; foreach (Data.ExtraSongData.DifficultyData diffLevel in songData._difficulties) { var difficulty = diffLevel._difficulty; string characteristic = diffLevel._beatmapCharacteristicName; if (characteristic == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.characteristicName || characteristic == selectedDiff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName) { currentCharacteristic = characteristic; } if (!levelLabels.ContainsKey(characteristic)) { levelLabels.Add(characteristic, new OverrideLabels()); } OverrideLabels charLabels = levelLabels[characteristic]; if (!string.IsNullOrWhiteSpace(diffLevel._difficultyLabel)) { switch (difficulty) { case BeatmapDifficulty.Easy: charLabels.EasyOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Normal: charLabels.NormalOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Hard: charLabels.HardOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.Expert: charLabels.ExpertOverride = diffLevel._difficultyLabel; break; case BeatmapDifficulty.ExpertPlus: charLabels.ExpertPlusOverride = diffLevel._difficultyLabel; break; } } } if (!string.IsNullOrWhiteSpace(currentCharacteristic)) { SetCurrentLabels(levelLabels[currentCharacteristic]); } else { clearOverrideLabels(); } ____beatmapDifficultySegmentedControlController.SetData(____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.difficultyBeatmaps, ____beatmapDifficultySegmentedControlController.selectedDifficulty); clearOverrideLabels(); } }
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; } } }
//Time - Downloads //BPM - Plays //Notes - BPM //Obstacles - Upvotes //Bombs - Downvotes protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation) { gameObject.SetActive(true); _levelDetails = GetComponentsInChildren <StandardLevelDetailView>(true).First(x => x.name == "LevelDetail"); _levelDetails.gameObject.SetActive(true); (_levelDetails.transform as RectTransform).anchoredPosition = new Vector2(-40, 0); BeatmapDifficultySegmentedControlController beatmapDifficultySegmentedControl = GetComponentsInChildren <BeatmapDifficultySegmentedControlController>(true).First(x => x.name == "BeatmapDifficultySegmentedControl"); beatmapDifficultySegmentedControl.gameObject.SetActive(false); BeatmapCharacteristicSegmentedControlController beatmapCharacteristicSegmentedControl = GetComponentsInChildren <BeatmapCharacteristicSegmentedControlController>(true).First(x => x.name == "BeatmapCharacteristicSegmentedControl"); beatmapCharacteristicSegmentedControl.gameObject.SetActive(false); RemoveCustomUIElements(rectTransform); _levelParams = GetComponentsInChildren <LevelParamsPanel>().First(x => x.name == "LevelParamsPanel"); foreach (HoverHint hint in _levelParams.transform.GetComponentsInChildren <HoverHint>()) { switch (hint.name) { case "Time": { hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.DownloadIcon; }; break; case "BPM": { hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.PlayIcon; }; break; case "NotesCount": { hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "MetronomeIcon"); }; break; case "ObstaclesCount": { hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.ThumbUp; }; break; case "BombsCount": { hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.ThumbDown; }; break; } Destroy(hint); } RectTransform yourStats = GetComponentsInChildren <RectTransform>().First(x => x.name == "Stats"); yourStats.gameObject.SetActive(true); TextMeshProUGUI[] _textComponents = GetComponentsInChildren <TextMeshProUGUI>(); try { songNameText = _textComponents.First(x => x.name == "SongNameText"); downloadsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "Time"); downloadsText.fontSize = 3f; playsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "BPM"); playsText.fontSize = 3f; // foreach (var x in _textComponents) // { // Console.WriteLine(x.name); // Console.WriteLine(x.transform.parent.name); // } difficulty1Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxRank"); //.text = "Expert/+"; difficulty1Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxRank"); difficulty2Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "Highscore");//.text = "Hard"; difficulty2Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "Highscore"); difficulty3Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxCombo");//.text = "Easy/Normal"; difficulty3Text = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxCombo"); } catch (Exception e) { Plugin.log.Critical("Unable to convert detail view controller! Exception: " + e); } _downloadButton = _levelDetails.playButton; _downloadButton.SetButtonText("DOWNLOAD"); _downloadButton.ToggleWordWrapping(false); _downloadButton.onClick.RemoveAllListeners(); _downloadButton.onClick.AddListener(() => { downloadButtonPressed?.Invoke(_currentSong); }); (_downloadButton.transform as RectTransform).sizeDelta = new Vector2(26f, 8.8f); _favoriteButton = _levelDetails.practiceButton; _favoriteButton.SetButtonIcon(Sprites.AddToFavorites); _favoriteButton.onClick.RemoveAllListeners(); _favoriteButton.onClick.AddListener(() => { favoriteButtonPressed?.Invoke(_currentSong); }); coverImage = _levelDetails.GetPrivateField <RawImage>("_coverImage"); _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(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.transform as RectTransform).anchoredPosition = new Vector2(-40f, 0f); } }
//Time - Downloads //BPM - Plays //Notes - BPM //Obstacles - Upvotes //Bombs - Downvotes protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation && type == ActivationType.AddedToHierarchy) { RemoveCustomUIElements(rectTransform); _levelDetails = GetComponentsInChildren <LevelParamsPanel>().First(x => x.name == "LevelParamsPanel"); foreach (HoverHint hint in _levelDetails.transform.GetComponentsInChildren <HoverHint>()) { switch (hint.name) { case "Time": { hint.GetComponentInChildren <Image>().sprite = Base64Sprites.DownloadIcon; }; break; case "BPM": { hint.GetComponentInChildren <Image>().sprite = Base64Sprites.PlayIcon; }; break; case "NotesCount": { hint.GetComponentInChildren <Image>().sprite = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "MetronomeIcon"); }; break; case "ObstaclesCount": { hint.GetComponentInChildren <Image>().sprite = Base64Sprites.ThumbUp; }; break; case "BombsCount": { hint.GetComponentInChildren <Image>().sprite = Base64Sprites.ThumbDown; }; break; } Destroy(hint); } RectTransform yourStats = GetComponentsInChildren <RectTransform>(true).First(x => x.name == "YourStats"); yourStats.gameObject.SetActive(true); RectTransform buttonsRect = GetComponentsInChildren <RectTransform>().First(x => x.name == "Buttons"); buttonsRect.anchoredPosition = new Vector2(0f, 6f); TextMeshProUGUI[] _textComponents = GetComponentsInChildren <TextMeshProUGUI>(); try { songNameText = _textComponents.First(x => x.name == "SongNameText"); downloadsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "Time"); downloadsText.fontSize = 3f; playsText = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "BPM"); playsText.fontSize = 3f; _textComponents.First(x => x.name == "YourStatsTitle").text = "Difficulties"; _textComponents.First(x => x.name == "HighScoreText").text = "Expert/+"; difficulty1Text = _textComponents.First(x => x.name == "HighScoreValueText"); _textComponents.First(x => x.name == "MaxComboText").text = "Hard"; difficulty2Text = _textComponents.First(x => x.name == "MaxComboValueText"); _textComponents.First(x => x.name == "MaxRankText").text = "Easy/Normal"; _textComponents.First(x => x.name == "MaxRankText").rectTransform.sizeDelta = new Vector2(18f, 3f); difficulty3Text = _textComponents.First(x => x.name == "MaxRankValueText"); } catch (Exception e) { Logger.Exception("Unable to convert detail view controller! Exception: " + e); } _downloadButton = GetComponentsInChildren <Button>().First(x => x.name == "PlayButton"); _downloadButton.GetComponentsInChildren <TextMeshProUGUI>().First().text = "DOWNLOAD"; _downloadButton.onClick.RemoveAllListeners(); _downloadButton.onClick.AddListener(() => { downloadButtonPressed?.Invoke(_currentSong); }); _favoriteButton = GetComponentsInChildren <Button>().First(x => x.name == "PracticeButton"); _favoriteButton.GetComponentsInChildren <Image>().First(x => x.name == "Icon").sprite = Base64Sprites.AddToFavorites; _favoriteButton.onClick.RemoveAllListeners(); _favoriteButton.onClick.AddListener(() => { favoriteButtonPressed?.Invoke(_currentSong); }); } }