Skip to content

Commit e9bb433

Browse files
Add Cumulative Release Notes buttons that gets deactivated if the version selected in't supported by the alpha release notess sites. Split cumulative and non-cumulative OpenReleaseNotes function for better clarity.
1 parent 732d859 commit e9bb433

File tree

3 files changed

+57
-26
lines changed

3 files changed

+57
-26
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,10 @@
512512
<Label Content="Download &amp; Install" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
513513
</Button>
514514
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
515-
</Button>
516-
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite_Copy" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
517515
<Label Content="Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
518516
</Button>
519-
<Button Grid.Column="4" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite_Copy2" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" ToolTip="Show All Release notes between this version on the older, closest one installed.&lt;br&gt;Only works for final versions." >
520-
<Label Content="Cumulated Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
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}}" />
521519
</Button>
522520
</Grid>
523521
</Grid>

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+19
Original file line numberDiff line numberDiff line change
@@ -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
{
@@ -1542,6 +1555,12 @@ private void BtnOpenWebsite_Click(object sender, RoutedEventArgs e)
15421555
Tools.OpenReleaseNotes(unity?.Version);
15431556
}
15441557

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

Diff for: UnityLauncherPro/Tools.cs

+36-22
Original file line numberDiff line numberDiff line change
@@ -588,36 +588,20 @@ public static bool VersionIsChinese(string version)
588588

589589

590590
//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.
591-
public static bool HasAlphaReleaseNotes(string version) => version.Contains("f") || version.Contains("p");
591+
public static bool HasAlphaReleaseNotes(string version) => VersionIsArchived(version) || VersionIsPatch(version);
592+
593+
public static string GetAlphaReleaseNotesURL(string fromVersion, string toVersion = null)
594+
=> "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + fromVersion + "&toVersion=" + (toVersion != null ? toVersion : fromVersion);
592595

593596
// open release notes page in browser
594597
public static bool OpenReleaseNotes(string version)
595598
{
596599
bool result = false;
597600
if (string.IsNullOrEmpty(version)) return false;
598-
599601
string url = null;
600-
if (Properties.Settings.Default.useAlphaReleaseNotes && HasAlphaReleaseNotes(version))
602+
if(Properties.Settings.Default.useAlphaReleaseNotes && HasAlphaReleaseNotes(version))
601603
{
602-
//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"
603-
//so if we find a good installed candidate, we need the version just above it (installed or not) that has release notes page
604-
var comparisonVersion = version;
605-
var closestInstalledVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
606-
if (closestInstalledVersion != null)
607-
{
608-
comparisonVersion = closestInstalledVersion;
609-
string nextFinalVersionAfterInstalled = closestInstalledVersion;
610-
611-
//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.
612-
do
613-
nextFinalVersionAfterInstalled = Tools.FindNearestVersion(nextFinalVersionAfterInstalled, MainWindow.updatesAsStrings);
614-
while (nextFinalVersionAfterInstalled != null && !HasAlphaReleaseNotes(nextFinalVersionAfterInstalled));
615-
616-
if (nextFinalVersionAfterInstalled != null) comparisonVersion = nextFinalVersionAfterInstalled;
617-
618-
}
619-
620-
url = "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + comparisonVersion + "&toVersion=" + version;
604+
url = GetAlphaReleaseNotesURL(version);
621605
}
622606
else
623607
{
@@ -630,6 +614,36 @@ public static bool OpenReleaseNotes(string version)
630614
return result;
631615
}
632616

617+
public static bool OpenReleaseNotes_Cumulative(string version)
618+
{
619+
bool result = false;
620+
if (string.IsNullOrEmpty(version)) return false;
621+
622+
string url = null;
623+
var comparisonVersion = version;
624+
//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"
625+
//so if we find a good installed candidate, we need the version just above it (installed or not) that has release notes page
626+
var closestInstalledVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
627+
if (closestInstalledVersion != null)
628+
{
629+
comparisonVersion = closestInstalledVersion;
630+
string nextFinalVersionAfterInstalled = closestInstalledVersion;
631+
632+
//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.
633+
do
634+
nextFinalVersionAfterInstalled = Tools.FindNearestVersion(nextFinalVersionAfterInstalled, MainWindow.updatesAsStrings);
635+
while (nextFinalVersionAfterInstalled != null && !HasAlphaReleaseNotes(nextFinalVersionAfterInstalled));
636+
637+
if (nextFinalVersionAfterInstalled != null) comparisonVersion = nextFinalVersionAfterInstalled;
638+
639+
}
640+
url = GetAlphaReleaseNotesURL(comparisonVersion,version);
641+
642+
OpenURL(url);
643+
result = true;
644+
return result;
645+
}
646+
633647
public static void OpenURL(string url)
634648
{
635649
Process.Start(url);

0 commit comments

Comments
 (0)