Skip to content

Commit d3dfb03

Browse files
authored
Merge pull request #157 from SixParQuatre/MoreReleaseNotesButton
Add 'Cumulative Release Note' button
2 parents 1df1105 + e9bb433 commit d3dfb03

File tree

3 files changed

+81
-23
lines changed

3 files changed

+81
-23
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml

+16-8
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@
4848
<!-- Tab: Projects-->
4949
<TabItem Header="Projects" Style="{DynamicResource TabItemStyle1}" Padding="0,0,0,0" Margin="-1,1,1,-1" BorderBrush="{x:Null}">
5050
<Grid>
51+
<Grid.ColumnDefinitions>
52+
<ColumnDefinition Width="185*"/>
53+
<ColumnDefinition Width="693*"/>
54+
</Grid.ColumnDefinitions>
5155
<!-- search box -->
52-
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
56+
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" Grid.ColumnSpan="2" >
5357
<!--<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />-->
5458
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
5559
<TextBlock.Style>
@@ -84,10 +88,10 @@
8488
</Button>
8589
</Grid>
8690

87-
<Button Style="{StaticResource CustomButton}" ToolTip="Browse and add existing project to list" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,38,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" TabIndex="10" />
88-
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" x:Name="btnRefreshProjectList" Content="" Height="22" Width="26" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshProjectList_Click" TabIndex="11"/>
91+
<Button Style="{StaticResource CustomButton}" ToolTip="Browse and add existing project to list" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,38,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" TabIndex="10" Grid.Column="1" />
92+
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" x:Name="btnRefreshProjectList" Content="" Height="22" Width="26" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshProjectList_Click" TabIndex="11" Grid.Column="1"/>
8993

90-
<DataGrid x:Name="gridRecent" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeDatagridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" ContextMenuOpening="GridRecent_ContextMenuOpening" BeginningEdit="GridRecent_BeginningEdit" RowHeight="21" ColumnReordered="GridRecent_ColumnReordered" Sorting="gridRecent_Sorting" >
94+
<DataGrid x:Name="gridRecent" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeDatagridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" ContextMenuOpening="GridRecent_ContextMenuOpening" BeginningEdit="GridRecent_BeginningEdit" RowHeight="21" ColumnReordered="GridRecent_ColumnReordered" Sorting="gridRecent_Sorting" Grid.ColumnSpan="2" >
9195

9296
<DataGrid.CommandBindings>
9397
<CommandBinding Command="ApplicationCommands.Copy" Executed="CopyRowFolderToClipBoard" CanExecute="CanExecute_Copy"/>
@@ -241,7 +245,7 @@
241245
</DataGrid>
242246

243247
<!-- bottom buttoms row -->
244-
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
248+
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5" Grid.ColumnSpan="2">
245249
<Grid.ColumnDefinitions>
246250
<ColumnDefinition Width="14*" />
247251
<ColumnDefinition Width="17*" />
@@ -492,7 +496,8 @@
492496
<ColumnDefinition Width="20*" />
493497
<ColumnDefinition Width="18*" />
494498
<ColumnDefinition Width="28*" />
495-
<ColumnDefinition Width="26*" />
499+
<ColumnDefinition Width="14*" />
500+
<ColumnDefinition Width="18*" />
496501
</Grid.ColumnDefinitions>
497502
<Grid.RowDefinitions>
498503
<RowDefinition Height="32" />
@@ -507,7 +512,10 @@
507512
<Label Content="Download &amp; Install" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
508513
</Button>
509514
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
510-
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
515+
<Label Content="Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
516+
</Button>
517+
<Button Grid.Column="4" Style="{StaticResource CustomButton}" x:Name="btnShowCumulatedReleaseNotes" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnShowCumulatedReleaseNotes_Click" ToolTip="Show all Release Notes between the selected version and the older, closest one installed. Only works for final and patch versions." >
518+
<Label Content="Cumulative Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
511519
</Button>
512520
</Grid>
513521
</Grid>
@@ -791,7 +799,7 @@
791799
<CheckBox x:Name="chkQuitAfterOpen" Content="Close after opening project" Checked="ChkQuitAfterOpen_CheckedChanged" Unchecked="ChkQuitAfterOpen_CheckedChanged" ToolTip="Closes launcher after running project (not really useful)" HorizontalAlignment="Left"/>
792800
<CheckBox x:Name="chkQuitAfterCommandline" Content="Close after launching from Explorer" Unchecked="ChkQuitAfterCommandline_CheckedChanged" Checked="ChkQuitAfterCommandline_CheckedChanged" ToolTip="Close launcher after running from commandline or Explorer (recommended)" HorizontalAlignment="Left"/>
793801
<CheckBox x:Name="chkAllowSingleInstanceOnly" Content="Allow single instance only" Checked="ChkAllowSingleInstanceOnly_CheckedChanged" Unchecked="ChkAllowSingleInstanceOnly_CheckedChanged" ToolTip="Activates already running instance, instead of starting new exe (not working if app is minized to taskbar)" HorizontalAlignment="Left"/>
794-
<CheckBox x:Name="useAlphaReleaseNotesSite" Content="Use Unity Alpha Release Notes Site (Unity 6 not supported)" ToolTip="Use the superior (but alpha) Unity Release Notes (https://alpha.release-notes.ds.unity3d.com/) site when clicking on the ReleaseNotes button. Otherwise will default to the normal build page." Checked="UseAlphaReleaseNotes_Checked" Unchecked="UseAlphaReleaseNotes_Checked"/>
802+
<CheckBox x:Name="useAlphaReleaseNotesSite" Content="Use Unity Alpha Release Notes Site (only for final versions) " ToolTip="Use the superior (but alpha) Unity Release Notes (https://alpha.release-notes.ds.unity3d.com/) site when clicking on the ReleaseNotes button. Otherwise will default to the normal build page." Checked="UseAlphaReleaseNotes_Checked" Unchecked="UseAlphaReleaseNotes_Checked"/>
795803
<CheckBox x:Name="chkStreamerMode" Content="Streamer Mode (hide project names and folders)" ToolTip="Hide project names and folders in main view" Checked="ChkStreamerMode_Checked" Unchecked="ChkStreamerMode_Checked" HorizontalAlignment="Left"/>
796804
<!--<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
797805
<TextBox x:Name="txtTemplatePackagesFolder" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" ToolTip="Folder for your custom unitypackage templates (for new project)" Padding="0,3,0,0" Width="110" TextChanged="TxtTemplatePackagesFolder_TextChanged" />

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public partial class MainWindow : Window
4646
System.Windows.Forms.NotifyIcon notifyIcon;
4747

4848
Updates[] updatesSource;
49-
public static List<string> updatesAsStrings;
49+
public static List<string> updatesAsStrings = new List<string>();
5050

5151
string _filterString = null;
5252
bool multiWordSearch = false;
@@ -140,6 +140,7 @@ void Start()
140140

141141
// clear updates grid
142142
dataGridUpdates.Items.Clear();
143+
dataGridUpdates.SelectionChanged += DataGridUpdates_SelectionChanged;
143144

144145
// clear buildreport grids
145146
gridBuildReport.Items.Clear();
@@ -177,6 +178,18 @@ void Start()
177178
isInitializing = false;
178179
}
179180

181+
private void DataGridUpdates_SelectionChanged(object sender, SelectionChangedEventArgs e)
182+
{
183+
var selectedUp = GetSelectedUpdate();
184+
bool showCumulative = false;
185+
if (selectedUp != null)
186+
{
187+
var unityVer = GetSelectedUpdate().Version;
188+
showCumulative = Tools.HasAlphaReleaseNotes(unityVer);
189+
}
190+
btnShowCumulatedReleaseNotes.IsEnabled = showCumulative;
191+
}
192+
180193
// bring old window to front, but needs matching appname.. https://stackoverflow.com/a/36804161/5452781
181194
private static void ActivateOtherWindow()
182195
{
@@ -1543,6 +1556,12 @@ private void BtnOpenWebsite_Click(object sender, RoutedEventArgs e)
15431556
Tools.OpenReleaseNotes(unity?.Version);
15441557
}
15451558

1559+
private void BtnShowCumulatedReleaseNotes_Click(object sender, RoutedEventArgs e)
1560+
{
1561+
var unity = GetSelectedUpdate();
1562+
Tools.OpenReleaseNotes_Cumulative(unity?.Version);
1563+
}
1564+
15461565
private void ChkMinimizeToTaskbar_CheckedChanged(object sender, RoutedEventArgs e)
15471566
{
15481567
if (this.IsActive == false) return; // dont run code on window init

Diff for: UnityLauncherPro/Tools.cs

+45-14
Original file line numberDiff line numberDiff line change
@@ -590,28 +590,25 @@ public static bool VersionIsAlpha(string version)
590590

591591
public static bool VersionIsChinese(string version)
592592
{
593-
return version.Contains("c1");
593+
return version.Contains("c1");
594594
}
595595

596+
597+
//as of 21 May 2021, only final 'f' versions are now available on the alpha release notes for Unity 2018 and newer. 2017 and 5 still have patch 'p' versions as well.
598+
public static bool HasAlphaReleaseNotes(string version) => VersionIsArchived(version) || VersionIsPatch(version);
599+
600+
public static string GetAlphaReleaseNotesURL(string fromVersion, string toVersion = null)
601+
=> "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + fromVersion + "&toVersion=" + (toVersion != null ? toVersion : fromVersion);
602+
596603
// open release notes page in browser
597604
public static bool OpenReleaseNotes(string version)
598605
{
599606
bool result = false;
600607
if (string.IsNullOrEmpty(version)) return false;
601-
602-
//var url = Tools.GetUnityReleaseURL(version);
603608
string url = null;
604-
bool noAlphaReleaseNotesPage = version.Contains("6000") && !version.Contains("f");
605-
if (Properties.Settings.Default.useAlphaReleaseNotes && !noAlphaReleaseNotesPage)
609+
if(Properties.Settings.Default.useAlphaReleaseNotes && HasAlphaReleaseNotes(version))
606610
{
607-
//with the alpha release notes, we want a diff between the 2 versions, but the site just shows all the changes inclusive of from
608-
// so we need to compare the currently selected version to the one right after it that is available (installed or not)
609-
610-
var closestVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
611-
var getNextVersionToClosest = closestVersion == null ? null : Tools.FindNearestVersion(version, MainWindow.updatesAsStrings);
612-
if (getNextVersionToClosest == null) getNextVersionToClosest = version;
613-
614-
url = "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + getNextVersionToClosest + "&toVersion=" + version;
611+
url = GetAlphaReleaseNotesURL(version);
615612
}
616613
else
617614
{
@@ -624,6 +621,36 @@ public static bool OpenReleaseNotes(string version)
624621
return result;
625622
}
626623

624+
public static bool OpenReleaseNotes_Cumulative(string version)
625+
{
626+
bool result = false;
627+
if (string.IsNullOrEmpty(version)) return false;
628+
629+
string url = null;
630+
var comparisonVersion = version;
631+
//with the alpha release notes, we want a diff between an installed version and the one selected, but the site just shows all the changes inclusive of "fromVersion=vers"
632+
//so if we find a good installed candidate, we need the version just above it (installed or not) that has release notes page
633+
var closestInstalledVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
634+
if (closestInstalledVersion != null)
635+
{
636+
comparisonVersion = closestInstalledVersion;
637+
string nextFinalVersionAfterInstalled = closestInstalledVersion;
638+
639+
//wwe need a loop here, to find the nearest final version. It might be better to warn the user about this before opening the page.
640+
do
641+
nextFinalVersionAfterInstalled = Tools.FindNearestVersion(nextFinalVersionAfterInstalled, MainWindow.updatesAsStrings);
642+
while (nextFinalVersionAfterInstalled != null && !HasAlphaReleaseNotes(nextFinalVersionAfterInstalled));
643+
644+
if (nextFinalVersionAfterInstalled != null) comparisonVersion = nextFinalVersionAfterInstalled;
645+
646+
}
647+
url = GetAlphaReleaseNotesURL(comparisonVersion,version);
648+
649+
OpenURL(url);
650+
result = true;
651+
return result;
652+
}
653+
627654
public static void OpenURL(string url)
628655
{
629656
Process.Start(url);
@@ -1047,10 +1074,14 @@ private static string FetchUnityVersionNumberFromHTML(string url)
10471074

10481075
public static string FindNearestVersion(string currentVersion, List<string> allAvailable, bool checkBelow = false)
10491076
{
1077+
if (allAvailable == null)
1078+
return null;
1079+
10501080
string result = null;
10511081

10521082
// add current version to list, to sort it with others
1053-
allAvailable.Add(currentVersion);
1083+
if (!allAvailable.Contains(currentVersion))
1084+
allAvailable.Add(currentVersion);
10541085

10551086
// sort list
10561087
if (checkBelow)

0 commit comments

Comments
 (0)