Skip to content

Commit b36f67a

Browse files
committed
add "win64" as default platform, add releasetype (lts/alpha/beta) to new project dialog, move releasetype checking to Tools, fix preferred version initial value from "none" to null,
1 parent 3ae9d10 commit b36f67a

File tree

7 files changed

+57
-21
lines changed

7 files changed

+57
-21
lines changed

Diff for: UnityLauncherPro/Data/UnityInstallation.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace UnityLauncherPro
66
public class UnityInstallation : IValueConverter
77
{
88
public string Version { set; get; }
9-
public long VersionCode { set; get; } // version as number, for sorting
9+
public long VersionCode { set; get; } // version as number, cached for sorting
1010
public string Path { set; get; } // exe path
1111
public DateTime? Installed { set; get; }
1212

@@ -16,6 +16,8 @@ public class UnityInstallation : IValueConverter
1616

1717
public bool IsPreferred { set; get; }
1818

19+
public string ReleaseType { set; get; } // Alpha, Beta, LTS.. TODO could be enum
20+
1921
// https://stackoverflow.com/a/5551986/5452781
2022
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
2123
{

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+6-14
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public partial class MainWindow : Window
3434
public static ObservableDictionary<string, string> unityInstalledVersions = new ObservableDictionary<string, string>(); // versionID and installation folder
3535
public static readonly string launcherArgumentsFile = "LauncherArguments.txt";
3636
public static readonly string projectNameFile = "ProjectName.txt";
37-
public static string preferredVersion = "none";
37+
public static string preferredVersion = null;
3838
public static int projectNameSetting = 0; // 0 = folder or ProjectName.txt if exists, 1=ProductName
3939

4040
const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
@@ -310,18 +310,9 @@ private bool UpdatesFilter(object item)
310310
bool checkedAlphas = (bool)rdoAlphas.IsChecked;
311311
bool checkedBetas = (bool)rdoBetas.IsChecked;
312312

313-
bool matchLTS = false;
314-
if (checkedLTSs)
315-
{
316-
var version = unity.Version.Split('.');
317-
var versionInt = int.Parse(version[0]);
318-
var versionMinor = int.Parse(version[1]);
319-
// https://unity3d.com/unity/qa/lts-releases
320-
matchLTS = (versionInt >= 2017 && versionMinor == 4) || (versionInt > 2019 && versionMinor == 3);
321-
}
322-
323-
bool matchAlphas = checkedAlphas && unity.Version.IndexOf("a", 0, StringComparison.CurrentCultureIgnoreCase) > -1;
324-
bool matchBetas = checkedBetas && unity.Version.IndexOf("b", 0, StringComparison.CurrentCultureIgnoreCase) > -1;
313+
bool matchLTS = checkedLTSs && Tools.IsLTS(unity.Version);
314+
bool matchAlphas = checkedAlphas && Tools.IsAlpha(unity.Version);
315+
bool matchBetas = checkedBetas && Tools.IsBeta(unity.Version);
325316

326317
// match search string and some radiobutton
327318
if (haveSearchString)
@@ -1804,7 +1795,8 @@ void CreateNewEmptyProject(string targetFolder = null)
18041795
Console.WriteLine("Missing selected Unity version, probably launching from context menu");
18051796
newVersion = preferredVersion;
18061797
// if no preferred version, use latest
1807-
if (preferredVersion == null) newVersion = unityInstallationsSource[0].Version;
1798+
if (string.IsNullOrEmpty(newVersion)) newVersion = unityInstallationsSource[0].Version;
1799+
18081800
}
18091801

18101802
var suggestedName = targetFolder != null ? Path.GetFileName(targetFolder) : Tools.GetSuggestedProjectName(newVersion, rootFolder);

Diff for: UnityLauncherPro/NewProject.xaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:UnityLauncherPro"
77
mc:Ignorable="d"
8-
Title="Create New Project" Height="460" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
8+
Title="Create New Project" Height="460" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
99

1010
<Grid>
1111
<StackPanel Margin="10,3">
1212
<Label Content="Unity Version" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0,0,0,3" Padding="5,5,5,3" />
1313
<DataGrid x:Name="gridAvailableVersions" KeyboardNavigation.TabNavigation = "None" SelectionMode="Single" Height="270" Margin="0" VerticalAlignment="Top" HeadersVisibility="None" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" Foreground="{DynamicResource ThemeButtonForeground}" Background="{DynamicResource ThemeMainBackgroundColor}" SelectionChanged="GridAvailableVersions_SelectionChanged" IsTabStop="True" TabIndex="1" Loaded="GridAvailableVersions_Loaded" EnableRowVirtualization="False" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" PreviewMouseDoubleClick="gridAvailableVersions_PreviewMouseDoubleClick">
1414
<DataGrid.Columns>
1515
<DataGridTextColumn Header="Version" Binding="{Binding Version}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
16-
<DataGridTextColumn Header="Platforms" Binding="{Binding PlatformsCombined}" IsReadOnly="True" CanUserResize="False" MinWidth="370" />
16+
<DataGridTextColumn Header="Platforms" Binding="{Binding PlatformsCombined}" IsReadOnly="True" CanUserResize="False" MinWidth="270" />
17+
<DataGridTextColumn Header="Release" Binding="{Binding ReleaseType}" IsReadOnly="True" CanUserResize="False" MinWidth="70" />
1718
</DataGrid.Columns>
1819
</DataGrid>
1920

Diff for: UnityLauncherPro/NewProject.xaml.cs

+22-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,29 @@ public NewProject(string unityVersion, string suggestedName, string targetFolder
3838
txtNewProjectName.Text = newName;
3939
lblNewProjectFolder.Content = targetFolder;
4040

41-
// fill available versions, TODO could show which modules are installed
42-
if (gridAvailableVersions.ItemsSource == null) gridAvailableVersions.ItemsSource = MainWindow.unityInstallationsSource;
41+
// fill available versions
42+
if (gridAvailableVersions.ItemsSource == null)
43+
{
44+
// get release type info (not done in mainwindow yet, to avoid doing extra stuff)
45+
for (int i = 0, len = MainWindow.unityInstallationsSource.Length; i < len; i++)
46+
{
47+
var vers = MainWindow.unityInstallationsSource[i].Version;
48+
if (Tools.IsLTS(vers))
49+
{
50+
MainWindow.unityInstallationsSource[i].ReleaseType = "LTS";
51+
}
52+
else if (Tools.IsAlpha(vers))
53+
{
54+
MainWindow.unityInstallationsSource[i].ReleaseType = "Alpha";
55+
}
56+
else if (Tools.IsBeta(vers))
57+
{
58+
MainWindow.unityInstallationsSource[i].ReleaseType = "Beta";
59+
}
60+
}
4361

62+
gridAvailableVersions.ItemsSource = MainWindow.unityInstallationsSource;
63+
}
4464
// we have that version installed
4565
if (MainWindow.unityInstalledVersions.ContainsKey(unityVersion) == true)
4666
{

Diff for: UnityLauncherPro/Properties/Settings.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: UnityLauncherPro/Properties/Settings.settings

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<Value Profile="(Default)" />
9797
</Setting>
9898
<Setting Name="newProjectPlatform" Type="System.String" Scope="User">
99-
<Value Profile="(Default)" />
99+
<Value Profile="(Default)">win64</Value>
100100
</Setting>
101101
<Setting Name="searchProjectPathAlso" Type="System.Boolean" Scope="User">
102102
<Value Profile="(Default)">False</Value>

Diff for: UnityLauncherPro/Tools.cs

+21
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,27 @@ public static void SetBuildStatus(Color color)
17771777
mainWindow.Dispatcher.Invoke(() => { mainWindow.SetBuildStatus(color); });
17781778
}
17791779

1780+
// https://unity3d.com/unity/alpha
1781+
public static bool IsAlpha(string version)
1782+
{
1783+
return version.IndexOf("a", 0, StringComparison.CurrentCultureIgnoreCase) > -1;
1784+
}
1785+
1786+
// https://unity3d.com/beta/
1787+
public static bool IsBeta(string version)
1788+
{
1789+
return version.IndexOf("b", 0, StringComparison.CurrentCultureIgnoreCase) > -1;
1790+
}
1791+
1792+
// https://unity3d.com/unity/qa/lts-releases
1793+
public static bool IsLTS(string versionRaw)
1794+
{
1795+
var version = versionRaw.Split('.');
1796+
var versionInt = int.Parse(version[0]);
1797+
var versionMinor = int.Parse(version[1]);
1798+
return (versionInt >= 2017 && versionMinor == 4) || (versionInt > 2019 && versionMinor == 3);
1799+
}
1800+
17801801
} // class
17811802

17821803
} // namespace

0 commit comments

Comments
 (0)