Пример #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);
                }
            }
Пример #2
0
            public static string GetVersion(string input)
            {
                RPGMakerVersion _version = RGSSAD.GetVersion(input);

                switch (_version)
                {
                case RPGMakerVersion.Xp: return("RPG Maker XP");

                case RPGMakerVersion.Vx: return("RPG Maker VX");

                case RPGMakerVersion.VxAce: return("RPG Maker VX Ace");

                case RPGMakerVersion.Invalid:
                default:
                    return(null);
                }
            }
Пример #3
0
            public static void MakeProjectWithSavePath(bool ignoreComplete = false)
            {
                try
                {
                    Functions.Operation.ExecuteIfProjectSelected(() => {
                        Misc.EnsurePathExists(FileDialog._SaveDialog.DirectoryPath.ToString());
                        ProjectGenerator.GenerateProject(RGSSAD.GetVersion(Program.ProjectPath), FileDialog._SaveDialog.DirectoryPath.ToString());

                        if (!ignoreComplete)
                        {
                            Application.Run(Operation.Complete);
                        }
                    });
                }
                catch (Exception ex)
                {
                    Application.RequestStop(); Operation.ShowError(ex.Message);
                }
            }
Пример #4
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;
                }
            }
Пример #5
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);
            }
Пример #6
0
        private void openRGSSADToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            StringBuilder fileTypesStringBuilder = new StringBuilder();

            fileTypesStringBuilder.Append("RPG Maker XP Encrypted Archive (.rgssad)|*.rgssad|");
            fileTypesStringBuilder.Append("RPG Maker VX Encrypted Archive (.rgss2a)|*.rgss2a|");
            fileTypesStringBuilder.Append("RPG Maker VX Ace Encrypted Archive (.rgss3a)|*.rgss3a|");
            fileTypesStringBuilder.Append("All Files (*.*)|*.*");

            openFileDialog.Filter = fileTypesStringBuilder.ToString();

            var result = openFileDialog.ShowDialog();

            if (result == DialogResult.Abort || result == DialogResult.Cancel)
            {
                return;
            }

            // It's ok to reset here because user has decided to select other file
            Reset();

            string inputFilePath = openFileDialog.FileName;

            currentArchiveVersion = RGSSAD.GetVersion(inputFilePath);

            if (currentArchiveVersion == RPGMakerVersion.Invalid)
            {
                MessageBox.Show("Invalid input file.", "Invalid input file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                switch (currentArchiveVersion)
                {
                case RPGMakerVersion.Xp:
                case RPGMakerVersion.Vx:
                    currentArchive = new RGSSADv1(inputFilePath);
                    break;

                case RPGMakerVersion.VxAce:
                    currentArchive = new RGSSADv3(inputFilePath);
                    break;
                }
            }
            catch (InvalidArchiveException)
            {
                MessageBox.Show("Archive is invalid or corrupted. Reading failed.", "Invalid archive",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (UnsupportedArchiveException)
            {
                MessageBox.Show("Archive is not supported or it is corrupted.", "Archive not supported",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong with reading or extraction. Archive is likely invalid or corrupted.", "Archive corrupted",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (ArchivedFile archivedFile in currentArchive.ArchivedFiles)
            {
                archivedFilesListBox.Items.Add(archivedFile.Name);
            }

            SetClickableElementsEnabled(true);

            statusLabel.Text = "Archive opened succesfully.";
        }
Пример #7
0
        private 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);
            }

            var 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:
                    new RGSSADv1(_commandLineOptions.InputPaths.First())
                    .ExtractAllFiles(outputDirectoryPath);
                    break;

                case RPGMakerVersion.VxAce:
                    new RGSSADv3(_commandLineOptions.InputPaths.First())
                    .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);
            }
        }