Skip to content

Commit 614d00d

Browse files
committed
添加了更多下载设置、添加本地话资源
1 parent 1415f0a commit 614d00d

File tree

12 files changed

+260
-68
lines changed

12 files changed

+260
-68
lines changed

Natsurainko.FluentLauncher/Natsurainko.FluentLauncher.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<ItemGroup>
7575
<!-- NuGet Packages -->
7676
<PackageReference Include="ColorCode.WinUI" Version="2.0.15" />
77-
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250314-build.2076" />
77+
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250811-build.2202" />
7878
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
7979
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.2.250402" />
8080
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.2.250402" />
@@ -83,24 +83,24 @@
8383
<PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.2.250402" />
8484
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.250402" />
8585
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.250402" />
86-
<PackageReference Include="HelixToolkit.SharpDX.Assimp" Version="2.27.0" />
87-
<PackageReference Include="HelixToolkit.WinUI" Version="2.27.0" />
88-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.7" />
89-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.7" />
90-
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.7" />
86+
<PackageReference Include="HelixToolkit.SharpDX.Assimp" Version="2.27.2" />
87+
<PackageReference Include="HelixToolkit.WinUI" Version="2.27.2" />
88+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
89+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
90+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.8" />
9191
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
9292
<PrivateAssets>all</PrivateAssets>
9393
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9494
</PackageReference>
9595
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
96-
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4654" />
96+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4948" />
9797
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0" />
9898
<PackageReference Include="Serilog" Version="4.3.0" />
9999
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.0" />
100100
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
101101
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
102102
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
103-
<PackageReference Include="System.Management" Version="9.0.7" />
103+
<PackageReference Include="System.Management" Version="9.0.8" />
104104
<PackageReference Include="WindowsAPICodePack.Shell.CommonFileDialogs" Version="1.1.5" />
105105
<PackageReference Include="WinUIEx" Version="2.6.0" />
106106

Natsurainko.FluentLauncher/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
pages.WithPage<Views.Settings.AccountPage, ViewModels.Settings.AccountViewModel>("Settings/Account");
9999
pages.WithPage<Views.Settings.DownloadPage, ViewModels.Settings.DownloadViewModel>("Settings/Download");
100100
pages.WithPage<Views.Settings.AppearancePage, ViewModels.Settings.AppearanceViewModel>("Settings/Appearance");
101+
pages.WithPage<Views.Settings.LauncherPage, ViewModels.Settings.LauncherViewModel>("Settings/Launcher");
101102
pages.WithPage<Views.Settings.AboutPage, ViewModels.Settings.AboutViewModel>("Settings/About");
102103
pages.WithPage<Views.Settings.SkinPage, ViewModels.Settings.SkinViewModel>("Settings/Account/Skin");
103104

Natsurainko.FluentLauncher/Services/Network/CacheInterfaceService.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ internal class CacheInterfaceService(
3434
_ => LauncherMetaVersionManifest
3535
};
3636

37-
public string VersionManifestFileName => settingsService.CurrentDownloadSource switch
38-
{
39-
"Bmclapi" => "cache-interfaces\\bmclapi2.bangbang93.com\\version_manifest_v2.json",
40-
_ => "cache-interfaces\\piston-meta.mojang.com\\version_manifest_v2.json"
41-
};
42-
4337
public Task<string?> RequestStringAsync(string url, InterfaceRequestMethod method, string? targetFileName = default)
4438
=> RequestStringAsync(url, method, task => { }, targetFileName);
4539

Natsurainko.FluentLauncher/Services/Network/DownloadService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public DownloadService(
6464

6565
_settingsService.MaxDownloadThreadsChanged += (_, _) => SetDownloader();
6666
_settingsService.CurrentDownloadSourceChanged += (_, _) => SetDownloader();
67+
_settingsService.MaxRetryCountChanged += (_, _) => SetDownloader();
68+
_settingsService.EnableFragmentDownloadChanged += (_, _) => SetDownloader();
6769
}
6870

6971
public async Task DownloadResourceFileAsync(CurseForgeFile curseForgeFile, string folder, Action<string>? continueWith = null)
@@ -194,10 +196,11 @@ private void SetDownloader()
194196
{
195197
_downloader = new(
196198
httpClient: _httpClient,
197-
workersPerDownloadTask: 8,
199+
workersPerDownloadTask: _settingsService.FragmentDownloadWorkerCount,
198200
concurrentDownloadTasks: _settingsService.MaxDownloadThreads,
199201
enableMultiPartDownload: _settingsService.EnableFragmentDownload,
200-
mirror: DownloadMirror);
202+
mirror: DownloadMirror,
203+
maxRetryCount: _settingsService.MaxRetryCount);
201204
}
202205

203206
IInstanceInstaller GetInstanceInstaller(

Natsurainko.FluentLauncher/Services/Settings/SettingsService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Text.Json.Nodes;
1010
using Windows.Storage;
1111
using Windows.Win32.UI.WindowsAndMessaging;
12+
using static System.Runtime.InteropServices.JavaScript.JSType;
1213

1314
namespace Natsurainko.FluentLauncher.Services.Settings;
1415

@@ -87,15 +88,21 @@ public partial class SettingsService : SettingsContainer
8788

8889
#region Download Settings
8990

90-
[SettingItem(Default = "Mojang", Converter = typeof(JsonStringConverter<string>))]
91+
[SettingItem(Default = "Official", Converter = typeof(JsonStringConverter<string>))]
9192
public partial string CurrentDownloadSource { get; set; }
9293

9394
[SettingItem(Default = true, Converter = typeof(JsonStringConverter<bool>))]
9495
public partial bool EnableFragmentDownload { get; set; }
9596

97+
[SettingItem(Default = 4, Converter = typeof(JsonStringConverter<int>))]
98+
public partial int FragmentDownloadWorkerCount { get; set; }
99+
96100
[SettingItem(Default = 64, Converter = typeof(JsonStringConverter<int>))]
97101
public partial int MaxDownloadThreads { get; set; }
98102

103+
[SettingItem(Default = 6, Converter = typeof(JsonStringConverter<int>))]
104+
public partial int MaxRetryCount { get; set; }
105+
99106
#endregion
100107

101108
[SettingItem(Default = "")]

Natsurainko.FluentLauncher/ViewModels/Settings/DownloadViewModel.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ internal partial class DownloadViewModel : SettingsPageVM, ISettingsViewModel
1414
private readonly SettingsService _settingsService;
1515
private readonly LocalStorageService _localStorageService;
1616

17-
[ObservableProperty]
18-
[BindToSetting(Path = nameof(SettingsService.CurrentDownloadSource))]
19-
public partial string CurrentDownloadSource { get; set; }
20-
2117
[ObservableProperty]
2218
[BindToSetting(Path = nameof(SettingsService.MaxDownloadThreads))]
2319
public partial int MaxDownloadThreads { get; set; }
@@ -26,18 +22,37 @@ internal partial class DownloadViewModel : SettingsPageVM, ISettingsViewModel
2622
[BindToSetting(Path = nameof(SettingsService.EnableFragmentDownload))]
2723
public partial bool EnableFragmentDownload { get; set; }
2824

29-
public string CoreConfigurationsFolder => _localStorageService.GetDirectory("GameConfigsFolder").FullName;
25+
[ObservableProperty]
26+
[BindToSetting(Path = nameof(SettingsService.FragmentDownloadWorkerCount))]
27+
public partial int FragmentDownloadWorkerCount { get; set; }
28+
29+
[ObservableProperty]
30+
[BindToSetting(Path = nameof(SettingsService.MaxRetryCount))]
31+
public partial int MaxRetryCount { get; set; }
3032

31-
public string LauncherCacheFolder => LocalStorageService.LocalFolderPath;
33+
[ObservableProperty]
34+
public partial int CurrentDownloadSource { get; set; }
35+
36+
partial void OnCurrentDownloadSourceChanged(int value)
37+
{
38+
_settingsService.CurrentDownloadSource = CurrentDownloadSource switch
39+
{
40+
1 => "Bmclapi",
41+
_ => "Official"
42+
};
43+
}
3244

3345
public DownloadViewModel(SettingsService settingsService, LocalStorageService localStorageService)
3446
{
3547
_settingsService = settingsService;
3648
_localStorageService = localStorageService;
3749

3850
(this as ISettingsViewModel).InitializeSettings();
39-
}
4051

41-
[RelayCommand]
42-
void OpenCacheFolder(string folder) => ExplorerHelper.OpenFolder(folder);
52+
CurrentDownloadSource = settingsService.CurrentDownloadSource switch
53+
{
54+
"Bmclapi" => 1,
55+
_ => 0
56+
};
57+
}
4358
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using FluentLauncher.Infra.Settings.Mvvm;
3+
using Natsurainko.FluentLauncher.Services.Settings;
4+
5+
namespace Natsurainko.FluentLauncher.ViewModels.Settings;
6+
7+
internal partial class LauncherViewModel : SettingsPageVM, ISettingsViewModel
8+
{
9+
[SettingsProvider]
10+
private readonly SettingsService _settingsService;
11+
12+
[ObservableProperty]
13+
public partial int AfterInstanceLaunched { get; set; }
14+
15+
public LauncherViewModel(SettingsService settingsService)
16+
{
17+
_settingsService = settingsService;
18+
19+
(this as ISettingsViewModel).InitializeSettings();
20+
}
21+
}

Natsurainko.FluentLauncher/Views/Settings/DefaultPage.xaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
x:Uid="Settings_DefaultPage_Card3"
4747
Command="{x:Bind VM.CardClickCommand}"
4848
CommandParameter="Settings/Download"
49-
Description="Adjust download performance, set download sources, and manage cache"
50-
Header="Download &amp; Cache settings"
49+
Description="Adjust network and download settings, including setting download sources, adjusting download behavior, etc."
50+
Header="Network &amp; Download settings"
5151
HeaderIcon="{xh:FontIcon Glyph=&#xe896;}"
5252
IsClickEnabled="True" />
5353

@@ -60,6 +60,15 @@
6060
HeaderIcon="{xh:FontIcon Glyph=&#xE790;}"
6161
IsClickEnabled="True" />
6262

63+
<controls:SettingsCard
64+
x:Uid="Settings_DefaultPage_Card5"
65+
Command="{x:Bind VM.CardClickCommand}"
66+
CommandParameter="Settings/Launcher"
67+
Description="Launcher application settings, including user interface behavior, application storage settings, program running logs, etc."
68+
Header="Launcher settings"
69+
HeaderIcon="{xh:FontIcon Glyph=&#xE737;}"
70+
IsClickEnabled="True" />
71+
6372
<controls:SettingsCard
6473
x:Name="ExtensionsCard"
6574
x:Load="{x:Bind ENABLE_LOAD_EXTENSIONS}"
@@ -76,7 +85,8 @@
7685
Text="Language" />
7786

7887
<controls:SettingsCard
79-
x:Uid="Settings_DefaultPage_Card5"
88+
x:Uid="Settings_DefaultPage_Card6"
89+
Description="The translation is not guaranteed to be 100% accurate. The translated texts for some languages ​​are provided by machine translation or community contributors."
8090
Header="Language Settings"
8191
HeaderIcon="{xh:FontIcon Glyph=&#xf2b7;}">
8292
<mycontrols:NoScrollingComboBox ItemsSource="{x:Bind utils:LocalizedStrings.SupportedLanguages}" SelectedItem="{x:Bind VM.CurrentLanguage, Mode=TwoWay, Converter={StaticResource LanguageInfoConverter}}">
@@ -109,10 +119,10 @@
109119
Text="About" />
110120

111121
<controls:SettingsCard
112-
x:Uid="Settings_DefaultPage_Card6"
122+
x:Uid="Settings_DefaultPage_Card7"
113123
Command="{x:Bind VM.CardClickCommand}"
114124
CommandParameter="Settings/About"
115-
Description="Xcube Studio ©2022-2024. All rights reserved."
125+
Description="Xcube Studio ©2022-2025. All rights reserved."
116126
Header="Fluent Launcher"
117127
IsClickEnabled="True">
118128

Natsurainko.FluentLauncher/Views/Settings/DownloadPage.xaml

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,36 @@
2626
<TextBlock
2727
x:Uid="Settings_DownloadPage_T1"
2828
Style="{ThemeResource SettingsTitleSectionHeaderTextBlockStyle}"
29-
Text="Download" />
29+
Text="Network" />
3030

3131
<controls:SettingsCard
3232
x:Uid="Settings_DownloadPage_Card1"
33-
Header="Current download sources"
33+
Description="Applicable to Minecraft original list pull and instance installation, loader installation, not applicable to other resource interfaces"
34+
Header="Current download source"
3435
HeaderIcon="{xh:FontIcon Glyph=&#xEBD3;}">
35-
<ComboBox SelectedItem="{x:Bind VM.CurrentDownloadSource, Mode=TwoWay}">
36-
<x:String>Mojang</x:String>
37-
<x:String>Bmclapi</x:String>
36+
<ComboBox MinWidth="200" SelectedIndex="{x:Bind VM.CurrentDownloadSource, Mode=TwoWay}">
37+
<ComboBoxItem x:Uid="Settings_DownloadPage_Item1" Content="Official Download Sources (except OptiFine)" />
38+
<ComboBoxItem x:Uid="Settings_DownloadPage_Item2" Content="bangbang93's Mirror Download Source" />
3839
</ComboBox>
3940
</controls:SettingsCard>
4041

4142
<controls:SettingsCard
4243
x:Uid="Settings_DownloadPage_Card2"
43-
Description="Please optimize and adjust according to the actual network environment"
44+
Description="Community-provided mirror interfaces (Mcim)"
45+
Header="Mirror interfaces for third-party resources (for CurseForge and Modrinth)"
46+
HeaderIcon="{xh:FontIcon Glyph=&#xEBD3;}"
47+
IsEnabled="False">
48+
<ToggleSwitch />
49+
</controls:SettingsCard>
50+
51+
<TextBlock
52+
x:Uid="Settings_DownloadPage_T2"
53+
Style="{ThemeResource SettingsSectionHeaderTextBlockStyle}"
54+
Text="Download Behavior" />
55+
56+
<controls:SettingsCard
57+
x:Uid="Settings_DownloadPage_Card3"
58+
Description="We recommend that this value should not be higher than 64. Too high a number of download threads may be considered an attack or an unreasonable request by the server and the connection may be rejected."
4459
Header="Maximum number of download threads"
4560
HeaderIcon="{xh:FontIcon Glyph=&#xE713;}">
4661
<StackPanel Orientation="Horizontal" Spacing="10">
@@ -62,48 +77,63 @@
6277
</controls:SettingsCard>
6378

6479
<controls:SettingsCard
65-
x:Uid="Settings_DownloadPage_Card3"
80+
x:Uid="Settings_DownloadPage_Card4"
6681
Description="Can effectively speed up when encountering large files"
6782
Header="Enable fragmented download of large files"
6883
HeaderIcon="{xh:FontIcon Glyph=&#xEC4A;}">
6984
<ToggleSwitch IsOn="{x:Bind VM.EnableFragmentDownload, Mode=TwoWay}" />
7085
</controls:SettingsCard>
7186

72-
<TextBlock
73-
x:Uid="Settings_DownloadPage_T2"
74-
Style="{ThemeResource SettingsSectionHeaderTextBlockStyle}"
75-
Text="Cache" />
76-
7787
<controls:SettingsCard
78-
x:Uid="Settings_DownloadPage_Card4"
79-
ActionIcon="{xh:FontIcon Glyph=&#xED43;}"
80-
Command="{x:Bind VM.OpenCacheFolderCommand}"
81-
CommandParameter="{x:Bind VM.CoreConfigurationsFolder, Mode=OneWay}"
82-
Header="Specific core configuration storage directory"
83-
HeaderIcon="{xh:FontIcon Glyph=&#xED43;}"
84-
IsClickEnabled="True">
85-
<controls:SettingsCard.Description>
88+
x:Uid="Settings_DownloadPage_Card5"
89+
Description="We recommend that this value should not be higher than 8. Too high a number of download threads may be considered an attack or an unreasonable request by the server and the connection may be rejected."
90+
Header="Number of download shards"
91+
HeaderIcon="{xh:FontIcon Glyph=&#xE713;}"
92+
IsEnabled="{x:Bind VM.EnableFragmentDownload, Mode=OneWay}">
93+
<StackPanel Orientation="Horizontal" Spacing="10">
8694
<TextBlock
87-
Text="{x:Bind VM.CoreConfigurationsFolder, Mode=OneWay}"
88-
TextTrimming="CharacterEllipsis"
89-
TextWrapping="NoWrap" />
90-
</controls:SettingsCard.Description>
95+
VerticalAlignment="Center"
96+
Style="{ThemeResource BaseTextBlockStyle}"
97+
Text="{x:Bind VM.FragmentDownloadWorkerCount, Mode=OneWay}" />
98+
99+
<Slider
100+
Width="128"
101+
Maximum="16"
102+
Minimum="4"
103+
SnapsTo="Ticks"
104+
TickFrequency="2"
105+
TickPlacement="Outside"
106+
Value="{x:Bind VM.FragmentDownloadWorkerCount, Mode=TwoWay}">
107+
<i:Interaction.Behaviors>
108+
<behaviors:SettingsCardContentMaxWidthBehavior AscendentType="Grid" AutoMaxWidth="True" />
109+
</i:Interaction.Behaviors>
110+
</Slider>
111+
</StackPanel>
91112
</controls:SettingsCard>
92113

93114
<controls:SettingsCard
94-
x:Uid="Settings_DownloadPage_Card5"
95-
ActionIcon="{xh:FontIcon Glyph=&#xED43;}"
96-
Command="{x:Bind VM.OpenCacheFolderCommand}"
97-
CommandParameter="{x:Bind VM.LauncherCacheFolder, Mode=OneWay}"
98-
Header="Launcher cache folder (including caches of images, texts, interfaces, etc.)"
99-
HeaderIcon="{xh:FontIcon Glyph=&#xED43;}"
100-
IsClickEnabled="True">
101-
<controls:SettingsCard.Description>
115+
x:Uid="Settings_DownloadPage_Card6"
116+
Header="Maximum number of retries when download fails"
117+
HeaderIcon="{xh:FontIcon Glyph=&#xE72C;}">
118+
<StackPanel Orientation="Horizontal" Spacing="10">
102119
<TextBlock
103-
Text="{x:Bind VM.LauncherCacheFolder, Mode=OneWay}"
104-
TextTrimming="CharacterEllipsis"
105-
TextWrapping="NoWrap" />
106-
</controls:SettingsCard.Description>
120+
VerticalAlignment="Center"
121+
Style="{ThemeResource BaseTextBlockStyle}"
122+
Text="{x:Bind VM.MaxRetryCount, Mode=OneWay}" />
123+
124+
<Slider
125+
Width="128"
126+
Maximum="8"
127+
Minimum="4"
128+
SnapsTo="Ticks"
129+
TickFrequency="2"
130+
TickPlacement="Outside"
131+
Value="{x:Bind VM.MaxRetryCount, Mode=TwoWay}">
132+
<i:Interaction.Behaviors>
133+
<behaviors:SettingsCardContentMaxWidthBehavior AscendentType="Grid" AutoMaxWidth="True" />
134+
</i:Interaction.Behaviors>
135+
</Slider>
136+
</StackPanel>
107137
</controls:SettingsCard>
108138

109139
</StackPanel>

0 commit comments

Comments
 (0)