Skip to content

Commit f068166

Browse files
committed
Unity tab: add explore install folder, add open release notes, add run unity only. UpgradeWindow: add esc key to cancel, fix keyboard scrolling in list
1 parent 1e45cc3 commit f068166

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

UnityLauncherPro/MainWindow.xaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</Style>
7373

7474
<!-- datagrid hide selected cell borders -->
75-
<!--<Style TargetType="{x:Type DataGridCell}">
75+
<Style TargetType="{x:Type DataGridCell}">
7676
<Setter Property="BorderBrush" Value="Transparent" />
7777
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
7878
<Setter Property="Margin" Value="0,0.5,0,0.5" />
@@ -84,10 +84,10 @@
8484
<Setter Property="Background" Value="Transparent" />
8585
</Trigger>
8686
</Style.Triggers>
87-
</Style>-->
87+
</Style>
8888

8989
<Style x:Key="NoFocusCellStyle" TargetType="DataGridCell">
90-
<Setter Property="Focusable" Value="False"/>
90+
<!--<Setter Property="Focusable" Value="False"/>-->
9191
</Style>
9292

9393
<!-- custom buttons -->
@@ -225,8 +225,8 @@
225225

226226
</Window.Resources>
227227

228-
229-
228+
229+
230230

231231
<!-- UI -->
232232

@@ -387,7 +387,6 @@
387387
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnExplore" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnExplore_Click" >
388388
<Label Foreground="{DynamicResource ButtonForeground}">_Explore</Label>
389389
</Button>
390-
391390
</Grid>
392391
</Grid>
393392
</TabItem>
@@ -441,20 +440,25 @@
441440
<!-- bottom buttoms row -->
442441
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
443442
<Grid.ColumnDefinitions>
443+
<ColumnDefinition Width="20*" />
444444
<ColumnDefinition Width="20*" />
445445
<ColumnDefinition Width="45*" />
446446
<ColumnDefinition Width="15*" />
447+
447448
</Grid.ColumnDefinitions>
448449
<Grid.RowDefinitions>
449450
<RowDefinition Height="32" />
450451
</Grid.RowDefinitions>
451-
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnRunUnity" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}">
452-
<Label Foreground="{DynamicResource ButtonForeground}">_Upgrade</Label>
452+
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnReleaseNotes" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnReleaseNotes_Click">
453+
<Label Foreground="{DynamicResource ButtonForeground}" Content="Release Notes"/>
454+
</Button>
455+
<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">
456+
<Label Foreground="{DynamicResource ButtonForeground}" Content="Update"/>
453457
</Button>
454-
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnReleaseNotes" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="8,0,0,0" BorderBrush="{x:Null}" >
458+
<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" >
455459
<Label Foreground="{DynamicResource ButtonForeground}">_Run Unity</Label>
456460
</Button>
457-
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnExploreUnity" Background="{DynamicResource ButtonBackground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Foreground="{DynamicResource ButtonForeground}" >
461+
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnExploreUnity" Background="{DynamicResource ButtonBackground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Foreground="{DynamicResource ButtonForeground}" Click="BtnExploreUnity_Click" >
458462
<Label Foreground="{DynamicResource ButtonForeground}">_Explore</Label>
459463
</Button>
460464

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ Project GetSelectedProject()
456456
return (Project)gridRecent.SelectedItem;
457457
}
458458

459+
UnityInstallation GetSelectedUnity()
460+
{
461+
return (UnityInstallation)dataGridUnitys.SelectedItem;
462+
}
463+
459464
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
460465
{
461466
// override Enter for datagrid
@@ -543,6 +548,33 @@ private void GridRecent_Loaded(object sender, RoutedEventArgs e)
543548
DataGridRow row = (DataGridRow)gridRecent.ItemContainerGenerator.ContainerFromIndex(0);
544549
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
545550
}
551+
552+
private void BtnExploreUnity_Click(object sender, RoutedEventArgs e)
553+
{
554+
var unity = GetSelectedUnity();
555+
if (unity == null) return;
556+
var path = Path.GetDirectoryName(unity.Path);
557+
Tools.LaunchExplorer(path);
558+
}
559+
560+
private void BtnRunUnity_Click(object sender, RoutedEventArgs e)
561+
{
562+
var unity = GetSelectedUnity();
563+
if (unity == null) return;
564+
Tools.LaunchExe(unity.Path);
565+
}
566+
567+
private void BtnReleaseNotes_Click(object sender, RoutedEventArgs e)
568+
{
569+
var unity = GetSelectedUnity();
570+
if (unity == null) return;
571+
Tools.OpenReleaseNotes(unity.Version);
572+
}
573+
574+
private void BtnUpdateUnity_Click(object sender, RoutedEventArgs e)
575+
{
576+
// TODO check for newer available version in Updates tab, select that row and jump to tab
577+
}
546578
} // class
547579
} //namespace
548580

UnityLauncherPro/UpgradeWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<Button Style="{StaticResource CustomButton}" x:Name="btnUpgradeProject" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="0,434,8,0" BorderBrush="{x:Null}" HorizontalAlignment="Right" Width="159" VerticalAlignment="Top" Height="51" Click="BtnUpgradeProject_Click" >
190190
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Upgrade Project"/>
191191
</Button>
192-
<DataGrid x:Name="gridAvailableVersions" SelectionMode="Single" HorizontalAlignment="Left" Height="304" Margin="10,121,0,0" VerticalAlignment="Top" Width="393" HeadersVisibility="None" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" Foreground="{DynamicResource ButtonForeground}" Background="{DynamicResource MainBackgroundColor}" PreviewKeyDown="GridAvailableVersions_PreviewKeyDown">
192+
<DataGrid x:Name="gridAvailableVersions" SelectionMode="Single" HorizontalAlignment="Left" Height="304" Margin="10,121,0,0" VerticalAlignment="Top" Width="393" HeadersVisibility="None" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" Foreground="{DynamicResource ButtonForeground}" Background="{DynamicResource MainBackgroundColor}" PreviewKeyDown="GridAvailableVersions_PreviewKeyDown" Loaded="GridAvailableVersions_Loaded">
193193
<DataGrid.Columns>
194194
<DataGridTextColumn Header="Key" Binding="{Binding Key}" IsReadOnly="True" />
195195
<DataGridTextColumn Header="Value" Binding="{Binding Value}" IsReadOnly="True" />

UnityLauncherPro/UpgradeWindow.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Windows;
5+
using System.Windows.Controls;
56
using System.Windows.Input;
67

78
namespace UnityLauncherPro
@@ -101,6 +102,17 @@ private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventA
101102
DialogResult = true;
102103
return;
103104
}
105+
else // other keys
106+
{
107+
switch (e.Key)
108+
{
109+
case Key.Escape:
110+
DialogResult = false;
111+
break;
112+
default:
113+
break;
114+
}
115+
}
104116

105117
base.OnKeyDown(e);
106118
}
@@ -109,5 +121,12 @@ private void GridAvailableVersions_PreviewKeyDown(object sender, KeyEventArgs e)
109121
{
110122
Tools.HandleDataGridScrollKeys(sender, e);
111123
}
124+
125+
private void GridAvailableVersions_Loaded(object sender, RoutedEventArgs e)
126+
{
127+
gridAvailableVersions.Focus();
128+
DataGridRow row = (DataGridRow)gridAvailableVersions.ItemContainerGenerator.ContainerFromIndex(gridAvailableVersions.SelectedIndex);
129+
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
130+
}
112131
}
113132
}

0 commit comments

Comments
 (0)