Skip to content

Commit

Permalink
Merge pull request #157 from SixParQuatre/MoreReleaseNotesButton
Browse files Browse the repository at this point in the history
Add 'Cumulative Release Note' button
  • Loading branch information
unitycoder authored Aug 15, 2024
2 parents 1df1105 + e9bb433 commit d3dfb03
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 23 deletions.
24 changes: 16 additions & 8 deletions UnityLauncherPro/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@
<!-- Tab: Projects-->
<TabItem Header="Projects" Style="{DynamicResource TabItemStyle1}" Padding="0,0,0,0" Margin="-1,1,1,-1" BorderBrush="{x:Null}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="185*"/>
<ColumnDefinition Width="693*"/>
</Grid.ColumnDefinitions>
<!-- search box -->
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" Grid.ColumnSpan="2" >
<!--<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />-->
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
<TextBlock.Style>
Expand Down Expand Up @@ -84,10 +88,10 @@
</Button>
</Grid>

<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" />
<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"/>
<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" />
<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"/>

<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" >
<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" >

<DataGrid.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="CopyRowFolderToClipBoard" CanExecute="CanExecute_Copy"/>
Expand Down Expand Up @@ -241,7 +245,7 @@
</DataGrid>

<!-- bottom buttoms row -->
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="14*" />
<ColumnDefinition Width="17*" />
Expand Down Expand Up @@ -492,7 +496,8 @@
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="18*" />
<ColumnDefinition Width="28*" />
<ColumnDefinition Width="26*" />
<ColumnDefinition Width="14*" />
<ColumnDefinition Width="18*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
Expand All @@ -507,7 +512,10 @@
<Label Content="Download &amp; Install" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
</Button>
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
<Label Content="Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
</Button>
<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." >
<Label Content="Cumulative Release Notes" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Control}, Mode=FindAncestor}}" />
</Button>
</Grid>
</Grid>
Expand Down Expand Up @@ -791,7 +799,7 @@
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<!--<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
<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" />
Expand Down
21 changes: 20 additions & 1 deletion UnityLauncherPro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public partial class MainWindow : Window
System.Windows.Forms.NotifyIcon notifyIcon;

Updates[] updatesSource;
public static List<string> updatesAsStrings;
public static List<string> updatesAsStrings = new List<string>();

string _filterString = null;
bool multiWordSearch = false;
Expand Down Expand Up @@ -140,6 +140,7 @@ void Start()

// clear updates grid
dataGridUpdates.Items.Clear();
dataGridUpdates.SelectionChanged += DataGridUpdates_SelectionChanged;

// clear buildreport grids
gridBuildReport.Items.Clear();
Expand Down Expand Up @@ -177,6 +178,18 @@ void Start()
isInitializing = false;
}

private void DataGridUpdates_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedUp = GetSelectedUpdate();
bool showCumulative = false;
if (selectedUp != null)
{
var unityVer = GetSelectedUpdate().Version;
showCumulative = Tools.HasAlphaReleaseNotes(unityVer);
}
btnShowCumulatedReleaseNotes.IsEnabled = showCumulative;
}

// bring old window to front, but needs matching appname.. https://stackoverflow.com/a/36804161/5452781
private static void ActivateOtherWindow()
{
Expand Down Expand Up @@ -1543,6 +1556,12 @@ private void BtnOpenWebsite_Click(object sender, RoutedEventArgs e)
Tools.OpenReleaseNotes(unity?.Version);
}

private void BtnShowCumulatedReleaseNotes_Click(object sender, RoutedEventArgs e)
{
var unity = GetSelectedUpdate();
Tools.OpenReleaseNotes_Cumulative(unity?.Version);
}

private void ChkMinimizeToTaskbar_CheckedChanged(object sender, RoutedEventArgs e)
{
if (this.IsActive == false) return; // dont run code on window init
Expand Down
59 changes: 45 additions & 14 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,28 +590,25 @@ public static bool VersionIsAlpha(string version)

public static bool VersionIsChinese(string version)
{
return version.Contains("c1");
return version.Contains("c1");
}


//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.
public static bool HasAlphaReleaseNotes(string version) => VersionIsArchived(version) || VersionIsPatch(version);

public static string GetAlphaReleaseNotesURL(string fromVersion, string toVersion = null)
=> "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + fromVersion + "&toVersion=" + (toVersion != null ? toVersion : fromVersion);

// open release notes page in browser
public static bool OpenReleaseNotes(string version)
{
bool result = false;
if (string.IsNullOrEmpty(version)) return false;

//var url = Tools.GetUnityReleaseURL(version);
string url = null;
bool noAlphaReleaseNotesPage = version.Contains("6000") && !version.Contains("f");
if (Properties.Settings.Default.useAlphaReleaseNotes && !noAlphaReleaseNotesPage)
if(Properties.Settings.Default.useAlphaReleaseNotes && HasAlphaReleaseNotes(version))
{
//with the alpha release notes, we want a diff between the 2 versions, but the site just shows all the changes inclusive of from
// so we need to compare the currently selected version to the one right after it that is available (installed or not)

var closestVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
var getNextVersionToClosest = closestVersion == null ? null : Tools.FindNearestVersion(version, MainWindow.updatesAsStrings);
if (getNextVersionToClosest == null) getNextVersionToClosest = version;

url = "https://alpha.release-notes.ds.unity3d.com/search?fromVersion=" + getNextVersionToClosest + "&toVersion=" + version;
url = GetAlphaReleaseNotesURL(version);
}
else
{
Expand All @@ -624,6 +621,36 @@ public static bool OpenReleaseNotes(string version)
return result;
}

public static bool OpenReleaseNotes_Cumulative(string version)
{
bool result = false;
if (string.IsNullOrEmpty(version)) return false;

string url = null;
var comparisonVersion = version;
//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"
//so if we find a good installed candidate, we need the version just above it (installed or not) that has release notes page
var closestInstalledVersion = Tools.FindNearestVersion(version, MainWindow.unityInstalledVersions.Keys.ToList(), true);
if (closestInstalledVersion != null)
{
comparisonVersion = closestInstalledVersion;
string nextFinalVersionAfterInstalled = closestInstalledVersion;

//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.
do
nextFinalVersionAfterInstalled = Tools.FindNearestVersion(nextFinalVersionAfterInstalled, MainWindow.updatesAsStrings);
while (nextFinalVersionAfterInstalled != null && !HasAlphaReleaseNotes(nextFinalVersionAfterInstalled));

if (nextFinalVersionAfterInstalled != null) comparisonVersion = nextFinalVersionAfterInstalled;

}
url = GetAlphaReleaseNotesURL(comparisonVersion,version);

OpenURL(url);
result = true;
return result;
}

public static void OpenURL(string url)
{
Process.Start(url);
Expand Down Expand Up @@ -1047,10 +1074,14 @@ private static string FetchUnityVersionNumberFromHTML(string url)

public static string FindNearestVersion(string currentVersion, List<string> allAvailable, bool checkBelow = false)
{
if (allAvailable == null)
return null;

string result = null;

// add current version to list, to sort it with others
allAvailable.Add(currentVersion);
if (!allAvailable.Contains(currentVersion))
allAvailable.Add(currentVersion);

// sort list
if (checkBelow)
Expand Down

0 comments on commit d3dfb03

Please sign in to comment.