private void button3_Click(object sender, EventArgs e)
        {
            var new_dict = new Dictionary <string, byte[]>();

            foreach (var item in WiiU_Files)
            {
                if (!item.Key.EndsWith(".byml"))
                {
                    var m = new MemoryStream();
                    m.Write(item.Value, 0, item.Value.Length);
                    var b = m.ReadStream();
                    b.ByteOrder = ByteOrder.LittleEndian;
                    var data = b.GetBytes();
                    b.Dispose();
                    m.Dispose();
                    new_dict.Add(item.Key, data);
                }
                else
                {
                    var m = new MemoryStream(item.Value);
                    var d = m.GetByml();
                    d.byteOrder = ByteOrder.LittleEndian;
                    var data = d.GetBytes();
                    m.Dispose();
                    new_dict.Add(item.Key, data);
                }
            }
            var Data = new SarcData
            {
                HashOnly   = Hashs[0],
                Files      = new_dict,
                endianness = ByteOrder.LittleEndian
            };
            var            name = WiiU_File.Name.Substring(0, WiiU_File.Name.Length - 8);
            var            src  = YAZ0.Compress(Data.PackSarcData().GetBytes());
            SaveFileDialog save = new SaveFileDialog
            {
                Filter           = "Szs files (*.szs)|*.szs|All files (*.*)|*.*",
                FilterIndex      = 1,
                Title            = "Save the new Stage.",
                DefaultExt       = ".szs",
                CheckPathExists  = true,
                InitialDirectory = Directory.GetCurrentDirectory(),
                OverwritePrompt  = true,
                FileName         = name
            };

            if (save.ShowDialog().IsResult(DialogResult.OK))
            {
                File.WriteAllBytes(save.FileName, src);
                MessageBox.Show("Complete!");
            }
        }
Example #2
0
 public static byte[] PackSarc(this SarcData data)
 {
     return(data.PackSarcData().GetBytes());
 }
        private void button4_Click(object sender, EventArgs e)
        {
            var Map_Data   = new Dictionary <string, byte[]>();
            var Sound_Data = new Dictionary <string, byte[]>();
            var new_dict   = new Dictionary <string, byte[]>();

            foreach (var item in Switch_Files)
            {
                if (!item.Key.EndsWith(".byml"))
                {
                    var m = new MemoryStream();
                    m.Write(item.Value, 0, item.Value.Length);
                    var b = m.ReadStream();
                    b.ByteOrder = ByteOrder.BigEndian;
                    var data = b.GetBytes();
                    b.Dispose();
                    m.Dispose();
                    new_dict.Add(item.Key, data);
                }
                else
                {
                    var f = new FileInfo(item.Key);
                    var m = new MemoryStream(item.Value);
                    var d = m.GetByml();
                    d.byteOrder = ByteOrder.BigEndian;
                    var data = d.GetBytes();
                    m.Dispose();
                    if (f.Name.Contains(Names.Camera) || f.Name.Contains(Names.Map))
                    {
                        Map_Data.Add(item.Key, data);
                    }
                    else if (f.Name.Contains(Names.Sound))
                    {
                        Sound_Data.Add(item.Key, data);
                    }
                    else
                    {
                        new_dict.Add(item.Key, data);
                    }
                }
            }
            var Design = new SarcData
            {
                HashOnly   = Hash,
                Files      = new_dict,
                endianness = ByteOrder.BigEndian
            };
            var Sound = new SarcData
            {
                HashOnly   = Hash,
                Files      = Sound_Data,
                endianness = ByteOrder.BigEndian
            };
            var Map = new SarcData
            {
                HashOnly   = Hash,
                Files      = Map_Data,
                endianness = ByteOrder.BigEndian
            };
            var Name = Switch_File.Name.Substring(0, Switch_File.Name.Length - 4);
            FolderBrowserDialog folder = new FolderBrowserDialog
            {
                UseDescriptionForTitle = true,
                Description            = "Select a folder to save the new Stage to.",
                RootFolder             = Environment.SpecialFolder.Recent,
                ShowNewFolderButton    = true
            };

            if (folder.ShowDialog().IsResult(DialogResult.OK))
            {
                Directory.SetCurrentDirectory(folder.SelectedPath);
                File.WriteAllBytes(Name + "Design1.szs", YAZ0.Compress(Design.PackSarcData().GetBytes()));
                File.WriteAllBytes(Name + "Sound1.szs", YAZ0.Compress(Sound.PackSarcData().GetBytes()));
                File.WriteAllBytes(Name + "Map1.szs", YAZ0.Compress(Map.PackSarcData().GetBytes()));
                MessageBox.Show("Complete!");
            }
        }
Example #4
0
 /// <summary>
 /// Packs the SarcData.
 /// </summary>
 /// <param name="data">The SarcData to pack</param>
 /// <returns>A byte[] array of the packed data.</returns>
 public byte[] PackSarc(SarcData data)
 {
     return(data.PackSarcData().GetBytes());
 }