void SarcEditor(object sender, EventArgs e) { OpenFileDialog opn = new OpenFileDialog() { Filter = "szs file|*.szs|every file|*.*" }; if (opn.ShowDialog() != DialogResult.OK) { return; } byte[] file = File.ReadAllBytes(opn.FileName); if (file[0] == 'S' && file[1] == 'A' && file[2] == 'R' && file[3] == 'C') { new SarcEditor(SARC.UnpackRamN(file)).Show(); } else if (file[0] == 'Y' && file[1] == 'a' && file[2] == 'z' && file[3] == '0') { new SarcEditor(SARC.UnpackRamN(YAZ0.Decompress(file))).Show(); } else { MessageBox.Show("Unknown file format"); } }
private void replaceToolStripMenuItem_Click(object sender, EventArgs e) { byte[] compressedSarc = null; var s = SARC.PackN(loadedSarc); if (numericUpDown1.Value != 0) { compressedSarc = YAZ0.Compress(s.Item2, (int)numericUpDown1.Value, (uint)s.Item1); } else { compressedSarc = s.Item2; } //sourceStream.Position = 0; sourceStream.Write(compressedSarc, 0, compressedSarc.Length); }
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { var sav = new SaveFileDialog() { Filter = "szs file|*.szs|sarc file|*.sarc" }; if (sav.ShowDialog() != DialogResult.OK) { return; } if (numericUpDown1.Value == 0) { File.WriteAllBytes(sav.FileName, SARC.PackN(loadedSarc).Item2); } else { var s = SARC.PackN(loadedSarc); File.WriteAllBytes(sav.FileName, YAZ0.Compress(s.Item2, (int)numericUpDown1.Value, (uint)s.Item1)); } }
public void OpenFile(string filename, Stream file) { new SarcEditor(SARC.UnpackRamN(file)).Show(); }