diff --git a/CUE4Parse b/CUE4Parse index 8304388d..8d95611f 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 8304388d6bec644d298382942fe02b3e0ee1e7d0 +Subproject commit 8d95611f407181e07d849ebe594f0133e88c55f9 diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 031da686..dc171282 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -73,7 +73,6 @@ - @@ -182,7 +181,6 @@ - diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 3bbea72b..c32b5781 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -34,12 +34,13 @@ using CUE4Parse.UE4.Oodle.Objects; using CUE4Parse.UE4.Readers; using CUE4Parse.UE4.Shaders; using CUE4Parse.UE4.Versions; -using CUE4Parse.UE4.Wwise; +using CUE4Parse.UE4.Wwise; +using CUE4Parse.UE4.Wwise.Objects.HIRC; using CUE4Parse_Conversion; using CUE4Parse_Conversion.Sounds; using CUE4Parse.FileProvider.Objects; using CUE4Parse.UE4.Assets; -using CUE4Parse.UE4.Objects.UObject; +using CUE4Parse.UE4.Objects.UObject; using CUE4Parse.Utils; using EpicManifestParser; using EpicManifestParser.UE; @@ -60,7 +61,6 @@ using SkiaSharp; using UE4Config.Parsing; using Application = System.Windows.Application; using FGuid = CUE4Parse.UE4.Objects.Core.Misc.FGuid; -using CUE4Parse.UE4.Wwise.Objects; namespace FModel.ViewModels; @@ -845,7 +845,9 @@ public class CUE4ParseViewModel : ViewModel var projectName = string.IsNullOrEmpty(Provider.ProjectName) ? "Game" : Provider.ProjectName; var baseWwiseAudioPath = DetermineBaseWwiseAudioPath(projectName, kvp.Value.Value); - var audioEventPath = pointer.Object.Value.GetPathName().StartsWith("Game") ? pointer.Object.Value.GetPathName().Replace("Game", projectName) : pointer.Object.Value.GetPathName(); + var audioEventPath = pointer.Object.Value.GetPathName().StartsWith("/Game") + ? string.Concat(projectName, pointer.Object.Value.GetPathName().AsSpan(5)) + : pointer.Object.Value.GetPathName(); foreach (var soundBank in kvp.Value.Value.SoundBanks) { @@ -886,8 +888,10 @@ public class CUE4ParseViewModel : ViewModel TraverseAndSave(eventAction.ReferencedId); } - } - + } + + // TODO: If EventActionPlay points to different soundbank ID than we're currently in, use `wwiseReader.IdToString` to convert to bank name, serialize it, and continue traversing from there + // TODO: It's possible for switch container to point to a different soundbank without referencing it in any way. I don't know how to handle that yet void TraverseAndSave(uint id) { if (!hierarchyTable.TryGetValue(id, out var hierarchy)) @@ -896,7 +900,17 @@ public class CUE4ParseViewModel : ViewModel switch (hierarchy.Data) { case HierarchySoundSfxVoice soundSfx: - SaveWemSound(soundSfx.SourceId); + SaveWemSound(soundSfx.Source.SourceId); + break; + + case HierarchyMusicRandomSequenceContainer musicRandomSequenceContainer: + foreach (var childId in musicRandomSequenceContainer.ChildIds) + TraverseAndSave(childId); + break; + + case HierarchyMusicSwitchContainer musicSwitchContainer: + foreach (var childId in musicSwitchContainer.ChildIds) + TraverseAndSave(childId); break; case HierarchyMusicTrack musicTrack: @@ -905,22 +919,22 @@ public class CUE4ParseViewModel : ViewModel break; case HierarchyMusicSegment musicSegment: - foreach (var childId in musicSegment.ChildIDs) + foreach (var childId in musicSegment.ChildIds) TraverseAndSave(childId); break; case HierarchyRandomSequenceContainer randomContainer: - foreach (var childId in randomContainer.ChildIDs) + foreach (var childId in randomContainer.ChildIds) TraverseAndSave(childId); break; case HierarchySwitchContainer switchContainer: - foreach (var childId in switchContainer.ChildIDs) + foreach (var childId in switchContainer.ChildIds) TraverseAndSave(childId); break; case HierarchyLayerContainer layerContainer: - foreach (var childId in layerContainer.ChildIDs) + foreach (var childId in layerContainer.ChildIds) TraverseAndSave(childId); break; } @@ -1061,7 +1075,7 @@ public class CUE4ParseViewModel : ViewModel private void SaveAndPlaySound(string fullPath, string ext, byte[] data) { - if (fullPath.StartsWith("/")) fullPath = fullPath[1..]; + if (fullPath.StartsWith('/')) fullPath = fullPath[1..]; var savedAudioPath = Path.Combine(UserSettings.Default.AudioDirectory, UserSettings.Default.KeepDirectoryStructure ? fullPath : fullPath.SubstringAfterLast('/')).Replace('\\', '/') + $".{ext.ToLowerInvariant()}";