mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix game resource convert
This commit is contained in:
@@ -3,12 +3,8 @@
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Snap.Hutao.Core.Database;
|
||||
using Snap.Hutao.Core.Setting;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Snap.Hutao.Core.DependencyInjection;
|
||||
|
||||
@@ -48,9 +44,6 @@ internal static class IocConfiguration
|
||||
#endif
|
||||
context.Database.Migrate();
|
||||
}
|
||||
|
||||
SettingEntry entry = context.Settings.SingleOrAdd(SettingEntry.Culture, CultureInfo.CurrentCulture.Name);
|
||||
Localization.Initialize(entry.Value!);
|
||||
}
|
||||
|
||||
return services.AddDbContext<AppDbContext>(builder =>
|
||||
|
||||
@@ -54,6 +54,11 @@ internal static class Activation
|
||||
/// <returns>是否提升了权限</returns>
|
||||
public static bool GetElevated()
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
|
||||
{
|
||||
WindowsPrincipal principal = new(identity);
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Globalization;
|
||||
using Windows.Globalization;
|
||||
|
||||
namespace Snap.Hutao.Core.Setting;
|
||||
|
||||
/// <summary>
|
||||
/// 本地化
|
||||
/// </summary>
|
||||
internal static class Localization
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化本地化语言
|
||||
/// </summary>
|
||||
/// <param name="culture">语言代码</param>
|
||||
public static void Initialize(string culture)
|
||||
{
|
||||
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(culture);
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
ApplicationLanguages.PrimaryLanguageOverride = culture;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using Snap.Hutao.Core.Database;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
using System.Globalization;
|
||||
using Windows.Globalization;
|
||||
|
||||
namespace Snap.Hutao.Option;
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Snap.Hutao.Core.Setting;
|
||||
using Snap.Hutao.Option;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Globalization;
|
||||
using WinRT;
|
||||
|
||||
namespace Snap.Hutao;
|
||||
@@ -27,8 +31,11 @@ public static partial class Program
|
||||
ComWrappersSupport.InitializeComWrappers();
|
||||
|
||||
// by adding the using statement, we can dispose the injected services when we closing
|
||||
using (InitializeDependencyInjection())
|
||||
using (ServiceProvider serviceProvider = InitializeDependencyInjection())
|
||||
{
|
||||
AppOptions options = serviceProvider.GetRequiredService<AppOptions>();
|
||||
InitializeCulture(options.CurrentCulture);
|
||||
|
||||
// In a Desktop app this runs a message pump internally,
|
||||
// and does not return until the application shuts down.
|
||||
Application.Start(InitializeApp);
|
||||
@@ -42,10 +49,13 @@ public static partial class Program
|
||||
_ = Ioc.Default.GetRequiredService<App>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化依赖注入
|
||||
/// </summary>
|
||||
/// <returns>The ServiceProvider, so that we can dispose it.</returns>
|
||||
private static void InitializeCulture(CultureInfo cultureInfo)
|
||||
{
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
ApplicationLanguages.PrimaryLanguageOverride = cultureInfo.Name;
|
||||
}
|
||||
|
||||
private static ServiceProvider InitializeDependencyInjection()
|
||||
{
|
||||
ServiceProvider services = new ServiceCollection()
|
||||
|
||||
@@ -323,8 +323,8 @@ internal sealed class GameService : IGameService
|
||||
// https://docs.unity.cn/cn/current/Manual/PlayerCommandLineArguments.html
|
||||
string commandLine = new CommandLineBuilder()
|
||||
.AppendIf("-popupwindow", options.IsBorderless)
|
||||
.Append("-screen-fullscreen", options.IsFullScreen ? 1 : 0)
|
||||
.AppendIf("-window-mode", options.IsExclusive, "exclusive")
|
||||
.Append("-screen-fullscreen", options.IsFullScreen ? 1 : 0)
|
||||
.Append("-screen-width", options.ScreenWidth)
|
||||
.Append("-screen-height", options.ScreenHeight)
|
||||
.Append("-monitor", options.Monitor.Value)
|
||||
|
||||
@@ -9,7 +9,6 @@ using Snap.Hutao.Core.Database;
|
||||
using Snap.Hutao.Model;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
using Snap.Hutao.Win32;
|
||||
using Windows.Graphics;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Graphics.Gdi;
|
||||
@@ -345,11 +344,14 @@ internal sealed class LaunchOptions : ObservableObject, IOptions<LaunchOptions>
|
||||
{
|
||||
if (SetProperty(ref monitor, value))
|
||||
{
|
||||
using (IServiceScope scope = serviceScopeFactory.CreateScope())
|
||||
if (monitor != null)
|
||||
{
|
||||
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
appDbContext.Settings.ExecuteDeleteWhere(e => e.Key == SettingEntry.LaunchMonitor);
|
||||
appDbContext.Settings.AddAndSave(new(SettingEntry.LaunchMonitor, value.Value.ToString()));
|
||||
using (IServiceScope scope = serviceScopeFactory.CreateScope())
|
||||
{
|
||||
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
appDbContext.Settings.ExecuteDeleteWhere(e => e.Key == SettingEntry.LaunchMonitor);
|
||||
appDbContext.Settings.AddAndSave(new(SettingEntry.LaunchMonitor, value.Value.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +307,7 @@ internal sealed class PackageConverter
|
||||
try
|
||||
{
|
||||
await CopyToWithProgressAsync(webStream, fileStream, info.Target, totalBytes, progress).ConfigureAwait(false);
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
string remoteMd5 = await Digest.GetStreamMD5Async(fileStream).ConfigureAwait(false);
|
||||
if (info.Md5 == remoteMd5.ToLowerInvariant())
|
||||
{
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock Text="{shcm:ResourceString Name=ViewDialogLaunchGamePackageConvertHint}"/>
|
||||
<TextBlock
|
||||
MinWidth="360"
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding State.Description}"/>
|
||||
<ProgressBar
|
||||
Margin="0,16,0,4"
|
||||
IsIndeterminate="{Binding State.IsIndeterminate}"
|
||||
Maximum="1"
|
||||
Value="{Binding State.Percent}"/>
|
||||
<TextBlock
|
||||
MinWidth="360"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding State.Description}"/>
|
||||
</StackPanel>
|
||||
</ContentDialog>
|
||||
|
||||
Reference in New Issue
Block a user