private void WC3ExportButton_Click(object sender, EventArgs e) { bool success = false; using (var sfd = new SaveFileDialog()) { sfd.Filter = "WC3 (*.wc3)|*.wc3|All files (*.*)|*.*"; sfd.Title = "Save Mystery Gift file"; sfd.FilterIndex = 1; byte[] data = new byte[Length]; byte[] wc = sav.GetData(sav.GetBlockOffset(Block) + Offset_WC, Length_WC); byte[] script = sav.GetData(sav.GetBlockOffset(Block) + Offset_Script, Length_Script); Array.Copy(wc, 0, data, 0, Length_WC); Array.Copy(script, 0, data, Offset_Script_WC3, Length_Script); if (!data.IsRangeAll((byte)0, 0, data.Length)) { if (sfd.ShowDialog() == DialogResult.OK) { try { File.WriteAllBytes(sfd.FileName, data); success = true; } catch (Exception) { MessageBox.Show("Unable to write Mystery Gift file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("There is no Mystery Gift in this save file.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (success) { Close(); MessageBox.Show($"Mystery Gift exported to {sfd.FileName}!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void ECBExportButton_Click(object sender, EventArgs e) { bool success = false; using (var sfd = new SaveFileDialog()) { sfd.Filter = "ECB (*.ecb)|*.ecb|All files (*.*)|*.*"; sfd.Title = "Save e-Card Berry file"; sfd.FilterIndex = 1; byte[] data = sav.GetData(sav.GetBlockOffset(Block) + Offset, Length); if (!data.IsRangeAll((byte)0, 0, data.Length)) { if (sfd.ShowDialog() == DialogResult.OK) { try { File.WriteAllBytes(sfd.FileName, data); success = true; } catch (Exception) { MessageBox.Show("Unable to write e-Card Berry file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("There is no e-Card Berry in this save file.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (success) { Close(); MessageBox.Show($"e-Card Trainer exported to {sfd.FileName}!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }