コード例 #1
0
        public override Explorer OpenFile(OpenFileEventArgs args)
        {
            var filedata = args.File.Data ?? GetFileData(args.File);

            if (args.File.Name.EndsWith(".bnk") && filedata is FPakEntry entry)
            {
                var data     = InspectedFile.ReadEntry(entry);
                var bankinfo = _files.Where(f => f.Name == "SoundbanksInfo.xml").SingleOrDefault();
                if (bankinfo != null)
                {
                    var bankData = InspectedFile.ReadEntry(bankinfo.Data);
                    var doc      = new XmlDocument();
                    var xml      = Encoding.UTF8.GetString(bankData);
                    doc.LoadXml(xml);
                    var info = new SoundBankInfo(doc);
                    return(new UE4.VorbisBank.BankExplorer(new UE4.VorbisBank.BankFile(data, info)));
                }
                else
                {
                    return(new UE4.VorbisBank.BankExplorer(new UE4.VorbisBank.BankFile(data)));
                }
            }
            else if (args.File.Name.EndsWith(".uasset") && filedata is FPakEntry asset)
            {
                var data = InspectedFile.ReadEntry(filedata);
                new UAsset(data, GetCookedAssetVersion());
                return(null);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
 public static void AddSoundBank(string bankName, string bankLanguage, ref PlatformEntry soundBankDict)
 {
     if (!soundBankDict.ContainsKey(bankName))
     {
         soundBankDict.Add(bankName, new SoundBankEntry());
     }
     soundBankDict[bankName][bankLanguage] = new SoundBankInfo();
 }
コード例 #3
0
        private void ExportFileEntry(FarFile file, string Dir)
        {
            var filedata = file.Data ?? GetFileData(file);

            if (file.IsDirectory)
            {
                Directory.CreateDirectory(Dir);
                if (filedata is PakExplorer index)
                {
                    index._files.ForEach(f => ExportFileEntry(f, Path.Combine(Dir, f.Name)));
                }
            }
            else if (file.Name.EndsWith(".bnk") && filedata is FPakEntry entry)
            {
                UE4.VorbisBank.BankFile bank = null;
                var data     = InspectedFile.ReadEntry(entry);
                var bankinfo = _files.Where(f => f.Name == "SoundbanksInfo.xml").SingleOrDefault();
                if (bankinfo != null)
                {
                    var bankData = InspectedFile.ReadEntry(bankinfo.Data);
                    var doc      = new XmlDocument();
                    var xml      = Encoding.UTF8.GetString(bankData);
                    doc.LoadXml(xml);
                    var info = new SoundBankInfo(doc);
                    bank = new UE4.VorbisBank.BankFile(data, info);
                }
                else
                {
                    bank = new UE4.VorbisBank.BankFile(data);
                }

                File.WriteAllBytes(Dir, data);
                var folder = Path.Combine(Path.GetDirectoryName(Dir), Path.GetFileNameWithoutExtension(Dir));
                Directory.CreateDirectory(folder);
                bank.Files.ForEach(track => File.WriteAllBytes(Path.Combine(folder, track.Name), bank.ReadTrack(track)));
            }
            else
            {
                var data = InspectedFile.ReadEntry(filedata);
                if (data != null)
                {
                    File.WriteAllBytes(Dir, data);
                }
            }
        }
コード例 #4
0
        public BankFile(byte[] Data, SoundBankInfo info = null) : this()
        {
            Buffer = Data;

            Magic = ToInt32();
            if (Magic == 0x44484B42)
            {
                HeaderLength = ToInt32();
                var HeaderEnd = Tell();
                Version     = ToInt32();
                SoundBankId = ToUInt32();

                Seek(HeaderEnd + HeaderLength);

                DIDXMagic = ToInt32();
                if (DIDXMagic == 0x58444944)
                {
                    ChunkLength = ToInt32();
                    var filecount = ChunkLength / 12;
                    Files = new List <BankTrack>(filecount);
                    foreach (var i in Enumerable.Range(0, filecount))
                    {
                        var trackId = ToUInt32();
                        Files.Add(new BankTrack()
                        {
                            Id     = trackId,
                            Offset = ToInt32(),
                            Length = ToInt32(),
                            Name   = info != null ? info.GetTrackName(SoundBankId, trackId) : trackId.ToString() + ".wem"
                        });
                    }
                }

                var DataMagic = ToInt32();
                var DataLen   = ToInt32();
            }
        }