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();

            var downloadButton = optionsMenu.AddButton(0,
                                                       "Download" + SongBrowser.GetDifficultyString(songd),
                                                       new Action(() => { MelonCoroutines.Start(SongBrowser.DownloadSong(song.download_url)); TMP.text = "Added song to download queue!"; }),
                                                       null,
                                                       null);

            downloadButton.button.destroyOnShot = true;

            row.Add(downloadButton.gameObject);

            var previewButton = optionsMenu.AddButton(1,
                                                      "Preview",
                                                      new Action(() => { MelonCoroutines.Start(SongBrowser.StreamPreviewSong(song.preview_url)); }),
                                                      null,
                                                      null);

            row.Add(previewButton.gameObject);


            optionsMenu.scrollable.AddRow(row);
        }
Exemple #2
0
            private static void Postfix(SongSelect __instance, SongSelect.SongSelectItemEntry entry)
            {
                var song = SongList.I.GetSong(entry.songID);

                if (entry.item.mapperLabel != null)
                {
                    //package data to be used for display
                    SongBrowser.SongDisplayPackage songd = new SongBrowser.SongDisplayPackage();

                    songd.hasEasy     = song.hasEasy;
                    songd.hasStandard = song.hasNormal;
                    songd.hasAdvanced = song.hasHard;
                    songd.hasExpert   = song.hasExpert;

                    //if song data loader is installed look for custom tags
                    if (SongBrowser.songDataLoaderInstalled)
                    {
                        songd = SongBrowser.SongDisplayPackage.FillCustomData(songd, song.songID);
                    }


                    CachedCalculation easy   = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Easy.ToString());
                    CachedCalculation normal = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Normal.ToString());
                    CachedCalculation hard   = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Hard.ToString());
                    CachedCalculation expert = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Expert.ToString());

                    //add mine tag if there are mines
                    if (song.hasEasy && easy.hasMines)
                    {
                        songd.customEasyTags.Insert(0, "Mines");
                    }
                    if (song.hasNormal && normal.hasMines)
                    {
                        songd.customStandardTags.Insert(0, "Mines");
                    }
                    if (song.hasHard && hard.hasMines)
                    {
                        songd.customAdvancedTags.Insert(0, "Mines");
                    }
                    if (song.hasExpert && expert.hasMines)
                    {
                        songd.customExpertTags.Insert(0, "Mines");
                    }

                    //add 360 tag
                    if (song.hasEasy && easy.is360)
                    {
                        songd.customEasyTags.Insert(0, "360");
                    }
                    if (song.hasNormal && normal.is360)
                    {
                        songd.customStandardTags.Insert(0, "360");
                    }
                    if (song.hasHard && hard.is360)
                    {
                        songd.customAdvancedTags.Insert(0, "360");
                    }
                    if (song.hasExpert && expert.is360)
                    {
                        songd.customExpertTags.Insert(0, "360");
                    }

                    songd.customExpertTags   = songd.customExpertTags.Distinct().ToList();
                    songd.customStandardTags = songd.customStandardTags.Distinct().ToList();
                    songd.customAdvancedTags = songd.customAdvancedTags.Distinct().ToList();
                    songd.customEasyTags     = songd.customEasyTags.Distinct().ToList();

                    entry.item.mapperLabel.text += SongBrowser.GetDifficultyString(songd);
                }
            }
        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);
        }