private void InternalCombinePatches() { if (ProgressChange != null) { ProgressChange(this, new ProgressChangeEventArgs(0, 0, 0)); } if (StatusChange != null) { StatusChange(this, new StatusChangeEventArgs(String.Format("Combining Patches..."))); } _combinedPatchFile = Path.Combine(_patchToFolder, "temp.patch"); for (int i = 0; i < _patches.Length; i++) { if (_patches[i].FileID == (int)FileID.Anim_mul) { int id = _patches[i].BlockID; int fileIndex = BodyConverter.Convert(ref id); if (fileIndex == 1) { continue; } else if (fileIndex == 2) { _patches[i].FileID = (int)FileID.Anim2_mul; } else if (fileIndex == 3) { _patches[i].FileID = (int)FileID.Anim3_mul; } else if (fileIndex == 4) { _patches[i].FileID = (int)FileID.Anim4_mul; } else { _patches[i].FileID = (int)FileID.Anim5_mul; } } } PatchWriter.CreateMUO(_combinedPatchFile, _patches, ProgressChange); if (ProgressChange != null) { ProgressChange(this, new ProgressChangeEventArgs(100, 0, 0)); } if (PatchingComplete != null) { PatchingComplete(this, new OperationCompleteArgs()); } _thread.Join(); }
public static void CreateUOP(string path, Patch[] patches, ProgressChangeHandler progressDelegate) { PatchWriter writer = new PatchWriter(File.Create(path), PatchFileType.UOP); writer.WriteUOPHeader(); writer.Write(patches.Length); writer.Write((int)0);//Unknown for( int i = 0; i < patches.Length; i++ ) { writer.WriteUOPPatch(patches[i]); if( i != 0 && progressDelegate != null ) progressDelegate(writer, new ProgressChangeEventArgs(((100 * i) / patches.Length), i, patches.Length)); } writer.Close(); }
public static void CreateMUO(string path, Patch[] patches, ProgressChangeHandler progressDelegate) { PatchWriter writer = new PatchWriter(File.Create(path), PatchFileType.MUO); writer.WriteMUOHeader(); writer.WriteMUOMetaData(new string[] { "MUO", "Created with PatchLib", "Jeff Boulanger" }); writer.Write((int)patches.Length); for( int i = 0; i < patches.Length; i++ ) { writer.WriteMUOPatch(patches[i]); if( i != 0 && progressDelegate != null ) progressDelegate(writer, new ProgressChangeEventArgs(((100 * i) / patches.Length), i, patches.Length)); } writer.Close(); }
public static void CreateMUO(string path, Patch[] patches, ProgressChangeHandler progressDelegate) { PatchWriter writer = new PatchWriter(File.Create(path), PatchFileType.MUO); writer.WriteMUOHeader(); writer.WriteMUOMetaData(new string[] { "MUO", "Created with PatchLib", "Jeff Boulanger" }); writer.Write((int)patches.Length); for (int i = 0; i < patches.Length; i++) { writer.WriteMUOPatch(patches[i]); if (i != 0 && progressDelegate != null) { progressDelegate(writer, new ProgressChangeEventArgs(((100 * i) / patches.Length), i, patches.Length)); } } writer.Close(); }
public static void CreateUOP(string path, Patch[] patches, ProgressChangeHandler progressDelegate) { PatchWriter writer = new PatchWriter(File.Create(path), PatchFileType.UOP); writer.WriteUOPHeader(); writer.Write(patches.Length); writer.Write((int)0); //Unknown for (int i = 0; i < patches.Length; i++) { writer.WriteUOPPatch(patches[i]); if (i != 0 && progressDelegate != null) { progressDelegate(writer, new ProgressChangeEventArgs(((100 * i) / patches.Length), i, patches.Length)); } } writer.Close(); }
private void patchConverterToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.Title = "Select the patch you wish to convert"; openFileDialog.Filter = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul"; openFileDialog.FileName = string.Empty; if (openFileDialog.ShowDialog() == DialogResult.OK) { UpdateStatus("Loading " = openFileDialog.FileName + "..."); PatchReader reader = new PatchReader(File.Open(openFileDialog.FileName, FileMode.Open), PatchReader.ExtensionToPatchFileType(Path.GetExtension(openFileDialog.FileName))); UpdateStatus("Reading patches, please wait... "); List<Patch> patches = reader.ReadPatches(); UpdateStatus("Loaded " + patches.Count.ToString() + " patches into memory..."); saveFileDialog.Title = "Select where you wish to save the patches to"; saveFileDialog.Filter = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul"; saveFileDialog.FileName = string.Empty; if (saveFileDialog.ShowDialog() == DialogResult.OK) { PatchFileType type = PatchReader.ExtensionToPatchFileType(Path.GetExtension(saveFileDialog.FileName)); UpdateStatus("Saving patches, please wait... "); PatchWriter writer = new PatchWriter(File.Open(saveFileDialog.FileName, FileMode.OpenOrCreate), type); switch (type) { case PatchFileType.MUO: PatchWriter.CreateMUO(saveFileDialog.FileName, patches); break; case PatchFileType.UOP: PatchWriter.CreateUOP(saveFileDialog.FileName, patches); break; case PatchFileType.Verdata: break; } UpdateStatus("Patch conversion complete"); MessageBox.Show("Patch conversion complete", "Success"); } else MessageBox.Show("Patch conversion process aborted", "Aborted"); if (reader != null) reader.Close(); patches = null; } }