private static void StartDownload(string songID, string downloadURL, TextMeshPro tmp)
 {
     downloadCount++;
     missingSongsIDs.Remove(songID);         // remove from local list so we don't queue it up again if Download All is used
     AddSongItems(songItemMenu);             // refresh list
     MelonCoroutines.Start(SongDownloader.DownloadSong(downloadURL, OnDownloadDone));
 }
예제 #2
0
        public static void GoToWebSearchPage()
        {
            SongDownloader.StartNewSongSearch();

            if (backButton == null)
            {
                var button = GameObject.Find("menu/ShellPage_Settings/page/backParent/back");
                backButton       = button.GetComponentInChildren <GunButton>();
                backText         = button.GetComponentInChildren <TextMeshPro>();
                originalBackText = backText.text;

                UnityEngine.Object.Destroy(button.GetComponentInChildren <Localizer>());
            }

            if (songItemPanel == null)
            {
                secondaryPanel = GameObject.Instantiate(GameObject.Find("ShellPage_Settings"));
                secondaryPanel.SetActive(true);
                secondaryPanel.transform.Rotate(0, -65, 0);
                SpawnSecondaryPanel(secondaryPanel);
            }
            else
            {
                SpawnSecondaryPanel(secondaryPanel);
            }

            primaryMenu.ShowPage(OptionsMenu.Page.Customization);
            CleanUpPage(primaryMenu);
            AddButtons(primaryMenu);
            primaryMenu.screenTitle.text = "Filters";
            Config.UpdateSongCount(SongBrowser.newSongCount);             //User has seen new songs
        }
예제 #3
0
 private static void DownloadFullPage()
 {
     // for now this debug message will be visible the entire time
     // once downloads are actually async this should be called once every few seconds
     KataConfig.I.CreateDebugText("Downloading...", new Vector3(0f, -1f, 5f), 5f, null, false, 0.2f);
     foreach (var song in activeSongList.songs)
     {
         OnDownloadStart(song);
         MelonCoroutines.Start(SongDownloader.DownloadSong(song.song_id, song.download_url, (songID, success) => { OnDownloadDone(song, success); }));
     }
 }
        private static IEnumerator DownloadAll()
        {
            yield return(new WaitForSeconds(0.5f));

            foreach (string id in missingSongsIDs)
            {
                downloadCount++;
                MelonCoroutines.Start(SongDownloader.DownloadSong(((Song)SongRequests.missingSongs[id]).download_url, OnDownloadAllComplete));
                yield return(null);
            }
        }
예제 #5
0
 private static void Postfix(StartupLogo __instance, ref StartupLogo.State state)
 {
     if (state == StartupLogo.State.Done)
     {
         SongDownloader.StartNewSongSearch();
         PlaylistManager.OnApplicationStart();
         FilterPanel.OnApplicationStart();
         SongLoadingManager.StartSongListUpdate();
         //PlaylistManager.GetAllApiSongs();
     }
 }
 public void DownloadSingleSong(string filename, bool showPopup, GunButton button, TextMeshPro label)
 {
     if (backButton is null && button != null)
     {
         backButton      = button;
         backButtonLabel = label;
         backButton.SetInteractable(false);
         backButtonLabel.text  = "Loading..";
         backButtonLabel.alpha = .25f;
     }
     if (showPopup)
     {
         PlaylistUtil.Popup("Downloading..");
     }
     MelonCoroutines.Start(SongDownloader.DoSongWebSearch(filename, OnWebSearchDone, DifficultyFilter.All, false, 1, false, true));
 }
예제 #7
0
        public override void OnApplicationStart()
        {
            Config.RegisterConfig();
            mainSongDirectory        = Path.Combine(Application.streamingAssetsPath, "HmxAudioAssets", "songs");
            downloadsDirectory       = Application.dataPath.Replace("Audica_Data", "Downloads");
            deletedDownloadsListPath = Path.Combine(downloadsDirectory, "SongBrowserDownload_DeletedFiles");
            CheckFolderDirectories();

            if (MelonHandler.Mods.Any(it => it.Info.SystemType.Name == nameof(SongDataLoader)))
            {
                songDataLoaderInstalled = true;
                MelonLogger.Msg("Song Data Loader is installed. Enabling integration");
            }
            else
            {
                MelonLogger.Warning("Song Data Loader is not installed. Consider downloading it for the best experience :3");
            }

            if (MelonHandler.Mods.Any(it => it.Info.SystemType.Name == nameof(ModSettings)))
            {
                modSettingsInstalled = true;
            }

            if (MelonHandler.Mods.Any(it => it.Assembly.GetName().Name == "AuthorableModifiers"))
            {
                var scoreVersion           = new Version(MelonHandler.Mods.First(it => it.Assembly.GetName().Name == "AuthorableModifiers").Info.Version);
                var lastUnsupportedVersion = new Version("1.2.4");
                var result = scoreVersion.CompareTo(lastUnsupportedVersion);
                if (result > 0)
                {
                    authorableInstalled = true;
                }
            }

            if (!SongBrowser.emptiedDownloadsFolder)
            {
                Utility.EmptyDownloadsFolder();
            }

            if (!isInitialized && MenuState.sState != MenuState.State.TitleScreen)
            {
                SongDownloader.StartNewSongSearch();
                PlaylistManager.OnApplicationStart();
                FilterPanel.OnApplicationStart();
                SongLoadingManager.StartSongListUpdate();
            }
        }
 public void OnWebSearchDone(string search, APISongList result)
 {
     if (result is null)
     {
         if (IsDownloadingMissing && prepareDownloadMissing)
         {
             IsDownloadingMissing   = false;
             prepareDownloadMissing = false;
         }
         return;
     }
     if (result.song_count == 1)
     {
         Song song = result.songs[0];
         ActiveDownloads++;
         MelonCoroutines.Start(SongDownloader.DownloadSong(song.song_id, song.download_url, OnDownloadComplete));
     }
 }
 public void OnWebSearchDone(string search, APISongList result)
 {
     if (result is null)
     {
         /*if (IsDownloadingMissing && prepareDownloadMissing)
          * {
          *  IsDownloadingMissing = false;
          *  prepareDownloadMissing = false;
          * }*/
         MelonLogger.Msg("search returned no matches.");
         return;
     }
     if (result.song_count == 1)
     {
         Song song = result.songs[0];
         ActiveDownloads++;
         MelonLogger.Msg("Downloading " + song.song_id);
         MelonCoroutines.Start(SongDownloader.DownloadSong(song.song_id, song.download_url, OnDownloadComplete));
     }
 }
예제 #10
0
        private static void AddPageButtons(OptionsMenu optionsMenu)
        {
            var row          = new Il2CppSystem.Collections.Generic.List <GameObject>();
            var previousPage = optionsMenu.AddButton(0,
                                                     "Previous Page",
                                                     new Action(() => { SongDownloader.PreviousPage(); SongDownloader.StartNewPageSearch(); optionsMenu.scrollable.SnapTo(0); }),
                                                     null,
                                                     null);

            row.Add(previousPage.gameObject);

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

            row.Add(nextPage.gameObject);
            optionsMenu.scrollable.AddRow(row);
        }
예제 #11
0
            private static bool Prefix(KeyboardEntry __instance, KeyCode keyCode, string label)
            {
                if (SongBrowser.shouldShowKeyboard)
                {
                    if (PlaylistManager.state == PlaylistManager.PlaylistState.Creating)
                    {
                        switch (label)
                        {
                        case "done":
                            __instance.Hide();
                            break;

                        case "clear":
                            PlaylistCreatePanel.newName = "";
                            break;

                        default:
                            PlaylistCreatePanel.newName += label;
                            break;
                        }
                        if (PlaylistCreatePanel.playlistText != null)
                        {
                            PlaylistCreatePanel.playlistText.text = PlaylistCreatePanel.newName;
                        }
                    }

                    if (SongSearch.searchInProgress)
                    {
                        switch (label)
                        {
                        case "done":
                            __instance.Hide();
                            SongBrowser.shouldShowKeyboard = false;
                            SongSearch.OnNewUserSearch();
                            break;

                        case "clear":
                            SongSearch.query = "";
                            break;

                        default:
                            SongSearch.query += label;
                            break;
                        }

                        if (SongSearchScreen.searchText != null)
                        {
                            SongSearchScreen.searchText.text = SongSearch.query;
                        }
                    }
                    else
                    {
                        switch (label)
                        {
                        case "done":
                            __instance.Hide();
                            SongBrowser.shouldShowKeyboard = false;
                            SongDownloader.StartNewSongSearch();
                            break;

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

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

                        if (SongDownloaderUI.searchText != null)
                        {
                            SongDownloaderUI.searchText.text = SongDownloader.searchString;
                        }
                    }
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
예제 #12
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();
                SongDownloader.StartNewSongSearch();
            }),
                                   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);

            if (!SongDownloader.UseNewAPI)
            {
                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();
                    SongDownloader.StartNewSongSearch();
                }),
                                    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
                                       (SongDownloader.UseNewAPI ? 0 : 1,
                                       "Download current page",
                                       new Action(() =>
            {
                DownloadFullPage();
            }),
                                       null,
                                       "Downloads all songs from the current page, this will cause major stutters");

            if (SongDownloader.UseNewAPI)
            {
                optionsMenu.scrollable.AddRow(downloadFullPage.gameObject);
            }

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

            if (SongDownloader.UseNewAPI)
            {
                string popularityFilterText = "Sort by downloads: " + popularity.ToString();
                popularityToggle = optionsMenu.AddButton
                                       (1,
                                       popularityFilterText,
                                       new Action(() =>
                {
                    if (popularity)
                    {
                        popularity = false;
                    }
                    else
                    {
                        popularity = true;
                    }

                    popularityToggle.label.text = "Sort by downloads: " + popularity.ToString();
                    SongDownloader.StartNewSongSearch();
                }),
                                       null,
                                       "Sorts songs by number of downloads rather than date.");
                popularityToggle.button.doMeshExplosion = false;
                popularityToggle.button.doParticles     = false;
                optionsMenu.scrollable.AddRow(popularityToggle.gameObject);
            }
            else
            {
                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();
                    SongDownloader.StartNewSongSearch();
                }),
                                       null,
                                       "Sorts songs 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);
        }
예제 #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();

            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);
        }
 private static void StartWebSearch(QueryData data)
 {
     webSearchQueryData.Add(data.Title, data);
     MelonCoroutines.Start(SongDownloader.DoSongWebSearch(data.Title, ProcessWebSearchResult, DifficultyFilter.All));
 }