From adc19388c9a7272879f80e6d8fcac4e60a5bb02e Mon Sep 17 00:00:00 2001
From: Masusder <59669685+Masusder@users.noreply.github.com>
Date: Thu, 1 May 2025 19:06:52 +0200
Subject: [PATCH] Generic search for wwise directory (v2)
and cute icon
---
FModel/FModel.csproj | 2 +
FModel/Resources/deadbydaylight.png | Bin 0 -> 680 bytes
FModel/ViewModels/CUE4ParseViewModel.cs | 64 +++++++++++++++---------
FModel/Views/Resources/Resources.xaml | 5 +-
4 files changed, 47 insertions(+), 24 deletions(-)
create mode 100644 FModel/Resources/deadbydaylight.png
diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj
index dc171282..031da686 100644
--- a/FModel/FModel.csproj
+++ b/FModel/FModel.csproj
@@ -73,6 +73,7 @@
+
@@ -181,6 +182,7 @@
+
diff --git a/FModel/Resources/deadbydaylight.png b/FModel/Resources/deadbydaylight.png
new file mode 100644
index 0000000000000000000000000000000000000000..45aeb77dee79519aac2f52a63740392ac3d94df5
GIT binary patch
literal 680
zcmV;Z0$2TsP)Px%Vo5|nR5(wSluxMDRTPE4&wBRfm1dxrI4Y7HND=5jK`^sP(Ll063MvhI2{;H0tN%R+q%S~{dB9oV
zJ@sUge}E@|QT3%HzXJ<_`RboZ=BQWu0SyB94EPW@r!Gr!6j%%FS3gK{9(Wm;p{4ws@dX!VCA
zUjZfbW5BJ}!3}k|FGWc<0B-?r01x#Mt0BH
zTzDS%zmoI;906WYAFjP5H-K$wS$9ezzYZJ+9tU0kjx@lcV@6Mg;{H2eF7STQIaPpV
zZ4SCNd=mHrc&bzRDd4vz^2B`A$v)sq^-^sPvgxzHFY29Y+f-js7qqwxu(t-WL+3NV
z+d$1miC&bx3T*ATaAXib`T3gqNVmi!m(>C;z(qBPo$1}y;$6TA_1u&wYM1UNZ1Lwc
z#qGN)-J$Mo@oT_O>XqpL>`{02bg)nTs3%_9tvJczMrpZjau>C#wyU4^B;2Id6LM!I
zsh9M6`<`3R_{8J`MQ)cCt3UT7d{G_km!wQkkKVKZCLT^wmaRFM*18QnBn;J_=P+pi
O0000 f.Path.Contains("/WwiseAudio/") && f.Path.EndsWith(".bnk", StringComparison.OrdinalIgnoreCase));
- string bnkDirectory = bnkFile != null ? Path.GetDirectoryName(bnkFile.Path.Replace('/', Path.DirectorySeparatorChar)) : null;
-
foreach (var kvp in wwiseData.EventLanguageMap)
{
if (!kvp.Value.HasValue)
continue;
- var projectName = string.IsNullOrEmpty(Provider.ProjectName) ? "Game" : Provider.ProjectName;
- var baseWwiseAudioPath = Path.Combine(projectName, "Content", "WwiseAudio", "Cooked");
-
- // If .bnk was found we will use that for base wwise directory
- if (!string.IsNullOrEmpty(bnkDirectory))
- {
- baseWwiseAudioPath = bnkDirectory;
- }
-
+ var projectName = string.IsNullOrEmpty(Provider.ProjectName) ? "Game" : Provider.ProjectName;
+ var baseWwiseAudioPath = DetermineBaseWwiseAudioPath(projectName, kvp.Value.Value);
var audioEventPath = pointer.Object.Value.GetPathName().Replace("Game", projectName);
foreach (var soundBank in kvp.Value.Value.SoundBanks)
@@ -951,16 +939,11 @@ public class CUE4ParseViewModel : ViewModel
foreach (var media in kvp.Value.Value.Media)
{
- var candidatePath = Path.Combine(baseWwiseAudioPath, media.MediaPathName.Text);
- var mediaRelativePath = media.MediaPathName.Text.Replace('\\', '/');
+ var mediaRelativePath = Path.Combine(baseWwiseAudioPath, media.MediaPathName.Text.Replace('\\', '/'));
- if (!Provider.TrySaveAsset(candidatePath, out byte[] data))
- {
- candidatePath = Path.Combine(baseWwiseAudioPath, mediaRelativePath);
- if (!Provider.TrySaveAsset(candidatePath, out data))
- {
- continue;
- }
+ if (!Provider.TrySaveAsset(mediaRelativePath, out byte[] data))
+ {
+ continue;
}
var debugName = !string.IsNullOrEmpty(media.DebugName.Text)
@@ -1154,5 +1137,40 @@ public class CUE4ParseViewModel : ViewModel
private static bool HasFlag(EBulkType a, EBulkType b)
{
return (a & b) == b;
+ }
+
+ private string DetermineBaseWwiseAudioPath(string projectName, FWwiseEventCookedData value)
+ {
+ var files = Provider.Files.Values.ToList();
+
+ // Most common directory
+ var baseWwiseAudioPath = Path.Combine(projectName, "Content", "WwiseAudio");
+
+ var soundBankName = value.SoundBanks.FirstOrDefault().SoundBankPathName.ToString() ?? string.Empty;
+ var mediaPathName = value.Media.FirstOrDefault().MediaPathName.Text ?? string.Empty;
+
+ if (!string.IsNullOrEmpty(soundBankName))
+ {
+ var matchingFile = files.FirstOrDefault(f => f.Path.Contains(soundBankName));
+ if (matchingFile != null)
+ {
+ var matchingDirectory = matchingFile.Path[..matchingFile.Path.LastIndexOf(soundBankName)];
+ baseWwiseAudioPath = matchingDirectory.Replace('/', Path.DirectorySeparatorChar);
+ return baseWwiseAudioPath;
+ }
+ }
+
+ if (!string.IsNullOrEmpty(mediaPathName))
+ {
+ var matchingFile = files.FirstOrDefault(f => f.Path.Contains(mediaPathName));
+ if (matchingFile != null)
+ {
+ var matchingDirectory = matchingFile.Path[..matchingFile.Path.LastIndexOf(mediaPathName)];
+ baseWwiseAudioPath = matchingDirectory.Replace('/', Path.DirectorySeparatorChar);
+ return baseWwiseAudioPath;
+ }
+ }
+
+ return baseWwiseAudioPath;
}
}
diff --git a/FModel/Views/Resources/Resources.xaml b/FModel/Views/Resources/Resources.xaml
index 1d1500ed..be269162 100644
--- a/FModel/Views/Resources/Resources.xaml
+++ b/FModel/Views/Resources/Resources.xaml
@@ -1,4 +1,4 @@
-
+
+
+