private void LoadSoundResourceTable(IReader reader) { if (_soundResources == null) { _soundResources = _cacheFile.SoundGestalt.LoadSoundResourceTable(reader); } }
public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); /* * This was been fixed up to support the changes that came from sound injection, but has not really been tested * but it still isn't great/complete and was mainly only done so I didn't leave in a control where most of its code has been commented out and broken * not to mention this is all moot with MCC using external proprietary files for sounds * if i had to complete it, id probably add extra methods to SoundResourceTable and SoundGestalt to grab pitch ranges on demand instead of loading in everything every time * -Zedd */ _buildInfo = buildInfo; _cacheLocation = cacheLocation; _tag = tag; _cache = cache; _streamManager = streamManager; var viewModel = new ViewModel(); DataContext = viewModel; viewModel.TagName = _tag.TagFileName; viewModel.Sound = _sound; if (!_cache.ResourceMetaLoader.SupportsSounds) { IsEnabled = false; MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet."); return; } using (var reader = _streamManager.OpenRead()) { // load gestalt if (_cache.SoundGestalt != null) { _soundResourceTable = _cache.SoundGestalt.LoadSoundResourceTable(reader); } _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader); var resourceTable = _cache.Resources.LoadResourceTable(reader); _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex); _resourcePages = new [] { _soundResource.Location.PrimaryPage, _soundResource.Location.SecondaryPage, _soundResource.Location.TertiaryPage, }; viewModel.ResourcePages = new ObservableCollection <ResourcePage>(_resourcePages.ToList()); } for (int i = 0; i < _sound.PitchRangeCount; i++) { var pitchrange = _soundResourceTable.PitchRanges[_sound.FirstPitchRangeIndex + i]; foreach (var permutation in pitchrange.Permutations) { viewModel.Permutations.Add(new ViewModel.ViewPermutation { Name = _cache.StringIDs.GetString(permutation.Name), Index = i, SoundPermutation = permutation }); } } }