private static void CreateSongItem(Song song, OptionsMenu optionsMenu) { var row = new Il2CppSystem.Collections.Generic.List <GameObject>(); var textBlock = optionsMenu.AddTextBlock(0, song.title + " - " + song.artist + " (mapped by " + song.author + ")"); var TMP = textBlock.transform.GetChild(0).GetComponent <TextMeshPro>(); TMP.fontSizeMax = 32; TMP.fontSizeMin = 8; optionsMenu.scrollable.AddRow(textBlock.gameObject); //package data to be used for display SongBrowser.SongDisplayPackage songd = new SongBrowser.SongDisplayPackage(); songd.hasEasy = song.beginner; songd.hasStandard = song.standard; songd.hasAdvanced = song.advanced; songd.hasExpert = song.expert; //if song data loader is installed look for custom tags if (SongBrowser.songDataLoaderInstalled) { songd = SongBrowser.SongDisplayPackage.FillCustomData(songd, song.song_id); } songd.customExpertTags = songd.customExpertTags.Distinct().ToList(); songd.customStandardTags = songd.customStandardTags.Distinct().ToList(); songd.customAdvancedTags = songd.customAdvancedTags.Distinct().ToList(); songd.customEasyTags = songd.customEasyTags.Distinct().ToList(); bool destroyOnShot = true; Action onHit = new Action(() => { OnDownloadStart(song); MelonCoroutines.Start(SongDownloader.DownloadSong(song.song_id, song.download_url, (songID, success) => { OnDownloadDone(song, success); })); KataConfig.I.CreateDebugText("Downloading...", new Vector3(0f, -1f, 5f), 5f, null, false, 0.2f); }); string label = "Download" + SongBrowser.GetDifficultyString(songd); float alpha = 1f; bool interactable = true; string[] splitURL = song.download_url.Split('/'); string audicaName = splitURL[splitURL.Length - 1]; if (SongLoadingManager.songFilenames.Contains(song.filename) || SongDownloader.downloadedFileNames.Contains(song.filename) || SongDownloader.failedDownloads.Contains(song.filename)) { if (SongDownloader.failedDownloads.Contains(song.filename)) { label = "Download unavailable"; } else { label = "Downloaded!"; } destroyOnShot = false; onHit = new Action(() => { }); alpha = 0.25f; interactable = false; } var downloadButton = optionsMenu.AddButton(0, label, onHit, null, null); downloadButton.button.SetInteractable(interactable); downloadButton.button.destroyOnShot = destroyOnShot; downloadButton.button.doMeshExplosion = destroyOnShot; downloadButton.label.alpha = alpha; downloadButtons.Add(song, downloadButton); row.Add(downloadButton.gameObject); var previewButton = optionsMenu.AddButton(1, "Preview", new Action(() => { MelonCoroutines.Start(SongDownloader.StreamPreviewSong(song.preview_url)); }), null, null); row.Add(previewButton.gameObject); optionsMenu.scrollable.AddRow(row); }
private static void CreateSongItem(Song song, OptionsMenu optionsMenu) { var row = new Il2CppSystem.Collections.Generic.List <GameObject>(); var textBlock = optionsMenu.AddTextBlock(0, song.title + " - " + song.artist + " (mapped by " + song.author + ")"); var TMP = textBlock.transform.GetChild(0).GetComponent <TextMeshPro>(); TMP.fontSizeMax = 32; TMP.fontSizeMin = 8; optionsMenu.scrollable.AddRow(textBlock.gameObject); // Skip button bool destroyOnShot = true; Action onHit = new Action(() => { missingSongsIDs.Remove(song.song_id); // remove from local copy SongRequests.missingSongs.Remove(song.song_id); // remove from main list AddSongItems(optionsMenu); // refresh list }); var skipButton = optionsMenu.AddButton(1, "Skip", onHit, null, null); skipButton.button.destroyOnShot = destroyOnShot; skipButton.button.doMeshExplosion = destroyOnShot; // Download button Action onHit2 = new Action(() => { StartDownload(song.song_id, song.download_url, TMP); }); var downloadButton = optionsMenu.AddButton(0, "Download", onHit2, null, null); downloadButton.button.destroyOnShot = destroyOnShot; downloadButton.button.doMeshExplosion = destroyOnShot; // Preview button var previewButton = optionsMenu.AddButton(0, "Preview", new Action(() => { MelonCoroutines.Start(SongDownloader.StreamPreviewSong(song.preview_url)); }), null, null); optionsMenu.scrollable.AddRow(previewButton.gameObject); row.Add(downloadButton.gameObject); row.Add(skipButton.gameObject); optionsMenu.scrollable.AddRow(row); }