Skip to content

Commit ed027de

Browse files
committed
refresh unity installations on project refresh, fetch updates list on go to updates for unity version button
1 parent df871cb commit ed027de

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
476476
</Button>
477477
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnUpdateUnity" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnUpdateUnity_Click">
478-
<Label Content="Update" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
478+
<Label Content="Go to Updates" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
479479
</Button>
480480
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnRunUnity" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnRunUnity_Click" >
481481
<Label Content="_Run Unity" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+34-21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.IO;
1010
using System.Runtime.InteropServices;
1111
using System.Threading;
12+
using System.Threading.Tasks;
1213
using System.Windows;
1314
using System.Windows.Controls;
1415
using System.Windows.Data;
@@ -352,7 +353,7 @@ void AddUnityInstallationRootFolder()
352353
}
353354

354355
// waits for unity update results and assigns to datagrid
355-
async void CallGetUnityUpdates()
356+
async Task CallGetUnityUpdates()
356357
{
357358
dataGridUpdates.ItemsSource = null;
358359
var task = GetUnityUpdates.Scan();
@@ -364,6 +365,32 @@ async void CallGetUnityUpdates()
364365
dataGridUpdates.ItemsSource = updatesSource;
365366
}
366367

368+
async void GoLookForUpdatesForThisUnity()
369+
{
370+
// call for updates list fetch
371+
await CallGetUnityUpdates();
372+
373+
var unity = GetSelectedUnity();
374+
if (unity == null) return;
375+
// NOTE for now, just select the same version.. then user can see what has been released after this
376+
// NOTE if updates are not loaded, should wait for that
377+
if (dataGridUpdates.ItemsSource != null)
378+
{
379+
tabControl.SelectedIndex = 2;
380+
// find matching version
381+
for (int i = 0; i < dataGridUpdates.Items.Count; i++)
382+
{
383+
Updates row = (Updates)dataGridUpdates.Items[i];
384+
if (row.Version == unity.Version)
385+
{
386+
dataGridUpdates.SelectedIndex = i;
387+
dataGridUpdates.ScrollIntoView(row);
388+
break;
389+
}
390+
}
391+
}
392+
}
393+
367394
void RefreshRecentProjects()
368395
{
369396
// clear search
@@ -636,6 +663,8 @@ private void MenuItemCopyVersion_Click(object sender, RoutedEventArgs e)
636663

637664
private void BtnRefreshProjectList_Click(object sender, RoutedEventArgs e)
638665
{
666+
// we want to refresh unity installs also, to make sure version colors are correct
667+
UpdateUnityInstallationsList();
639668
RefreshRecentProjects();
640669
}
641670

@@ -686,27 +715,11 @@ private void BtnReleaseNotes_Click(object sender, RoutedEventArgs e)
686715

687716
private void BtnUpdateUnity_Click(object sender, RoutedEventArgs e)
688717
{
689-
var unity = GetSelectedUnity();
690-
if (unity == null) return;
691-
// NOTE for now, just select the same version.. then user can see what has been released after this
692-
// NOTE if updates are not loaded, should wait for that
693-
if (dataGridUpdates.ItemsSource != null)
694-
{
695-
tabControl.SelectedIndex = 2;
696-
// find matching version
697-
for (int i = 0; i < dataGridUpdates.Items.Count; i++)
698-
{
699-
Updates row = (Updates)dataGridUpdates.Items[i];
700-
if (row.Version == unity.Version)
701-
{
702-
dataGridUpdates.SelectedIndex = i;
703-
dataGridUpdates.ScrollIntoView(row);
704-
break;
705-
}
706-
}
707-
}
718+
GoLookForUpdatesForThisUnity();
708719
}
709720

721+
722+
710723
// if press up/down in search box, move to first item in results
711724
private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
712725
{
@@ -1135,7 +1148,7 @@ private void MenuItemCopyPath_Click(object sender, RoutedEventArgs e)
11351148
{
11361149
var proj = GetSelectedProject();
11371150
// fix slashes so that it works in save dialogs
1138-
copy = proj?.Path.Replace('/','\\');
1151+
copy = proj?.Path.Replace('/', '\\');
11391152
}
11401153
if (copy != null) Clipboard.SetText(copy);
11411154
}

0 commit comments

Comments
 (0)