Skip to content
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 FModel/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ public enum EAssetCategory : uint
AudioEvent = Media + 5,
Particle = AssetCategoryExtensions.CategoryBase + (9 << 16),
GameSpecific = AssetCategoryExtensions.CategoryBase + (10 << 16),
Borderlands4 = GameSpecific + 1,
Borderlands = GameSpecific + 1,
}
66 changes: 49 additions & 17 deletions FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using CUE4Parse.GameTypes.KRD.Assets.Exports;
using CUE4Parse.GameTypes.Borderlands4.Assets.Exports;
using CUE4Parse.GameTypes.Borderlands4.Wwise;
using CUE4Parse.GameTypes.Borderlands3.Assets.Exports;
using CUE4Parse.MappingsProvider;
using CUE4Parse.UE4.AssetRegistry;
using CUE4Parse.UE4.Assets;
Expand Down Expand Up @@ -792,7 +793,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
var directory = Path.GetDirectoryName(entry.Path) ?? "/FMOD/Desktop/";
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
}

break;
Expand All @@ -807,7 +808,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
var medias = WwiseProvider.ExtractBankSounds(wwise);
foreach (var media in medias)
{
SaveAndPlaySound(media.OutputPath, media.Extension, media.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, media.OutputPath, media.Extension, media.Data, saveAudio, updateUi);
}

break;
Expand All @@ -823,7 +824,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
var extractedSounds = CriWareProvider.ExtractCriWareSounds(awbReader, archive.Name);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
}

break;
Expand All @@ -839,7 +840,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
var extractedSounds = CriWareProvider.ExtractCriWareSounds(acbReader, archive.Name);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
}

break;
Expand All @@ -854,7 +855,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
// todo: CSCore.MediaFoundation.MediaFoundationException The byte stream type of the given URL is unsupported. case "aif":
{
var data = Provider.SaveAsset(entry);
SaveAndPlaySound(entry.PathWithoutExtension, entry.Extension, data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, entry.PathWithoutExtension, entry.Extension, data, saveAudio, updateUi);

break;
}
Expand Down Expand Up @@ -1114,15 +1115,24 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
case UExternalSource when (isNone || saveAudio) && pointer.Object.Value is UExternalSource externalSource:
{
var audioName = Path.GetFileNameWithoutExtension(externalSource.ExternalSourcePath);
SaveAndPlaySound(audioName, "wem", externalSource.Data?.WemFile ?? [], saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, audioName, "wem", externalSource.Data?.WemFile ?? [], saveAudio, updateUi);
return false;
}
case UAkAudioBank when (isNone || saveAudio) && pointer.Object.Value is UAkAudioBank soundBank:
{
var extractedSounds = WwiseProvider.ExtractBankSounds(soundBank);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(cancellationToken, sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
case UAkAudioEvent when (isNone || saveAudio) && pointer.Object.Value is UAkAudioEvent audioEvent:
{
var extractedSounds = WwiseProvider.ExtractAudioEventSounds(audioEvent);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
Expand All @@ -1132,7 +1142,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var directory = Path.GetDirectoryName(fmodEvent.Owner?.Name) ?? "/FMOD/Desktop/";
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
Expand All @@ -1142,7 +1152,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var directory = Path.GetDirectoryName(fmodBank.Owner?.Name) ?? "/FMOD/Desktop/";
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
Expand All @@ -1161,7 +1171,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
directory = Path.GetDirectoryName(atomObject.Owner.Provider.FixPath(directory));
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name).Replace("\\", "/"), sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name).Replace("\\", "/"), sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
Expand All @@ -1181,7 +1191,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
return false;
}

SaveAndPlaySound(TabControl.SelectedTab.Entry.PathWithoutExtension.Replace('\\', '/'), audioFormat, data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, TabControl.SelectedTab.Entry.PathWithoutExtension.Replace('\\', '/'), audioFormat, data, saveAudio, updateUi);
return false;
}
case UAkMediaAsset when (isNone || saveAudio) && pointer.Object.Value is UAkMediaAsset akMediaAsset:
Expand All @@ -1192,7 +1202,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var shouldDecompress = UserSettings.Default.CompressedAudioMode is ECompressedAudio.PlayDecompressed;
akMediaAssetData.Decode(shouldDecompress, out var audioFormat, out var data);

SaveAndPlaySound(audioName, audioFormat, data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, audioName, audioFormat, data, saveAudio, updateUi);
}
return false;
}
Expand All @@ -1208,12 +1218,22 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var audioName = akMediaAsset.MediaName ?? $"{akAudioEventData.Outer.Name} ({akMediaAsset.ID})";
akMediaAssetData.Decode(shouldDecompress, out var audioFormat, out var data);

SaveAndPlaySound(audioName, audioFormat, data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, audioName, audioFormat, data, saveAudio, updateUi);
}
}
}
return false;
}
// Borderlands 3
case UDialogPerformanceData when (isNone || saveAudio) && pointer.Object.Value is UDialogPerformanceData dialogPerformanceData:
{
var extractedSounds = WwiseProvider.ExtractDialogBorderlands3(dialogPerformanceData);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(cancellationToken, sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
}
return false;
}
// Borderlands 4
case UFaceFXAnimSet when (isNone || saveAudio) && pointer.Object.Value is UFaceFXAnimSet faceFXAnimSet:
{
Expand All @@ -1225,7 +1245,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var extractedSounds = WwiseProvider.ExtractAudioEventBorderlands4(faceFXAnimData.ID.Name, false);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
}
}

Expand All @@ -1239,7 +1259,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
var extractedSounds = WwiseProvider.ExtractAudioEventBorderlands4(eventName, useSoundTag);
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
SaveAndPlaySound(cancellationToken, sound.OutputPath, sound.Extension, sound.Data, saveAudio, updateUi);
}
}

Expand Down Expand Up @@ -1379,14 +1399,15 @@ public void Decompile(GameFile entry)
TabControl.SelectedTab.SetDocumentText(cpp, false, false);
}

private void SaveAndPlaySound(string fullPath, string ext, byte[] data, bool isBulk, bool updateUi)
private void SaveAndPlaySound(CancellationToken cancellationToken, string fullPath, string ext, byte[] data, bool isBulk, bool updateUi)
{
if (fullPath.StartsWith('/')) fullPath = fullPath[1..];
var savedAudioPath = Path.Combine(UserSettings.Default.AudioDirectory,
UserSettings.Default.KeepDirectoryStructure ? fullPath : fullPath.SubstringAfterLast('/')).Replace('\\', '/') + $".{ext.ToLowerInvariant()}";

if (isBulk)
{
cancellationToken.ThrowIfCancellationRequested();
Directory.CreateDirectory(savedAudioPath.SubstringBeforeLast('/'));
using var stream = new FileStream(savedAudioPath, FileMode.Create, FileAccess.Write);
using (var writer = new BinaryWriter(stream))
Expand All @@ -1398,7 +1419,18 @@ private void SaveAndPlaySound(string fullPath, string ext, byte[] data, bool isB
if (UserSettings.Default.ConvertAudioOnBulkExport)
{
AudioPlayerViewModel.TryConvert(savedAudioPath, data, out string wavFilePath);
savedAudioPath = wavFilePath;
if (!string.IsNullOrEmpty(wavFilePath))
{
savedAudioPath = wavFilePath;
}
else if (updateUi)
{
FLogger.Append(ELog.Error, () =>
{
FLogger.Text("Failed to convert audio to WAV format, aborting extraction.", Constants.WHITE, true);
});
return;
}
}

Log.Information("Successfully saved {FilePath}", savedAudioPath);
Expand Down
11 changes: 9 additions & 2 deletions FModel/ViewModels/GameFileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Media.Imaging;

using CUE4Parse.FileProvider.Objects;
using CUE4Parse.GameTypes.Borderlands3.Assets.Exports;
using CUE4Parse.GameTypes.Borderlands4.Assets.Exports;
using CUE4Parse.GameTypes.FN.Assets.Exports.DataAssets;
using CUE4Parse.GameTypes.SMG.UE4.Assets.Exports.Wwise;
Expand Down Expand Up @@ -257,8 +258,9 @@ or USoundAtomCueSheet or UAkAudioType or UExternalSource or UExternalSourceBank
UNiagaraSystem or UNiagaraScriptBase or UParticleSystem => (EAssetCategory.Particle, EBulkType.None),

// Game specific assets below
UGbxGraphAsset => (EAssetCategory.Borderlands4, EBulkType.Audio), // Borderlands 4
UFaceFXAnimSet when _applicationView.CUE4Parse?.Provider.Versions.Game is EGame.GAME_Borderlands4 => (EAssetCategory.Borderlands4, EBulkType.Audio), // Borderlands 4
UBorderlandsDialogObject => (EAssetCategory.Borderlands, EBulkType.None), // Borderlands 3;
UGbxGraphAsset or UDialogScriptData or UDialogPerformanceData => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4; Borderlands 3;
UFaceFXAnimSet when _applicationView.CUE4Parse?.Provider.Versions.Game is EGame.GAME_Borderlands4 => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4;

_ => (EAssetCategory.All, EBulkType.None),
};
Expand Down Expand Up @@ -427,6 +429,11 @@ private Task ResolveByExtensionAsync(EResolveCompute resolve)
bitmap.Dispose();
});
}
// Game specific extensions below
case "ace": // Borderlands 3
case "ncs": // Borderlands 4
AssetCategory = EAssetCategory.Borderlands;
break;
default:
AssetCategory = EAssetCategory.All; // just so it sets resolved
break;
Expand Down
3 changes: 2 additions & 1 deletion FModel/Views/Resources/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<SolidColorBrush x:Key="AudioBrush" Color="MediumSeaGreen" />
<SolidColorBrush x:Key="SoundBankBrush" Color="DarkSeaGreen" />
<SolidColorBrush x:Key="AudioEventBrush" Color="DarkTurquoise" />
<SolidColorBrush x:Key="AudioEventBrush" Color="LightSeaGreen" />

<SolidColorBrush x:Key="VideoBrush" Color="IndianRed" />
<SolidColorBrush x:Key="DataTableBrush" Color="SteelBlue" />
Expand All @@ -47,6 +47,7 @@
<SolidColorBrush x:Key="CssBrush" Color="MediumPurple" />
<SolidColorBrush x:Key="GitBrush" Color="Coral" />
<SolidColorBrush x:Key="CsvBrush" Color="ForestGreen" />
<SolidColorBrush x:Key="AIBrush" Color="LightGray" />

<!-- For specific games -->
<SolidColorBrush x:Key="BorderlandsBrush" Color="Yellow"></SolidColorBrush>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur

EAssetCategory.ByteCode => ("CodeIcon", "CodeBrush"),

EAssetCategory.Borderlands4 => ("BorderlandsIcon", "BorderlandsBrush"),
EAssetCategory.Borderlands => ("BorderlandsIcon", "BorderlandsBrush"),

_ => ("AssetIcon", "NeutralBrush")
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

var (geometry, brush) = folderName switch
{
"ai" => ("AIIcon", "AIBrush"),
"textures" or "texture" or "ui" or "icons" or "umgassets" or "hud" or "hdri" or "tex" => ("TextureIconAlt", "TextureBrush"),
"config" or "tags" => ("ConfigIcon", "ConfigBrush"),
"audio" or "wwiseaudio" or "wwise" or "fmod" or "sound" or "sounds" or "cue" => ("AudioIconAlt", "AudioBrush"),
Expand Down
1 change: 1 addition & 0 deletions FModel/Views/Resources/Icons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Geometry x:Key="JavaScriptIcon">M3,3H21V21H3V3M7.73,18.04C8.13,18.89 8.92,19.59 10.27,19.59C11.77,19.59 12.8,18.79 12.8,17.04V11.26H11.1V17C11.1,17.86 10.75,18.08 10.2,18.08C9.62,18.08 9.38,17.68 9.11,17.21L7.73,18.04M13.71,17.86C14.21,18.84 15.22,19.59 16.8,19.59C18.4,19.59 19.6,18.76 19.6,17.23C19.6,15.82 18.79,15.19 17.35,14.57L16.93,14.39C16.2,14.08 15.89,13.87 15.89,13.37C15.89,12.96 16.2,12.64 16.7,12.64C17.18,12.64 17.5,12.85 17.79,13.37L19.1,12.5C18.55,11.54 17.77,11.17 16.7,11.17C15.19,11.17 14.22,12.13 14.22,13.4C14.22,14.78 15.03,15.43 16.25,15.95L16.67,16.13C17.45,16.47 17.91,16.68 17.91,17.26C17.91,17.74 17.46,18.09 16.76,18.09C15.93,18.09 15.45,17.66 15.09,17.06L13.71,17.86Z</Geometry>
<Geometry x:Key="CssIcon">M5,3L4.35,6.34H17.94L17.5,8.5H3.92L3.26,11.83H16.85L16.09,15.64L10.61,17.45L5.86,15.64L6.19,14H2.85L2.06,18L9.91,21L18.96,18L20.16,11.97L20.4,10.76L21.94,3H5Z</Geometry>
<Geometry x:Key="CsvIcon">M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2M15 16L13 20H10L12 16H9V11H15V16M13 9V3.5L18.5 9H13Z</Geometry>
<Geometry x:Key="AIIcon">M12,2A2,2 0 0,1 14,4C14,4.74 13.6,5.39 13,5.73V7H14A7,7 0 0,1 21,14H22A1,1 0 0,1 23,15V18A1,1 0 0,1 22,19H21V20A2,2 0 0,1 19,22H5A2,2 0 0,1 3,20V19H2A1,1 0 0,1 1,18V15A1,1 0 0,1 2,14H3A7,7 0 0,1 10,7H11V5.73C10.4,5.39 10,4.74 10,4A2,2 0 0,1 12,2M7.5,13A2.5,2.5 0 0,0 5,15.5A2.5,2.5 0 0,0 7.5,18A2.5,2.5 0 0,0 10,15.5A2.5,2.5 0 0,0 7.5,13M16.5,13A2.5,2.5 0 0,0 14,15.5A2.5,2.5 0 0,0 16.5,18A2.5,2.5 0 0,0 19,15.5A2.5,2.5 0 0,0 16.5,13Z</Geometry>

<!-- For specific games-->
<Geometry x:Key="BorderlandsIcon">M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6 ZM12,11A3,3 0 1,0 12,17A3,3 0 0,0 12,11 ZM12,12.5L14,16H13L12,14.5L11,16H10L12,12.5Z</Geometry>
Expand Down