@@ -505,6 +505,96 @@ private static void BuildAssetMap(string file, List<AssetEntry> assets, ClassIDT
505
505
}
506
506
}
507
507
508
+ public static string [ ] ParseAssetMap ( string mapName , ExportListType mapType , ClassIDType [ ] typeFilter , Regex [ ] nameFilter , Regex [ ] containerFilter )
509
+ {
510
+ var matches = new HashSet < string > ( ) ;
511
+
512
+ switch ( mapType )
513
+ {
514
+ case ExportListType . MessagePack :
515
+ {
516
+ using var stream = File . OpenRead ( mapName ) ;
517
+ var assetMap = MessagePackSerializer . Deserialize < AssetMap > ( stream , MessagePackSerializerOptions . Standard . WithCompression ( MessagePackCompression . Lz4BlockArray ) ) ;
518
+ foreach ( var entry in assetMap . AssetEntries )
519
+ {
520
+ var isNameMatch = nameFilter . Length == 0 || nameFilter . Any ( x => x . IsMatch ( entry . Name ) ) ;
521
+ var isContainerMatch = containerFilter . Length == 0 || containerFilter . Any ( x => x . IsMatch ( entry . Container ) ) ;
522
+ var isTypeMatch = typeFilter . Length == 0 || typeFilter . Any ( x => x == entry . Type ) ;
523
+ if ( isNameMatch && isContainerMatch && isTypeMatch )
524
+ {
525
+ matches . Add ( entry . Source ) ;
526
+ }
527
+ }
528
+ }
529
+
530
+ break ;
531
+ case ExportListType . XML :
532
+ {
533
+ using var stream = File . OpenRead ( mapName ) ;
534
+ using var reader = XmlReader . Create ( stream ) ;
535
+ reader . ReadToFollowing ( "Assets" ) ;
536
+ reader . ReadToFollowing ( "Asset" ) ;
537
+ do
538
+ {
539
+ reader . ReadToFollowing ( "Name" ) ;
540
+ var name = reader . ReadInnerXml ( ) ;
541
+
542
+ var isNameMatch = nameFilter . Length == 0 || nameFilter . Any ( x => x . IsMatch ( name ) ) ;
543
+
544
+ reader . ReadToFollowing ( "Container" ) ;
545
+ var container = reader . ReadInnerXml ( ) ;
546
+
547
+ var isContainerMatch = containerFilter . Length == 0 || containerFilter . Any ( x => x . IsMatch ( container ) ) ;
548
+
549
+ reader . ReadToFollowing ( "Type" ) ;
550
+ var type = reader . ReadInnerXml ( ) ;
551
+
552
+ var isTypeMatch = typeFilter . Length == 0 || typeFilter . Any ( x => x . ToString ( ) . Equals ( type , StringComparison . OrdinalIgnoreCase ) ) ;
553
+
554
+ reader . ReadToFollowing ( "PathID" ) ;
555
+ var pathID = reader . ReadInnerXml ( ) ;
556
+
557
+ reader . ReadToFollowing ( "Source" ) ;
558
+ var source = reader . ReadInnerXml ( ) ;
559
+
560
+ if ( isNameMatch && isContainerMatch && isTypeMatch )
561
+ {
562
+ matches . Add ( source ) ;
563
+ }
564
+
565
+ reader . ReadEndElement ( ) ;
566
+ } while ( reader . ReadToNextSibling ( "Asset" ) ) ;
567
+ }
568
+
569
+ break ;
570
+ case ExportListType . JSON :
571
+ {
572
+ using var stream = File . OpenRead ( mapName ) ;
573
+ using var file = new StreamReader ( stream ) ;
574
+ using var reader = new JsonTextReader ( file ) ;
575
+
576
+ var serializer = new JsonSerializer ( ) { Formatting = Newtonsoft . Json . Formatting . Indented } ;
577
+ serializer . Converters . Add ( new StringEnumConverter ( ) ) ;
578
+
579
+ var entries = serializer . Deserialize < List < AssetEntry > > ( reader ) ;
580
+ foreach ( var entry in entries )
581
+ {
582
+ var isNameMatch = nameFilter . Length == 0 || nameFilter . Any ( x => x . IsMatch ( entry . Name ) ) ;
583
+ var isContainerMatch = containerFilter . Length == 0 || containerFilter . Any ( x => x . IsMatch ( entry . Container ) ) ;
584
+ var isTypeMatch = typeFilter . Length == 0 || typeFilter . Any ( x => x == entry . Type ) ;
585
+ if ( isNameMatch && isContainerMatch && isTypeMatch )
586
+ {
587
+ matches . Add ( entry . Source ) ;
588
+ }
589
+ }
590
+ }
591
+
592
+ break ;
593
+ }
594
+
595
+ return matches . ToArray ( ) ;
596
+ }
597
+
508
598
private static void UpdateContainers ( List < AssetEntry > assets , Game game )
509
599
{
510
600
if ( game . Type . IsGISubGroup ( ) && assets . Count > 0 )
0 commit comments