/// <summary> /// Imports the QB/PAB/DBG paks /// </summary> /// <returns>List of failed files</returns> public GameFile[] ImportPaks(FileCopyProgress callback) { List<GameFile> gf = new List<GameFile>(); GameFile pak = new GameFile(_project.GameInfo.QbPakFilename, localGameFilename(_project.GameInfo.QbPakFilename), GameFileType.QbPak); GameFile pab = null; List<GameFile> failed = new List<GameFile>(); if (_project.GameInfo.HasQbPab) pab = new GameFile(_project.GameInfo.QbPabFilename, localGameFilename(_project.GameInfo.QbPabFilename), GameFileType.QbPab); GameFile dbg = new GameFile(_project.GameInfo.DbgPakFilename, localGameFilename(_project.GameInfo.DbgPakFilename), GameFileType.DbgPak); try { GameFile[] gameSongs; if (_project.GameInfo.HasQbPab) gameSongs = GameFile.CreateArray(pak, pab, dbg); else gameSongs = GameFile.CreateArray(pak, dbg); this.Import(gameSongs, delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gameSongs[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); } finally { } return failed.ToArray(); }
/// <summary> /// Read a single file from the game /// </summary> /// <param name="gameFile"></param> /// <returns>List of failed files</returns> public GameFile[] Import(GameFile gameFile, FileCopyProgress callback) { List<GameFile> failed = new List<GameFile>(); List<GameFile> gf = new List<GameFile>(); _fileCopy.SetSourcePath(_gameLocation); _fileCopy.ImportFile(gameFile.GameName, gameFile.LocalName, delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gf[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); if (!io.File.Exists(gameFile.LocalName)) throw new ApplicationException("Failed to import files from the game source."); _files.Add(gameFile.GameName, gameFile); return failed.ToArray(); }
/// <summary> /// Imports the notes PAK files for all songs in the EditSongs /// </summary> /// <returns>Array of extracted GameFiles</returns> public GameFile[] ImportBackgroundAudio(FileCopyProgress callback) { GameFile[] gameSongs = new GameFile[2]; List<GameFile> failed = new List<GameFile>(); gameSongs[0] = new GameFile(_project.GameInfo.StreamDat, localGameFilename(_project.GameInfo.StreamDat), GameFileType.Dat); gameSongs[1] = new GameFile(_project.GameInfo.StreamWad, localGameFilename(_project.GameInfo.StreamWad), GameFileType.Wad); this.Import(gameSongs, delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gameSongs[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); return gameSongs; }
/// <summary> /// /// </summary> /// <param name="gameFiles"></param> /// <param name="callback"></param> /// <returns>Failed gamefiles.</returns> public GameFile[] Import(GameFile[] gameFiles, FileCopyProgress callback) { List<GameFile> failed = new List<GameFile>(); _fileCopy.SetSourcePath(_gameLocation); _fileCopy.ImportFiles(GameFile.CreateGameArray(gameFiles), GameFile.CreateLocalArray(gameFiles), delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gameFiles[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); foreach (GameFile gf in gameFiles) { if (!io.File.Exists(gf.LocalName)) throw new ApplicationException("Failed to import files from the game source."); if (!_files.ContainsKey(gf.GameName)) { _files.Add(gf.GameName, gf); gf.UpdateLocalDateTime(); } } return failed.ToArray(); }
/// <summary> /// Write a single files to the game /// </summary> /// <param name="gameFile"></param> /// <returns>List of failed files</returns> public GameFile[] Export(GameFile gameFile, FileCopyProgress callback) { List<GameFile> failed = new List<GameFile>(); List<GameFile> gf = new List<GameFile>(); _fileCopy.SetSourcePath(_gameLocation); _fileCopy.ExportFile(gameFile.LocalName, gameFile.GameName, delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gf[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); gameFile.UpdateLocalDateTime(); return failed.ToArray(); }
/// <summary> /// Write files to the game /// </summary> /// <param name="gameFiles"></param> /// <returns>List of failed files</returns> public GameFile[] Export(GameFile[] gameFiles, FileCopyProgress callback) { List<GameFile> failed = new List<GameFile>(); _fileCopy.SetSourcePath(_gameLocation); _fileCopy.ExportFiles(GameFile.CreateLocalArray(gameFiles), GameFile.CreateGameArray(gameFiles), delegate(string gameFilename, string diskFilename, int fileNo, int fileCount, float percentage, bool success) { if (!success) failed.Add(gameFiles[fileNo]); if (callback != null) callback(gameFilename, diskFilename, fileNo, fileCount, percentage, success); }); foreach (GameFile gf in gameFiles) gf.UpdateLocalDateTime(); return failed.ToArray(); }
/// <summary> /// A new file has been created, used when new files are to be written/updated in the game. /// </summary> public void AddNew(GameFile gameFile) { _files.Add(gameFile.GameName, gameFile); }
/// <summary> /// A new file has been created, used when new files are to be written/updated in the game. /// </summary> public void AddNew(GameFile[] gameFiles) { foreach (GameFile gf in gameFiles) _files.Add(gf.GameName, gf); }