From 39f8ea57023161d3318cb2c0ad0c90fb527124f4 Mon Sep 17 00:00:00 2001 From: Masusder <59669685+Masusder@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:39:57 +0200 Subject: [PATCH] Generalized wwiseaudio dir lookup --- FModel/ViewModels/CUE4ParseViewModel.cs | 36 ++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index cc4bb7ce..cdec8acb 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -842,15 +842,33 @@ public class CUE4ParseViewModel : ViewModel if (!kvp.Value.HasValue) continue; foreach (var media in kvp.Value.Value.Media) - { - if (!Provider.TrySaveAsset(Path.Combine("Game/WwiseAudio/", media.MediaPathName.Text), out var data)) continue; - - var namedPath = string.Concat( - Provider.ProjectName, "/Content/WwiseAudio/", - media.DebugName.Text.SubstringBeforeLast('.').Replace('\\', '/'), - " (", kvp.Key.LanguageName.Text, ")"); - SaveAndPlaySound(namedPath, media.MediaPathName.Text.SubstringAfterLast('.'), data); - } + { + var mediaRelativePath = media.MediaPathName.Text.Replace('\\', '/'); + var projectName = string.IsNullOrEmpty(Provider.ProjectName) ? "Game" : Provider.ProjectName; + var baseWwiseAudioPath = Path.Combine(projectName, "Content", "WwiseAudio"); + var candidatePath = Path.Combine(baseWwiseAudioPath, "Cooked", media.MediaPathName.Text); + if (!Provider.TrySaveAsset(candidatePath, out byte[] data)) + { + candidatePath = Path.Combine(baseWwiseAudioPath, mediaRelativePath); + if (!Provider.TrySaveAsset(candidatePath, out data)) + { + continue; + } + } + + var debugName = !string.IsNullOrEmpty(media.DebugName.Text) + ? media.DebugName.Text.SubstringBeforeLast('.') + : Path.GetFileNameWithoutExtension(mediaRelativePath); + + var namedPath = Path.Combine( + projectName, + "Content", + "WwiseAudio", + $"{debugName.Replace('\\', '/')} ({kvp.Key.LanguageName.Text})" + ); + + SaveAndPlaySound(namedPath, Path.GetExtension(mediaRelativePath).TrimStart('.'), data); + } } return false; }