public static WwiseIndex Load(Stream input) { if (input == null) { throw new ArgumentNullException("input"); } var magic = input.ReadValueU32(Endian.Little); if (magic != 0x58444957 && magic.Swap() != 0x58444957) { throw new FormatException("invalid magic"); } var endian = magic == 0x58444957 ? Endian.Little : Endian.Big; var version = input.ReadValueU32(endian); if (version != 1) { throw new FormatException("unexpected version"); } var reader = new FileFormats.Unreal.FileReader(input, version, endian); var index = new WwiseIndex(); index.Serialize(reader); return(index); }
public static WwiseIndex Load(Stream input) { if (input == null) { throw new ArgumentNullException("input"); } var magic = input.ReadValueU32(Endian.Little); if (magic != 0x58444957 && magic.Swap() != 0x58444957) { throw new FormatException("invalid magic"); } var endian = magic == 0x58444957 ? Endian.Little : Endian.Big; var version = input.ReadValueU32(endian); if (version != 1) { throw new FormatException("unexpected version"); } var reader = new FileFormats.Unreal.FileReader(input, version, endian); var index = new WwiseIndex(); index.Serialize(reader); return index; }
private void OnLoad(object sender, EventArgs e) { var exePath = GetExecutablePath(); string path = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\BioWare\Mass Effect 3", "Install Dir", null) ?? (string) Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BioWare\Mass Effect 3", "Install Dir", null); if (path != null) { path = Path.Combine(path, "BioGame"); path = Path.Combine(path, "CookedPCConsole"); this._PackagePath = path; } else { this._PackagePath = null; } var converterPath = Path.Combine(exePath, "ww2ogg.exe"); if (File.Exists(converterPath) == false) { this.convertCheckBox.Checked = false; this.convertCheckBox.Enabled = false; this.LogError("ww2ogg.exe is not present in \"{0}\"!", exePath); } else { this._ConverterPath = converterPath; } var revorbPath = Path.Combine(exePath, "revorb.exe"); if (File.Exists(revorbPath) == false) { this.revorbCheckBox.Checked = false; this.revorbCheckBox.Enabled = false; } else { this._RevorbPath = revorbPath; } this.ToggleControls(false); var indexPath = Path.Combine(exePath, "Wwise.idx"); if (File.Exists(indexPath) == false) { this.LogError("Wwise.idx is not present in \"{0}\"!", exePath); } else { this.LogMessage("Loading Wwise index..."); var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); DateTime startTime = DateTime.Now; var task = Task <List <WwiseLocation> > .Factory.StartNew( () => { using (var input = File.OpenRead(indexPath)) { var index = WwiseIndex.Load(input); if (input.Position != input.Length) { throw new FormatException("did not consume entire file"); } var locations = new List <WwiseLocation>(); foreach (var resource in index.Resources) { var firstInstance = resource.Instances .OrderByDescending(i => i.IsPackage == false) .First(); var location = new WwiseLocation() { Hash = resource.Hash, Path = index.Strings[firstInstance.PathIndex], Name = index.Strings[firstInstance.NameIndex], Actor = index.Strings[firstInstance.ActorIndex], Group = index.Strings[firstInstance.GroupIndex], Locale = index.Strings[firstInstance.LocaleIndex], File = index.Strings[firstInstance.FileIndex], IsPackage = firstInstance.IsPackage, Offset = firstInstance.Offset, Size = firstInstance.Size, }; foreach (var instance in resource.Instances.Except(new[] { firstInstance })) { location.Duplicates.Add(new WwiseLocation() { Hash = resource.Hash, Path = index.Strings[instance.PathIndex], Name = index.Strings[instance.NameIndex], Actor = index.Strings[instance.ActorIndex], Group = index.Strings[instance.GroupIndex], Locale = index.Strings[instance.LocaleIndex], File = index.Strings[instance.FileIndex], IsPackage = instance.IsPackage, Offset = instance.Offset, Size = instance.Size, }); } locations.Add(location); } return(locations); } }); task.ContinueWith( t => { var elapsed = DateTime.Now.Subtract(startTime); this.LogSuccess("Loaded Wwise index in {0}m {1}s {2}ms", elapsed.Minutes, elapsed.Seconds, elapsed.Milliseconds); this.LogMessage("{0} entries ({1} duplicates)", t.Result.Count, t.Result.Sum(i => i.Duplicates.Count)); this.OnWwiseIndexLoaded(t.Result); }, System.Threading.CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, uiScheduler); task.ContinueWith( t => { this.LogError("Failed to load Wwise index."); if (t.Exception != null) { if (t.Exception.InnerException != null) { this.LogError(t.Exception.InnerException.ToString()); } else { this.LogError(t.Exception.ToString()); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, uiScheduler); } }