@@ -583,6 +583,9 @@ public void ModelFolder(CancellationToken cancellationToken, TreeItem folder)
583583 public void AnimationFolder ( CancellationToken cancellationToken , TreeItem folder )
584584 => BulkFolder ( cancellationToken , folder , asset => Extract ( cancellationToken , asset , TabControl . HasNoTabs , EBulkType . Animations | EBulkType . Auto ) ) ;
585585
586+ public void AudioFolder ( CancellationToken cancellationToken , TreeItem folder )
587+ => BulkFolder ( cancellationToken , folder , asset => Extract ( cancellationToken , asset , TabControl . HasNoTabs , EBulkType . Audio | EBulkType . Auto ) ) ;
588+
586589 public void Extract ( CancellationToken cancellationToken , GameFile entry , bool addNewTab = false , EBulkType bulk = EBulkType . None )
587590 {
588591 Log . Information ( "User DOUBLE-CLICKED to extract '{FullPath}'" , entry . Path ) ;
@@ -594,6 +597,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
594597 var updateUi = ! HasFlag ( bulk , EBulkType . Auto ) ;
595598 var saveProperties = HasFlag ( bulk , EBulkType . Properties ) ;
596599 var saveTextures = HasFlag ( bulk , EBulkType . Textures ) ;
600+ var saveAudio = HasFlag ( bulk , EBulkType . Audio ) ;
597601 switch ( entry . Extension )
598602 {
599603 case "uasset" :
@@ -738,7 +742,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
738742 var medias = WwiseProvider . ExtractBankSounds ( wwise ) ;
739743 foreach ( var media in medias )
740744 {
741- SaveAndPlaySound ( media . OutputPath , media . Extension , media . Data ) ;
745+ SaveAndPlaySound ( media . OutputPath , media . Extension , media . Data , saveAudio ) ;
742746 }
743747
744748 break ;
@@ -753,7 +757,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
753757 // todo: CSCore.MediaFoundation.MediaFoundationException The byte stream type of the given URL is unsupported. case "aif":
754758 {
755759 var data = Provider . SaveAsset ( entry ) ;
756- SaveAndPlaySound ( entry . PathWithoutExtension , entry . Extension , data ) ;
760+ SaveAndPlaySound ( entry . PathWithoutExtension , entry . Extension , data , saveAudio ) ;
757761
758762 break ;
759763 }
@@ -868,6 +872,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
868872 var isNone = bulk == EBulkType . None ;
869873 var updateUi = ! HasFlag ( bulk , EBulkType . Auto ) ;
870874 var saveTextures = HasFlag ( bulk , EBulkType . Textures ) ;
875+ var saveAudio = HasFlag ( bulk , EBulkType . Audio ) ;
871876
872877 var pointer = new FPackageIndex ( pkg , index + 1 ) . ResolvedObject ;
873878 if ( pointer ? . Object is null ) return false ;
@@ -938,37 +943,37 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
938943 TabControl . SelectedTab . AddImage ( sourceFile . SubstringAfterLast ( '/' ) , false , bitmap , false , updateUi ) ;
939944 return false ;
940945 }
941- case UAkAudioEvent when isNone && pointer . Object . Value is UAkAudioEvent audioEvent :
946+ case UAkAudioEvent when ( isNone || saveAudio ) && pointer . Object . Value is UAkAudioEvent audioEvent :
942947 {
943948 var extractedSounds = WwiseProvider . ExtractAudioEventSounds ( audioEvent ) ;
944949 foreach ( var sound in extractedSounds )
945950 {
946- SaveAndPlaySound ( sound . OutputPath , sound . Extension , sound . Data ) ;
951+ SaveAndPlaySound ( sound . OutputPath , sound . Extension , sound . Data , saveAudio ) ;
947952 }
948953 return false ;
949954 }
950- case UFMODEvent when isNone && pointer . Object . Value is UFMODEvent fmodEvent :
955+ case UFMODEvent when ( isNone || saveAudio ) && pointer . Object . Value is UFMODEvent fmodEvent :
951956 {
952957 var extractedSounds = FmodProvider . ExtractEventSounds ( fmodEvent ) ;
953958 var directory = Path . GetDirectoryName ( fmodEvent . Owner ? . Name ) ?? "/FMOD/Desktop/" ;
954959 foreach ( var sound in extractedSounds )
955960 {
956- SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data ) ;
961+ SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data , saveAudio ) ;
957962 }
958963 return false ;
959964 }
960- case UFMODBank when isNone && pointer . Object . Value is UFMODBank fmodBank :
965+ case UFMODBank when ( isNone || saveAudio ) && pointer . Object . Value is UFMODBank fmodBank :
961966 {
962967 var extractedSounds = FmodProvider . ExtractBankSounds ( fmodBank ) ;
963968 var directory = Path . GetDirectoryName ( fmodBank . Owner ? . Name ) ?? "/FMOD/Desktop/" ;
964969 foreach ( var sound in extractedSounds )
965970 {
966- SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data ) ;
971+ SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data , saveAudio ) ;
967972 }
968973 return false ;
969974 }
970- case UAkMediaAssetData when isNone :
971- case USoundWave when isNone :
975+ case UAkMediaAssetData when isNone || saveAudio :
976+ case USoundWave when isNone || saveAudio :
972977 {
973978 var shouldDecompress = UserSettings . Default . CompressedAudioMode == ECompressedAudio . PlayDecompressed ;
974979 pointer . Object . Value . Decode ( shouldDecompress , out var audioFormat , out var data ) ;
@@ -979,7 +984,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
979984 return false ;
980985 }
981986
982- SaveAndPlaySound ( TabControl . SelectedTab . Entry . PathWithoutExtension . Replace ( '\\ ' , '/' ) , audioFormat , data ) ;
987+ SaveAndPlaySound ( TabControl . SelectedTab . Entry . PathWithoutExtension . Replace ( '\\ ' , '/' ) , audioFormat , data , saveAudio ) ;
983988 return false ;
984989 }
985990 case UWorld when isNone && UserSettings . Default . PreviewWorlds :
@@ -1100,13 +1105,13 @@ public void Decompile(GameFile entry)
11001105 TabControl . SelectedTab . SetDocumentText ( cpp , false , false ) ;
11011106 }
11021107
1103- private void SaveAndPlaySound ( string fullPath , string ext , byte [ ] data )
1108+ private void SaveAndPlaySound ( string fullPath , string ext , byte [ ] data , bool isBulk )
11041109 {
11051110 if ( fullPath . StartsWith ( '/' ) ) fullPath = fullPath [ 1 ..] ;
11061111 var savedAudioPath = Path . Combine ( UserSettings . Default . AudioDirectory ,
11071112 UserSettings . Default . KeepDirectoryStructure ? fullPath : fullPath . SubstringAfterLast ( '/' ) ) . Replace ( '\\ ' , '/' ) + $ ".{ ext . ToLowerInvariant ( ) } ";
11081113
1109- if ( ! UserSettings . Default . IsAutoOpenSounds )
1114+ if ( ! UserSettings . Default . IsAutoOpenSounds || isBulk )
11101115 {
11111116 Directory . CreateDirectory ( savedAudioPath . SubstringBeforeLast ( '/' ) ) ;
11121117 using var stream = new FileStream ( savedAudioPath , FileMode . Create , FileAccess . Write ) ;
@@ -1188,4 +1193,4 @@ private static bool HasFlag(EBulkType a, EBulkType b)
11881193 {
11891194 return ( a & b ) == b ;
11901195 }
1191- }
1196+ }
0 commit comments