Skip to content

Commit 6356aae

Browse files
committed
updates: add download & install button, add null version checks
1 parent f6bab9e commit 6356aae

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,19 @@
411411
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
412412
<Grid.ColumnDefinitions>
413413
<ColumnDefinition Width="20*" />
414-
<ColumnDefinition Width="45*" />
414+
<ColumnDefinition Width="33*" />
415+
<ColumnDefinition Width="33*" />
415416
</Grid.ColumnDefinitions>
416417
<Grid.RowDefinitions>
417418
<RowDefinition Height="32" />
418419
</Grid.RowDefinitions>
419-
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnDonwloadInBrowser" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnDonwloadInBrowser_Click">
420+
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnDownloadInBrowser" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnDownloadInBrowser_Click">
420421
<Label Content="_Download in browser" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
421422
</Button>
422-
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
423+
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnDownloadInstallUpdate" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="btnDownloadInstallUpdate_Click">
424+
<Label Content="Download &amp; Install" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
425+
</Button>
426+
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
423427
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
424428
</Button>
425429
</Grid>

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+18-2
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ private void BtnRefreshUnityList_Click(object sender, RoutedEventArgs e)
13851385
UpdateUnityInstallationsList();
13861386
}
13871387

1388-
private void BtnDonwloadInBrowser_Click(object sender, RoutedEventArgs e)
1388+
private void BtnDownloadInBrowser_Click(object sender, RoutedEventArgs e)
13891389
{
13901390
var unity = GetSelectedUpdate();
13911391
string url = Tools.GetUnityReleaseURL(unity?.Version);
@@ -1400,6 +1400,20 @@ private void BtnDonwloadInBrowser_Click(object sender, RoutedEventArgs e)
14001400
}
14011401
}
14021402

1403+
private void btnDownloadInstallUpdate_Click(object sender, RoutedEventArgs e)
1404+
{
1405+
var unity = GetSelectedUpdate();
1406+
string url = Tools.GetUnityReleaseURL(unity?.Version);
1407+
if (string.IsNullOrEmpty(url) == false)
1408+
{
1409+
Tools.DownloadAndInstall(url, unity?.Version);
1410+
}
1411+
else
1412+
{
1413+
Console.WriteLine("Failed getting Unity Installer URL for " + unity?.Version);
1414+
}
1415+
}
1416+
14031417
private void BtnOpenWebsite_Click(object sender, RoutedEventArgs e)
14041418
{
14051419
var unity = GetSelectedUpdate();
@@ -2694,7 +2708,7 @@ private void MenuItemDownloadInBrowser_Click(object sender, RoutedEventArgs e)
26942708
{
26952709
var unity = GetSelectedUpdate();
26962710
string exeURL = Tools.ParseDownloadURLFromWebpage(unity?.Version);
2697-
Tools.DownloadInBrowser(exeURL, unity?.Version);
2711+
if (exeURL != null) Tools.DownloadInBrowser(exeURL, unity?.Version);
26982712
}
26992713

27002714
private void MenuItemDownloadLinuxModule_Click(object sender, RoutedEventArgs e)
@@ -3322,6 +3336,8 @@ private void tabControl_PreviewKeyDown(object sender, KeyEventArgs e)
33223336
}
33233337
}
33243338

3339+
3340+
33253341
//private void BtnBrowseTemplateUnityPackagesFolder_Click(object sender, RoutedEventArgs e)
33263342
//{
33273343
// var folder = Tools.BrowseForOutputFolder("Select unitypackage Templates folder");

Diff for: UnityLauncherPro/Tools.cs

+2
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ public static string ParseDownloadURLFromWebpage(string version)
649649
{
650650
string url = "";
651651

652+
if (string.IsNullOrEmpty(version)) return null;
653+
652654
using (WebClient client = new WebClient())
653655
{
654656
// get correct page url

Diff for: UnityLauncherPro/UpgradeWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<Button Style="{StaticResource CustomButton}" x:Name="btnDownload" Background="{DynamicResource ThemeButtonBackground}" Foreground="#FFC1C1C1" Margin="9,0,9,0" BorderBrush="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="35" Click="BtnDownload_Click" Width="125" >
2222
<Label Foreground="{DynamicResource ThemeButtonForeground}" Content="Download in _Browser"/>
2323
</Button>
24-
<Button Style="{StaticResource CustomButton}" x:Name="btnInstall" Background="{DynamicResource ThemeButtonBackground}" Foreground="#FFC1C1C1" BorderBrush="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="35" Width="125" Click="btnInstall_Click" >
24+
<Button Style="{StaticResource CustomButton}" x:Name="btnInstall" Background="{DynamicResource ThemeButtonBackground}" Foreground="#FFC1C1C1" BorderBrush="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="35" Width="125" Click="btnInstall_Click" ToolTip="Downloads Unity web installer into Temp folder and runs it (Root folder path is copied to clipboard)" >
2525
<Label Foreground="{DynamicResource ThemeButtonForeground}" Content="_Download &amp; Install"/>
2626
</Button>
2727
</StackPanel>

0 commit comments

Comments
 (0)