/// <summary> /// Pack an SDS from the FileInfo given. /// </summary> /// <param name="file">location of SDS.</param> private void PackSDS(FileInfo file) { if (file == null) { MessageBox.Show("File is null"); } //begin.. infoText.Text = "Saving SDS.."; ArchiveFile archiveFile = new ArchiveFile { Platform = Platform.PC, Unknown20 = new byte[16] { 55, 51, 57, 55, 57, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; archiveFile.BuildResources(file.Directory.FullName + "/extracted/" + file.Name); foreach (ResourceEntry entry in archiveFile.ResourceEntries) { if (entry.Data == null) { throw new FormatException(); } } using (var output = File.Create(file.FullName)) { archiveFile.Serialize(output, ToolkitSettings.SerializeSDSOption == 0 ? ArchiveSerializeOptions.OneBlock : ArchiveSerializeOptions.Compress); } infoText.Text = "Saved SDS."; }
public override void Save() { var game = GameStorage.Instance.GetSelectedGame(); ArchiveFile archiveFile = new ArchiveFile(); archiveFile.Platform = Platform.PC; // MII: DE no longer has this data in the header. if (game.GameType == GamesEnumerator.MafiaII) { archiveFile.Unknown20 = new byte[16] { 55, 51, 57, 55, 57, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; } if (game.GameType == GamesEnumerator.MafiaI_DE || game.GameType == GamesEnumerator.MafiaIII) { archiveFile.Version = 20; } else { archiveFile.Version = 19; } // We should now to try pack the SDS. if (!archiveFile.BuildResources(file.Directory.FullName + "/extracted/" + file.Name)) { MessageBox.Show("Failed to pack SDS.", "Toolkit", MessageBoxButtons.OK); return; } foreach (ResourceEntry entry in archiveFile.ResourceEntries) { if (entry.Data == null) { throw new FormatException(); } } using (var output = File.Create(file.FullName)) { archiveFile.Serialize(output, ToolkitSettings.SerializeSDSOption == 0 ? ArchiveSerializeOptions.OneBlock : ArchiveSerializeOptions.Compress); } archiveFile = null; }
public void SaveSDSWithCustomFolder(GamesEnumerator GameType, string Folder) { ArchiveFile archiveFile = new ArchiveFile(); archiveFile.Platform = Platform.PC; archiveFile.SetGameType(GameType); // MII: DE no longer has this data in the header. if (GameType == GamesEnumerator.MafiaII) { archiveFile.Unknown20 = new byte[16] { 55, 51, 57, 55, 57, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; } if (GameType == GamesEnumerator.MafiaI_DE || GameType == GamesEnumerator.MafiaIII) { archiveFile.Version = 20; } else { archiveFile.Version = 19; } // We should now to try pack the SDS. if (!archiveFile.BuildResources(Folder)) { MessageBox.Show("Failed to pack SDS.", "Toolkit", MessageBoxButtons.OK); return; } foreach (ResourceEntry entry in archiveFile.ResourceEntries) { if (entry.Data == null) { throw new FormatException(); } } using (var output = File.Create(file.FullName)) { archiveFile.Serialize(output, ArchiveSerializeOptions.Compress); } archiveFile = null; }
/// <summary> /// Pack an SDS from the FileInfo given. /// </summary> /// <param name="file">location of SDS.</param> private void PackSDS(FileInfo file) { if (file == null) { MessageBox.Show("File is null"); } //backup file before repacking.. if (!Directory.Exists(file.Directory.FullName + "/BackupSDS")) { Directory.CreateDirectory(file.Directory.FullName + "/BackupSDS"); } //place copy in new folder. File.Copy(file.FullName, file.Directory.FullName + "/BackupSDS/" + file.Name, true); //begin.. infoText.Text = "Saving SDS.."; ArchiveFile archiveFile = new ArchiveFile { Platform = Platform.PC, Unknown20 = new byte[16] { 55, 51, 57, 55, 57, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; archiveFile.BuildResources(file.Directory.FullName + "/extracted/" + file.Name); foreach (ResourceEntry entry in archiveFile.ResourceEntries) { if (entry.Data == null) { throw new FormatException(); } } using (var output = File.Create(file.FullName)) { archiveFile.Serialize(output, ArchiveSerializeOptions.Compress); } infoText.Text = "Saved SDS."; }