public static void ExtractAllFiles(bool ignoreComplete = false) { string path = Program.ProjectPath; string where = Functions.FileDialog._SaveDialog.DirectoryPath.ToString(); //WaitDialog.Width = 15; //WaitDialog.Height = 3; RPGMakerVersion _version = RGSSAD.GetVersion(path); switch (_version) { case RPGMakerVersion.Xp: case RPGMakerVersion.Vx: { RGSSADv1 encrypted = new RGSSADv1(path); try { Misc.UpdateStatus("Extracting all files for a XP/VX archive..."); encrypted.ExtractAllFiles(where, StaticWindows.Settings.OverwriteFiles); } catch (IOException file) { Operation.ShowError(file.Message); } encrypted.Dispose(); break; } case RPGMakerVersion.VxAce: { RGSSADv3 encrypted = new RGSSADv3(path); try { Misc.UpdateStatus("Extracting all files for a VX Ace archive..."); encrypted.ExtractAllFiles(where, StaticWindows.Settings.OverwriteFiles); } catch (IOException file) { Operation.ShowError(file.Message); } encrypted.Dispose(); break; } default: break; } if (!ignoreComplete) { Application.Run(Operation.Complete); } }
public void CorrectAmountOfArchivedFilesIsReadFromXpArchive() { FileHelpers.CopyArchives(); RGSSADv1 rgssad = new RGSSADv1(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerXpArchiveName)); Assert.AreEqual(16, rgssad.ArchivedFiles.Count); rgssad.Dispose(); FileHelpers.Cleanup(); }
public void CorrectFileNamesAreReadFromVxArchive() { FileHelpers.CopyArchives(); RGSSADv1 rgssad = new RGSSADv1(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxArchiveName)); // Verified with Falos RPG Maker Decrypter Assert.AreEqual(@"Data\Actors.rvdata", rgssad.ArchivedFiles[0].Name); Assert.AreEqual(@"Data\Animations.rvdata", rgssad.ArchivedFiles[1].Name); Assert.AreEqual(@"Data\Areas.rvdata", rgssad.ArchivedFiles[2].Name); rgssad.Dispose(); FileHelpers.Cleanup(); }
public void CorrectKeysAreReadFromXpArchive() { FileHelpers.CopyArchives(); RGSSADv1 rgssad = new RGSSADv1(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerXpArchiveName)); // Verified with Falos RPG Maker Decrypter Assert.AreEqual((uint)0x7B7448AE, rgssad.ArchivedFiles[0].Key); Assert.AreEqual((uint)0x366D564E, rgssad.ArchivedFiles[1].Key); Assert.AreEqual((uint)0x222699FE, rgssad.ArchivedFiles[2].Key); rgssad.Dispose(); FileHelpers.Cleanup(); }
public void CorrectSizesAreReadFromXpArchive() { FileHelpers.CopyArchives(); RGSSADv1 rgssad = new RGSSADv1(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerXpArchiveName)); // Verified with Falos RPG Maker Decrypter Assert.AreEqual(10981, rgssad.ArchivedFiles[0].Size); Assert.AreEqual(136243, rgssad.ArchivedFiles[1].Size); Assert.AreEqual(4285, rgssad.ArchivedFiles[2].Size); rgssad.Dispose(); FileHelpers.Cleanup(); }
public void CorrectOffsetsAreReadFromVxArchive() { FileHelpers.CopyArchives(); RGSSADv1 rgssad = new RGSSADv1(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxArchiveName)); // Verified with Falos RPG Maker Decrypter Assert.AreEqual(34, rgssad.ArchivedFiles[0].Offset); Assert.AreEqual(10951, rgssad.ArchivedFiles[1].Offset); Assert.AreEqual(139280, rgssad.ArchivedFiles[2].Offset); rgssad.Dispose(); FileHelpers.Cleanup(); }
public static void FindAndExtractFile(bool ignoreComplete = false) { string path = Program.ProjectPath; string where = Functions.FileDialog._SaveDialog.DirectoryPath.ToString(); string file = StaticWindows.ExportOneFile.GetFile(); //WaitDialog.Width = 15; //WaitDialog.Height = 3; Functions.Misc.UpdateStatus("Extracting file: " + file); RPGMakerVersion _version = RGSSAD.GetVersion(path); switch (_version) { case RPGMakerVersion.Xp: case RPGMakerVersion.Vx: { RGSSADv1 encrypted = new RGSSADv1(path); try { ArchivedFile _result = encrypted.ArchivedFiles.FirstOrDefault(x => x.Name.Contains(file)); if ((_result.Name ?? "TheresNoFileHere") != "TheresNoFileHere") { encrypted.ExtractFile(_result, where, StaticWindows.Settings.OverwriteFiles); } if (!ignoreComplete) { Functions.Misc.UpdateStatus("Extracted file: " + file); Application.Run(Operation.Complete); } } catch (IOException fileErr) { Operation.ShowError(fileErr.Message + "\n\n" + fileErr.Source); } encrypted.Dispose(); break; } case RPGMakerVersion.VxAce: { RGSSADv3 encrypted = new RGSSADv3(path); try { ArchivedFile _result = encrypted.ArchivedFiles.FirstOrDefault(x => x.Name.Contains(file)); if ((_result.Name ?? "TheresNoFileHere") != "TheresNoFileHere") { encrypted.ExtractFile(_result, where, StaticWindows.Settings.OverwriteFiles); } if (!ignoreComplete) { Functions.Misc.UpdateStatus("Extracted file: " + file); Application.Run(Operation.Complete); } } catch (IOException fileErr) { Operation.ShowError(fileErr.Message + "\n\n" + fileErr.Source); } encrypted.Dispose(); break; } default: break; } }
public static void GetAllFiles() { string path = Program.ProjectPath; string infoText = ""; //WaitDialog.Width = 15; //WaitDialog.Height = 3; RPGMakerVersion _version = RGSSAD.GetVersion(path); switch (_version) { case RPGMakerVersion.Xp: case RPGMakerVersion.Vx: { RGSSADv1 encrypted = new RGSSADv1(path); max = (int)Math.Ceiling((double)encrypted.ArchivedFiles.Count / 10); int size = 0; foreach (ArchivedFile file in encrypted.ArchivedFiles) { size += file.Size; } infoText = "Amount of files: " + encrypted.ArchivedFiles.Count + " (" + Misc.FileSize(size) + " total)\n\n"; for (int q = location * 10; q < Math.Min((location + 1) * 10, encrypted.ArchivedFiles.Count); q++) { infoText += (encrypted.ArchivedFiles[q].Name).Substring(0, Math.Min(58 - Misc.FileSize(encrypted.ArchivedFiles[q].Size).Length, encrypted.ArchivedFiles[q].Name.Length)) + " (" + Misc.FileSize(encrypted.ArchivedFiles[q].Size) + ")" + "\n"; } Misc.UpdateStatus("Displaying files " + ((location * 10) + 1) + " thru " + Math.Min((location + 1) * 10, encrypted.ArchivedFiles.Count) + " out of " + encrypted.ArchivedFiles.Count.ToString()); encrypted.Dispose(); break; } case RPGMakerVersion.VxAce: { RGSSADv3 encrypted = new RGSSADv3(path); max = (int)Math.Ceiling((double)encrypted.ArchivedFiles.Count / 10); int size = 0; foreach (ArchivedFile file in encrypted.ArchivedFiles) { size += file.Size; } infoText = "Amount of files: " + encrypted.ArchivedFiles.Count + " (" + Misc.FileSize(size) + " total)\n\n"; for (int q = location * 10; q < Math.Min((location + 1) * 10, encrypted.ArchivedFiles.Count); q++) { infoText += (encrypted.ArchivedFiles[q].Name).Substring(0, Math.Min(58 - Misc.FileSize(encrypted.ArchivedFiles[q].Size).Length, encrypted.ArchivedFiles[q].Name.Length)) + " (" + Misc.FileSize(encrypted.ArchivedFiles[q].Size) + ")" + "\n"; } encrypted.Dispose(); break; } default: break; } infoText += "\n" + (location + 1).ToString() + " / " + max.ToString(); infoLabel.Text = infoText; AllFiles.ColorScheme = Program.ArchivedList; Application.Run(AllFiles); }
static void Main(string[] args) { _commandLineOptions = new CommandLineOptions(); if (Parser.Default.ParseArguments(args, _commandLineOptions) == false) { Environment.Exit(1); } if (_commandLineOptions.InputPaths.Count == 0) { Console.WriteLine(_commandLineOptions.GetUsage()); Environment.Exit(1); } RPGMakerVersion version = RGSSAD.GetVersion(_commandLineOptions.InputPaths.First()); if (version == RPGMakerVersion.Invalid) { Console.WriteLine("Invalid input file."); Environment.Exit(1); } string outputDirectoryPath; if (_commandLineOptions.OutputDirectoryPath != null) { outputDirectoryPath = _commandLineOptions.OutputDirectoryPath; } else { FileInfo fi = new FileInfo(_commandLineOptions.InputPaths.First()); outputDirectoryPath = fi.DirectoryName; } try { switch (version) { case RPGMakerVersion.Xp: case RPGMakerVersion.Vx: RGSSADv1 rgssadv1 = new RGSSADv1(_commandLineOptions.InputPaths.First()); rgssadv1.ExtractAllFiles(outputDirectoryPath); break; case RPGMakerVersion.VxAce: RGSSADv3 rgssadv2 = new RGSSADv3(_commandLineOptions.InputPaths.First()); rgssadv2.ExtractAllFiles(outputDirectoryPath); break; } } catch (InvalidArchiveException) { Console.WriteLine("Archive is invalid or corrupted. Reading failed."); Environment.Exit(1); } catch (UnsupportedArchiveException) { Console.WriteLine("Archive is not supported or it is corrupted."); Environment.Exit(1); } catch (Exception) { Console.WriteLine("Something went wrong with reading or extraction. Archive is likely invalid or corrupted."); Environment.Exit(1); } if (_commandLineOptions.GenerateProjectFile) { ProjectGenerator.GenerateProject(version, outputDirectoryPath); } }