@@ -56,6 +56,9 @@ public partial class MainWindow : Window
56
56
Dictionary < string , SolidColorBrush > origResourceColors = new Dictionary < string , SolidColorBrush > ( ) ;
57
57
string themefile = "theme.ini" ;
58
58
59
+ string latestBuildReportProjectPath = null ;
60
+
61
+
59
62
public MainWindow ( )
60
63
{
61
64
InitializeComponent ( ) ;
@@ -285,7 +288,7 @@ void LoadSettings()
285
288
lstRootFolders . Items . Clear ( ) ;
286
289
lstRootFolders . ItemsSource = Properties . Settings . Default . rootFolders ;
287
290
288
- // restore datagrid column widths
291
+ // restore recent project datagrid column widths
289
292
int [ ] gridColumnWidths = Properties . Settings . Default . gridColumnWidths ;
290
293
if ( gridColumnWidths != null )
291
294
{
@@ -296,6 +299,17 @@ void LoadSettings()
296
299
}
297
300
}
298
301
302
+ // restore buildreport datagrid column widths
303
+ gridColumnWidths = Properties . Settings . Default . gridColumnWidthsBuildReport ;
304
+ if ( gridColumnWidths != null )
305
+ {
306
+ for ( int i = 0 ; i < gridColumnWidths . Length ; ++ i )
307
+ {
308
+ if ( i >= gridBuildReport . Columns . Count ) break ; // too many columns were saved, probably some test columns
309
+ gridBuildReport . Columns [ i ] . Width = gridColumnWidths [ i ] ;
310
+ }
311
+ }
312
+
299
313
// other setting vars
300
314
preferredVersion = Properties . Settings . Default . preferredVersion ;
301
315
@@ -322,6 +336,7 @@ void LoadSettings()
322
336
323
337
useHumanFriendlyDateFormat = Properties . Settings . Default . useHumandFriendlyLastModified ;
324
338
339
+
325
340
// recent grid column display index order
326
341
var order = Properties . Settings . Default . recentColumnsOrder ;
327
342
@@ -349,10 +364,13 @@ void LoadSettings()
349
364
350
365
} // LoadSettings()
351
366
367
+
352
368
private void SaveSettingsOnExit ( )
353
369
{
354
- // save list column widths
370
+ // save recent project column widths
355
371
List < int > gridWidths ;
372
+
373
+ // if we dont have any settings yet
356
374
if ( Properties . Settings . Default . gridColumnWidths != null )
357
375
{
358
376
gridWidths = new List < int > ( Properties . Settings . Default . gridColumnWidths ) ;
@@ -362,8 +380,8 @@ private void SaveSettingsOnExit()
362
380
gridWidths = new List < int > ( ) ;
363
381
}
364
382
365
- // restore data grid view widths
366
- var colum = gridRecent . Columns [ 0 ] ;
383
+ // get data grid view widths
384
+ var column = gridRecent . Columns [ 0 ] ;
367
385
for ( int i = 0 ; i < gridRecent . Columns . Count ; ++ i )
368
386
{
369
387
if ( Properties . Settings . Default . gridColumnWidths != null && Properties . Settings . Default . gridColumnWidths . Length > i )
@@ -378,6 +396,36 @@ private void SaveSettingsOnExit()
378
396
Properties . Settings . Default . gridColumnWidths = gridWidths . ToArray ( ) ;
379
397
Properties . Settings . Default . Save ( ) ;
380
398
399
+
400
+ // save buildrepot column widths
401
+ gridWidths . Clear ( ) ;
402
+
403
+ // if we dont have any settings yet
404
+ if ( Properties . Settings . Default . gridColumnWidthsBuildReport != null )
405
+ {
406
+ gridWidths = new List < int > ( Properties . Settings . Default . gridColumnWidthsBuildReport ) ;
407
+ }
408
+ else
409
+ {
410
+ gridWidths = new List < int > ( ) ;
411
+ }
412
+
413
+ // get data grid view widths
414
+ column = gridBuildReport . Columns [ 0 ] ;
415
+ for ( int i = 0 ; i < gridBuildReport . Columns . Count ; ++ i )
416
+ {
417
+ if ( Properties . Settings . Default . gridColumnWidthsBuildReport != null && Properties . Settings . Default . gridColumnWidthsBuildReport . Length > i )
418
+ {
419
+ gridWidths [ i ] = ( int ) gridBuildReport . Columns [ i ] . Width . Value ;
420
+ }
421
+ else
422
+ {
423
+ gridWidths . Add ( ( int ) gridBuildReport . Columns [ i ] . Width . Value ) ;
424
+ }
425
+ }
426
+ Properties . Settings . Default . gridColumnWidthsBuildReport = gridWidths . ToArray ( ) ;
427
+ Properties . Settings . Default . Save ( ) ;
428
+
381
429
}
382
430
383
431
void UpdateUnityInstallationsList ( )
@@ -423,6 +471,11 @@ Updates GetSelectedUpdate()
423
471
return ( Updates ) dataGridUpdates . SelectedItem ;
424
472
}
425
473
474
+ BuildReportItem GetSelectedBuildItem ( )
475
+ {
476
+ return ( BuildReportItem ) gridBuildReport . SelectedItem ;
477
+ }
478
+
426
479
void AddUnityInstallationRootFolder ( )
427
480
{
428
481
var dialog = new System . Windows . Forms . FolderBrowserDialog ( ) ;
@@ -1635,54 +1688,42 @@ private void GridRecent_ContextMenuOpening(object sender, ContextMenuEventArgs e
1635
1688
1636
1689
private void BtnRefreshBuildReport_Click ( object sender , RoutedEventArgs e )
1637
1690
{
1638
- // TODO keep previous build report (total size?) so can compare to current one
1639
-
1640
1691
var logFile = Path . Combine ( Tools . GetEditorLogsFolder ( ) , "Editor.log" ) ;
1641
- //Console.WriteLine("read editor log: " + logFile);
1642
1692
1643
- List < string > rows = new List < string > ( ) ;
1693
+ if ( File . Exists ( logFile ) == false ) return ;
1644
1694
1645
- try
1646
- {
1647
- using ( var fs = new FileStream ( logFile , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
1648
- using ( var sr = new StreamReader ( fs , Encoding . Default ) )
1649
- {
1650
- while ( sr . EndOfStream == false )
1651
- {
1652
- // TODO only start collecting when find build report start, and need to reset list if another build report later
1653
- var r = sr . ReadLine ( ) ;
1654
- rows . Add ( r ) ;
1655
- }
1656
- }
1657
-
1658
- }
1659
- catch ( Exception ex )
1660
- {
1661
- Console . WriteLine ( ex . Message ) ;
1662
- throw ;
1663
- }
1695
+ // NOTE this can fail on a HUGE log file
1696
+ string [ ] rows = File . ReadAllLines ( logFile ) ;
1664
1697
1665
1698
if ( rows == null )
1666
1699
{
1667
1700
Console . WriteLine ( "Failed to open editor log: " + logFile ) ;
1668
1701
return ;
1669
1702
}
1670
1703
1671
- // TODO parse project folder info also, so can browse to selected file
1672
-
1673
1704
int startRow = - 1 ;
1674
1705
int endRow = - 1 ;
1706
+
1707
+ for ( int i = 0 , len = rows . Length ; i < len ; i ++ )
1708
+ {
1709
+ // get current project path from log file
1710
+ if ( rows [ i ] == "-projectPath" )
1711
+ {
1712
+ latestBuildReportProjectPath = rows [ i + 1 ] ;
1713
+ break ;
1714
+ }
1715
+ }
1716
+ if ( string . IsNullOrEmpty ( latestBuildReportProjectPath ) ) Console . WriteLine ( "Failed to parse project path from logfile.." ) ;
1717
+
1675
1718
// loop backwards to find latest report
1676
- for ( int i = rows . Count - 1 ; i >= 0 ; i -- )
1719
+ for ( int i = rows . Length - 1 ; i >= 0 ; i -- )
1677
1720
{
1678
1721
// find start of build report
1679
- //if (rows[i].IndexOf("Build Report") == 0) // TODO take overview also
1680
1722
if ( rows [ i ] . IndexOf ( "Used Assets and files from the Resources folder, sorted by uncompressed size:" ) == 0 )
1681
1723
{
1682
1724
startRow = i + 1 ;
1683
-
1684
1725
// find end of report
1685
- for ( int k = i ; k < rows . Count ; k ++ )
1726
+ for ( int k = i ; k < rows . Length ; k ++ )
1686
1727
{
1687
1728
if ( rows [ k ] . IndexOf ( "-------------------------------------------------------------------------------" ) == 0 )
1688
1729
{
@@ -1700,13 +1741,12 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
1700
1741
return ;
1701
1742
}
1702
1743
1703
- var reportSource = new BuildReport [ endRow - startRow ] ;
1744
+ var reportSource = new BuildReportItem [ endRow - startRow ] ;
1704
1745
1705
- // get report rows
1746
+ // parse actual report rows
1706
1747
int index = 0 ;
1707
1748
for ( int i = startRow ; i < endRow ; i ++ )
1708
1749
{
1709
- //Console.WriteLine(rows[i]);
1710
1750
var d = rows [ i ] . Trim ( ) ;
1711
1751
1712
1752
// get tab after kb
@@ -1720,10 +1760,11 @@ private void BtnRefreshBuildReport_Click(object sender, RoutedEventArgs e)
1720
1760
continue ;
1721
1761
}
1722
1762
1723
- var r = new BuildReport ( ) ;
1763
+ var r = new BuildReportItem ( ) ;
1724
1764
r . Size = d . Substring ( 0 , space1 ) ;
1725
1765
r . Percentage = d . Substring ( space1 + 2 , space2 - space1 - 1 ) ;
1726
1766
r . Path = d . Substring ( space2 + 2 , d . Length - space2 - 2 ) ;
1767
+ r . Format = Path . GetExtension ( r . Path ) ;
1727
1768
reportSource [ index ++ ] = r ;
1728
1769
}
1729
1770
gridBuildReport . ItemsSource = reportSource ;
@@ -2029,16 +2070,26 @@ private void GridRecent_ColumnReordered(object sender, DataGridColumnEventArgs e
2029
2070
Properties . Settings . Default . Save ( ) ;
2030
2071
}
2031
2072
2073
+ private void MenuItemExploreBuildItem_Click ( object sender , RoutedEventArgs e )
2074
+ {
2075
+ OpenSelectedBuildReportFile ( ) ;
2076
+ }
2032
2077
2078
+ private void GridBuildReport_PreviewMouseDoubleClick ( object sender , MouseButtonEventArgs e )
2079
+ {
2080
+ OpenSelectedBuildReportFile ( ) ;
2081
+ }
2082
+
2083
+ void OpenSelectedBuildReportFile ( )
2084
+ {
2085
+ var item = GetSelectedBuildItem ( ) ;
2086
+
2087
+ if ( item != null )
2088
+ {
2089
+ string filePath = Path . Combine ( latestBuildReportProjectPath , item . Path ) ;
2090
+ Tools . LaunchExplorerSelectFile ( filePath ) ;
2091
+ }
2092
+ }
2033
2093
2034
- //private void CmbPlatformSelection_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
2035
- //{
2036
- // var comb = (ComboBox)sender;
2037
- // Console.WriteLine(comb.Name);
2038
- // comb.HorizontalContentAlignment = HorizontalAlignment.Stretch;
2039
- // comb.VerticalContentAlignment = VerticalAlignment.Center;
2040
- // comb.HorizontalAlignment = HorizontalAlignment.Stretch;
2041
- // comb.VerticalAlignment = VerticalAlignment.Center;
2042
- //}
2043
2094
} // class
2044
2095
} //namespace
0 commit comments