Exemplo n.º 1
0
        private void importDownloadArc_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title            = "Select .arc file";
            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.CheckPathExists  = true;
            openFileDialog1.InitialDirectory = Properties.Settings.Default.DLCArcsDir;
            openFileDialog1.Filter           = "1PP archives (*.arc)|*.arc";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Properties.Settings.Default.DLCArcsDir = Path.GetDirectoryName(openFileDialog1.FileName);
                Properties.Settings.Default.Save();

                byte[] potentialFile = File.ReadAllBytes(openFileDialog1.FileName);

                activeSaveFile.embeddedArc           = new arcfile();
                activeSaveFile.embeddedArc.form1     = form1;
                activeSaveFile.embeddedArc.filebytes = potentialFile;

                //make some recommended changes to the arc before import (so that it fits)
                activeSaveFile.embeddedArc.ReadArc();

                foreach (archivedfile file in activeSaveFile.embeddedArc.archivedfiles)
                {
                    file.ReadFile();    //looks redundant as rebuildarc does this anyway, but we need to read it out before changing the compression information, otherwise rebuildarc's readarc call will try to decompress even if it's not actually compressed yet
                    file.has_LZ11_filesize   = true;
                    file.was_LZ11_compressed = true;
                }

                activeSaveFile.embeddedArc.use_custom_filename_table = false;

                activeSaveFile.embeddedArc.RebuildArc();

                if (activeSaveFile.embeddedArc.filebytes.Length > 0xF540)   //exceeds even the custom size
                {
                    Console.WriteLine(activeSaveFile.embeddedArc.filebytes.Length);
                    MessageBox.Show("That arc file is too big.\nIt should be smaller than 61KB.", "Arc file is too big", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    activeSaveFile.GetDownloadableMissionName();
                    exportDownloadArc.Enabled = true;
                }
            }
        }
Exemplo n.º 2
0
        private void importDownloadArc_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title            = "Select .arc file";
            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.CheckPathExists  = true;
            openFileDialog1.InitialDirectory = Properties.Settings.Default.DLCArcsDir;
            openFileDialog1.Filter           = "1PP archives (*.arc)|*.arc";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Properties.Settings.Default.DLCArcsDir = Path.GetDirectoryName(openFileDialog1.FileName);
                Properties.Settings.Default.Save();

                byte[] potentialFile = File.ReadAllBytes(openFileDialog1.FileName);

                activeSaveFile.embeddedArc           = new arcfile();
                activeSaveFile.embeddedArc.form1     = form1;
                activeSaveFile.embeddedArc.filebytes = potentialFile;

                //make some recommended changes to the arc before import (so that it fits)
                activeSaveFile.embeddedArc.ReadArc();

                author.Text     = "Author: None";
                authorNote.Text = "Author's note: None";

                for (int i = activeSaveFile.embeddedArc.archivedfiles.Count - 1; i >= 0; i--)
                {
                    activeSaveFile.embeddedArc.archivedfiles[i].ReadFile();    //this may look redundant, as rebuildarc does this anyway, but we need to read it out before changing the compression information, otherwise rebuildarc's readarc call will try to decompress even if it's not actually compressed yet

                    if (!activeSaveFile.embeddedArc.archivedfiles[i].was_LZ10_compressed && !activeSaveFile.embeddedArc.archivedfiles[i].was_LZ11_compressed)
                    {
                        activeSaveFile.embeddedArc.archivedfiles[i].has_LZ11_filesize   = true;
                        activeSaveFile.embeddedArc.archivedfiles[i].was_LZ11_compressed = true;
                    }

                    if (activeSaveFile.embeddedArc.archivedfiles[i].filename.ToLower() == "/info.txt")
                    {
                        activeSaveFile.SetAuthorDetails();
                        activeSaveFile.embeddedArc.archivedfiles.RemoveAt(i);
                    }
                }

                activeSaveFile.embeddedArc.use_custom_filename_table = false;

                activeSaveFile.embeddedArc.RebuildArc();

                if (activeSaveFile.embeddedArc.filebytes.Length > 0xF540)   //used to be 0xFEF0 when extended saves were allowed
                {
                    MessageBox.Show("That arc file is too big.\nIts effective size should be smaller than 61KB.\nYour arc was: " + ((float)activeSaveFile.embeddedArc.filebytes.Length / (float)1024.00) + "KB.", "Arc file is too big", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    activeSaveFile.embeddedArc          = null;
                    downloadableMissionNameDisplay.Text = "Downloadable Mission: None";
                    exportDownloadArc.Enabled           = false;
                }
                else if (activeSaveFile.embeddedArc.filebytes.Length > 0xF540)   //exceeds even the custom size
                {
                    //THIS DOES NOT WORK IN-GAME, so it has been dummied out here.
                    if (MessageBox.Show("That arc file would usually be too big.\nHowever, it can still be loaded if you use an action replay code on the EU version of the game.\nWould you like to do this?", "Arc file is too big, but there is a solution", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        activeSaveFile.extendedSaveMode = true;
                        activeSaveFile.GetDownloadableMissionName();
                        exportDownloadArc.Enabled = true;
                        ShowActionReplayCodeForm ARform = new ShowActionReplayCodeForm();
                        //ARform.SetInfo(saveExtenderCodeEU,"Allow extended saves","For: Elite Penguin Force (EU version only)","Normal saves will be incompatible while the code is active.\nSaving the game is disabled while the code is active.");
                        ARform.Show();
                    }
                    else
                    {
                        activeSaveFile.embeddedArc          = null;
                        downloadableMissionNameDisplay.Text = "Downloadable Mission: None";
                        exportDownloadArc.Enabled           = false;
                    }
                }
                else
                {
                    activeSaveFile.extendedSaveMode = false;
                    activeSaveFile.GetDownloadableMissionName();
                    exportDownloadArc.Enabled = true;
                }
            }
        }