Skip to content

Support for audio events from Wwise soundbanks #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CUE4Parse
Submodule CUE4Parse updated 163 files
15 changes: 15 additions & 0 deletions FModel/Settings/CustomDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ public static IList<CustomDirectory> Default(string gameName)
new("Shop Backgrounds", "ShooterGame/Content/UI/OutOfGame/MainMenu/Store/Shared/Textures/"),
new("Weapon Renders", "ShooterGame/Content/UI/Screens/OutOfGame/MainMenu/Collection/Assets/Large/")
};
case "Dead by Daylight":
return new List<CustomDirectory>
{
new("Characters V1", "DeadByDaylight/Plugins/DBDCharacters/"),
new("Characters V2", "DeadByDaylight/Plugins/Runtime/Bhvr/DBDCharacters/"),
new("Characters (Deprecated)", "DeadbyDaylight/Content/Characters/"),
new("Meshes", "DeadByDaylight/Content/Meshes/"),
new("Textures", "DeadByDaylight/Content/Textures/"),
new("Icons", "DeadByDaylight/Content/UI/UMGAssets/Icons/"),
new("Blueprints", "DeadByDaylight/Content/Blueprints/"),
new("Audio Events", "DeadByDaylight/Content/Audio/Events/"),
new("Audio", "DeadByDaylight/Content/WwiseAudio/Cooked/"),
new("Data Tables", "DeadByDaylight/Content/Data/"),
new("Localization", "DeadByDaylight/Content/Localization/")
};
default:
return new List<CustomDirectory>();
}
Expand Down
33 changes: 13 additions & 20 deletions FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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;
Expand Down Expand Up @@ -115,7 +115,8 @@ public Snooper SnooperViewer
public AssetsFolderViewModel AssetsFolder { get; }
public SearchViewModel SearchVm { get; }
public TabControlViewModel TabControl { get; }
public ConfigIni IoStoreOnDemand { get; }
public ConfigIni IoStoreOnDemand { get; }
public WwiseProvider WwiseProvider { get; set; }

public CUE4ParseViewModel()
{
Expand Down Expand Up @@ -840,23 +841,15 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
TabControl.SelectedTab.AddImage(sourceFile.SubstringAfterLast('/'), false, bitmap, false, updateUi);
return false;
}
case UAkAudioEvent when isNone && pointer.Object.Value is UAkAudioEvent { EventCookedData: { } wwiseData }:
{
foreach (var kvp in wwiseData.EventLanguageMap)
{
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);
}
}
case UAkAudioEvent when isNone && pointer.Object.Value is UAkAudioEvent audioEvent:
{
WwiseProvider ??= new WwiseProvider(Provider, audioEvent);

var extractedSounds = WwiseProvider.ExtractAudioEventSounds(audioEvent, UserSettings.Default.AudioDirectory);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(sound.OutputPath, sound.Extension, sound.Data);
}
return false;
}
case UAkMediaAssetData when isNone:
Expand Down Expand Up @@ -949,7 +942,7 @@ public void ShowMetadata(GameFile entry)

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()}";

Expand Down
6 changes: 3 additions & 3 deletions FModel/ViewModels/GameSelectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private IEnumerable<DirectorySettings> EnumerateDetectedGames()
yield return GetUnrealEngineGame("9361c8c6d2f34b42b5f2f61093eedf48", "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds);
yield return GetRiotGame("VALORANT", "ShooterGame\\Content\\Paks", EGame.GAME_Valorant);
yield return DirectorySettings.Default("VALORANT [LIVE]", Constants._VAL_LIVE_TRIGGER, ue: EGame.GAME_Valorant);
yield return GetSteamGame(381210, "\\DeadByDaylight\\Content\\Paks", EGame.GAME_UE4_27); // Dead By Daylight
yield return GetSteamGame(381210, "\\DeadByDaylight\\Content\\Paks", EGame.GAME_DeadByDaylight, aesKey: "0x22b1639b548124925cf7b9cbaa09f9ac295fcf0324586d6b37ee1d42670b39b3"); // Dead By Daylight
yield return GetSteamGame(578080, "\\TslGame\\Content\\Paks", EGame.GAME_PlayerUnknownsBattlegrounds); // PUBG
yield return GetSteamGame(1172380, "\\SwGame\\Content\\Paks", EGame.GAME_StarWarsJediFallenOrder); // STAR WARS Jedi: Fallen Order™
yield return GetSteamGame(677620, "\\PortalWars\\Content\\Paks", EGame.GAME_Splitgate); // Splitgate
Expand Down Expand Up @@ -151,13 +151,13 @@ private DirectorySettings GetRiotGame(string gameName, string pakDirectory, EGam
return null;
}

private DirectorySettings GetSteamGame(int id, string pakDirectory, EGame ueVersion)
private DirectorySettings GetSteamGame(int id, string pakDirectory, EGame ueVersion, string aesKey = "")
{
var steamInfo = SteamDetection.GetSteamGameById(id);
if (steamInfo is not null)
{
Log.Debug("Found {GameName} in steam manifests", steamInfo.Name);
return DirectorySettings.Default(steamInfo.Name, $"{steamInfo.GameRoot}{pakDirectory}", ue: ueVersion);
return DirectorySettings.Default(steamInfo.Name, $"{steamInfo.GameRoot}{pakDirectory}", ue: ueVersion, aes: aesKey);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion FModel/Views/Resources/Resources.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FModel"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Expand Down