private void ExportPKM(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Title = "Open ramsav.bin"; ofd.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*"; if (ofd.ShowDialog() != DialogResult.OK) { return; } byte[] input = File.ReadAllBytes(ofd.FileName); if (Path.GetFileName(ofd.FileName).Contains("ramsav")) { SAV6 sav = null; if (input.Length == 0x70000) { sav = new SAV6XY(RAM2SAV.GetMAIN(input)); } else if (input.Length == 0x80000) { sav = new SAV6AO(RAM2SAV.GetMAIN(input)); } if (sav != null) { using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { if (fbd.ShowDialog() != DialogResult.OK) { return; } sav.DumpBoxes(fbd.SelectedPath); for (int i = 0; i < sav.PartyCount; i++) { PKM pkm = sav.GetPartySlotAtIndex(i); string filename = $"{fbd.SelectedPath}\\{pkm.FileName}"; File.WriteAllBytes(filename, pkm.Data); } } } } } }
private void ExportPcdata(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Title = "Open ramsav.bin"; ofd.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*"; if (ofd.ShowDialog() != DialogResult.OK) { return; } byte[] input = File.ReadAllBytes(ofd.FileName); if (Path.GetFileName(ofd.FileName).Contains("ramsav")) { SAV6 sav = null; if (input.Length == 0x70000) { sav = new SAV6XY(RAM2SAV.GetMAIN(input)); } else if (input.Length == 0x80000) { sav = new SAV6AO(RAM2SAV.GetMAIN(input)); } if (sav != null) { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Title = "Save pcdata.bin"; sfd.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*"; sfd.FileName = "ramsav_pcdata.bin"; if (sfd.ShowDialog() != DialogResult.OK) { return; } File.WriteAllBytes(sfd.FileName, sav.GetPCBinary()); } } } } }