Beispiel #1
0
            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 CorrectAmountOfArchivedFilesIsReadFromVxAceArchive()
        {
            FileHelpers.CopyArchives();

            RGSSADv3 rgssad = new RGSSADv3(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxAceArchiveName));

            Assert.AreEqual(16, rgssad.ArchivedFiles.Count);

            rgssad.Dispose();

            FileHelpers.Cleanup();
        }
        public void CorrectKeysAreReadFromVxAceArchive()
        {
            FileHelpers.CopyArchives();

            RGSSADv3 rgssad = new RGSSADv3(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxAceArchiveName));

            // Verified with Falos RPG Maker Decrypter
            Assert.AreEqual((uint)0x00000029, rgssad.ArchivedFiles[0].Key);
            Assert.AreEqual((uint)0x00004823, rgssad.ArchivedFiles[1].Key);
            Assert.AreEqual((uint)0x000018BE, rgssad.ArchivedFiles[2].Key);

            rgssad.Dispose();

            FileHelpers.Cleanup();
        }
        public void CorrectSizesAreReadFromVxAceArchive()
        {
            FileHelpers.CopyArchives();

            RGSSADv3 rgssad = new RGSSADv3(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxAceArchiveName));

            // Verified with Falos RPG Maker Decrypter
            Assert.AreEqual(3032, rgssad.ArchivedFiles[0].Size);
            Assert.AreEqual(218459, rgssad.ArchivedFiles[1].Size);
            Assert.AreEqual(11472, rgssad.ArchivedFiles[2].Size);

            rgssad.Dispose();

            FileHelpers.Cleanup();
        }
        public void CorrectFileNamesAreReadFromVxAceArchive()
        {
            FileHelpers.CopyArchives();

            RGSSADv3 rgssad = new RGSSADv3(Path.Combine(FileHelpers.TempDirectoryPath, Constants.RpgMakerVxAceArchiveName));

            // Verified with Falos RPG Maker Decrypter
            Assert.AreEqual(@"Data\Actors.rvdata2", rgssad.ArchivedFiles[0].Name);
            Assert.AreEqual(@"Data\Animations.rvdata2", rgssad.ArchivedFiles[1].Name);
            Assert.AreEqual(@"Data\Armors.rvdata2", rgssad.ArchivedFiles[2].Name);

            rgssad.Dispose();

            FileHelpers.Cleanup();
        }
Beispiel #6
0
            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;
                }
            }
Beispiel #7
0
            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);
            }
Beispiel #8
0
        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);
            }
        }