diff --git a/src/Snap.Hutao/.editorconfig b/src/Snap.Hutao/.editorconfig index d3d7c0b4..5905c66a 100644 --- a/src/Snap.Hutao/.editorconfig +++ b/src/Snap.Hutao/.editorconfig @@ -110,7 +110,6 @@ dotnet_diagnostic.SA1642.severity = none dotnet_diagnostic.IDE0005.severity = warning dotnet_diagnostic.IDE0060.severity = none -dotnet_diagnostic.IDE0290.severity = none # SA1208: System using directives should be placed before other using directives dotnet_diagnostic.SA1208.severity = none @@ -321,7 +320,8 @@ dotnet_diagnostic.CA2227.severity = suggestion # CA2251: 使用 “string.Equals” dotnet_diagnostic.CA2251.severity = suggestion -csharp_style_prefer_primary_constructors = true:suggestion + +csharp_style_prefer_primary_constructors = false:none [*.vb] #### 命名样式 #### diff --git a/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs b/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs index 3db6ad1f..3c345662 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs @@ -3,6 +3,7 @@ using Microsoft.Win32.SafeHandles; using Snap.Hutao.Core.Diagnostics; +using System.Buffers; using System.IO; using System.Net.Http; @@ -77,34 +78,36 @@ internal sealed class HttpShardCopyWorker : IDisposable using (HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); - - Memory buffer = new byte[bufferSize]; - using (Stream stream = await response.Content.ReadAsStreamAsync(token).ConfigureAwait(false)) + using (IMemoryOwner memoryOwner = MemoryPool.Shared.Rent()) { - int totalBytesRead = 0; - int bytesReadAfterPreviousReport = 0; - do + Memory buffer = memoryOwner.Memory; + using (Stream stream = await response.Content.ReadAsStreamAsync(token).ConfigureAwait(false)) { - int bytesRead = await stream.ReadAsync(buffer, token).ConfigureAwait(false); - if (bytesRead <= 0) + int totalBytesRead = 0; + int bytesReadAfterPreviousReport = 0; + do { - progress.Report(new(bytesReadAfterPreviousReport)); - bytesReadAfterPreviousReport = 0; - break; - } + int bytesRead = await stream.ReadAsync(buffer, token).ConfigureAwait(false); + if (bytesRead <= 0) + { + progress.Report(new(bytesReadAfterPreviousReport)); + bytesReadAfterPreviousReport = 0; + break; + } - await RandomAccess.WriteAsync(destFileHandle, buffer[..bytesRead], shard.StartOffset + totalBytesRead, token).ConfigureAwait(false); + await RandomAccess.WriteAsync(destFileHandle, buffer[..bytesRead], shard.StartOffset + totalBytesRead, token).ConfigureAwait(false); - totalBytesRead += bytesRead; - bytesReadAfterPreviousReport += bytesRead; - if (stopwatch.GetElapsedTime().TotalMilliseconds > 500) - { - progress.Report(new(bytesReadAfterPreviousReport)); - bytesReadAfterPreviousReport = 0; - stopwatch = ValueStopwatch.StartNew(); + totalBytesRead += bytesRead; + bytesReadAfterPreviousReport += bytesRead; + if (stopwatch.GetElapsedTime().TotalMilliseconds > 500) + { + progress.Report(new(bytesReadAfterPreviousReport)); + bytesReadAfterPreviousReport = 0; + stopwatch = ValueStopwatch.StartNew(); + } } + while (true); } - while (true); } } } diff --git a/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamCopyWorker.cs b/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamCopyWorker.cs index 31455288..f27c9416 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamCopyWorker.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamCopyWorker.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using Snap.Hutao.Core.Diagnostics; +using System.Buffers; using System.IO; namespace Snap.Hutao.Core.IO; @@ -51,26 +52,30 @@ internal class StreamCopyWorker long totalBytesRead = 0; int bytesRead; - Memory buffer = new byte[bufferSize]; - do + using (IMemoryOwner memoryOwner = MemoryPool.Shared.Rent(bufferSize)) { - bytesRead = await source.ReadAsync(buffer).ConfigureAwait(false); - if (bytesRead == 0) - { - progress.Report(statusFactory(totalBytesRead)); - break; - } + Memory buffer = memoryOwner.Memory; - await destination.WriteAsync(buffer[..bytesRead]).ConfigureAwait(false); - - totalBytesRead += bytesRead; - if (stopwatch.GetElapsedTime().TotalMilliseconds > 1000) + do { - progress.Report(statusFactory(totalBytesRead)); - stopwatch = ValueStopwatch.StartNew(); + bytesRead = await source.ReadAsync(buffer).ConfigureAwait(false); + if (bytesRead is 0) + { + progress.Report(statusFactory(totalBytesRead)); + break; + } + + await destination.WriteAsync(buffer[..bytesRead]).ConfigureAwait(false); + + totalBytesRead += bytesRead; + if (stopwatch.GetElapsedTime().TotalMilliseconds > 1000) + { + progress.Report(statusFactory(totalBytesRead)); + stopwatch = ValueStopwatch.StartNew(); + } } + while (bytesRead > 0); } - while (bytesRead > 0); } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/Activation.cs b/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/Activation.cs index b84fedf3..beb3f261 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/Activation.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/Activation.cs @@ -116,15 +116,15 @@ internal sealed partial class Activation : IActivation // If it's the first time launch, we show the guide window anyway. // Otherwise, we check if there's any unfulfilled resource category present. - if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, GuideState.Language) >= GuideState.StaticResourceBegin) + if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) >= GuideState.StaticResourceBegin) { if (StaticResource.IsAnyUnfulfilledCategoryPresent()) { - UnsafeLocalSetting.Set(SettingKeys.Major1Minor7Revision0GuideState, GuideState.StaticResourceBegin); + UnsafeLocalSetting.Set(SettingKeys.Major1Minor10Revision0GuideState, GuideState.StaticResourceBegin); } } - if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, GuideState.Language) < GuideState.Completed) + if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed) { await taskContext.SwitchToMainThreadAsync(); serviceProvider.GetRequiredService(); diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Setting/SettingKeys.cs b/src/Snap.Hutao/Snap.Hutao/Core/Setting/SettingKeys.cs index db6749c2..0e2e2b6d 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Setting/SettingKeys.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Setting/SettingKeys.cs @@ -20,7 +20,9 @@ internal static class SettingKeys #region Application public const string LaunchTimes = "LaunchTimes"; public const string DataFolderPath = "DataFolderPath"; - public const string Major1Minor7Revision0GuideState = "Major1Minor7Revision0GuideState"; + public const string Major1Minor10Revision0GuideState = "Major1Minor10Revision0GuideState1"; + public const string StaticResourceImageQuality = "StaticResourceImageQuality"; + public const string StaticResourceUseTrimmedArchive = "StaticResourceUseTrimmedArchive"; public const string HotKeyMouseClickRepeatForever = "HotKeyMouseClickRepeatForever"; public const string IsAllocConsoleDebugModeEnabled = "IsAllocConsoleDebugModeEnabled2"; #endregion @@ -60,6 +62,10 @@ internal static class SettingKeys #endregion #region Obsolete + + [Obsolete("重置新手引导状态")] + public const string Major1Minor7Revision0GuideState = "Major1Minor7Revision0GuideState"; + [Obsolete("重置调试控制台开关")] public const string IsAllocConsoleDebugModeEnabledLegacy1 = "IsAllocConsoleDebugModeEnabled"; #endregion diff --git a/src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml b/src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml index 1c1d719c..03e26d1a 100644 --- a/src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml +++ b/src/Snap.Hutao/Snap.Hutao/GuideWindow.xaml @@ -8,7 +8,7 @@ xmlns:shvg="using:Snap.Hutao.View.Guide" mc:Ignorable="d"> - + diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx index e7ec6e09..3c149bcf 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx @@ -1397,6 +1397,12 @@ 用户使用协议与法律声明 + + 基础设置 + + + 稍后可以在设置中修改 + 文档 @@ -1407,7 +1413,7 @@ 安装完成后重启胡桃以查看是否正常生效 - 如果上方的图标中存在乱码,请前往 + 如果上方的图标中存在乱码或方块字,请前往 下载并自行安装图标字体 @@ -1424,6 +1430,24 @@ 资源 + + 图像资源设置 + + + * 除非你卸载并重新安装胡桃,否则你将无法更改这些设置 + + + 图片资源包体 + + + 全部资源(节省 0% 磁盘空间占用) + + + 部分资源(节省 13.5% 磁盘空间占用) + + + 图片资源质量 + 深渊统计 @@ -1613,6 +1637,12 @@ 下载资源文件中,请稍候 + + 高质量(节省 72.8% 磁盘空间占用) + + + 原图(节省 0% 磁盘空间占用) + 请输入正确的邮箱 diff --git a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj index 05c4de84..fff69edf 100644 --- a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj +++ b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj @@ -347,9 +347,6 @@ - - - MSBuild:Compile diff --git a/src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml b/src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml index 2ef8d89f..09ab6d59 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Guide/GuideView.xaml @@ -6,6 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mxi="using:Microsoft.Xaml.Interactivity" + xmlns:shc="using:Snap.Hutao.Control" xmlns:shcb="using:Snap.Hutao.Control.Behavior" xmlns:shcm="using:Snap.Hutao.Control.Markup" xmlns:shvg="using:Snap.Hutao.ViewModel.Guide" @@ -49,7 +50,7 @@ - + + VerticalAlignment="Center" + Spacing="{ThemeResource SettingsCardSpacing}"> - + @@ -169,6 +174,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +