コード例 #1
0
ファイル: iSDAT.cs プロジェクト: calvarado194/layton-rando
        private void btnWav_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string sound = SaveFile();

            SaveFileDialog o = new SaveFileDialog();

            o.FileName = SearchFile().name;
            o.Filter   = "WAVE (*.wav)|*.wav";
            if (o.ShowDialog() == DialogResult.OK)
            {
                string wavSaved = o.FileName;

                switch (SearchFile().type)
                {
                case FormatSound.SWAV:
                    WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), false), wavSaved);
                    break;

                case FormatSound.STRM:
                    WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), false), wavSaved);
                    break;
                }
            }

            File.Delete(sound);
            this.Cursor = Cursors.Default;
        }
コード例 #2
0
ファイル: iSDAT.cs プロジェクト: calvarado194/layton-rando
        private void btnReproducir_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                btnStop.PerformClick();

                if (File.Exists(wavFile))
                {
                    File.Delete(wavFile);
                }
                if (File.Exists(loopFile))
                {
                    File.Delete(loopFile);
                }

                string sound = SaveFile();
                wavFile = Path.GetTempFileName();
                if (checkLoop.Checked)
                {
                    loopFile = Path.GetTempFileName();
                }

                switch (SearchFile().type)
                {
                case FormatSound.SWAV:
                    WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), false), wavFile);
                    if (checkLoop.Checked)
                    {
                        WAV.Write(SWAV.ConvertToWAV(SWAV.Read(sound), true), loopFile);
                    }
                    break;

                case FormatSound.STRM:
                    WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), false), wavFile);
                    if (checkLoop.Checked)
                    {
                        WAV.Write(STRM.ConvertToWAV(STRM.Read(sound), true), loopFile);
                    }
                    break;
                }

                File.Delete(sound);

                if (checkLoop.Checked)
                {
                    bgdWorker = new Thread(bgdWorker_DoWork);
                    bgdWorker.Start(new String[] { wavFile, loopFile });
                }
                else
                {
                    soundPlayer = new SoundPlayer(wavFile);
                    soundPlayer.Play();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
コード例 #3
0
ファイル: iSDAT.cs プロジェクト: calvarado194/layton-rando
        private void btnUncompress_Click(object sender, EventArgs e)
        {
            System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + Path.DirectorySeparatorChar +
                                                                         "Plugins" + Path.DirectorySeparatorChar + "SDATLang.xml");
            xml = xml.Element(pluginHost.Get_Language());
            xml = xml.Element("iSDAT");

            if (btnUncompress.Text == xml.Element("S07").Value)
            {
                #region Unpack SWAR file
                string swar = SaveFile();

                sSWAV[]  archivos = SWAR.ConvertToSWAV(SWAR.Read(swar));
                string[] swav     = new string[archivos.Length];

                Folder carpeta = new Folder();
                carpeta.name  = SearchFile().name;
                carpeta.files = new List <Sound>();

                for (int i = 0; i < archivos.Length; i++)
                {
                    swav[i] = pluginHost.Get_TempFolder() + '\\' + Path.GetRandomFileName();
                    SWAV.Write(archivos[i], swav[i]);

                    Sound newSound = new Sound();
                    newSound.id = lastFileID;
                    lastFileID++;
                    newSound.internalID = newSound.id;
                    newSound.name       = "SWAV_" + i.ToString() + ".swav";
                    newSound.offset     = 0x00;
                    newSound.type       = FormatSound.SWAV;
                    newSound.path       = swav[i];
                    newSound.size       = (uint)new FileInfo(swav[i]).Length;

                    carpeta.files.Add(newSound);
                }

                // Lo añadimos al nodo
                Add_Files(ref carpeta, (int)SearchFile().id);

                TreeNode selected = treeFiles.SelectedNode;
                selected = CarpetaToNodo(carpeta);

                // Agregamos los nodos al árbol
                TreeNode[] nodos = new TreeNode[selected.Nodes.Count];
                selected.Nodes.CopyTo(nodos, 0);
                treeFiles.SelectedNode.Tag = selected.Tag;
                selected.Nodes.Clear();

                treeFiles.SelectedNode.Nodes.AddRange((TreeNode[])nodos);
                treeFiles.SelectedNode.Expand();
                #endregion
                btnUncompress.Text = xml.Element("S12").Value;
            }
            else
            {
                #region Pack SWAR file
                Folder       swar   = SearchFolder(Convert.ToInt32(treeFiles.SelectedNode.Tag), sdat.files.root);
                List <sSWAV> sounds = new List <sSWAV>();

                for (int i = 0; i < swar.files.Count; i++)
                {
                    String tempFile = SaveFile((int)swar.files[i].id);
                    sSWAV  swav     = SWAV.Read(tempFile);
                    sounds.Add(swav);
                    File.Delete(tempFile);
                }

                String fileout = Path.GetTempFileName();
                SWAR.Write(sounds.ToArray(), fileout);
                ChangeFile(Convert.ToInt32(treeFiles.SelectedNode.Tag), fileout);
                #endregion
            }
        }
コード例 #4
0
ファイル: iSDAT.cs プロジェクト: calvarado194/layton-rando
        private void btnImport_Click(object sender, EventArgs e)
        {
            Sound  selectedFile = SearchFile();
            String fileout      = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName();

            OpenFileDialog o = new OpenFileDialog();

            o.CheckFileExists = true;
            o.AddExtension    = true;
            o.DefaultExt      = "wav";
            o.Filter          = "WAVE audio format (*.wav)|*.wav";
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            String filein = o.FileName;

            sWAV wav = new sWAV();

            try { wav = WAV.Read(filein); }
            catch (Exception ex) { MessageBox.Show(ex.Message); return; }

            NewAudioOptions dialog = new NewAudioOptions(pluginHost, (selectedFile.type == FormatSound.SWAV ? true : false));

            switch (selectedFile.type)
            {
            case FormatSound.STRM:
                sSTRM oldStrm = STRM.Read(SaveFile());
                dialog.Compression = oldStrm.head.waveType;
                dialog.BlockSize   = (int)oldStrm.head.blockLen;
                dialog.Loop        = (oldStrm.head.loop != 0 ? true : false);
                dialog.LoopOffset  = (int)oldStrm.head.loopOffset;
                dialog.SampleRate  = (int)wav.wave.fmt.sampleRate;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                sSTRM strm = STRM.ConvertToSTRM(wav, dialog.Compression);
                strm.head.loop       = (byte)(dialog.Loop ? 0x01 : 0x00);
                strm.head.loopOffset = (uint)dialog.LoopOffset;

                STRM.Write(strm, fileout);
                break;

            case FormatSound.SWAV:
                sSWAV oldSwav = SWAV.Read(SaveFile());
                dialog.Compression = oldSwav.data.info.nWaveType;
                dialog.Loop        = (oldSwav.data.info.bLoop != 0 ? true : false);
                dialog.LoopLength  = (int)oldSwav.data.info.nNonLoopLen;
                dialog.LoopOffset  = (int)oldSwav.data.info.nLoopOffset;
                dialog.SampleRate  = (int)wav.wave.fmt.sampleRate;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                sSWAV swav = SWAV.ConvertToSWAV(wav, dialog.Compression, dialog.Volume);

                swav.data.info.bLoop       = (byte)(dialog.Loop ? 0x01 : 0x00);
                swav.data.info.nLoopOffset = (ushort)dialog.LoopOffset;
                swav.data.info.nNonLoopLen = (uint)dialog.LoopLength;

                SWAV.Write(swav, fileout);
                break;

            case FormatSound.SSEQ:
            case FormatSound.SSAR:
            case FormatSound.SBNK:
            case FormatSound.SWAR:
            default:
                break;
            }

            if (!File.Exists(fileout))
            {
                return;
            }
            ChangeFile((int)selectedFile.id, fileout);
        }
コード例 #5
0
ファイル: iSDAT.cs プロジェクト: calvarado194/layton-rando
        private void btnInfo_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> info = new Dictionary <string, string>();

            switch (SearchFile().type)
            {
            case FormatSound.STRM:
                info = STRM.Information(STRM.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAV:
                info = SWAV.Information(SWAV.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAR:
                info = SWAR.Information(SWAR.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SSEQ:
                break;

            case FormatSound.SSAR:
                break;

            case FormatSound.SBNK:
                break;

            default:
                break;
            }


            Form ven = new Form();

            ven.Size            = new System.Drawing.Size(260, 440);
            ven.FormBorderStyle = FormBorderStyle.FixedDialog;
            ven.ShowIcon        = false;
            ven.MaximizeBox     = false;
            ven.MinimizeBox     = false;
            ven.Icon            = Icon.FromHandle(Properties.Resources.information.GetHicon());

            ListView     list    = new ListView();
            ColumnHeader column1 = new ColumnHeader();

            column1.Text = columnCampo.Text;
            ColumnHeader column2 = new ColumnHeader();

            column2.Text = columnValor.Text;
            list.Columns.Add(column1);
            list.Columns.Add(column2);

            foreach (String value in info.Keys)
            {
                if (value.StartsWith("/b"))
                {
                    String text = value.Replace("/b", "");
                    list.Items.Add(text, text, 0);
                    list.Items[text].Font = new Font("Microsoft Sans Serif", 9, FontStyle.Bold);
                    list.Items[text].SubItems.Add(info[value]);
                }
                else
                {
                    list.Items.Add(value, value, 0);
                    list.Items[value].SubItems.Add(info[value]);
                }
            }
            list.Size = new System.Drawing.Size(250, 430);
            list.View = View.Details;
            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.Dock = DockStyle.Fill;
            ven.Controls.Add(list);
            ven.Text = btnInfo.Text;
            ven.Show();
        }