private void WC3ImportButton_Click(object sender, EventArgs e) { bool success = false; using (var ofd = new OpenFileDialog()) { ofd.Filter = "WC3 (*.wc3)|*.wc3|All files (*.*)|*.*"; ofd.Title = "Open Mystery Gift file"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { long fileSize = new FileInfo(ofd.FileName).Length; if (fileSize == Length) { try { byte[] data = Checksums.FixWC3Checksum(File.ReadAllBytes(ofd.FileName)); byte[] wc = new byte[Length_WC]; byte[] script = new byte[Length_Script]; Array.Copy(data, 0, wc, 0, Length_WC); Array.Copy(data, Offset_Script_WC3, script, 0, Length_Script); File.ReadAllBytes(ofd.FileName).CopyTo(sav.Large, Offset_WC); File.ReadAllBytes(ofd.FileName).CopyTo(sav.Large, Offset_Script); success = true; } catch (Exception) { MessageBox.Show("Unable to read Mystery Gift file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show($"Invalid file size ({fileSize} bytes). Expected {Length} bytes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (success) { Close(); MessageBox.Show("Mystery Gift imported!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void ECBImportButton_Click(object sender, EventArgs e) { bool success = false; using (var ofd = new OpenFileDialog()) { ofd.Filter = "ECB (*.ecb)|*.ecb|All files (*.*)|*.*"; ofd.Title = "Open e-Card Berry file"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { long fileSize = new FileInfo(ofd.FileName).Length; if (fileSize == Length) { try { sav.SetData(Checksums.FixECBChecksum(File.ReadAllBytes(ofd.FileName)), sav.GetBlockOffset(Block) + Offset); success = true; } catch (Exception) { MessageBox.Show("Unable to read e-Card Berry file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show($"Invalid file size ({fileSize} bytes). Expected {Length} bytes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (success) { Close(); MessageBox.Show("e-Card Berry imported!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void WN3ImportButton_Click(object sender, EventArgs e) { bool success = false; using (var ofd = new OpenFileDialog()) { ofd.Filter = "WN3 (*.wn3)|*.wn3|All files (*.*)|*.*"; ofd.Title = "Open Wonder News file"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { long fileSize = new FileInfo(ofd.FileName).Length; if (fileSize == Length) { try { Checksums.FixWN3Checksum(File.ReadAllBytes(ofd.FileName)).CopyTo(sav.Large, Offset); success = true; } catch (Exception) { MessageBox.Show("Unable to read Wonder News file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show($"Invalid file size ({fileSize} bytes). Expected {Length} bytes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (success) { Close(); MessageBox.Show("Wonder News imported!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }