Esempio n. 1
0
 public bool equals(AudioPatch that)
 {
     return(
         this.startOffset == that.startOffset &&
         this.lengthOffset == that.lengthOffset &&
         this.isFile30 == that.isFile30);
 }
Esempio n. 2
0
        // unpatches audio by replacing bytes with the original audio data
        private void unpatchAudio(AudioPatch a)
        {
            Stream s;

            byte[] data;

            if (a.isFile30)
            {
                s    = File.Open(workingDirectory + "\\30", FileMode.Open);
                data = file30;
            }
            else
            {
                s    = File.Open(workingDirectory + "\\31", FileMode.Open);
                data = file31;
            }

            BinaryReader br = new BinaryReader(s);

            s.Position = a.startOffset - 1;
            for (int i = a.startOffset; i < a.startOffset + a.lengthOffset; i++)
            {
                data[i] = br.ReadByte();
            }

            br.Close();
        }
Esempio n. 3
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     foreach (int i in patchList.SelectedIndices)
     {
         ListViewItem l = patchList.Items[i];
         AudioPatch   a = (AudioPatch)l.Tag;
         unpatchAudio(a);
         patchList.Items.Remove(l);
     }
 }
Esempio n. 4
0
        private void addAudioPatch(AudioPatch a)
        {
            foreach (ListViewItem ls in patchList.Items)
            {
                AudioPatch a1 = (AudioPatch)ls.Tag;
                if (a1.startOffset == a.startOffset)
                {
                    patchList.Items.Remove(ls);
                }
            }

            ListViewItem i = new ListViewItem();

            i.Text = a.ToString();
            i.Tag  = a;
            patchList.Items.Add(i);
        }
Esempio n. 5
0
        private void savePatch()
        {
            List <AudioPatch> jsPatchList = new List <AudioPatch>();

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "ZIP files (*.zip)|*.zip";

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // delete old temporary directory, if there
            try
            {
                Directory.Delete("temp", true);
            }
            catch (DirectoryNotFoundException) { }


            Directory.CreateDirectory("temp");
            foreach (ListViewItem li in patchList.Items)
            {
                AudioPatch a = (AudioPatch)li.Tag;
                File.Copy(a.fileName, "temp\\" + Path.GetFileName(a.fileName));
                a.fileName = Path.GetFileName(a.fileName);
                jsPatchList.Add(a);
            }

            string jsonData = JsonConvert.SerializeObject(jsPatchList);

            File.WriteAllText("temp\\patch.json", jsonData);

            try
            {
                ZipFile.CreateFromDirectory("temp", sfd.FileName);
            } catch (System.IO.IOException)
            {
                File.Delete(sfd.FileName);
                ZipFile.CreateFromDirectory("temp", sfd.FileName);
            }

            Directory.Delete("temp", true);
        }