Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11c9ffc

Browse files
authored
Merge pull request#167 from Legi428/AsyncReleasesDL
Fix issues with fetching updates of Unity versions by using the new Api
2 parentsf9cf564 +64cc970 commit11c9ffc

15 files changed

+531
-431
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespaceUnityLauncherPro
2+
{
3+
publicreadonlystructDownloadProgress
4+
{
5+
publiclongTotalRead{get;}
6+
publiclongTotalBytes{get;}
7+
8+
publicDownloadProgress(longtotalRead,longtotalBytes)
9+
{
10+
TotalRead=totalRead;
11+
TotalBytes=totalBytes;
12+
}
13+
}
14+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
usingSystem;
2+
usingSystem.Text.Json;
3+
usingSystem.Text.Json.Serialization;
4+
5+
namespaceUnityLauncherPro
6+
{
7+
publicclassUnityVersion
8+
{
9+
[JsonPropertyName("version")]
10+
publicstringVersion{get;set;}
11+
[JsonPropertyName("stream")]
12+
[JsonConverter(typeof(UnityVersionStreamConverter))]
13+
publicUnityVersionStreamStream{get;set;}
14+
[JsonPropertyName("releaseDate")]
15+
publicDateTimeReleaseDate{get;set;}
16+
}
17+
18+
publicclassUnityVersionStreamConverter:JsonConverter<UnityVersionStream>
19+
{
20+
publicoverrideUnityVersionStreamRead(refUtf8JsonReaderreader,TypetypeToConvert,JsonSerializerOptionsoptions)
21+
{
22+
stringstreamString=reader.GetString();
23+
if(Enum.TryParse<UnityVersionStream>(streamString,true,outvarresult))
24+
{
25+
returnresult;
26+
}
27+
thrownewJsonException($"Unable to convert\"{streamString}\" to UnityVersionStream");
28+
}
29+
30+
publicoverridevoidWrite(Utf8JsonWriterwriter,UnityVersionStreamvalue,JsonSerializerOptionsoptions)
31+
{
32+
writer.WriteStringValue(value.ToString().ToUpper());
33+
}
34+
}
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
usingSystem.Collections.Generic;
2+
usingSystem.Text.Json.Serialization;
3+
4+
namespaceUnityLauncherPro
5+
{
6+
publicclassUnityVersionResponse
7+
{
8+
[JsonPropertyName("offset")]
9+
publicintOffset{get;set;}
10+
[JsonPropertyName("limit")]
11+
publicintLimit{get;set;}
12+
[JsonPropertyName("total")]
13+
publicintTotal{get;set;}
14+
[JsonPropertyName("results")]
15+
publicList<UnityVersion>Results{get;set;}
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespaceUnityLauncherPro
2+
{
3+
publicenumUnityVersionStream
4+
{
5+
Alpha,
6+
Beta,
7+
LTS,
8+
Tech
9+
}
10+
}

‎UnityLauncherPro/Data/Updates.cs‎

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Windowx:Class="UnityLauncherPro.DownloadProgressWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Title="Download Progress"Height="70"Width="500"
5+
ResizeMode="NoResize"
6+
WindowStyle="None"
7+
PreviewLostKeyboardFocus="Window_PreviewLostKeyboardFocus"
8+
Background="{DynamicResource ThemeDarkestBackground}">
9+
<Grid>
10+
<Grid>
11+
<LabelContent="{Binding Title, RelativeSource={RelativeSource AncestorType=Window}, FallbackValue=Title}"IsHitTestVisible="False"Margin="5,0,0,-5"Foreground="{DynamicResource ThemeMainTitle}"FontSize="12"HorizontalAlignment="Left" />
12+
<ButtonBorderThickness="0"Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"HorizontalAlignment="Right"VerticalAlignment="Top"Height="23"Width="23"Background="Transparent"Click="CancelDownloadClick"Padding="0,2"IsTabStop="False">
13+
<TextBlockText=""FontSize="10"Foreground="{DynamicResource ThemeWindowMinClose}"Padding="5,3,4,4"HorizontalAlignment="Center" />
14+
</Button>
15+
</Grid>
16+
<GridVerticalAlignment="Bottom"Background="{DynamicResource ThemeMainBackgroundColor}">
17+
<ProgressBarx:Name="ProgressBar"Height="23"VerticalAlignment="Center"Margin="10, 10, 70, 10"/>
18+
<TextBlockx:Name="ProgressText"Text="0%"VerticalAlignment="Center"HorizontalAlignment="Center"Margin="10, 10, 70, 10"/>
19+
<ButtonStyle="{StaticResource CustomButton}"Content="Cancel"Width="50"Height="23"HorizontalAlignment="Right"Margin="10"Click="CancelDownloadClick"/>
20+
</Grid>
21+
</Grid>
22+
</Window>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
usingSystem;
2+
usingSystem.Windows;
3+
usingSystem.Windows.Input;
4+
5+
namespaceUnityLauncherPro
6+
{
7+
publicpartialclassDownloadProgressWindow
8+
{
9+
privatereadonlyAction_cancelAction;
10+
privatereadonlystring_subjectName;
11+
privatestaticMainWindowMainWindow=>Tools.mainWindow;
12+
13+
publicDownloadProgressWindow(stringsubjectName,ActioncancelAction=null)
14+
{
15+
InitializeComponent();
16+
_subjectName=subjectName;
17+
Title=subjectName;
18+
_cancelAction=cancelAction;
19+
Topmost=true;
20+
Owner=MainWindow;
21+
WindowStartupLocation=WindowStartupLocation.CenterOwner;
22+
MainWindow.IsEnabled=false;
23+
}
24+
25+
publicvoidUpdateProgress(DownloadProgressdownloadProgress)
26+
{
27+
Title=$"Downloading{_subjectName} ({downloadProgress.TotalRead/1024d/1024d:F1} MB /{downloadProgress.TotalBytes/1024d/1024d:F1} MB)";
28+
varprogress=downloadProgress.TotalBytes==0?0:downloadProgress.TotalRead*100d/downloadProgress.TotalBytes;
29+
ProgressBar.Value=progress;
30+
ProgressText.Text=$"{progress/100:P1}";
31+
}
32+
33+
privatevoidCancelDownloadClick(objectsender,RoutedEventArgse)
34+
{
35+
CancelDownload();
36+
}
37+
38+
privatevoidCancelDownload()
39+
{
40+
_cancelAction?.Invoke();
41+
}
42+
43+
privatevoidWindow_PreviewLostKeyboardFocus(objectsender,KeyboardFocusChangedEventArgse)
44+
{
45+
varwindow=(Window)sender;
46+
window.Topmost=true;
47+
}
48+
49+
protectedoverridevoidOnClosed(EventArgse)
50+
{
51+
base.OnClosed(e);
52+
_cancelAction?.Invoke();
53+
MainWindow.IsEnabled=true;
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp