16
16
using ME2Explorer . Unreal ;
17
17
using ME1Explorer . Unreal . Classes ;
18
18
using System . Xml ;
19
+ using System . Xml . Linq ;
19
20
20
21
namespace ME3Explorer
21
22
{
@@ -117,7 +118,7 @@ public enum nodeType
117
118
private Dictionary < string , List < PropertyReader . Property > > defaultStructValues ;
118
119
119
120
int ? selectedNodePos = null ;
120
-
121
+ private Dictionary < string , string > ME1_TLK_DICT ;
121
122
public static readonly string [ ] ParsableBinaryClasses = { "Level" , "StaticMeshCollectionActor" , "Class" , "ObjectRedirector" , "Bio2DA" , "Bio2DANumberedRows" , "WwiseEvent" , "Material" , "StaticMesh" , "MaterialInstanceConstant" , "BioDynamicAnimSet" , "StaticMeshComponent" , "SkeletalMeshComponent" , "SkeletalMesh" , "Model" , "Polys" } ; //classes that have binary parse code
122
123
123
124
@@ -126,6 +127,20 @@ public BinaryInterpreter()
126
127
InitializeComponent ( ) ;
127
128
SetTopLevel ( false ) ;
128
129
defaultStructValues = new Dictionary < string , List < PropertyReader . Property > > ( ) ;
130
+
131
+ //Load ME1TLK
132
+ string tlkxmlpath = @"C:\users\mgame\desktop\me1tlk.xml" ;
133
+ if ( File . Exists ( tlkxmlpath ) )
134
+ {
135
+ XDocument xmlDocument = XDocument . Load ( tlkxmlpath ) ;
136
+ ME1_TLK_DICT =
137
+ ( from strings in xmlDocument . Descendants ( "string" )
138
+ select new
139
+ {
140
+ ID = strings . Element ( "id" ) . Value ,
141
+ Data = strings . Element ( "data" ) . Value ,
142
+ } ) . Distinct ( ) . ToDictionary ( o => o . ID , o => o . Data ) ;
143
+ }
129
144
}
130
145
131
146
/// <summary>
@@ -136,19 +151,7 @@ public BinaryInterpreter(IMEPackage importingPCC, IExportEntry importingExport,
136
151
{
137
152
//This will make it fairly slow, but will make it so I don't have to change everything.
138
153
InitializeComponent ( ) ;
139
- //Load ME1TLK
140
- string tlkxmlpath = @"C:\users\dev\desktop\tlk1.xml" ;
141
- if ( File . Exists ( tlkxmlpath ) )
142
- {
143
- XmlDocument xmlDocument = new XmlDocument ( ) ;
144
- xmlDocument . Load ( tlkxmlpath ) ;
145
- var configDictionary =
146
- ( from configDatum in xmlDocument . Descendents ( "string" )
147
- select new {
148
- Name = configDatum . attribute ( "name" ) . Value ,
149
- Value = configDatum . Attribute ( "value" ) . Value ,
150
- } ) . ToDictionary ( o => o . Name , o => o . Value ) ;
151
- }
154
+
152
155
153
156
SetTopLevel ( false ) ;
154
157
defaultStructValues = new Dictionary < string , List < PropertyReader . Property > > ( ) ;
@@ -351,6 +354,9 @@ private void StartObjectRedirectorScan(string nodeNameToSelect = null)
351
354
352
355
private void StartBio2DAScan ( string nodeNameToSelect = null )
353
356
{
357
+ Random random = new Random ( ) ;
358
+ string [ ] stringRefColumns = { "StringRef" , "SaveGameStringRef" , "Title" , "LabelRef" , "Name" , "ActiveWorld" , "Description" , "ButtonLabel" } ;
359
+
354
360
resetPropEditingControls ( ) ;
355
361
treeView1 . BeginUpdate ( ) ;
356
362
treeView1 . Nodes . Clear ( ) ;
@@ -363,18 +369,30 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
363
369
{
364
370
string rowLabelsVar = "m_sRowLabel" ;
365
371
var props = export . GetProperty < ArrayProperty < NameProperty > > ( rowLabelsVar ) ;
366
- foreach ( NameProperty n in props )
372
+ if ( props != null )
367
373
{
368
- rowNames . Add ( n . ToString ( ) ) ;
374
+ foreach ( NameProperty n in props )
375
+ {
376
+ rowNames . Add ( n . ToString ( ) ) ;
377
+ }
378
+ } else
379
+ {
380
+ return ;
369
381
}
370
382
}
371
383
else
372
384
{
373
385
string rowLabelsVar = "m_lstRowNumbers" ; //Bio2DANumberedRows
374
386
var props = export . GetProperty < ArrayProperty < IntProperty > > ( rowLabelsVar ) ;
375
- foreach ( IntProperty n in props )
387
+ if ( props != null )
376
388
{
377
- rowNames . Add ( n . Value . ToString ( ) ) ;
389
+ foreach ( IntProperty n in props )
390
+ {
391
+ rowNames . Add ( n . Value . ToString ( ) ) ;
392
+ }
393
+ } else
394
+ {
395
+ return ;
378
396
}
379
397
}
380
398
@@ -416,7 +434,7 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
416
434
if ( cellcount > 0 )
417
435
{
418
436
419
- TreeNode node = new TreeNode ( curroffset . ToString ( "X4" ) + " # of cells in this Bio2DA?? : " + cellcount ) ;
437
+ TreeNode node = new TreeNode ( curroffset . ToString ( "X4" ) + " Number of cells in this Bio2DA : " + cellcount ) ;
420
438
node . Name = curroffset . ToString ( ) ;
421
439
topLevelTree . Nodes . Add ( node ) ;
422
440
curroffset += 4 ;
@@ -445,6 +463,14 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
445
463
//int
446
464
int ival = BitConverter . ToInt32 ( data , curroffset ) ;
447
465
valueStr = ival . ToString ( ) ;
466
+ if ( stringRefColumns . Contains ( columnNames [ colindex ] ) )
467
+ {
468
+ string tlkVal ;
469
+ if ( ME1_TLK_DICT != null && ME1_TLK_DICT . TryGetValue ( valueStr , out tlkVal ) )
470
+ {
471
+ valueStr += " " + tlkVal ;
472
+ }
473
+ }
448
474
curroffset += 4 ;
449
475
tag = nodeType . StructLeafInt ;
450
476
break ;
@@ -457,21 +483,22 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
457
483
break ;
458
484
case 2 :
459
485
//float
486
+ float f = NextFloat ( random ) ;
487
+ while ( f < 0 )
488
+ {
489
+ f = NextFloat ( random ) ;
490
+ }
491
+ byte [ ] buff2 = BitConverter . GetBytes ( f ) ;
492
+ for ( int o = 0 ; o < 4 ; o ++ )
493
+ {
494
+ data [ curroffset + o ] = buff2 [ o ] ;
495
+ }
496
+
460
497
float fval = BitConverter . ToSingle ( data , curroffset ) ;
461
498
valueStr = fval . ToString ( ) ;
462
499
curroffset += 4 ;
463
500
tag = nodeType . StructLeafFloat ;
464
501
break ;
465
- case 255 :
466
- int unval = BitConverter . ToInt32 ( data , curroffset ) ;
467
- valueStr = unval . ToString ( ) ;
468
- curroffset += 4 ;
469
- break ;
470
- default :
471
- valueStr = "UNKNOWN DATATYPE " + dataType + " " + BitConverter . ToInt32 ( data , curroffset ) ;
472
- curroffset += 4 ;
473
- break ;
474
-
475
502
}
476
503
477
504
node = new TreeNode ( offsetstr + " " + columnNames [ colindex ] + ": " + valueStr ) ;
@@ -491,10 +518,9 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
491
518
}
492
519
else
493
520
{
494
- string [ ] stringRefColumns = { "StringRef" } ;
495
521
curroffset += 4 ; //theres a 0 here for some reason
496
522
cellcount = BitConverter . ToInt32 ( data , curroffset ) ;
497
- TreeNode node = new TreeNode ( curroffset . ToString ( "X4" ) + " INDEXED # of cells in this Bio2DA?? : " + cellcount ) ;
523
+ TreeNode node = new TreeNode ( curroffset . ToString ( "X4" ) + " Number of indexed cells in this Bio2DA: " + cellcount ) ;
498
524
node . Name = curroffset . ToString ( ) ;
499
525
topLevelTree . Nodes . Add ( node ) ;
500
526
curroffset += 4 ; //theres a 0 here for some reason
@@ -532,6 +558,14 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
532
558
if ( cell != null )
533
559
{
534
560
columnNode = new TreeNode ( columnname + ": " + cell . GetDisplayableValue ( ) ) ;
561
+ if ( stringRefColumns . Contains ( columnname ) )
562
+ {
563
+ string tlkVal ;
564
+ if ( ME1_TLK_DICT != null && ME1_TLK_DICT . TryGetValue ( cell . GetDisplayableValue ( ) , out tlkVal ) )
565
+ {
566
+ columnNode . Text += " " + tlkVal ;
567
+ }
568
+ }
535
569
switch ( cell . Type )
536
570
{
537
571
case Bio2DACell . TYPE_FLOAT :
@@ -541,14 +575,7 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
541
575
columnNode . Tag = nodeType . StructLeafName ;
542
576
break ;
543
577
case Bio2DACell . TYPE_INT :
544
- if ( stringRefColumns . Contains ( columnname ) )
545
- {
546
- columnNode . Tag = nodeType . StringRefProperty ;
547
- }
548
- else
549
- {
550
- columnNode . Tag = nodeType . StructLeafInt ;
551
- }
578
+ columnNode . Tag = nodeType . StructLeafInt ;
552
579
break ;
553
580
}
554
581
columnNode . Name = cell . Offset . ToString ( ) ;
@@ -560,81 +587,6 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
560
587
rownode . Nodes . Add ( columnNode ) ;
561
588
}
562
589
}
563
- // //TreeNode rownode = new TreeNode(curroffset.ToString("X4") + ": " + rowNames[i]);
564
- // //rownode.Name = curroffset.ToString();
565
- // //topLevelTree.Nodes.Add(rownode);
566
- // curroffset += 4;
567
- //{
568
- // int index = BitConverter.ToInt32(data, curroffset);
569
- // Console.WriteLine("Index difference " + (index - currentindex));
570
- // try
571
- // {
572
- // if (index - currentindex != 1 && currentindex != -1)
573
- // {
574
- // //skip some columns
575
- // for (int x = 0; x < index - currentindex && colindex + x < columnNames.Count(); x++)
576
- // {
577
- // node = new TreeNode(columnNames[colindex + x] + ": Skipped by table");
578
- // rownode.Nodes.Add(node);
579
- // }
580
- // colindex += index - currentindex;
581
- // continue;
582
- // }
583
- // }
584
- // catch (Exception e)
585
- // {
586
- // // Console.WriteLine(e.Message);
587
- // }
588
- // currentindex = index;
589
- // numindexed++;
590
- // curroffset += 4;
591
- // byte dataType = 255;
592
- // //if (cellcount != 0)
593
- // //{
594
- // dataType = data[curroffset];
595
- // curroffset++;
596
- // //}
597
- // string valueStr = "";
598
- // string nodename = curroffset.ToString();
599
- // string offsetstr = curroffset.ToString("X4");
600
- // switch (dataType)
601
- // {
602
-
603
- // case 0:
604
- // //int
605
- // int ival = BitConverter.ToInt32(data, curroffset);
606
- // valueStr = ival.ToString();
607
- // curroffset += 4;
608
- // break;
609
- // case 1:
610
- // //name
611
- // int nval = BitConverter.ToInt32(data, curroffset);
612
- // valueStr = pcc.getNameEntry(nval);
613
- // curroffset += 8;
614
- // break;
615
- // case 2:
616
- // //float
617
- // float fval = BitConverter.ToSingle(data, curroffset);
618
- // valueStr = fval.ToString();
619
- // curroffset += 4;
620
- // break;
621
- // case 255:
622
- // int unval = BitConverter.ToInt32(data, curroffset);
623
- // valueStr = unval.ToString();
624
- // curroffset += 4;
625
- // break;
626
- // default:
627
- // valueStr = "UNKNOWN DATATYPE " + dataType + " " + BitConverter.ToInt32(data, curroffset);
628
- // curroffset += 4;
629
- // break;
630
-
631
- // }
632
-
633
- // node = new TreeNode(offsetstr + " " + columnNames[colindex] + " as index " + index + ": " + valueStr);
634
- // node.Name = nodename;
635
- // rownode.Nodes.Add(node);
636
- // }
637
- //}
638
590
TreeNode nodex = new TreeNode ( "Number of nodes indexed: " + numindexed ) ;
639
591
treeView1 . Nodes . Add ( nodex ) ;
640
592
}
@@ -660,9 +612,18 @@ private void StartBio2DAScan(string nodeNameToSelect = null)
660
612
topLevelTree . Name = "0" ;
661
613
662
614
treeView1 . EndUpdate ( ) ;
615
+ memory = data ;
616
+ export . Data = data ;
663
617
memsize = memory . Length ;
664
618
}
665
619
620
+ static float NextFloat ( Random random )
621
+ {
622
+ double mantissa = ( random . NextDouble ( ) * 2.0 ) - 1.0 ;
623
+ double exponent = Math . Pow ( 2.0 , random . Next ( - 3 , 20 ) ) ;
624
+ return ( float ) ( mantissa * exponent ) ;
625
+ }
626
+
666
627
private void StartWWiseEventScan ( string nodeNameToSelect = null )
667
628
{
668
629
resetPropEditingControls ( ) ;
0 commit comments