コード例 #1
0
ファイル: MainForm.cs プロジェクト: gtlittlewing/FFTPatcher
        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 patchPspIsoMenuItem_Click(object sender, EventArgs e)
        {
            DoWorkEventHandler doWork =
                delegate(object sender1, DoWorkEventArgs args)
            {
                PspIso.PatchISO(sender1 as BackgroundWorker, args, PatchPSPForm);
            };
            ProgressChangedEventHandler progress =
                delegate(object sender2, ProgressChangedEventArgs args)
            {
                progressBar.Visible = true;
                progressBar.Value   = args.ProgressPercentage;
            };
            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 is NotSupportedException)
                {
                    MessageBox.Show("File is not a recognized War of the Lions ISO image.", "Error", MessageBoxButtons.OK);
                }
                else if (args.Error != null)
                {
                    HandleException(args.Error);
                }
            };

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

                Enabled = false;

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

                patchPsxBackgroundWorker.RunWorkerAsync();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: gtlittlewing/FFTPatcher
        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);
            }
        }