private void btnApplyPatch_Click(object sender, EventArgs e)
        {
            if (gridPatches.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a patch to apply.");
                return;
            }

            Program.m_ROM.BeginRW();

            try
            {
                m_Patches[gridPatches.SelectedRows[0].Index].ApplyPatch(Program.m_ROM);
                MessageBox.Show("Success");
                // Restore Data is generated on patch application, so reload patches
                Patch.PatchToXML(m_Patches);
                m_Patches = Patch.XMLToPatch();
                RefreshRow(gridPatches.SelectedRows[0].Index);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong: \n\n" + ex.Message);
            }

            Program.m_ROM.EndRW();
        }
Exemple #2
0
        public AdditionalPatchesForm()
        {
            InitializeComponent();

            m_Patches = Patch.XMLToPatch();

            populatePatchListTable();

            clearEditData();
        }
Exemple #3
0
        private void btnDeletePatch_Click(object sender, EventArgs e)
        {
            if (gridPatches.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a patch to delete.");
                return;
            }

            DialogResult dlgeResult = MessageBox.Show("Are you sure you want to delete this patch?", "Confirm Deletion", MessageBoxButtons.YesNo);

            if (dlgeResult == DialogResult.No)
            {
                return;
            }

            // Remove current patch from list of patches
            m_Patches.RemoveAt(gridPatches.SelectedRows[0].Index);
            // Write updated list of patches to XML file
            Patch.PatchToXML(m_Patches);

            Patch.XMLToPatch();
            populatePatchListTable();
        }
Exemple #4
0
        private void btnSavePatch_Click(object sender, EventArgs e)
        {
            string name   = txtPatchName.Text;
            string author = (txtAuthor.Text != "") ? txtAuthor.Text : null;

            bool   isFileToPatch = chkApplyToFile.Checked;
            bool   isOverlayToPatch = chkApplyToOverlay.Checked;
            String fileToPatch = (isFileToPatch) ? txtApplyToFile.Text : null;
            String overlayID = (isOverlayToPatch) ? txtOverlayID.Text : null;
            bool   decompressAllOverlays = chkDecompressAllOverlays.Checked;
            List <Patch.AddressDataPair> eurPatch = new List <Patch.AddressDataPair>(), usv1Patch = new List <Patch.AddressDataPair>(),
                                         usv2Patch = new List <Patch.AddressDataPair>(), japPatch = new List <Patch.AddressDataPair>();
            List <Patch.AddressDataPair> eurRestoreData = new List <Patch.AddressDataPair>(), usv1RestoreData = new List <Patch.AddressDataPair>(),
                                         usv2RestoreData = new List <Patch.AddressDataPair>(), japRestoreData = new List <Patch.AddressDataPair>();

            // Read entered patch data
            eurPatch  = ParseEnteredPatchData("EUR");
            usv1Patch = ParseEnteredPatchData("USv1");
            usv2Patch = ParseEnteredPatchData("USv2");
            japPatch  = ParseEnteredPatchData("JAP");

            // Generate the restore data for current ROM version by reading the current data at the addresses to be patched
            Program.m_ROM.BeginRW();
            if (decompressAllOverlays)
            {
                Helper.DecompressOverlaysWithinGame();
            }

            switch (Program.m_ROM.m_Version)
            {
            case NitroROM.Version.EUR:
                eurRestoreData = Patch.GenerateRestoreData(eurPatch);
                break;

            case NitroROM.Version.USA_v1:
                usv1RestoreData = Patch.GenerateRestoreData(usv1Patch);
                break;

            case NitroROM.Version.USA_v2:
                usv2RestoreData = Patch.GenerateRestoreData(usv2Patch);
                break;

            case NitroROM.Version.JAP:
                japRestoreData = Patch.GenerateRestoreData(japPatch);
                break;
            }

            Program.m_ROM.EndRW();

            // Finally, add the parsed details to the list of patches
            if (editingIndex == -1)
            {
                m_Patches.Add(new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData,
                                        usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays));
            }
            else
            {
                m_Patches[editingIndex] = new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData,
                                                    usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays);
            }

            // Write the updated patches to XML
            Patch.PatchToXML(m_Patches);

            // Reload the list of patches
            m_Patches = Patch.XMLToPatch();
            populatePatchListTable();
        }