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();
     }
 }
Ejemplo n.º 2
0
        private static void AddButtons(OptionsMenu optionsMenu)
        {
            var header = optionsMenu.AddHeader(0, "Playlist Name");

            optionsMenu.scrollable.AddRow(header);

            var nameField = optionsMenu.AddButton(0, "Name:", new Action(() => { SongBrowser.shouldShowKeyboard = true; optionsMenu.keyboard.Show(); }), null, "Enter the desired name for the playlist", optionsMenu.textEntryButtonPrefab);

            optionsMenu.scrollable.AddRow(nameField.gameObject);
            playlistText = nameField.gameObject.GetComponentInChildren <TextMeshPro>();

            var createButton = optionsMenu.AddButton(0, "Create Playlist", new Action(() =>
            {
                if (newName.Length == 0)
                {
                    return;
                }

                Playlist playlist = new Playlist(newName, new List <string>());
                playlist.filename = newName + ".playlist";
                PlaylistManager.AddNewPlaylist(playlist, true);
                //PlaylistManager.SelectPlaylist(playlist.name);
                PlaylistManager.SavePlaylist(playlist.name, false);
                PlaylistManager.SavePlaylistData();
                CancelCreate();
            }), null, "Create playlist with the entered name", optionsMenu.buttonPrefab);

            optionsMenu.scrollable.AddRow(createButton.gameObject);
        }
 private void PopulatePlaylists()
 {
     if (!playlistsPopulated)
     {
         playlistsPopulated = true;
         PlaylistManager.PopulatePlaylistsSongNames();
     }
 }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
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 DownloadMissingSongs()
        {
            if (missingSongsFound)
            {
                return;
            }
            missingSongsFound = true;
            if (PlaylistManager.playlists is null || PlaylistManager.playlists.Values.Count == 0)
            {
                return;
            }
            IsDownloadingMissing = true;
            //prepareDownloadMissing = true;
            List <string> songs = new List <string>();

            foreach (Playlist playlist in PlaylistManager.playlists.Values)
            {
                if (PlaylistManager.IsPlaylistInitialized(playlist.name))
                {
                    continue;
                }
                PlaylistManager.SetPlaylistInitialized(playlist.name);
                foreach (string song in playlist.songs)
                {
                    if (!SongLoadingManager.songDictionary.ContainsKey(song + ".audica"))
                    {
                        //hasMissingSongs = true;
                        songs.Add(song + ".audica");
                        //DownloadSong(song + ".audica");
                    }
                }
            }
            if (songs.Count > 0)
            {
                DownloadSongs(songs, false, null, null);
            }
            else
            {
                prepareDownloadMissing = false;
                IsDownloadingMissing   = false;
                PopulatePlaylists();
            }
        }
Ejemplo n.º 7
0
        public static void CancelEdit()
        {
            PlaylistManager.SavePlaylist(PlaylistManager.playlistToEdit.name, true);

            /*if (PlaylistDownloadManager.needReload)
             * {
             *      PlaylistManager.state = PlaylistManager.PlaylistState.None;
             *      MenuState.I.GoToSongPage();
             *      //PlaylistDownloadManager.Reload();
             * }
             * else
             * {
             *      PlaylistManager.state = PlaylistManager.PlaylistState.Selecting;
             *      OptionsMenu.I.ShowPage(OptionsMenu.Page.Main);
             * }*/
            PlaylistManager.state = PlaylistManager.PlaylistState.Selecting;
            OptionsMenu.I.ShowPage(OptionsMenu.Page.Main);
            SelectPlaylistButton.UpdatePlaylistButton();
        }
Ejemplo n.º 8
0
        private static void AddButtons(OptionsMenu optionsMenu)
        {
            /*var header = optionsMenu.AddHeader(0, "Playlists");
             * optionsMenu.scrollable.AddRow(header);*/
            OptionsMenuButton entry = null;

            foreach (string playlist in PlaylistManager.playlists.Keys)
            {
                var name = optionsMenu.AddTextBlock(0, playlist);
                var tmp  = name.transform.GetChild(0).GetComponent <TextMeshPro>();
                tmp.fontSizeMax = 32;
                tmp.fontSizeMin = 8;
                optionsMenu.scrollable.AddRow(name.gameObject);
                OptionsMenuButton edit = null;
                if (PlaylistManager.state == PlaylistManager.PlaylistState.Selecting)
                {
                    edit = optionsMenu.AddButton(0, "Edit", new Action(() =>
                    {
                        PlaylistManager.state = PlaylistManager.PlaylistState.Editing;
                        PlaylistManager.SetPlaylistToEdit(playlist);
                        OptionsMenu.I.ShowPage(OptionsMenu.Page.Misc);
                        SelectPlaylistButton.UpdatePlaylistButton();
                    }), null, "Edit this playlist", optionsMenu.buttonPrefab);
                }

                string txt = PlaylistManager.state == PlaylistManager.PlaylistState.Selecting ? "Select" : "Add";
                entry = optionsMenu.AddButton(1, txt, new Action(() =>
                {
                    if (PlaylistManager.state == PlaylistManager.PlaylistState.Selecting)
                    {
                        PlaylistManager.SelectPlaylist(playlist);
                    }
                    else
                    {
                        PlaylistManager.AddSongToPlaylist(playlist, AddPlaylistButton.songToAdd);
                        MenuState.I.GoToLaunchPage();
                        return;
                    }
                    PlaylistManager.state = PlaylistManager.PlaylistState.None;
                    FilterPanel.ResetFilterState();
                    MenuState.I.GoToSongPage();
                    SelectPlaylistButton.UpdatePlaylistButton();
                }), null, "Select this playlist", optionsMenu.buttonPrefab);

                Il2CppSystem.Collections.Generic.List <GameObject> row = new Il2CppSystem.Collections.Generic.List <GameObject>();
                //row.Add(name.gameObject);
                if (PlaylistManager.state == PlaylistManager.PlaylistState.Selecting)
                {
                    row.Add(edit.gameObject);
                }
                row.Add(entry.gameObject);
                optionsMenu.scrollable.AddRow(row);
            }
            var header = optionsMenu.AddHeader(0, "Create");

            optionsMenu.scrollable.AddRow(header);
            entry = optionsMenu.AddButton(0, "Create new Playlist", new Action(() =>
            {
                MelonLoader.MelonLogger.Msg("Create button shot");
                PlaylistManager.state = PlaylistManager.PlaylistState.Creating;
                OptionsMenu.I.ShowPage(OptionsMenu.Page.Misc);
                MenuState.I.GoToSettingsPage();
                SelectPlaylistButton.UpdatePlaylistButton();
            }), null, "Create a new playlist", optionsMenu.buttonPrefab);
            optionsMenu.scrollable.AddRow(entry.gameObject);
        }
Ejemplo n.º 9
0
        private static void AddButtons(OptionsMenu optionsMenu)
        {
            //var header = optionsMenu.AddHeader(0, PlaylistManager.playlistToEdit.name);
            var header = optionsMenu.AddHeader(0, "Song List");

            optionsMenu.scrollable.AddRow(header);
            int index = 0;

            Il2CppSystem.Collections.Generic.List <GameObject> row = new Il2CppSystem.Collections.Generic.List <GameObject>();
            foreach (KeyValuePair <string, string> song in PlaylistManager.playlistToEdit.songNames)
            {
                var name = optionsMenu.AddTextBlock(0, song.Value);
                var tmp  = name.transform.GetChild(0).GetComponent <TextMeshPro>();
                tmp.fontSizeMax = 32;
                tmp.fontSizeMin = 8;
                optionsMenu.scrollable.AddRow(name.gameObject);

                var delete = optionsMenu.AddButton(1, "Remove", new Action(() =>
                {
                    PlaylistManager.RemoveSongFromPlaylist(song.Key);
                    RefreshList();
                }), null, "Removes this song from this playlist", optionsMenu.buttonPrefab);
                row.Add(delete.gameObject);
                if (!SongLoadingManager.songDictionary.ContainsKey(song.Key + ".audica"))
                {
                    var download = optionsMenu.AddButton(0, "Download", new Action(() =>
                    {
                        var button = GameObject.Find("menu/ShellPage_Settings/page/backParent/back");
                        var label  = button.GetComponentInChildren <TextMeshPro>();
                        UnityEngine.Object.Destroy(button.GetComponentInChildren <Localizer>());
                        var bButton = button.GetComponentInChildren <GunButton>();
                        PlaylistManager.DownloadSingleSong(song.Key + ".audica", true, bButton, label);
                    }), null, "Download this song", optionsMenu.buttonPrefab);
                    download.button.destroyOnShot = true;
                    row.Add(download.gameObject);
                }

                optionsMenu.scrollable.AddRow(row);
                row = new Il2CppSystem.Collections.Generic.List <GameObject>();
                if (index < PlaylistManager.playlistToEdit.songs.Count - 1)
                {
                    var moveDown = optionsMenu.AddButton(0, "Move Down", new Action(() =>
                    {
                        PlaylistManager.MoveSongDown(song.Key);
                        RefreshList();
                    }), null, "Moves this song down in the playlist", optionsMenu.buttonPrefab);
                    row.Add(moveDown.gameObject);
                }
                if (index != 0)
                {
                    var moveUp = optionsMenu.AddButton(1, "Move Up", new Action(() =>
                    {
                        PlaylistManager.MoveSongUp(song.Key);
                        RefreshList();
                    }), null, "Moves this song up in the playlist", optionsMenu.buttonPrefab);
                    row.Add(moveUp.gameObject);
                }
                optionsMenu.scrollable.AddRow(row);
                index++;
                row = new Il2CppSystem.Collections.Generic.List <GameObject>();
            }
            header = optionsMenu.AddHeader(0, "Playlist Options");
            optionsMenu.scrollable.AddRow(header);

            var deletePlaylistButton = optionsMenu.AddButton(0, "Delete", new Action(() =>
            {
                PlaylistManager.DeletePlaylist();
                PlaylistManager.state = PlaylistManager.PlaylistState.Selecting;
                OptionsMenu.I.ShowPage(OptionsMenu.Page.Main);
                SelectPlaylistButton.UpdatePlaylistButton();
            }), null, "Deletes this Playlist", optionsMenu.buttonPrefab);

            //optionsMenu.scrollable.AddRow(deletePlaylistButton.gameObject);
            row.Add(deletePlaylistButton.gameObject);
            if (PlaylistManager.playlistToEdit.downloadedDict.Any(p => p.Value == false))
            {
                var downloadAllButton = optionsMenu.AddButton(1, "Download All", new Action(() =>
                {
                    var button = GameObject.Find("menu/ShellPage_Settings/page/backParent/back");
                    var label  = button.GetComponentInChildren <TextMeshPro>();
                    UnityEngine.Object.Destroy(button.GetComponentInChildren <Localizer>());
                    var bButton = button.GetComponentInChildren <GunButton>();
                    //bButton.SetInteractable(false);
                    List <string> songs = new List <string>();
                    foreach (KeyValuePair <string, string> song in PlaylistManager.playlistToEdit.songNames)
                    {
                        if (!SongLoadingManager.songDictionary.ContainsKey(song.Key + ".audica"))
                        {
                            songs.Add(song.Key + ".audica");
                            //PlaylistManager.DownloadSong(song.Key + ".audica", true, backButton);
                        }
                    }
                    if (songs.Count > 0)
                    {
                        PlaylistManager.DownloadSongs(songs, true, bButton, label);
                    }
                }), null, "Downloads all missing songs in this Playlist", optionsMenu.buttonPrefab);
                //optionsMenu.scrollable.AddRow(downloadAllButton.gameObject);
                row.Add(downloadAllButton.gameObject);
            }
            optionsMenu.scrollable.AddRow(row);
        }