public ModManager(QaeConfig config, Func <QuestomAssetsEngine> getEngine) { _config = config; _getEngine = getEngine; _modConfig = ModConfig.Load(_config); _originalModConfig = _modConfig.Clone(); }
public ImportManager(QaeConfig qaeConfig, Func <BeatOnConfig> getConfig, Func <QuestomAssetsEngine> getEngine, ShowToastDelegate showToast, Func <DownloadManager> getDownloadManager) { _qaeConfig = qaeConfig; _getConfig = getConfig; _getEngine = getEngine; _showToast = showToast; _getDownloadManager = getDownloadManager; }
public ImportManager(QaeConfig qaeConfig, Func <BeatOnConfig> getConfig, Func <QuestomAssetsEngine> getEngine, ShowToastDelegate showToast, Func <DownloadManager> getDownloadManager, Action triggerConfigChanged) { _qaeConfig = qaeConfig; _getConfig = getConfig; _getEngine = getEngine; _showToast = showToast; _getDownloadManager = getDownloadManager; _triggerConfigChanged = triggerConfigChanged; }
public SyncManager(QaeConfig config, DownloadManager downloadManager, GetBeatOnConfigDelegate getConfig, GetQaeDelegate getQae, ShowToastDelegate showToast) { _downloadManager = downloadManager; _getConfig = getConfig; _getQae = getQae; _showToast = showToast; _config = config; WebUtils.Initialize(new System.Net.Http.HttpClient()); }
public PostReloadSongFolders(BeatSaberModder mod, QaeConfig qaeConfig, ShowToastDelegate showToast, SendHostMessageDelegate sendMessage, GetQaeDelegate getQae, GetBeatOnConfigDelegate getConfig, Action triggerConfigChanged, SetSuppressConfigChangeMessages setSuppressMsg) { _mod = mod; _qaeConfig = qaeConfig; _showToast = showToast; _sendMessage = sendMessage; _getQae = getQae; _getConfig = getConfig; _triggerConfigChanged = triggerConfigChanged; _setSuppressMsg = setSuppressMsg; }
public GetImages(QaeConfig config) { _config = config; }
public GetModCover(QaeConfig config, GetBeatOnConfigDelegate getConfig) { _getConfig = getConfig; _config = config; }
public void loadlots() { QuestomAssets.Utils.ImageUtils.Instance = new ImageUtilsWin(); try { QaeConfig cfg2 = new QaeConfig() { AssetsPath = "Data", RootFileProvider = new FolderFileProvider(@"C:\Users\VR\Desktop\platform-tools_r28.0.3-windows\perftest", false), SongsPath = "customsongs", SongFileProvider = new FolderFileProvider(@"C:\Users\VR\Desktop\platform-tools_r28.0.3-windows\perftest", false) }; var qae2 = new QuestomAssetsEngine(cfg2); var config = qae2.GetCurrentConfig(); var folders = GetCustomSongsFromPath(@"C:\Users\VR\Desktop\platform-tools_r28.0.3-windows\perftest\customsongs"); if (folders.Count < 1) { Log.LogErr("Request to reload songs folder, but didn't find any songs!"); //not found probably isn't the right response code for this, but meh return; } Log.LogMsg($"Starting to reload custom songs from folders. Found {folders.Count} folders to evaluate"); //todo: probably don't just grab this one var playlist = config.Playlists.FirstOrDefault(x => x.PlaylistID == "CustomSongs"); if (playlist == null) { playlist = new BeatSaberPlaylist() { PlaylistID = "CustomSongs", PlaylistName = "Custom Songs" }; config.Playlists.Add(playlist); } int addedCtr = 0; foreach (var folder in folders) { string songId = folder.Replace("/", ""); songId = songId.Replace(" ", ""); if (config.Playlists.SelectMany(x => x.SongList).Any(x => x.SongID?.ToLower() == songId.ToLower())) { //SendStatusMessage($"Folder {folder} already loaded"); Log.LogMsg($"Custom song in folder {folder} appears to already be loaded, skipping it."); continue; } //safety check to make sure we aren't importing one with the same ID as a beatsaber song. It could be re-ID'ed, but this is a stopgap if (BSConst.KnownLevelIDs.Contains(songId)) { Log.LogErr($"Song in path {folder} would conflict with a built in songID and will be skipped"); continue; } // SendStatusMessage($"Adding song in {folder}"); Log.LogMsg($"Adding custom song in folder {folder} to playlist ID {playlist.PlaylistID}"); playlist.SongList.Add(new BeatSaberSong() { SongID = songId, CustomSongPath = Path.Combine(cfg2.SongsPath, folder) }); addedCtr++; //maybe limit how many //if (addedCtr > 200) //{ // ShowToast("Too Many Songs", "That's too many at once. After these finish and you 'Sync to Beat Saber', then try 'Reload Songs Folder' again to load more.", ToastType.Warning, 10); // break; //} } if (addedCtr > 0) { Log.LogMsg("Updating config with loaded song folders"); qae2.UpdateConfig(config); } qae2.Save(); } finally { } QaeConfig cfg3 = new QaeConfig() { AssetsPath = "Data", RootFileProvider = new FolderFileProvider(@"C:\Users\VR\Desktop\platform-tools_r28.0.3-windows\perftest\Data", false), SongsPath = "customsongs", SongFileProvider = new FolderFileProvider(@"C:\Users\VR\Desktop\platform-tools_r28.0.3-windows\perftest\Data\customsongs", false) }; var qae3 = new QuestomAssetsEngine(cfg3); Assert.Pass(); }
//TODO: move the cache somewhere else or create an instance of this class and pass it around public CustomLevelLoader(AssetsFile assetsFile, QaeConfig config) { _assetsFile = assetsFile; _config = config; }
public GetPlaylistCover(GetBeatOnConfigDelegate getConfig, QaeConfig config) { _getConfig = getConfig; _config = config; }
public override List <AssetOp> GetUninstallOps(ModContext context) { if (UninstallAction == null) { throw new InvalidOperationException("Tried to install AssetsModComponent, but uninstall action is null."); } if (UninstallAction.Actions == null || UninstallAction.Actions.Count < 1) { throw new InvalidOperationException("Uninstall action has no asset actions defined!"); } if (string.IsNullOrEmpty(context.Config.BackupApkFileAbsolutePath)) { throw new InvalidOperationException("Uninstall assets mod can't happen when the backup APK isn't set!"); } string backup = null; if (!File.Exists(context.Config.BackupApkFileAbsolutePath)) { Log.LogErr($"WARNING: primary APK backup doesn't exist at {context.Config.BackupApkFileAbsolutePath}, will attempt to fall back..."); if (!File.Exists(context.Config.ModdedFallbackBackupPath)) { throw new Exception($"Backup APK file does not exist at {context.Config.BackupApkFileAbsolutePath} and even the fallback doesn't exist at {context.Config.ModdedFallbackBackupPath}"); } else { backup = context.Config.ModdedFallbackBackupPath; } } else { backup = context.Config.BackupApkFileAbsolutePath; } using (new LogTiming("preloading asset files for uninstall assets mod")) { if (UninstallAction.PreloadFiles != null) { UninstallAction.PreloadFiles.ForEach(x => context.GetEngine().Manager.GetAssetsFile(x)); } } Log.LogMsg($"Opening backup APK..."); List <AssetOp> ops = new List <AssetOp>(); using (var apk = new ZipFileProvider(backup, FileCacheMode.Memory, true, FileUtils.GetTempDirectory())) { var backupCfg = new QaeConfig() { AssetsPath = BeatSaber.BSConst.KnownFiles.AssetsRootPath, SongsPath = "", ModsSourcePath = "", PlaylistArtPath = "", RootFileProvider = apk }; using (var backupQae = new QuestomAssetsEngine(backupCfg)) { using (new LogTiming("preloading asset files for uninstall assets mod on BACKUP apk/qae")) { if (UninstallAction.PreloadFiles != null) { UninstallAction.PreloadFiles.ForEach(x => backupQae.Manager.GetAssetsFile(x)); } } using (new LogTiming("preloading asset files that are loaded in the main engine")) { context.GetEngine().Manager.OpenFiles.ForEach(x => backupQae.Manager.GetAssetsFile(x.AssetsFilename)); } context.BackupEngine = backupQae; foreach (var action in UninstallAction.Actions.OrderBy(x => x.StepNumber)) { using (new LogTiming($"getting operations for asset mod uninstall action step {action.StepNumber}")) { ops.AddRange(action.GetOps(context)); } } } context.BackupEngine = null; } Log.LogMsg($"Returning {ops.Count} for assets mod component uninstall..."); return(ops); }
internal void PerformFileOperation(QaeConfig config) { try { IFileProvider provider; switch (ProviderType) { case QueuedFileOperationProviderType.Root: provider = config.RootFileProvider; break; case QueuedFileOperationProviderType.ModLibs: provider = config.ModLibsFileProvider; break; case QueuedFileOperationProviderType.FileSystemRoot: provider = new FolderFileProvider("/", false); break; default: throw new NotImplementedException($"Provider type {ProviderType} is not implemented in QueuedFileOp."); } switch (Type) { case QueuedFileOperationType.DeleteFile: if (!provider.FileExists(TargetPath)) { Log.LogErr($"Queued file operation was supposed to delete '{TargetPath}' but it didn't exist!"); } else { provider.Delete(TargetPath); } break; case QueuedFileOperationType.DeleteFolder: if (!provider.DirectoryExists(TargetPath)) { Log.LogErr($"Queued file operation was supposed to delete '{TargetPath}' but it didn't exist!"); } else { provider.RmRfDir(TargetPath); } break; case QueuedFileOperationType.ExtractZipToFolder: throw new NotImplementedException(); case QueuedFileOperationType.WriteFile: provider.MkDir(TargetPath.GetDirectoryFwdSlash(), true); provider.Write(TargetPath, SourceData, true); provider.Save(); break; } } catch (NotImplementedException) { throw; } catch (Exception ex) { Log.LogErr($"Exception handling queued file operation of type {Type}", ex); throw; } }
public ModContext(string modPath, QaeConfig config, Func <QuestomAssetsEngine> getEngine) { ModPath = modPath; Config = config; GetEngine = getEngine; }