public DialogResult CustomShowDialog(IWin32Window owner, FFTPatch FFTPatch)
        {
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.Abilities, FFTPatch.Abilities.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.ActionMenus, FFTPatch.ActionMenus.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.InflictStatus, FFTPatch.InflictStatuses.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.ItemAttributes, FFTPatch.ItemAttributes.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.Items, FFTPatch.Items.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.JobLevels, FFTPatch.JobLevels.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.Jobs, FFTPatch.Jobs.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.MonsterSkills, FFTPatch.MonsterSkills.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.PoachProbabilities, FFTPatch.PoachProbabilities.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.Skillsets, FFTPatch.SkillSets.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.StatusAttributes, FFTPatch.StatusAttributes.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.MoveFindItems, FFTPatch.MoveFind.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.AbilityEffects, FFTPatch.Abilities.AllEffects.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.StoreInventory, FFTPatch.StoreInventories.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.AbilityAnimations, FFTPatch.AbilityAnimations.HasChanged);
            bootBinCheckedListBox.SetItemChecked((int)BootBinPatchable.Errands, FFTPatch.Propositions.HasChanged);

            dontChangeIcon0RadioButton.Checked = true;

            entd1CheckBox.Checked        = FFTPatch.ENTDs.ENTDs[0].HasChanged;
            entd2CheckBox.Checked        = FFTPatch.ENTDs.ENTDs[1].HasChanged;
            entd3CheckBox.Checked        = FFTPatch.ENTDs.ENTDs[2].HasChanged;
            entd4CheckBox.Checked        = FFTPatch.ENTDs.ENTDs[3].HasChanged;
            entd5CheckBox.Checked        = FFTPatch.ENTDs.PSPEvent.Exists(e => e.HasChanged);
            decryptCheckBox.Checked      = true;
            chk_ApplySlowdownfix.Checked = false;

            UpdateNextEnabled();

            return(ShowDialog(owner));
        }
        public void LoadFFTPatch(FFTPatch FFTPatch)
        {
            this.Enabled = true;

            PatchUtility.BuildReferenceList(FFTPatch.ItemAttributes, FFTPatch.InflictStatuses, FFTPatch.Abilities, FFTPatch.Items);

            allAbilitiesEditor1.UpdateView(FFTPatch.Abilities, FFTPatch.InflictStatuses, FFTPatch.Context);
            allActionMenusEditor1.UpdateView(FFTPatch.ActionMenus);
            allInflictStatusesEditor1.UpdateView(FFTPatch.InflictStatuses, FFTPatch.Context);
            allItemAttributesEditor1.UpdateView(FFTPatch.ItemAttributes, FFTPatch.Context);
            allItemsEditor1.UpdateView(FFTPatch.Items, FFTPatch.StoreInventories, FFTPatch.InflictStatuses, FFTPatch.ItemAttributes, FFTPatch.Context);
            allJobsEditor1.UpdateView(FFTPatch.Jobs, FFTPatch.Context);
            allMonsterSkillsEditor1.UpdateView(FFTPatch.MonsterSkills, FFTPatch.Context);
            allPoachProbabilitiesEditor1.UpdateView(FFTPatch.PoachProbabilities, FFTPatch.Context);
            allSkillSetsEditor1.UpdateView(FFTPatch.SkillSets, FFTPatch.Context);
            allStatusAttributesEditor1.UpdateView(FFTPatch.StatusAttributes, FFTPatch.Context);
            jobLevelsEditor1.UpdateView(FFTPatch.JobLevels, FFTPatch.Context);
            entdEditor1.UpdateView(FFTPatch.ENTDs, FFTPatch.Context);
            allMoveFindItemsEditor1.UpdateView(FFTPatch.MoveFind, FFTPatch.Context);
            allStoreInventoryEditor1.UpdateView(FFTPatch.StoreInventories, FFTPatch.Items, FFTPatch.Context);
            allAnimationsEditor1.UpdateView(FFTPatch.AbilityAnimations);
            allPropositionsEditor1.UpdateView(FFTPatch.Propositions, FFTPatch.Context);

            codeCreator1.UpdateView(FFTPatch);
            codesTab.Text            = FFTPatch.Context == Context.US_PSP ? "CWCheat" : "Gameshark";
            propositionsTabPage.Text = FFTPatch.Context == Context.US_PSP ? "Errands" : "Propositions";

            fftPatch = FFTPatch;
            Focus();
        }
Exemple #3
0
 public static void PatchPsxSavestateSimple(FFTPatch fftPatch, string filename)
 {
     using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
     {
         PatcherLib.Iso.PsxIso.PatchPsxSaveState(reader, GetPatches(fftPatch));
     }
 }
Exemple #4
0
        public static List <PatchedByteArray> GetPatches(FFTPatch FFTPatch)
        {
            List <PatchedByteArray> patches = new List <PatchedByteArray>();
            const Context           context = Context.US_PSP;

            patches.AddRange(FFTPatch.Abilities.GetPatches(context));
            patches.AddRange(FFTPatch.AbilityAnimations.GetPatches(context));
            patches.AddRange(FFTPatch.Abilities.AllEffects.GetPatches(context));
            patches.AddRange(FFTPatch.ActionMenus.GetPatches(context));

            IList <PatchedByteArray> entdPatches = FFTPatch.ENTDs.GetPatches(context);

            for (int i = 0; i < 5; i++)
            {
                patches.Add(entdPatches[i]);
            }

            patches.AddRange(FFTPatch.InflictStatuses.GetPatches(context));
            patches.AddRange(FFTPatch.ItemAttributes.GetPatches(context));
            patches.AddRange(FFTPatch.Items.GetPatches(context));
            patches.AddRange(FFTPatch.JobLevels.GetPatches(context));
            patches.AddRange(FFTPatch.Jobs.GetPatches(context));
            patches.AddRange(FFTPatch.MonsterSkills.GetPatches(context));
            patches.AddRange(FFTPatch.MoveFind.GetPatches(context));
            patches.AddRange(FFTPatch.PoachProbabilities.GetPatches(context));
            patches.AddRange(FFTPatch.SkillSets.GetPatches(context));
            patches.AddRange(FFTPatch.StatusAttributes.GetPatches(context));
            patches.AddRange(FFTPatch.StoreInventories.GetPatches(context));
            patches.AddRange(FFTPatch.Propositions.GetPatches(context));

            return(patches);
        }
Exemple #5
0
        public DialogResult CustomShowDialog(IWin32Window owner, FFTPatch FFTPatch)
        {
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.Abilities, FFTPatch.Abilities.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.ActionMenus, FFTPatch.ActionMenus.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.InflictStatus, FFTPatch.InflictStatuses.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.ItemAttributes, FFTPatch.ItemAttributes.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.Items, FFTPatch.Items.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.JobLevels, FFTPatch.JobLevels.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.Jobs, FFTPatch.Jobs.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.MonsterSkills, FFTPatch.MonsterSkills.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.Poach, FFTPatch.PoachProbabilities.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.Skillsets, FFTPatch.SkillSets.HasChanged);
            scusCheckedListBox.SetItemChecked((int)SCUSPatchable.StatusAttributes, FFTPatch.StatusAttributes.HasChanged);

            battleCheckedListBox.SetItemChecked((int)BATTLEPatchable.AbilityEffects, FFTPatch.Abilities.AllEffects.HasChanged);
            battleCheckedListBox.SetItemChecked((int)BATTLEPatchable.AbilityAnimations, FFTPatch.AbilityAnimations.HasChanged);
            battleCheckedListBox.SetItemChecked((int)BATTLEPatchable.MoveFindItems, FFTPatch.MoveFind.HasChanged);

            storeInventoryCheckBox.Checked = FFTPatch.StoreInventories.HasChanged;
            propositionsCheckBox.Checked   = FFTPatch.Propositions.HasChanged;

            dontChangeSceapRadioButton.Checked = true;

            entd1CheckBox.Checked = FFTPatch.ENTDs.ENTDs[0].HasChanged;
            entd2CheckBox.Checked = FFTPatch.ENTDs.ENTDs[1].HasChanged;
            entd3CheckBox.Checked = FFTPatch.ENTDs.ENTDs[2].HasChanged;
            entd4CheckBox.Checked = FFTPatch.ENTDs.ENTDs[3].HasChanged;
            eccCheckBox.Enabled   = false;
            eccCheckBox.Checked   = true;

            UpdateNextEnabled();

            return(ShowDialog(owner));
        }
Exemple #6
0
 private void openMenuItem_Click(object sender, System.EventArgs e)
 {
     openFileDialog.Filter = "FFTPatcher files (*.fftpatch)|*.fftpatch";
     if (openFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         TryAndHandle(delegate() { FFTPatch.LoadPatch(openFileDialog.FileName); }, true);
     }
 }
Exemple #7
0
 private void openPatchedPsxIso_Click(object sender, EventArgs e)
 {
     openFileDialog.Filter = "ISO images|*.iso;*.bin;*.img";
     if (openFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         TryAndHandle(delegate() { FFTPatch.OpenPatchedPsxIso(openFileDialog.FileName); }, true);
     }
 }
Exemple #8
0
 private void openPatchedPsxIso_Click(object sender, EventArgs e)
 {
     openFileDialog.Filter = "ISO images (*.iso, *.bin, *.img)|*.iso;*.bin;*.img";
     if (openFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         Environment.CurrentDirectory = Path.GetDirectoryName(openFileDialog.FileName);
         TryAndHandle(delegate() { FFTPatch.OpenPatchedPsxIso(openFileDialog.FileName); }, true);
     }
 }
Exemple #9
0
 public static void PatchPsxIsoSimple(FFTPatch fftPatch, string filename)
 {
     using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite))
     {
         List <PatchedByteArray> patches = GetPatches(fftPatch);
         foreach (PatchedByteArray patch in patches)
         {
             IsoPatch.PatchFileAtSector(IsoPatch.IsoType.Mode2Form1, stream, true, patch.Sector, patch.Offset, patch.GetBytes(), true);
         }
     }
 }
Exemple #10
0
        public ViewStatForm(FFTPatch fftPatch, int jobID)
        {
            InitializeComponent();

            this.fftPatch = fftPatch;
            this.jobID    = jobID;

            jobList = new List <Job>(fftPatch.Jobs.Jobs);

            SetupForm();
        }
Exemple #11
0
        private void openPatchedPspItem_Click(object sender, EventArgs e)
        {
            openFileDialog.FileName = string.Empty;
            openFileDialog.Filter   = "ISO images|*.iso;";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(openFileDialog.FileName);

                TryAndHandle(delegate() { FFTPatch.OpenPatchedPspIso(openFileDialog.FileName); }, true);
            }
        }
Exemple #12
0
        /// <summary>
        /// Saves CWCheat codes to a file.
        /// </summary>
        public static void SaveToFile(string path, FFTPatch FFTPatch)
        {
            string codes = GetAllCodes(FFTPatch);

            using (StreamWriter stream = new StreamWriter(path, false))
            {
                stream.NewLine = "\n";
                stream.WriteLine(usHeader);
                stream.WriteLine(codes);
                stream.WriteLine(euHeader);
                stream.WriteLine(codes);
            }
        }
Exemple #13
0
        private void saveAsPspMenuItem_Click(object sender, EventArgs e)
        {
            string fn = SavePatch(false);

            if (!string.IsNullOrEmpty(fn))
            {
                // HACK
                if (FFTPatch.Context != Context.US_PSP)
                {
                    FFTPatch.ConvertPsxPatchToPsp(fn);
                    FFTPatch.LoadPatch(fn);
                }
            }
        }
Exemple #14
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);
            }
        }
Exemple #15
0
 private string SavePatch(bool digest)
 {
     saveFileDialog.OverwritePrompt = true;
     saveFileDialog.Filter          = "FFTPatcher files (*.fftpatch)|*.fftpatch";
     if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         try
         {
             TryAndHandle(delegate() { FFTPatch.SavePatchToFile(saveFileDialog.FileName, FFTPatch.Context, digest); }, false, true);
             return(saveFileDialog.FileName);
         }
         catch (Exception)
         {
             MessageBox.Show("Could not open file.", "File not found", MessageBoxButtons.OK);
         }
     }
     return(string.Empty);
 }
Exemple #16
0
        public static void PatchISOSimple(FFTPatch FFTPatch, Stream stream)
        {
            PatcherLib.Iso.PspIso.PspIsoInfo info = PatcherLib.Iso.PspIso.PspIsoInfo.GetPspIsoInfo(stream);

            if (PatcherLib.Iso.PspIso.IsJP(stream, info))
            {
                throw new NotSupportedException("Unrecognized image.");
            }
            else
            {
                PatcherLib.Iso.PspIso.DecryptISO(stream, info);
            }

            List <PatchedByteArray> patches = GetPatches(FFTPatch);

            foreach (PatchedByteArray patch in patches)
            {
                PatcherLib.Iso.PspIso.ApplyPatch(stream, info, patch);
            }
        }
Exemple #17
0
        /// <summary>
        /// Patches the ISO.
        /// </summary>
        /// <param name="filename">The filename of the ISO to patch.</param>
        public static void PatchISO(FFTPatch FFTPatch, string filename, BackgroundWorker worker, IGeneratePatchList patches)
        {
            FileStream stream = null;

            try
            {
                stream = new FileStream(filename, FileMode.Open);
                PatchISO(FFTPatch, stream, worker, patches);
            }
            catch (NotSupportedException)
            {
                throw;
            }
            finally
            {
                if (stream != null)
                {
                    stream.Flush();
                    stream.Close();
                    stream = null;
                }
            }
        }
Exemple #18
0
        public static void PatchISOSimple(FFTPatch FFTPatch, string filename)
        {
            FileStream stream = null;

            try
            {
                stream = new FileStream(filename, FileMode.Open);
                PatchISOSimple(FFTPatch, stream);
            }
            catch (NotSupportedException)
            {
                throw;
            }
            finally
            {
                if (stream != null)
                {
                    stream.Flush();
                    stream.Close();
                    stream = null;
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Gets all codes.
        /// </summary>
        public static string GetAllCodes(FFTPatch FFTPatch)
        {
            if (FFTPatch == null)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            Context context = FFTPatch.Context;

            IGenerateCodes[] generators = new IGenerateCodes[] {
                FFTPatch.Abilities,
                FFTPatch.Jobs,
                FFTPatch.SkillSets,
                FFTPatch.MonsterSkills,
                FFTPatch.ActionMenus,
                FFTPatch.StatusAttributes,
                FFTPatch.PoachProbabilities,
                FFTPatch.JobLevels,
                FFTPatch.Items,
                FFTPatch.ItemAttributes,
                FFTPatch.InflictStatuses,
                FFTPatch.MoveFind,
                FFTPatch.AbilityAnimations,
                FFTPatch.StoreInventories,
                FFTPatch.Propositions
            };
            foreach (var gen in generators)
            {
                if (gen != null)
                {
                    AddGroups(sb, 24, gen.GetCodeHeader(context), gen.GenerateCodes(context, FFTPatch));
                }
            }
            return(sb.ToString());
        }
Exemple #20
0
 public static string CreatePatchXML(FFTPatch FFTPatch)
 {
     return(PatcherLib.Utilities.Utilities.CreatePatchXML(GetPatches(FFTPatch), Context.US_PSP, true, true, "FFTPatcher Edits", null));
 }
Exemple #21
0
 public static void PatchISO(FFTPatch FFTPatch, BackgroundWorker worker, DoWorkEventArgs args, IGeneratePatchList patches)
 {
     PatchISO(FFTPatch, patches.FileName, worker, patches);
 }
Exemple #22
0
        public static void PatchPsxIso(FFTPatch FFTPatch, BackgroundWorker backgroundWorker, DoWorkEventArgs e, IGeneratePatchList patchList)
        {
            string filename                 = patchList.FileName;
            int    numberOfTasks            = patchList.PatchCount * 2;
            int    tasksComplete            = 0;
            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            Action <string> sendProgress =
                delegate(string message)
            {
                backgroundWorker.ReportProgress(tasksComplete++ *100 / numberOfTasks, message);
            };

            const Context context = Context.US_PSX;

            if (patchList.Abilities)
            {
                patches.AddRange(FFTPatch.Abilities.GetPatches(context));
                sendProgress("Getting Abilities patches");
            }

            if (patchList.AbilityAnimations)
            {
                patches.AddRange(FFTPatch.AbilityAnimations.GetPatches(context));
                sendProgress("Getting Ability Animations patches");
            }
            if (patchList.AbilityEffects)
            {
                patches.AddRange(FFTPatch.Abilities.AllEffects.GetPatches(context));
                sendProgress("Getting Ability Effects patches");
            }

            if (patchList.ActionMenus)
            {
                patches.AddRange(FFTPatch.ActionMenus.GetPatches(context));
                sendProgress("Getting Action Menus patches");
            }

            if (patchList.ENTD.Exists(b => b == true))
            {
                IList <PatchedByteArray> entdPatches = FFTPatch.ENTDs.GetPatches(context);
                for (int i = 0; i < 4; i++)
                {
                    if (patchList.ENTD[i])
                    {
                        patches.Add(entdPatches[i]);
                        sendProgress(string.Format("Getting ENTD {0} patches", i));
                    }
                }
            }

            if (patchList.InflictStatus)
            {
                patches.AddRange(FFTPatch.InflictStatuses.GetPatches(context));
                sendProgress("Getting Inflict Status patches");
            }
            if (patchList.ItemAttributes)
            {
                patches.AddRange(FFTPatch.ItemAttributes.GetPatches(context));
                sendProgress("Getting Item Attributes patches");
            }
            if (patchList.Items)
            {
                patches.AddRange(FFTPatch.Items.GetPatches(context));
                sendProgress("Getting Item patches");
            }
            if (patchList.JobLevels)
            {
                patches.AddRange(FFTPatch.JobLevels.GetPatches(context));
                sendProgress("Getting Job Levels patches");
            }
            if (patchList.Jobs)
            {
                patches.AddRange(FFTPatch.Jobs.GetPatches(context));
                sendProgress("Getting Jobs patches");
            }
            if (patchList.MonsterSkills)
            {
                patches.AddRange(FFTPatch.MonsterSkills.GetPatches(context));
                sendProgress("Getting Monster Skills patches");
            }
            if (patchList.MoveFindItems)
            {
                patches.AddRange(FFTPatch.MoveFind.GetPatches(context));
                sendProgress("Getting Move/Find Items patches");
            }
            foreach (PatchedByteArray patch in patchList.OtherPatches)
            {
                patches.Add(patch);
                sendProgress("Getting other patches");
            }
            if (patchList.Poach)
            {
                patches.AddRange(FFTPatch.PoachProbabilities.GetPatches(context));
                sendProgress("Getting Poach Probabilities patches");
            }
            if (patchList.Skillsets)
            {
                patches.AddRange(FFTPatch.SkillSets.GetPatches(context));
                sendProgress("Getting Skillsets patches");
            }
            if (patchList.StatusAttributes)
            {
                patches.AddRange(FFTPatch.StatusAttributes.GetPatches(context));
                sendProgress("Getting Status attributes patches");
            }

            if (patchList.StoreInventory)
            {
                patches.AddRange(FFTPatch.StoreInventories.GetPatches(context));
                sendProgress("Getting store inventories patches");
            }
            if (patchList.Propositions)
            {
                patches.AddRange(FFTPatch.Propositions.GetPatches(context));
                sendProgress("Getting errands patches");
            }

            using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite))
            {
                foreach (PatchedByteArray patch in patches)
                {
                    IsoPatch.PatchFileAtSector(IsoPatch.IsoType.Mode2Form1, stream, true, patch.Sector,
                                               patch.Offset, patch.GetBytes(), true);
                    sendProgress("Patching ISO");
                }

                //if ( patchList.RegenECC )
                //{
                //    IsoPatch.FixupECC( IsoPatch.IsoType.Mode2Form1, stream );
                //    sendProgress( "Fixing ECC/EDC" );
                //}
            }
        }
Exemple #23
0
        public static void PatchPsxSavestate(FFTPatch FFTPatch, BackgroundWorker backgroundWorker, DoWorkEventArgs e, IGeneratePatchList patchList)
        {
            string filename                 = patchList.FileName;
            int    numberOfTasks            = patchList.PatchCount * 2;
            int    tasksComplete            = 0;
            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            Action <string> sendProgress =
                delegate(string message)
            {
                backgroundWorker.ReportProgress(tasksComplete++ *100 / numberOfTasks, message);
            };

            const Context context = Context.US_PSX;

            if (patchList.Abilities)
            {
                patches.AddRange(FFTPatch.Abilities.GetPatches(context));
                sendProgress("Getting Abilities patches");
            }

            if (patchList.AbilityAnimations)
            {
                patches.AddRange(FFTPatch.AbilityAnimations.GetPatches(context));
                sendProgress("Getting Ability Animations patches");
            }
            if (patchList.AbilityEffects)
            {
                patches.AddRange(FFTPatch.Abilities.AllEffects.GetPatches(context));
                sendProgress("Getting Ability Effects patches");
            }

            if (patchList.ActionMenus)
            {
                patches.AddRange(FFTPatch.ActionMenus.GetPatches(context));
                sendProgress("Getting Action Menus patches");
            }

            if (patchList.ENTD.Exists(b => b == true))
            {
                IList <PatchedByteArray> entdPatches = FFTPatch.ENTDs.GetPatches(context);
                for (int i = 0; i < 4; i++)
                {
                    if (patchList.ENTD[i])
                    {
                        patches.Add(entdPatches[i]);
                        sendProgress(string.Format("Getting ENTD {0} patches", i));
                    }
                }
            }

            if (patchList.InflictStatus)
            {
                patches.AddRange(FFTPatch.InflictStatuses.GetPatches(context));
                sendProgress("Getting Inflict Status patches");
            }
            if (patchList.ItemAttributes)
            {
                patches.AddRange(FFTPatch.ItemAttributes.GetPatches(context));
                sendProgress("Getting Item Attributes patches");
            }
            if (patchList.Items)
            {
                patches.AddRange(FFTPatch.Items.GetPatches(context));
                sendProgress("Getting Item patches");
            }
            if (patchList.JobLevels)
            {
                patches.AddRange(FFTPatch.JobLevels.GetPatches(context));
                sendProgress("Getting Job Levels patches");
            }
            if (patchList.Jobs)
            {
                patches.AddRange(FFTPatch.Jobs.GetPatches(context));
                sendProgress("Getting Jobs patches");
            }
            if (patchList.MonsterSkills)
            {
                patches.AddRange(FFTPatch.MonsterSkills.GetPatches(context));
                sendProgress("Getting Monster Skills patches");
            }
            if (patchList.MoveFindItems)
            {
                patches.AddRange(FFTPatch.MoveFind.GetPatches(context));
                sendProgress("Getting Move/Find Items patches");
            }
            foreach (PatchedByteArray patch in patchList.OtherPatches)
            {
                patches.Add(patch);
                sendProgress("Getting other patches");
            }
            if (patchList.Poach)
            {
                patches.AddRange(FFTPatch.PoachProbabilities.GetPatches(context));
                sendProgress("Getting Poach Probabilities patches");
            }
            if (patchList.Skillsets)
            {
                patches.AddRange(FFTPatch.SkillSets.GetPatches(context));
                sendProgress("Getting Skillsets patches");
            }
            if (patchList.StatusAttributes)
            {
                patches.AddRange(FFTPatch.StatusAttributes.GetPatches(context));
                sendProgress("Getting Status attributes patches");
            }

            if (patchList.StoreInventory)
            {
                patches.AddRange(FFTPatch.StoreInventories.GetPatches(context));
                sendProgress("Getting store inventories patches");
            }
            if (patchList.Propositions)
            {
                patches.AddRange(FFTPatch.Propositions.GetPatches(context));
                sendProgress("Getting errands patches");
            }

            //byte[] filecopy = File.ReadAllBytes(patchList.FileName);

            using (BinaryReader reader = new BinaryReader(File.Open(patchList.FileName, FileMode.Open)))
            {
                PatcherLib.Iso.PsxIso.PatchPsxSaveState(reader, patches);
            }
        }
Exemple #24
0
        /// <summary>
        /// Patches the ISO.
        /// </summary>
        /// <param name="stream">The stream of the ISO to patch.</param>
        public static void PatchISO(FFTPatch FFTPatch, Stream stream, BackgroundWorker worker, IGeneratePatchList patchList)
        {
            PatcherLib.Iso.PspIso.PspIsoInfo info = PatcherLib.Iso.PspIso.PspIsoInfo.GetPspIsoInfo(stream);

            if (PatcherLib.Iso.PspIso.IsJP(stream, info))
            {
                throw new NotSupportedException("Unrecognized image.");
            }

            int numberOfTasks = patchList.PatchCount * 2;
            int tasksComplete = 0;

            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            Action <string> sendProgress =
                delegate(string message)
            {
                worker.ReportProgress(++tasksComplete * 100 / numberOfTasks, message);
            };

            if (patchList.RegenECC)
            {
                PatcherLib.Iso.PspIso.DecryptISO(stream, info);
                sendProgress("Decrypting EBOOT.BIN");
            }

            const Context context = Context.US_PSP;

            if (patchList.Abilities)
            {
                patches.AddRange(FFTPatch.Abilities.GetPatches(context));
                sendProgress("Getting Abilities patches");
                sendProgress("Getting Abilities patches");
            }

            if (patchList.AbilityAnimations)
            {
                patches.AddRange(FFTPatch.AbilityAnimations.GetPatches(context));
                sendProgress("Getting Ability Animations patches");
                sendProgress("Getting Ability Animations patches");
            }

            if (patchList.AbilityEffects)
            {
                patches.AddRange(FFTPatch.Abilities.AllEffects.GetPatches(context));
                sendProgress("Getting Ability Effects patches");
                sendProgress("Getting Ability Effects patches");
            }

            if (patchList.ActionMenus)
            {
                patches.AddRange(FFTPatch.ActionMenus.GetPatches(context));
                sendProgress("Getting Action Menus patches");
                sendProgress("Getting Action Menus patches");
            }

            if (patchList.ENTD.Exists(b => b == true))
            {
                IList <PatchedByteArray> entdPatches = FFTPatch.ENTDs.GetPatches(context);
                for (int i = 0; i < 5; i++)
                {
                    if (patchList.ENTD[i])
                    {
                        patches.Add(entdPatches[i]);
                        sendProgress(string.Format("Getting ENTD {0} patches", i));
                    }
                }
            }

            if (patchList.InflictStatus)
            {
                patches.AddRange(FFTPatch.InflictStatuses.GetPatches(context));
                sendProgress("Getting Inflict Status patches");
                sendProgress("Getting Inflict Status patches");
            }
            if (patchList.ItemAttributes)
            {
                patches.AddRange(FFTPatch.ItemAttributes.GetPatches(context));
                sendProgress("Getting Item Attributes patches");
                sendProgress("Getting Item Attributes patches");
                sendProgress("Getting Item Attributes patches");
                sendProgress("Getting Item Attributes patches");
            }
            if (patchList.Items)
            {
                patches.AddRange(FFTPatch.Items.GetPatches(context));
                sendProgress("Getting Item patches");
                sendProgress("Getting Item patches");
                sendProgress("Getting Item patches");
                sendProgress("Getting Item patches");
            }
            if (patchList.JobLevels)
            {
                patches.AddRange(FFTPatch.JobLevels.GetPatches(context));
                sendProgress("Getting Job Levels patches");
                sendProgress("Getting Job Levels patches");
            }
            if (patchList.Jobs)
            {
                patches.AddRange(FFTPatch.Jobs.GetPatches(context));
                sendProgress("Getting Jobs patches");
                sendProgress("Getting Jobs patches");
            }
            if (patchList.MonsterSkills)
            {
                patches.AddRange(FFTPatch.MonsterSkills.GetPatches(context));
                sendProgress("Getting Monster Skills patches");
                sendProgress("Getting Monster Skills patches");
            }
            if (patchList.MoveFindItems)
            {
                patches.AddRange(FFTPatch.MoveFind.GetPatches(context));
                sendProgress("Getting Move/Find Items patches");
                sendProgress("Getting Move/Find Items patches");
            }
            foreach (PatchedByteArray patch in patchList.OtherPatches)
            {
                patches.Add(patch);
                sendProgress("Getting other patches");
            }
            if (patchList.Poach)
            {
                patches.AddRange(FFTPatch.PoachProbabilities.GetPatches(context));
                sendProgress("Getting Poach Probabilities patches");
                sendProgress("Getting Poach Probabilities patches");
            }
            if (patchList.Skillsets)
            {
                patches.AddRange(FFTPatch.SkillSets.GetPatches(context));
                sendProgress("Getting Skillsets patches");
                sendProgress("Getting Skillsets patches");
            }
            if (patchList.StatusAttributes)
            {
                patches.AddRange(FFTPatch.StatusAttributes.GetPatches(context));
                sendProgress("Getting Status attributes patches");
                sendProgress("Getting Status attributes patches");
            }

            if (patchList.StoreInventory)
            {
                patches.AddRange(FFTPatch.StoreInventories.GetPatches(context));
                sendProgress("Getting store inventories patches");
                sendProgress("Getting store inventories patches");
            }
            if (patchList.Propositions)
            {
                patches.AddRange(FFTPatch.Propositions.GetPatches(context));
                sendProgress("Getting errands patches");
                sendProgress("Getting errands patches");
            }

            foreach (PatchedByteArray patch in patches)
            {
                PatcherLib.Iso.PspIso.ApplyPatch(stream, info, patch);
                sendProgress("Patching ISO");
            }
        }
Exemple #25
0
 private void newPSXMenuItem_Click(object sender, System.EventArgs e)
 {
     FFTPatch.New(Context.US_PSX);
 }