public void SelectionChanged(IPreviewBeatmapLevel beatmap) { if (_levelCollectionTableView == null) { _levelCollectionTableView = Resources.FindObjectsOfTypeAll <LevelCollectionTableView>().FirstOrDefault(); } if (_database == null) { _database = SongDataCore.Plugin.Songs; } var hash = beatmap == null ? "" : beatmap.levelID.Replace("custom_level_", "").ToLower(); if (SongDataCore.Plugin.Songs.IsDataAvailable() && _database.Data.Songs.ContainsKey(hash)) { var song = _database.Data.Songs[hash]; MapActive = true; MapNotActive = false; Key = song.key; Rating = song.rating.ToString(); Downloads = song.downloadCount.ToString(); Upvotes = song.upVotes.ToString(); Downvotes = song.downVotes.ToString(); } else { MapActive = false; MapNotActive = true; parserParams.EmitEvent("close-desc"); } }
private void OnMenuSceneLoadedFresh() { Log.Info("OnMenuSceneLoadedFresh()"); Songs = new GameObject("SongDataCore_BeatStar").AddComponent <BeatStarDatabase>(); UnityEngine.Object.DontDestroyOnLoad(Songs.gameObject); // Force false, always load the database here. DatabasesLoaded = false; LoadDatabases(); }
internal static void Prefix(ref Image ____highlightImage, ref TextMeshProUGUI ____songNameText, ref TextMeshProUGUI ____authorText) { if (SongDataCore.Plugin.Songs.IsDataAvailable()) { if (_database == null) { _database = SongDataCore.Plugin.Songs; } if (____highlightImage != null) { if (_levelIDDict.ContainsKey(____songNameText.text + ____authorText.text)) { var id = _levelIDDict[____songNameText.text + ____authorText.text]; if (_database.Data.Songs.ContainsKey(id)) { var map = _database.Data.Songs[id]; var color = _colorGradient.Evaluate(map.rating); //Color.Lerp(Color.red, Color.green, map.rating); color.a = .5f; ____highlightImage.color = color; } else { if (____highlightImage != null) { ____highlightImage.color = _defaultHighlightColor; } } } else { if (____highlightImage != null) { ____highlightImage.color = _defaultHighlightColor; } } } } }