@@ -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" :
@@ -740,7 +744,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
740744 var medias = WwiseProvider . ExtractBankSounds ( wwise ) ;
741745 foreach ( var media in medias )
742746 {
743- SaveAndPlaySound ( media . OutputPath , media . Extension , media . Data ) ;
747+ SaveAndPlaySound ( media . OutputPath , media . Extension , media . Data , saveAudio ) ;
744748 }
745749
746750 break ;
@@ -755,7 +759,7 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
755759 // todo: CSCore.MediaFoundation.MediaFoundationException The byte stream type of the given URL is unsupported. case "aif":
756760 {
757761 var data = Provider . SaveAsset ( entry ) ;
758- SaveAndPlaySound ( entry . PathWithoutExtension , entry . Extension , data ) ;
762+ SaveAndPlaySound ( entry . PathWithoutExtension , entry . Extension , data , saveAudio ) ;
759763
760764 break ;
761765 }
@@ -870,6 +874,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
870874 var isNone = bulk == EBulkType . None ;
871875 var updateUi = ! HasFlag ( bulk , EBulkType . Auto ) ;
872876 var saveTextures = HasFlag ( bulk , EBulkType . Textures ) ;
877+ var saveAudio = HasFlag ( bulk , EBulkType . Audio ) ;
873878
874879 var pointer = new FPackageIndex ( pkg , index + 1 ) . ResolvedObject ;
875880 if ( pointer ? . Object is null ) return false ;
@@ -940,37 +945,37 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
940945 TabControl . SelectedTab . AddImage ( sourceFile . SubstringAfterLast ( '/' ) , false , bitmap , false , updateUi ) ;
941946 return false ;
942947 }
943- case UAkAudioEvent when isNone && pointer . Object . Value is UAkAudioEvent audioEvent :
948+ case UAkAudioEvent when ( isNone || saveAudio ) && pointer . Object . Value is UAkAudioEvent audioEvent :
944949 {
945950 var extractedSounds = WwiseProvider . ExtractAudioEventSounds ( audioEvent ) ;
946951 foreach ( var sound in extractedSounds )
947952 {
948- SaveAndPlaySound ( sound . OutputPath , sound . Extension , sound . Data ) ;
953+ SaveAndPlaySound ( sound . OutputPath , sound . Extension , sound . Data , saveAudio ) ;
949954 }
950955 return false ;
951956 }
952- case UFMODEvent when isNone && pointer . Object . Value is UFMODEvent fmodEvent :
957+ case UFMODEvent when ( isNone || saveAudio ) && pointer . Object . Value is UFMODEvent fmodEvent :
953958 {
954959 var extractedSounds = FmodProvider . ExtractEventSounds ( fmodEvent ) ;
955960 var directory = Path . GetDirectoryName ( fmodEvent . Owner ? . Name ) ?? "/FMOD/Desktop/" ;
956961 foreach ( var sound in extractedSounds )
957962 {
958- SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data ) ;
963+ SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data , saveAudio ) ;
959964 }
960965 return false ;
961966 }
962- case UFMODBank when isNone && pointer . Object . Value is UFMODBank fmodBank :
967+ case UFMODBank when ( isNone || saveAudio ) && pointer . Object . Value is UFMODBank fmodBank :
963968 {
964969 var extractedSounds = FmodProvider . ExtractBankSounds ( fmodBank ) ;
965970 var directory = Path . GetDirectoryName ( fmodBank . Owner ? . Name ) ?? "/FMOD/Desktop/" ;
966971 foreach ( var sound in extractedSounds )
967972 {
968- SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data ) ;
973+ SaveAndPlaySound ( Path . Combine ( directory , sound . Name ) , sound . Extension , sound . Data , saveAudio ) ;
969974 }
970975 return false ;
971976 }
972- case UAkMediaAssetData when isNone :
973- case USoundWave when isNone :
977+ case UAkMediaAssetData when isNone || saveAudio :
978+ case USoundWave when isNone || saveAudio :
974979 {
975980 var shouldDecompress = UserSettings . Default . CompressedAudioMode == ECompressedAudio . PlayDecompressed ;
976981 pointer . Object . Value . Decode ( shouldDecompress , out var audioFormat , out var data ) ;
@@ -981,7 +986,7 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
981986 return false ;
982987 }
983988
984- SaveAndPlaySound ( TabControl . SelectedTab . Entry . PathWithoutExtension . Replace ( '\\ ' , '/' ) , audioFormat , data ) ;
989+ SaveAndPlaySound ( TabControl . SelectedTab . Entry . PathWithoutExtension . Replace ( '\\ ' , '/' ) , audioFormat , data , saveAudio ) ;
985990 return false ;
986991 }
987992 case UWorld when isNone && UserSettings . Default . PreviewWorlds :
@@ -1102,13 +1107,13 @@ public void Decompile(GameFile entry)
11021107 TabControl . SelectedTab . SetDocumentText ( cpp , false , false ) ;
11031108 }
11041109
1105- private void SaveAndPlaySound ( string fullPath , string ext , byte [ ] data )
1110+ private void SaveAndPlaySound ( string fullPath , string ext , byte [ ] data , bool isBulk )
11061111 {
11071112 if ( fullPath . StartsWith ( '/' ) ) fullPath = fullPath [ 1 ..] ;
11081113 var savedAudioPath = Path . Combine ( UserSettings . Default . AudioDirectory ,
11091114 UserSettings . Default . KeepDirectoryStructure ? fullPath : fullPath . SubstringAfterLast ( '/' ) ) . Replace ( '\\ ' , '/' ) + $ ".{ ext . ToLowerInvariant ( ) } ";
11101115
1111- if ( ! UserSettings . Default . IsAutoOpenSounds )
1116+ if ( isBulk )
11121117 {
11131118 Directory . CreateDirectory ( savedAudioPath . SubstringBeforeLast ( '/' ) ) ;
11141119 using var stream = new FileStream ( savedAudioPath , FileMode . Create , FileAccess . Write ) ;
0 commit comments