Skip to content

Commit 4a9a441

Browse files
authored
Merge pull request #564 from Masusder/dev
Support for audio events from Wwise soundbanks
2 parents 1f1d2ae + e6ef050 commit 4a9a441

File tree

11 files changed

+109
-26
lines changed

11 files changed

+109
-26
lines changed

CUE4Parse

Submodule CUE4Parse updated 163 files

FModel/Settings/CustomDirectory.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ public static IList<CustomDirectory> Default(string gameName)
3030
new("Shop Backgrounds", "ShooterGame/Content/UI/OutOfGame/MainMenu/Store/Shared/Textures/"),
3131
new("Weapon Renders", "ShooterGame/Content/UI/Screens/OutOfGame/MainMenu/Collection/Assets/Large/")
3232
};
33+
case "Dead by Daylight":
34+
return new List<CustomDirectory>
35+
{
36+
new("Characters V1", "DeadByDaylight/Plugins/DBDCharacters/"),
37+
new("Characters V2", "DeadByDaylight/Plugins/Runtime/Bhvr/DBDCharacters/"),
38+
new("Characters (Deprecated)", "DeadbyDaylight/Content/Characters/"),
39+
new("Meshes", "DeadByDaylight/Content/Meshes/"),
40+
new("Textures", "DeadByDaylight/Content/Textures/"),
41+
new("Icons", "DeadByDaylight/Content/UI/UMGAssets/Icons/"),
42+
new("Blueprints", "DeadByDaylight/Content/Blueprints/"),
43+
new("Audio Events", "DeadByDaylight/Content/Audio/Events/"),
44+
new("Audio", "DeadByDaylight/Content/WwiseAudio/Cooked/"),
45+
new("Data Tables", "DeadByDaylight/Content/Data/"),
46+
new("Localization", "DeadByDaylight/Content/Localization/")
47+
};
3348
default:
3449
return new List<CustomDirectory>();
3550
}

FModel/Settings/UserSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,13 @@ public Camera.WorldMode CameraMode
439439
set => SetProperty(ref _cameraMode, value);
440440
}
441441

442+
private int _wwiseMaxBnkPrefetch;
443+
public int WwiseMaxBnkPrefetch
444+
{
445+
get => _wwiseMaxBnkPrefetch;
446+
set => SetProperty(ref _wwiseMaxBnkPrefetch, value);
447+
}
448+
442449
private int _previewMaxTextureSize = 1024;
443450
public int PreviewMaxTextureSize
444451
{

FModel/ViewModels/CUE4ParseViewModel.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ public bool ModelIsOverwritingMaterial
7878
set => SetProperty(ref _modelIsOverwritingMaterial, value);
7979
}
8080

81+
private bool _modelIsWaitingAnimation;
82+
public bool ModelIsWaitingAnimation
83+
{
84+
get => _modelIsWaitingAnimation;
85+
set => SetProperty(ref _modelIsWaitingAnimation, value);
86+
}
87+
8188
public bool IsSnooperOpen => _snooper is { Exists: true, IsVisible: true };
8289
private Snooper _snooper;
8390
public Snooper SnooperViewer
@@ -117,6 +124,8 @@ public Snooper SnooperViewer
117124
public SearchViewModel SearchVm { get; }
118125
public TabControlViewModel TabControl { get; }
119126
public ConfigIni IoStoreOnDemand { get; }
127+
private Lazy<WwiseProvider> _wwiseProviderLazy;
128+
public WwiseProvider WwiseProvider => _wwiseProviderLazy.Value;
120129

121130
public CUE4ParseViewModel()
122131
{
@@ -266,6 +275,7 @@ await _threadWorkerView.Begin(cancellationToken =>
266275
}
267276

268277
Provider.Initialize();
278+
_wwiseProviderLazy = new Lazy<WwiseProvider>(() => new WwiseProvider(Provider, UserSettings.Default.WwiseMaxBnkPrefetch));
269279
Log.Information($"{Provider.Versions.Game} ({Provider.Versions.Platform}) | Archives: x{Provider.UnloadedVfs.Count} | AES: x{Provider.RequiredKeys.Count} | Loose Files: x{Provider.Files.Count}");
270280
});
271281
}
@@ -670,9 +680,11 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
670680
var archive = entry.CreateReader();
671681
var wwise = new WwiseReader(archive);
672682
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(wwise, Formatting.Indented), saveProperties, updateUi);
673-
foreach (var (name, data) in wwise.WwiseEncodedMedias)
683+
684+
var medias = WwiseProvider.ExtractBankSounds(wwise);
685+
foreach (var media in medias)
674686
{
675-
SaveAndPlaySound(entry.Path.SubstringBeforeWithLast('/') + name, "WEM", data);
687+
SaveAndPlaySound(media.OutputPath, media.Extension, media.Data);
676688
}
677689

678690
break;
@@ -852,22 +864,12 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
852864
TabControl.SelectedTab.AddImage(sourceFile.SubstringAfterLast('/'), false, bitmap, false, updateUi);
853865
return false;
854866
}
855-
case UAkAudioEvent when isNone && pointer.Object.Value is UAkAudioEvent { EventCookedData: { } wwiseData }:
867+
case UAkAudioEvent when isNone && pointer.Object.Value is UAkAudioEvent audioEvent:
856868
{
857-
foreach (var kvp in wwiseData.EventLanguageMap)
869+
var extractedSounds = WwiseProvider.ExtractAudioEventSounds(audioEvent);
870+
foreach (var sound in extractedSounds)
858871
{
859-
if (!kvp.Value.HasValue) continue;
860-
861-
foreach (var media in kvp.Value.Value.Media)
862-
{
863-
if (!Provider.TrySaveAsset(Path.Combine("Game/WwiseAudio/", media.MediaPathName.Text), out var data)) continue;
864-
865-
var namedPath = string.Concat(
866-
Provider.ProjectName, "/Content/WwiseAudio/",
867-
media.DebugName.Text.SubstringBeforeLast('.').Replace('\\', '/'),
868-
" (", kvp.Key.LanguageName.Text, ")");
869-
SaveAndPlaySound(namedPath, media.MediaPathName.Text.SubstringAfterLast('.'), data);
870-
}
872+
SaveAndPlaySound(sound.OutputPath, sound.Extension, sound.Data);
871873
}
872874
return false;
873875
}
@@ -914,7 +916,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
914916
SnooperViewer.Run();
915917
return true;
916918
}
917-
case UAnimSequenceBase when isNone && UserSettings.Default.PreviewAnimations || SnooperViewer.Renderer.Options.ModelIsWaitingAnimation:
919+
case UAnimSequenceBase when isNone && UserSettings.Default.PreviewAnimations || ModelIsWaitingAnimation:
918920
{
919921
// animate all animations using their specified skeleton or when we explicitly asked for a loaded model to be animated (ignoring whether we wanted to preview animations)
920922
SnooperViewer.Renderer.Animate(pointer.Object.Value);
@@ -961,7 +963,7 @@ public void ShowMetadata(GameFile entry)
961963

962964
private void SaveAndPlaySound(string fullPath, string ext, byte[] data)
963965
{
964-
if (fullPath.StartsWith("/")) fullPath = fullPath[1..];
966+
if (fullPath.StartsWith('/')) fullPath = fullPath[1..];
965967
var savedAudioPath = Path.Combine(UserSettings.Default.AudioDirectory,
966968
UserSettings.Default.KeepDirectoryStructure ? fullPath : fullPath.SubstringAfterLast('/')).Replace('\\', '/') + $".{ext.ToLowerInvariant()}";
967969

FModel/ViewModels/GameSelectorViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private IEnumerable<DirectorySettings> EnumerateDetectedGames()
9999
yield return GetUnrealEngineGame("9361c8c6d2f34b42b5f2f61093eedf48", "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds);
100100
yield return GetRiotGame("VALORANT", "ShooterGame\\Content\\Paks", EGame.GAME_Valorant);
101101
yield return DirectorySettings.Default("VALORANT [LIVE]", Constants._VAL_LIVE_TRIGGER, ue: EGame.GAME_Valorant);
102-
yield return GetSteamGame(381210, "\\DeadByDaylight\\Content\\Paks", EGame.GAME_UE4_27); // Dead By Daylight
102+
yield return GetSteamGame(381210, "\\DeadByDaylight\\Content\\Paks", EGame.GAME_DeadByDaylight, aesKey: "0x22b1639b548124925cf7b9cbaa09f9ac295fcf0324586d6b37ee1d42670b39b3"); // Dead By Daylight
103103
yield return GetSteamGame(578080, "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds); // PUBG
104104
yield return GetSteamGame(1172380, "\\SwGame\\Content\\Paks", EGame.GAME_StarWarsJediFallenOrder); // STAR WARS Jedi: Fallen Order™
105105
yield return GetSteamGame(677620, "\\PortalWars\\Content\\Paks", EGame.GAME_Splitgate); // Splitgate
@@ -151,13 +151,13 @@ private DirectorySettings GetRiotGame(string gameName, string pakDirectory, EGam
151151
return null;
152152
}
153153

154-
private DirectorySettings GetSteamGame(int id, string pakDirectory, EGame ueVersion)
154+
private DirectorySettings GetSteamGame(int id, string pakDirectory, EGame ueVersion, string aesKey = "")
155155
{
156156
var steamInfo = SteamDetection.GetSteamGameById(id);
157157
if (steamInfo is not null)
158158
{
159159
Log.Debug("Found {GameName} in steam manifests", steamInfo.Name);
160-
return DirectorySettings.Default(steamInfo.Name, $"{steamInfo.GameRoot}{pakDirectory}", ue: ueVersion);
160+
return DirectorySettings.Default(steamInfo.Name, $"{steamInfo.GameRoot}{pakDirectory}", ue: ueVersion, aes: aesKey);
161161
}
162162

163163
return null;

FModel/Views/Resources/Resources.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:local="clr-namespace:FModel"
44
xmlns:system="clr-namespace:System;assembly=mscorlib"

FModel/Views/SettingsView.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<RowDefinition Height="Auto" />
4545
<RowDefinition Height="Auto" />
4646
<RowDefinition Height="Auto" />
47+
<RowDefinition Height="Auto" />
4748
</Grid.RowDefinitions>
4849
<Grid.ColumnDefinitions>
4950
<ColumnDefinition Width="Auto" />
@@ -227,6 +228,11 @@
227228
<TextBlock Grid.Row="17" Grid.Column="0" Text="Serialize Inlined Shader Maps" VerticalAlignment="Center" Margin="0 0 0 5" />
228229
<CheckBox Grid.Row="17" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
229230
IsChecked="{Binding ReadShaderMaps, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"/>
231+
232+
<TextBlock Grid.Row="18" Grid.Column="0" Text="Max Wwise Bank (.BNK) Prefetch" VerticalAlignment="Center" Margin="0 0 0 5" />
233+
<Slider Grid.Row="18" Grid.Column="2" Grid.ColumnSpan="5" TickPlacement="None" Minimum="0" Maximum="512" Ticks="0,2,4,8,16,32,64,128,256,512"
234+
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" Margin="0 5 0 5"
235+
Value="{Binding WwiseMaxBnkPrefetch, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"/>
230236
</Grid>
231237
</DataTemplate>
232238
<DataTemplate x:Key="CreatorTemplate">

FModel/Views/Snooper/Options.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace FModel.Views.Snooper;
1616
public class Options
1717
{
1818
public FGuid SelectedModel { get; private set; }
19-
public bool ModelIsWaitingAnimation { get; private set; }
2019
public int SelectedSection { get; private set; }
2120
public int SelectedMorph { get; private set; }
2221
public int SelectedAnimation{ get; private set; }
@@ -238,7 +237,7 @@ public void SwapMaterial(bool value)
238237

239238
public void AnimateMesh(bool value)
240239
{
241-
ModelIsWaitingAnimation = value;
240+
Services.ApplicationService.ApplicationView.CUE4Parse.ModelIsWaitingAnimation = value;
242241
}
243242

244243
public void ResetModelsLightsAnimations()

FModel/Views/Snooper/Renderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void Swap(UMaterialInstance unrealMaterial)
123123

124124
public void Animate(UObject anim)
125125
{
126-
if (!Options.ModelIsWaitingAnimation)
126+
if (!Services.ApplicationService.ApplicationView.CUE4Parse.ModelIsWaitingAnimation)
127127
{
128128
if (anim is UAnimSequenceBase animBase)
129129
{

FModel/Views/Snooper/SnimGui.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ private void DrawDetails(Snooper s)
624624
ImGui.EndTable();
625625
}
626626

627+
ImGui.SeparatorText("Manual Inputs");
628+
model.Transforms[model.SelectedInstance].ImGuiTransform(s.Renderer.CameraOp.Speed / 100f);
629+
627630
ImGui.EndTabItem();
628631
}
629632

0 commit comments

Comments
 (0)