@@ -40,6 +40,7 @@ public partial class MainWindow : Window
40
40
string _filterString = null ;
41
41
const string githubURL = "https://github.com/unitycoder/UnityLauncherPro" ;
42
42
int lastSelectedProjectIndex = 0 ;
43
+ public static string preferredVersion = "none" ;
43
44
Mutex myMutex ;
44
45
45
46
public MainWindow ( )
@@ -174,11 +175,11 @@ void FilterRecentProjects()
174
175
_filterString = txtSearchBox . Text ;
175
176
ICollectionView collection = CollectionViewSource . GetDefaultView ( projectsSource ) ;
176
177
collection . Filter = ProjectFilter ;
177
- // set first row selected
178
- if ( gridRecent . Items . Count > 0 )
179
- {
180
- gridRecent . SelectedIndex = 0 ;
181
- }
178
+ // set first row selected, if only 1 row
179
+ // if (gridRecent.Items.Count == 1 )
180
+ // {
181
+ // gridRecent.SelectedIndex = 0;
182
+ // }
182
183
}
183
184
184
185
void FilterUpdates ( )
@@ -242,7 +243,6 @@ void LoadSettings()
242
243
gridRecent . Columns [ 4 ] . Visibility = ( bool ) chkShowLauncherArgumentsColumn . IsChecked ? Visibility . Visible : Visibility . Collapsed ;
243
244
gridRecent . Columns [ 5 ] . Visibility = ( bool ) chkShowGitBranchColumn . IsChecked ? Visibility . Visible : Visibility . Collapsed ;
244
245
245
-
246
246
// update installations folder listbox
247
247
lstRootFolders . Items . Clear ( ) ;
248
248
lstRootFolders . ItemsSource = Properties . Settings . Default . rootFolders ;
@@ -256,6 +256,10 @@ void LoadSettings()
256
256
gridRecent . Columns [ i ] . Width = gridColumnWidths [ i ] ;
257
257
}
258
258
}
259
+
260
+ // other setting vars
261
+ preferredVersion = Properties . Settings . Default . preferredVersion ;
262
+
259
263
} // LoadSettings()
260
264
261
265
private void SaveSettingsOnExit ( )
@@ -292,6 +296,9 @@ private void SaveSettingsOnExit()
292
296
293
297
void UpdateUnityInstallationsList ( )
294
298
{
299
+ // reset preferred string, if user changed it
300
+ //preferredVersion = "none";
301
+
295
302
unityInstallationsSource = GetUnityInstallations . Scan ( ) ;
296
303
dataGridUnitys . ItemsSource = unityInstallationsSource ;
297
304
@@ -300,7 +307,7 @@ void UpdateUnityInstallationsList()
300
307
for ( int i = 0 , len = unityInstallationsSource . Length ; i < len ; i ++ )
301
308
{
302
309
var version = unityInstallationsSource [ i ] . Version ;
303
- if ( string . IsNullOrEmpty ( version ) == false && unityInstalledVersions . ContainsKey ( version ) == false )
310
+ if ( string . IsNullOrEmpty ( version ) == false && unityInstalledVersions . ContainsKey ( version ) == false )
304
311
{
305
312
unityInstalledVersions . Add ( version , unityInstallationsSource [ i ] . Path ) ;
306
313
}
@@ -339,13 +346,13 @@ void AddUnityInstallationRootFolder()
339
346
}
340
347
}
341
348
342
-
343
-
349
+ // waits for unity update results and assigns to datagrid
344
350
async void CallGetUnityUpdates ( )
345
351
{
346
352
dataGridUpdates . ItemsSource = null ;
347
353
var task = GetUnityUpdates . Scan ( ) ;
348
354
var items = await task ;
355
+ Console . WriteLine ( items == null ) ;
349
356
if ( items == null ) return ;
350
357
updatesSource = GetUnityUpdates . Parse ( items ) ;
351
358
if ( updatesSource == null ) return ;
@@ -485,7 +492,7 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
485
492
case Key . Escape : // clear project search
486
493
if ( txtSearchBox . Text == "" )
487
494
{
488
- Tools . SetFocusToGrid ( gridRecent ) ;
495
+ if ( txtSearchBox . IsFocused ) Tools . SetFocusToGrid ( gridRecent ) ;
489
496
}
490
497
txtSearchBox . Text = "" ;
491
498
break ;
@@ -555,11 +562,12 @@ private async void OnTabSelectionChanged(object sender, SelectionChangedEventArg
555
562
// if going into updates tab, fetch list (first time only)
556
563
if ( ( ( TabControl ) sender ) . SelectedIndex == ( int ) Tabs . Updates )
557
564
{
565
+ // if we dont have previous results yet, TODO scan again if previous was 24hrs ago
558
566
if ( updatesSource == null )
559
567
{
560
568
var task = GetUnityUpdates . Scan ( ) ;
561
- if ( task . IsCompleted == false ) return ;
562
569
var items = await task ;
570
+ if ( task . IsCompleted == false || task . IsFaulted == true ) return ;
563
571
if ( items == null ) return ;
564
572
updatesSource = GetUnityUpdates . Parse ( items ) ;
565
573
if ( updatesSource == null ) return ;
@@ -601,12 +609,14 @@ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
601
609
private void BtnLaunchProject_Click ( object sender , RoutedEventArgs e )
602
610
{
603
611
Tools . LaunchProject ( GetSelectedProject ( ) ) ;
612
+ Tools . SetFocusToGrid ( gridRecent ) ;
604
613
}
605
614
606
615
private void BtnExplore_Click ( object sender , RoutedEventArgs e )
607
616
{
608
617
var proj = GetSelectedProject ( ) ;
609
618
Tools . ExploreProjectFolder ( proj ) ;
619
+ Tools . SetFocusToGrid ( gridRecent ) ;
610
620
}
611
621
612
622
// copy selected row unity version to clipboard
@@ -719,6 +729,7 @@ private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
719
729
case Key . Up :
720
730
case Key . Down :
721
731
Tools . SetFocusToGrid ( gridRecent ) ;
732
+ e . Handled = true ; // to stay in first row
722
733
break ;
723
734
default :
724
735
break ;
@@ -814,6 +825,7 @@ private void TxtSearchBoxUpdates_PreviewKeyDown(object sender, KeyEventArgs e)
814
825
case Key . Up :
815
826
case Key . Down :
816
827
Tools . SetFocusToGrid ( dataGridUpdates ) ;
828
+ e . Handled = true ;
817
829
break ;
818
830
default :
819
831
break ;
@@ -935,7 +947,7 @@ private void BtnDonwloadInBrowser_Click(object sender, RoutedEventArgs e)
935
947
}
936
948
else
937
949
{
938
- Console . WriteLine ( "Failed getting Unity Installer URL for " + unity . Version ) ;
950
+ Console . WriteLine ( "Failed getting Unity Installer URL for " + unity ? . Version ) ;
939
951
}
940
952
}
941
953
@@ -1106,10 +1118,13 @@ private void BtnAssetPackages_Click(object sender, RoutedEventArgs e)
1106
1118
// sets selected unity version as preferred main unity version (to be preselected in case of unknown version projects, when creating new empty project, etc)
1107
1119
private void MenuItemSetPreferredUnityVersion_Click ( object sender , RoutedEventArgs e )
1108
1120
{
1109
- Properties . Settings . Default . preferredVersion = GetSelectedUnity ( ) . Version ;
1121
+ var ver = GetSelectedUnity ( ) . Version ;
1122
+ Properties . Settings . Default . preferredVersion = ver ;
1110
1123
Properties . Settings . Default . Save ( ) ;
1111
-
1112
- // TODO set star icon
1124
+
1125
+ preferredVersion = ver ;
1126
+ // TODO update unity list or just set value?
1127
+ UpdateUnityInstallationsList ( ) ;
1113
1128
1114
1129
}
1115
1130
} // class
0 commit comments