@@ -40,6 +40,7 @@ public partial class MainWindow : Window
4040 string _filterString = null;
4141 const string githubURL = "https://github.com/unitycoder/UnityLauncherPro";
4242 int lastSelectedProjectIndex = 0;
43+ public static string preferredVersion = "none";
4344 Mutex myMutex;
4445
4546 public MainWindow()
@@ -174,11 +175,11 @@ void FilterRecentProjects()
174175 _filterString = txtSearchBox.Text;
175176 ICollectionView collection = CollectionViewSource.GetDefaultView(projectsSource);
176177 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+ // }
182183 }
183184
184185 void FilterUpdates()
@@ -242,7 +243,6 @@ void LoadSettings()
242243 gridRecent.Columns[4].Visibility = (bool)chkShowLauncherArgumentsColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
243244 gridRecent.Columns[5].Visibility = (bool)chkShowGitBranchColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
244245
245-
246246 // update installations folder listbox
247247 lstRootFolders.Items.Clear();
248248 lstRootFolders.ItemsSource = Properties.Settings.Default.rootFolders;
@@ -256,6 +256,10 @@ void LoadSettings()
256256 gridRecent.Columns[i].Width = gridColumnWidths[i];
257257 }
258258 }
259+
260+ // other setting vars
261+ preferredVersion = Properties.Settings.Default.preferredVersion;
262+
259263 } // LoadSettings()
260264
261265 private void SaveSettingsOnExit()
@@ -292,6 +296,9 @@ private void SaveSettingsOnExit()
292296
293297 void UpdateUnityInstallationsList()
294298 {
299+ // reset preferred string, if user changed it
300+ //preferredVersion = "none";
301+
295302 unityInstallationsSource = GetUnityInstallations.Scan();
296303 dataGridUnitys.ItemsSource = unityInstallationsSource;
297304
@@ -300,7 +307,7 @@ void UpdateUnityInstallationsList()
300307 for (int i = 0, len = unityInstallationsSource.Length; i < len; i++)
301308 {
302309 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)
304311 {
305312 unityInstalledVersions.Add(version, unityInstallationsSource[i].Path);
306313 }
@@ -339,13 +346,13 @@ void AddUnityInstallationRootFolder()
339346 }
340347 }
341348
342-
343-
349+ // waits for unity update results and assigns to datagrid
344350 async void CallGetUnityUpdates()
345351 {
346352 dataGridUpdates.ItemsSource = null;
347353 var task = GetUnityUpdates.Scan();
348354 var items = await task;
355+ Console.WriteLine(items == null);
349356 if (items == null) return;
350357 updatesSource = GetUnityUpdates.Parse(items);
351358 if (updatesSource == null) return;
@@ -485,7 +492,7 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
485492 case Key.Escape: // clear project search
486493 if (txtSearchBox.Text == "")
487494 {
488- Tools.SetFocusToGrid(gridRecent);
495+ if (txtSearchBox.IsFocused) Tools.SetFocusToGrid(gridRecent);
489496 }
490497 txtSearchBox.Text = "";
491498 break;
@@ -555,11 +562,12 @@ private async void OnTabSelectionChanged(object sender, SelectionChangedEventArg
555562 // if going into updates tab, fetch list (first time only)
556563 if (((TabControl)sender).SelectedIndex == (int)Tabs.Updates)
557564 {
565+ // if we dont have previous results yet, TODO scan again if previous was 24hrs ago
558566 if (updatesSource == null)
559567 {
560568 var task = GetUnityUpdates.Scan();
561- if (task.IsCompleted == false) return;
562569 var items = await task;
570+ if (task.IsCompleted == false || task.IsFaulted == true) return;
563571 if (items == null) return;
564572 updatesSource = GetUnityUpdates.Parse(items);
565573 if (updatesSource == null) return;
@@ -601,12 +609,14 @@ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
601609 private void BtnLaunchProject_Click(object sender, RoutedEventArgs e)
602610 {
603611 Tools.LaunchProject(GetSelectedProject());
612+ Tools.SetFocusToGrid(gridRecent);
604613 }
605614
606615 private void BtnExplore_Click(object sender, RoutedEventArgs e)
607616 {
608617 var proj = GetSelectedProject();
609618 Tools.ExploreProjectFolder(proj);
619+ Tools.SetFocusToGrid(gridRecent);
610620 }
611621
612622 // copy selected row unity version to clipboard
@@ -719,6 +729,7 @@ private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
719729 case Key.Up:
720730 case Key.Down:
721731 Tools.SetFocusToGrid(gridRecent);
732+ e.Handled = true; // to stay in first row
722733 break;
723734 default:
724735 break;
@@ -814,6 +825,7 @@ private void TxtSearchBoxUpdates_PreviewKeyDown(object sender, KeyEventArgs e)
814825 case Key.Up:
815826 case Key.Down:
816827 Tools.SetFocusToGrid(dataGridUpdates);
828+ e.Handled = true;
817829 break;
818830 default:
819831 break;
@@ -935,7 +947,7 @@ private void BtnDonwloadInBrowser_Click(object sender, RoutedEventArgs e)
935947 }
936948 else
937949 {
938- Console.WriteLine("Failed getting Unity Installer URL for " + unity.Version);
950+ Console.WriteLine("Failed getting Unity Installer URL for " + unity? .Version);
939951 }
940952 }
941953
@@ -1106,10 +1118,13 @@ private void BtnAssetPackages_Click(object sender, RoutedEventArgs e)
11061118 // sets selected unity version as preferred main unity version (to be preselected in case of unknown version projects, when creating new empty project, etc)
11071119 private void MenuItemSetPreferredUnityVersion_Click(object sender, RoutedEventArgs e)
11081120 {
1109- Properties.Settings.Default.preferredVersion = GetSelectedUnity().Version;
1121+ var ver = GetSelectedUnity().Version;
1122+ Properties.Settings.Default.preferredVersion = ver;
11101123 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();
11131128
11141129 }
11151130 } // class
0 commit comments