Пример #1
0
        private void menuItem_SavePatchXML_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FileName        = string.Empty;
            dialog.CheckFileExists = false;
            dialog.OverwritePrompt = true;
            dialog.Filter          = "XML files (*.xml)|*.xml";

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    string xml = null;
                    if (fftPatch.Context == Context.US_PSX)
                    {
                        xml = PsxIso.CreatePatchXML(fftPatch);
                    }
                    else if (fftPatch.Context == Context.US_PSP)
                    {
                        xml = PspIso.CreatePatchXML(fftPatch);
                    }

                    File.WriteAllText(dialog.FileName, xml, System.Text.Encoding.UTF8);
                    PatcherLib.MyMessageBox.Show(this, "Complete!", "Complete!", MessageBoxButtons.OK);
                }
                catch (Exception)
                {
                    MyMessageBox.Show(this, "Could not save patch XML.", "Error", MessageBoxButtons.OK);
                }
            }
        }
Пример #2
0
        private void patchPsxIsoMenuItem_Click(object sender, EventArgs e)
        {
            PatchPSXForm.patchISO = true;
            DoWorkEventHandler doWork =
                delegate(object sender1, DoWorkEventArgs args)
            {
                PsxIso.PatchPsxIso(FFTPatch, sender1 as BackgroundWorker, args, PatchPSXForm);
            };
            ProgressChangedEventHandler progress =
                delegate(object sender2, ProgressChangedEventArgs args)
            {
                progressBar.Visible = true;
                progressBar.Value   = Math.Max(progressBar.Minimum, Math.Min(args.ProgressPercentage, progressBar.Maximum));
            };
            RunWorkerCompletedEventHandler completed = null;

            completed =
                delegate(object sender3, RunWorkerCompletedEventArgs args)
            {
                progressBar.Visible = false;
                Enabled             = true;
                patchPsxBackgroundWorker.ProgressChanged    -= progress;
                patchPsxBackgroundWorker.RunWorkerCompleted -= completed;
                patchPsxBackgroundWorker.DoWork             -= doWork;

                if (args.Error != null)
                {
                    HandleException(args.Error);
                }
            };


            if (PatchPSXForm.CustomShowDialog(this, FFTPatch) == DialogResult.OK)
            {
                patchPsxBackgroundWorker.ProgressChanged    += progress;
                patchPsxBackgroundWorker.RunWorkerCompleted += completed;
                patchPsxBackgroundWorker.DoWork             += doWork;

                Enabled = false;

                progressBar.Value   = 0;
                progressBar.Visible = true;

                patchPsxBackgroundWorker.RunWorkerAsync();
            }
        }
Пример #3
0
        private static bool HandleCommandLinePatch(string[] args)
        {
            System.Collections.Generic.KeyValuePair <string, string> patchFilepaths = PatcherLib.Utilities.Utilities.GetPatchFilepaths(args, ".fftpatch");

            if ((string.IsNullOrEmpty(patchFilepaths.Key)) || (string.IsNullOrEmpty(patchFilepaths.Value)))
            {
                return(false);
            }
            else
            {
                Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(patchFilepaths.Key);

                try
                {
                    FFTPatch fftPatch = new FFTPatch();
                    fftPatch.LoadPatch(patchFilepaths.Key);

                    if (fftPatch.Context == PatcherLib.Datatypes.Context.US_PSP)
                    {
                        if (!patchFilepaths.Value.ToLower().Trim().EndsWith(".psv"))
                        {
                            PspIso.PatchISOSimple(fftPatch, patchFilepaths.Value);
                        }
                    }
                    else
                    {
                        if (patchFilepaths.Value.ToLower().Trim().EndsWith(".psv"))
                        {
                            PsxIso.PatchPsxSavestateSimple(fftPatch, patchFilepaths.Value);
                        }
                        else
                        {
                            PsxIso.PatchPsxIsoSimple(fftPatch, patchFilepaths.Value);
                        }
                    }
                }
                catch (Exception ex)
                {
                    AttachConsole(ATTACH_PARENT_PROCESS);
                    Console.WriteLine("Error: " + ex.Message);
                }

                return(true);
            }
        }
Пример #4
0
        private void menuItem_PatchPSXSaveState_Click(object sender, EventArgs e)
        {
            PatchPSXForm.patchISO = false;
            DoWorkEventHandler doWork =
                delegate(object sender1, DoWorkEventArgs args)
            {
                PsxIso.PatchPsxSavestate(FFTPatch, sender1 as BackgroundWorker, args, PatchPSXForm);
            };
            ProgressChangedEventHandler progress =
                delegate(object sender2, ProgressChangedEventArgs args)
            {
                progressBar.Visible = true;
                progressBar.Value   = Math.Max(progressBar.Minimum, Math.Min(args.ProgressPercentage, progressBar.Maximum));
            };
            RunWorkerCompletedEventHandler completed = null;

            completed =
                delegate(object sender3, RunWorkerCompletedEventArgs args)
            {
                progressBar.Visible = false;
                Enabled             = true;
                patchPsxBackgroundWorker.ProgressChanged    -= progress;
                patchPsxBackgroundWorker.RunWorkerCompleted -= completed;
                patchPsxBackgroundWorker.DoWork             -= doWork;

                if (args.Error != null)
                {
                    HandleException(args.Error);
                }
            };

            if (PatchPSXForm.CustomShowDialog(this, FFTPatch) == DialogResult.OK)
            {
                patchPsxBackgroundWorker.ProgressChanged    += progress;
                patchPsxBackgroundWorker.RunWorkerCompleted += completed;
                patchPsxBackgroundWorker.DoWork             += doWork;

                Enabled = false;

                progressBar.Value   = 0;
                progressBar.Visible = true;

                patchPsxBackgroundWorker.RunWorkerAsync();
            }

            //SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            ////Patchbutton copy. Modify to patch byte array right to savestate.
            //saveFileDialog1.Filter = "PSV files (*.psv)|*.psv;*";
            //saveFileDialog1.FileName = string.Empty;
            //if (saveFileDialog1.ShowDialog(this) == DialogResult.OK)
            //{
            //    byte[] filecopy = File.ReadAllBytes(saveFileDialog1.FileName);
            //    using (BinaryReader b = new BinaryReader(File.Open(saveFileDialog1.FileName, FileMode.Open)))
            //    {
            //        foreach (AsmPatch patch in clb_Patches.CheckedItems)
            //        {
            //            PatcherLib.Iso.PsxIso.PatchPsxSaveState(b, patch, filecopy);
            //        }
            //    }
            //}
        }