예제 #1
0
        private void SetupPlaylistsWithSongs(int playlistCount, int songCount)
        {
            BeatSaberQuestomConfig config = null;
            QuestomAssetsEngine    qae    = new QuestomAssetsEngine(_apkFile);

            config = qae.GetCurrentConfig();

            for (int p = 0; p < playlistCount; p++)
            {
                var playlist = new BeatSaberPlaylist()
                {
                    PlaylistID   = string.Format(PlaylistIDFormat, p),
                    PlaylistName = string.Format(PlaylistNameFormat, p),
                    CoverArt     = new System.Drawing.Bitmap(COVER_ART_FILE)
                };
                for (int i = 0; i < songCount; i++)
                {
                    var song = new BeatSaberSong()
                    {
                        SongID           = string.Format(SongIDFormat, p, i),
                        CustomSongFolder = TEST_SONG_FOLDER
                    };

                    playlist.SongList.Add(song);
                }
                config.Playlists.Add(playlist);
            }
            qae.UpdateConfig(config);
        }
예제 #2
0
        static int FolderMode(FolderMode args)
        {
            QuestomAssets.Log.SetLogSink(new ConsoleSink());

            if (!string.IsNullOrWhiteSpace(args.CoverArt) && !File.Exists(args.CoverArt))
            {
                Log.LogErr("Playlist cover art file doesn't exist!");
                return(-1);
            }
            var customSongsFolders = GetCustomSongsFromPath(args.CustomSongsFolder);

            if (customSongsFolders.Count < 1)
            {
                Log.LogErr("No custom songs found!");
                return(-1);
            }
            try
            {
                Log.LogMsg($"Opening APK at '{args.ApkFile}'");
                QuestomAssetsEngine q = new QuestomAssetsEngine(args.ApkFile);

                Log.LogMsg($"Loading configuration...");
                var cfg = q.GetCurrentConfig(true);
                Log.LogMsg($"Configuration loaded");

                if (!args.NoPatch)
                {
                    Log.LogMsg($"Applying patches...");
                    if (!q.ApplyPatchSettingsFile())
                    {
                        Log.LogErr("Failed to apply patches.  Cannot continue.");
                        return(-1);
                    }
                }

                BeatSaberPlaylist playlist = cfg.Playlists.FirstOrDefault(x => x.PlaylistID == "CustomSongs");
                if (playlist == null)
                {
                    Log.LogMsg("Playlist doesn't already exist, creating it");
                    playlist = new BeatSaberPlaylist()
                    {
                        PlaylistID   = "CustomSongs",
                        PlaylistName = "Custom Songs"
                    };
                    cfg.Playlists.Add(playlist);
                }
                else if (args.DeleteSongs)
                {
                    Log.LogMsg("Deleting current songs from playlist before reloading");
                    playlist.SongList.Clear();
                }
                try
                {
                    playlist.CoverArt = string.IsNullOrWhiteSpace(args.CoverArt) ? null : new Bitmap(args.CoverArt);
                }
                catch (Exception ex)
                {
                    Log.LogErr($"Unable to load playlist cover art from {args.CoverArt}", ex);
                    playlist.CoverArt = null;
                }
                Log.LogMsg($"Attempting to load {customSongsFolders.Count} custom songs...");
                foreach (var cs in customSongsFolders)
                {
                    playlist.SongList.Add(new BeatSaberSong()
                    {
                        CustomSongFolder = cs
                    });
                }
                Log.LogMsg("Applying new configuration...");
                q.UpdateConfig(cfg);
                Log.LogMsg("Configuration updated");

                Log.LogMsg("Signing APK...");
                q.SignAPK();
                Log.LogMsg("APK signed");
                return(0);
            }
            catch (Exception ex)
            {
                Log.LogErr("Something went horribly wrong", ex);
                return(-1);
            }
        }