Exemple #1
0
        private void SavePatchXML()
        {
            List <AsmPatch> patches = GetAllSelectedPatches();

            foreach (AsmPatch patch in patches)
            {
                patch.Update(AsmUtility);
            }

            FreeSpaceMode mode = FreeSpace.GetMode(AsmUtility);
            string        xml  = PatchXmlReader.CreatePatchXML(patches, mode);

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter          = "XML file (*.xml)|*.xml";
            saveFileDialog.FileName        = string.Empty;
            saveFileDialog.CheckFileExists = false;

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                btn_SavePatchXML.Enabled = false;
                System.IO.File.WriteAllText(saveFileDialog.FileName, xml, Encoding.UTF8);
                PatcherLib.MyMessageBox.Show(this, "Complete!", "Complete!", MessageBoxButtons.OK);
                Close();
            }
        }
Exemple #2
0
        /*
         * private void ModifyPatch(AsmPatch patch)
         * {
         *  UpdateReferenceVariableValues(patch);
         *  foreach (PatchedByteArray patchedByteArray in patch)
         *  {
         *      if (patchedByteArray.IsAsm)
         *      {
         *          string encodeContent = patchedByteArray.AsmText;
         *          string strPrefix = "";
         *          IList<VariableType> variables = patch.Variables;
         *
         *          foreach (PatchedByteArray currentPatchedByteArray in patch)
         *          {
         *              if (!string.IsNullOrEmpty(currentPatchedByteArray.Label))
         *                  strPrefix += String.Format(".label @{0}, {1}\r\n", currentPatchedByteArray.Label, currentPatchedByteArray.RamOffset);
         *          }
         *          foreach (VariableType variable in variables)
         *          {
         *              strPrefix += String.Format(".eqv %{0}, {1}\r\n", ASMStringHelper.RemoveSpaces(variable.name).Replace(",", ""), AsmPatch.GetUnsignedByteArrayValue_LittleEndian(variable.byteArray));
         *          }
         *
         *          encodeContent = strPrefix + patchedByteArray.AsmText;
         *          //patchedByteArray.SetBytes(asmUtility.EncodeASM(encodeContent, (uint)patchedByteArray.RamOffset).EncodedBytes);
         *
         *          byte[] bytes = asmUtility.EncodeASM(encodeContent, (uint)patchedByteArray.RamOffset).EncodedBytes;
         *
         *          if ((!patchedByteArray.IsMoveSimple) && (patch.blockMoveList.Count > 0))
         *          {
         *              bytes = asmUtility.UpdateBlockReferences(bytes, (uint)patchedByteArray.RamOffset, true, patch.blockMoveList);
         *          }
         *
         *          patchedByteArray.SetBytes(bytes);
         *      }
         *  }
         * }
         */

        private void SavePatchXML()
        {
            string xml = PatchXmlReader.CreatePatchXML(GetCurrentFileSelectedPatches());

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter          = "XML file (*.xml)|*.xml";
            saveFileDialog.FileName        = string.Empty;
            saveFileDialog.CheckFileExists = false;

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                File.WriteAllText(saveFileDialog.FileName, xml, Encoding.UTF8);
                PatcherLib.MyMessageBox.Show(this, "Complete!", "Complete!", MessageBoxButtons.OK);
            }
        }