Example #1
0
 private static void Postfix(SongSelect __instance)
 {
     FilterPanel.Initialize();
     ScoreHistory.LoadHistory(PlatformChooser.I.GetLeaderboardID());
     MelonCoroutines.Start(SongBrowser.UpdateLastSongCount());
     MelonLogger.Msg("Updating song count");
 }
Example #2
0
        private static void LoadFavorites()
        {
            if (File.Exists(favoritesPath))
            {
                try
                {
                    string text = File.ReadAllText(favoritesPath);
                    favorites = JSON.Load(text).Make <Favorites>();
                }
                catch (Exception ex)
                {
                    MelonLoader.MelonLogger.Msg($"Unable to load favorites from file: {ex.Message}");
                    SongBrowser.DebugText("Unable to load favorites");

                    // make a backup of the existing file, just in case it still contains something
                    string backupPath = favoritesPath + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".temp";
                    File.Copy(favoritesPath, backupPath);

                    favorites         = new Favorites();
                    favorites.songIDs = new List <string>();
                }
            }
            else
            {
                favorites         = new Favorites();
                favorites.songIDs = new List <string>();
            }
        }
Example #3
0
            private static bool Prefix(KeyboardEntry __instance, KeyCode keyCode, string label)
            {
                if (SongBrowser.shouldShowKeyboard)
                {
                    switch (label)
                    {
                    case "done":
                        __instance.Hide();
                        SongBrowser.shouldShowKeyboard = false;
                        SongBrowser.page = 1;
                        SongBrowser.StartSongSearch();
                        break;

                    case "clear":
                        SongBrowser.searchString = "";
                        break;

                    default:
                        SongBrowser.searchString += label;
                        break;
                    }

                    if (SongDownloaderUI.searchText != null)
                    {
                        SongDownloaderUI.searchText.text = SongBrowser.searchString;
                    }
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
Example #4
0
 private static void Postfix(SongSelect __instance)
 {
     //FilterPanel.filteringFavorites = false;
     FilterPanel.Initialize();
     ScoreHistory.LoadHistory(PlatformChooser.I.GetLeaderboardID());
     MelonCoroutines.Start(SongBrowser.UpdateLastSongCount());
 }
Example #5
0
        private static void Delete()
        {
            var song = SongDataHolder.I.songData;

            SongBrowser.DebugText("Deleted " + song.title);
            SongBrowser.RemoveSong(song.songID);
        }
Example #6
0
 private static void DownloadFullPage()
 {
     foreach (var song in activeSongList.songs)
     {
         MelonCoroutines.Start(SongBrowser.DownloadSong(song.download_url));
     }
 }
 private void OnDownloadComplete(string search, bool success)
 {
     ActiveDownloads -= 1;
     if (!success)
     {
         MelonLogger.Warning("Download of " + search + " failed");
     }
     if (ActiveDownloads > 0)
     {
         return;
     }
     if (!IsDownloadingMissing)
     {
         SongBrowser.ReloadSongList();
         //EnableBackButton();
         return;
     }
     PlaylistManager.SavePlaylistData();
     //EnableBackButton();
     if (IsDownloadingMissing)
     {
         IsDownloadingMissing = false;
         SongLoadingManager.EnableButtons();
         PlaylistUtil.Popup("Missing playlist songs downloaded.");
         PopulatePlaylists();
         SongBrowser.ReloadSongList();
     }
 }
Example #8
0
        public static void SaveFavorites()
        {
            string text = JSON.Dump(favorites);

            try
            {
                int favCount = favorites.songIDs.Count;
                File.WriteAllText(favoritesPath + ".tmp", text);

                // check that file can be loaded and contains the correct number of favorites
                string    saved = File.ReadAllText(favoritesPath + ".tmp");
                Favorites favs  = JSON.Load(saved).Make <Favorites>();
                if (favCount == favs.songIDs.Count)
                {
                    // override existing favorites now that we know it worked
                    File.Delete(favoritesPath);
                    File.Copy(favoritesPath + ".tmp", favoritesPath);
                }
                else
                {
                    SongBrowser.DebugText("Unable to save favorites");
                }
            }
            catch (Exception ex)
            {
                MelonLoader.MelonLogger.Msg($"Unable to save favorites: {ex.Message}");
                SongBrowser.DebugText("Unable to save favorites");
            }
        }
Example #9
0
        private static void OnDeleteButtonShot()
        {
            var song = SongDataHolder.I.songData;

            SongBrowser.DebugText("Deleted " + song.title);
            SongBrowser.RemoveSong(song.songID);
            GameObject.FindObjectOfType <LaunchPanel>().Back();
        }
 private static void OnDownloadAllComplete()
 {
     downloadCount--;
     if (downloadCount == 0)
     {
         SongBrowser.ReloadSongList(false);
     }
 }
Example #11
0
 private static void Prefix(OptionsMenu __instance)
 {
     if (SongDownloaderUI.songItemPanel != null)
     {
         SongDownloaderUI.songItemPanel.SetPageActive(false);
     }
     if (SongBrowser.needRefresh)
     {
         SongBrowser.ReloadSongList();
     }
 }
        private void InitSongBrowserIntegration()
        {
            hasCompatibleSongBrowser = true;
            MelonLogger.Log("Song Browser is installed. Enabling integration");
            RequestUI.Register();

            // make sure queue is processed after song list reload
            // to show requested maps that were missing and just
            // got downloaded
            SongBrowser.RegisterSongListPostProcessing(ProcessQueueAfterRefresh);
        }
Example #13
0
        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);
        }
        public static void Cancel()
        {
            lookingAtMissingSongs = false;
            downloadAllButton.SetActive(false);

            if (needsSongListRefresh)
            {
                MenuState.I.GoToMainPage();
                SongBrowser.ReloadSongList(false);
            }
            else
            {
                MenuState.I.GoToSongPage();
                RequestUI.UpdateButtonText();
            }
        }
Example #15
0
        private static void AddPageButtons(OptionsMenu optionsMenu)
        {
            var row          = new Il2CppSystem.Collections.Generic.List <GameObject>();
            var previousPage = optionsMenu.AddButton(0,
                                                     "Previous Page",
                                                     new Action(() => { SongBrowser.PreviousPage(); SongBrowser.StartSongSearch(); optionsMenu.scrollable.SnapTo(0); }),
                                                     null,
                                                     null);

            row.Add(previousPage.gameObject);

            var nextPage = optionsMenu.AddButton(1,
                                                 "Next Page",
                                                 new Action(() => { SongBrowser.NextPage(); SongBrowser.StartSongSearch(); optionsMenu.scrollable.SnapTo(0); }),
                                                 null,
                                                 null);

            row.Add(nextPage.gameObject);
            optionsMenu.scrollable.AddRow(row);
        }
Example #16
0
        public static void AddFavorite(string songID)
        {
            var song = SongList.I.GetSong(songID);

            if (!song.extrasSong)
            {
                return;
            }
            if (favorites.songIDs.Contains(songID))
            {
                favorites.songIDs.Remove(songID);
                SongBrowser.DebugText($"Removed {song.title} from favorites!");
                SaveFavorites();
            }
            else
            {
                favorites.songIDs.Add(songID);
                SongBrowser.DebugText($"Added {song.title} to favorites!");
                SaveFavorites();
            }
        }
Example #17
0
        public static void GoToArenaPage(OptionsMenu optionsMenu)
        {
            SongBrowser.page = 1;
            if (songItemPanel == null)
            {
                secondaryPanel = GameObject.Instantiate(GameObject.Find("ShellPage_Settings"));
                secondaryPanel.SetActive(true);
                secondaryPanel.transform.Rotate(0, -65, 0);
                SpawnSecondaryPanel(secondaryPanel);
            }
            else
            {
                SpawnSecondaryPanel(secondaryPanel);
            }

            optionsMenu.ShowPage(OptionsMenu.Page.Customization);
            CleanUpPage(optionsMenu);
            AddButtons(optionsMenu);
            optionsMenu.screenTitle.text = "Filters";
            SongBrowser.lastSongCount    = SongBrowser.newSongCount;          //User has seen new songs
            SongBrowser.SaveConfig();
        }
Example #18
0
 private static bool Prefix(OptionsMenu __instance)
 {
     // should always be on the search page when this happens
     if (SongSearch.searchInProgress)
     {
         SongSearch.CancelSearch();
         return(false);
     }
     else if (PlaylistManager.state == PlaylistManager.PlaylistState.Selecting || PlaylistManager.state == PlaylistManager.PlaylistState.Adding)
     {
         PlaylistSelectPanel.CancelSelect();
         return(false);
     }
     else if (PlaylistManager.state == PlaylistManager.PlaylistState.Creating)
     {
         PlaylistCreatePanel.CancelCreate();
     }
     else if (PlaylistManager.state == PlaylistManager.PlaylistState.Editing)
     {
         PlaylistEditPanel.CancelEdit();
     }
     else if (PlaylistManager.state == PlaylistManager.PlaylistState.Endless)
     {
         PlaylistEndlessPanel.CancelEndless();
     }
     else
     {
         if (SongDownloaderUI.songItemPanel != null)
         {
             SongDownloaderUI.songItemPanel.SetPageActive(false);
         }
         if (SongDownloader.needRefresh)
         {
             SongBrowser.ReloadSongList(false);
         }
     }
     return(true);
 }
Example #19
0
        private static void AddButtons(OptionsMenu optionsMenu)
        {
            var header = optionsMenu.AddHeader(0, "Filter by: Artist, Title, Mapper");

            optionsMenu.scrollable.AddRow(header);

            var searchField = optionsMenu.AddButton(0, "Search:", new Action(() => { SongBrowser.shouldShowKeyboard = true; optionsMenu.keyboard.Show(); }), null, "Filter by: Artist, Title, Mapper", optionsMenu.textEntryButtonPrefab);

            optionsMenu.scrollable.AddRow(searchField.gameObject);
            searchText = searchField.gameObject.GetComponentInChildren <TextMeshPro>();

            var difficultyHeader = optionsMenu.AddHeader(0, "Filter difficulty");

            optionsMenu.scrollable.AddRow(difficultyHeader);

            string difficultyFilterText = difficultyFilter.ToString();

            difficultyToggle = optionsMenu.AddButton
                                   (0,
                                   difficultyFilterText,
                                   new Action(() =>
            {
                difficultyFilter++;
                if ((int)difficultyFilter > 4)
                {
                    difficultyFilter = 0;
                }
                difficultyToggle.label.text = difficultyFilter.ToString();
                SongBrowser.page            = 1;
                SongBrowser.StartSongSearch();
            }),
                                   null,
                                   "Filters the search to the selected difficulty");
            difficultyToggle.button.doMeshExplosion = false;
            difficultyToggle.button.doParticles     = false;
            optionsMenu.scrollable.AddRow(difficultyToggle.gameObject);

            var extraHeader = optionsMenu.AddHeader(0, "Extra");

            optionsMenu.scrollable.AddRow(extraHeader);

            string curatedFilterText = "Curated only: " + curated.ToString();

            curatedToggle = optionsMenu.AddButton
                                (0,
                                curatedFilterText,
                                new Action(() =>
            {
                if (curated)
                {
                    curated = false;
                }
                else
                {
                    curated = true;
                }

                curatedToggle.label.text = "Curated only: " + curated.ToString();
                SongBrowser.page         = 1;
                SongBrowser.StartSongSearch();
            }),
                                null,
                                "Filters the search to curated maps only");
            curatedToggle.button.doMeshExplosion = false;
            curatedToggle.button.doParticles     = false;
            optionsMenu.scrollable.AddRow(curatedToggle.gameObject);

            var downloadFullPage = optionsMenu.AddButton
                                       (1,
                                       "Download current page",
                                       new Action(() =>
            {
                DownloadFullPage();
            }),
                                       null,
                                       "Downloads all songs from the current page, this will cause major stutters");

            var RestoreSongs = optionsMenu.AddButton
                                   (0,
                                   "Restore Deleted Songs",
                                   new Action(() =>
            {
                SongBrowser.RestoreDeletedSongs();
            }),
                                   null,
                                   "Restores all the songs you have deleted.");
            //optionsMenu.scrollable.AddRow(RestoreSongs.gameObject);

            string popularityFilterText = "Sort by playcount: " + popularity.ToString();

            popularityToggle = optionsMenu.AddButton
                                   (1,
                                   popularityFilterText,
                                   new Action(() =>
            {
                if (popularity)
                {
                    popularity = false;
                }
                else
                {
                    popularity = true;
                }

                popularityToggle.label.text = "Sort by playcount: " + popularity.ToString();
                SongBrowser.page            = 1;
                SongBrowser.StartSongSearch();
            }),
                                   null,
                                   "Sorts downloads by leaderboard scores rather than date.");
            popularityToggle.button.doMeshExplosion = false;
            popularityToggle.button.doParticles     = false;
            optionsMenu.scrollable.AddRow(popularityToggle.gameObject);

            var downloadFolderBlock = optionsMenu.AddTextBlock(0, "You can hotload songs by placing them in Audica/Downloads and pressing F5");

            optionsMenu.scrollable.AddRow(downloadFolderBlock);
        }
Example #20
0
 private static void OnRefreshButtonShot()
 {
     MenuState.I.GoToMainPage();
     SongBrowser.ReloadSongList(false);
 }
Example #21
0
 private static void OnRefreshButtonShot()
 {
     SongBrowser.ReloadSongList();
     refreshButton = null;
     MelonCoroutines.Start(CreateRefreshButton());
 }
Example #22
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);
        }