Skip to content

Commit fd47430

Browse files
committed
add setting for using unoffical releases list
1 parent a870bb8 commit fd47430

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

UnityLauncherPro/GetUnityUpdates.cs

+15-14
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,29 @@ public static class GetUnityUpdates
1919

2020
static Dictionary<string, string> unofficialReleaseURLs = new Dictionary<string, string>();
2121

22-
public static async Task<List<UnityVersion>> FetchAll()
22+
public static async Task<List<UnityVersion>> FetchAll(bool useUnofficialList = false)
2323
{
2424
var cachedVersions = LoadCachedVersions();
2525
var newVersions = await FetchNewVersions(cachedVersions);
2626

27-
var unofficialVersions = await FetchUnofficialVersions(cachedVersions);
27+
var allVersions = newVersions.Concat(cachedVersions).ToList();
2828

29-
unofficialReleaseURLs.Clear();
30-
// TODO modify FetchUnofficialVersions to put items in this dictionary directly
31-
foreach (var version in unofficialVersions)
29+
if (useUnofficialList == true)
3230
{
33-
//Console.WriteLine("unofficial: " + version.Version + " , " + version.directURL);
34-
if (unofficialReleaseURLs.ContainsKey(version.Version) == false)
31+
var unofficialVersions = await FetchUnofficialVersions(cachedVersions);
32+
unofficialReleaseURLs.Clear();
33+
// TODO modify FetchUnofficialVersions to put items in this dictionary directlys
34+
foreach (var version in unofficialVersions)
3535
{
36-
unofficialReleaseURLs.Add(version.Version, version.directURL);
36+
//Console.WriteLine("unofficial: " + version.Version + " , " + version.directURL);
37+
if (unofficialReleaseURLs.ContainsKey(version.Version) == false)
38+
{
39+
unofficialReleaseURLs.Add(version.Version, version.directURL);
40+
}
3741
}
42+
allVersions = unofficialVersions.Concat(allVersions).ToList();
3843
}
3944

40-
var allVersions = newVersions.Concat(unofficialVersions).Concat(cachedVersions).ToList();
41-
//var allVersions = newVersions.Concat(cachedVersions).ToList();
42-
43-
// TODO save unofficial versions to cache also? or maybe not, they will appear in official list later
4445
if (newVersions.Count > 0)
4546
{
4647
SaveCachedVersions(allVersions);
@@ -168,9 +169,9 @@ private static async Task<string> ExtractDownloadUrlAsync(string json, string un
168169
Console.WriteLine("Unofficial release found in the list.");
169170

170171
string unityHash = ParseHashCodeFromURL(unofficialReleaseURLs[unityVersion]);
171-
// Console.WriteLine(unityHash);
172+
// Console.WriteLine(unityHash);
172173
string downloadURL = Tools.ParseDownloadURLFromWebpage(unityVersion, unityHash, false, true);
173-
// Console.WriteLine("direct download url: "+downloadURL);
174+
// Console.WriteLine("direct download url: "+downloadURL);
174175
return downloadURL;
175176
}
176177

UnityLauncherPro/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@
810810
<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"/>
811811
<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"/>
812812
<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"/>
813+
<CheckBox x:Name="useUnofficialReleaseList" Content="Use Unofficial Release Watch List (for latest downloads)" ToolTip="Checks latest releases from https://github.com/unitycoder/UnofficialUnityReleasesWatcher (if not yet available in The Unity Releases API)" Checked="useUnofficialReleaseList_Checked" Unchecked="useUnofficialReleaseList_Checked"/>
813814
<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"/>
814815
<!--<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
815816
<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" />

UnityLauncherPro/MainWindow.xaml.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ void LoadSettings()
459459
txtWebglRelativePath.Text = Settings.Default.webglBuildPath;
460460
txtCustomThemeFile.Text = Settings.Default.themeFile;
461461
useAlphaReleaseNotesSite.IsChecked = Settings.Default.useAlphaReleaseNotes;
462+
useUnofficialReleaseList.IsChecked = Settings.Default.useUnofficialReleaseList;
462463

463464
chkEnablePlatformSelection.IsChecked = Settings.Default.enablePlatformSelection;
464465
chkRunAutomatically.IsChecked = Settings.Default.runAutomatically;
@@ -783,7 +784,7 @@ void AddUnityInstallationRootFolder()
783784
async Task CallGetUnityUpdates()
784785
{
785786
dataGridUpdates.ItemsSource = null;
786-
var task = GetUnityUpdates.FetchAll();
787+
var task = GetUnityUpdates.FetchAll((bool)useUnofficialReleaseList.IsChecked);
787788
var items = await task;
788789
updatesSource = items.ToArray();
789790
if (updatesSource == null) return;
@@ -1105,7 +1106,7 @@ private async void OnTabSelectionChanged(object sender, SelectionChangedEventArg
11051106
// if we dont have previous results yet, TODO scan again if previous was 24hrs ago
11061107
if (updatesSource == null)
11071108
{
1108-
var task = GetUnityUpdates.FetchAll();
1109+
var task = GetUnityUpdates.FetchAll((bool)useUnofficialReleaseList.IsChecked);
11091110
var items = await task;
11101111
if (task.IsCompleted == false || task.IsFaulted == true) return;
11111112
if (items == null) return;
@@ -3832,6 +3833,14 @@ private void chkCheckSRP_Checked(object sender, RoutedEventArgs e)
38323833
Settings.Default.Save();
38333834
RefreshRecentProjects();
38343835
}
3836+
3837+
private void useUnofficialReleaseList_Checked(object sender, RoutedEventArgs e)
3838+
{
3839+
if (this.IsActive == false) return; // dont run code on window init
3840+
3841+
Settings.Default.useUnofficialReleaseList = (bool)useUnofficialReleaseList.IsChecked;
3842+
Settings.Default.Save();
3843+
}
38353844
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
38363845
//{
38373846
// var proj = GetSelectedProject();

UnityLauncherPro/Properties/Settings.Designer.cs

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

UnityLauncherPro/Properties/Settings.settings

+3
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,8 @@
148148
<Setting Name="checkSRP" Type="System.Boolean" Scope="User">
149149
<Value Profile="(Default)">False</Value>
150150
</Setting>
151+
<Setting Name="useUnofficialReleaseList" Type="System.Boolean" Scope="User">
152+
<Value Profile="(Default)">False</Value>
153+
</Setting>
151154
</Settings>
152155
</SettingsFile>

0 commit comments

Comments
 (0)