mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
completing
This commit is contained in:
6
src/Snap.Hutao/Snap.Hutao/Core/Void.cs
Normal file
6
src/Snap.Hutao/Snap.Hutao/Core/Void.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Core;
|
||||
|
||||
internal readonly struct Void;
|
||||
@@ -2441,6 +2441,18 @@
|
||||
<data name="ViewPageLaunchGameConfigurationSaveHint" xml:space="preserve">
|
||||
<value>所有选项仅会在启动游戏成功后保存</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameDisableFogDescription" xml:space="preserve">
|
||||
<value>移除光照渲染中的迷雾</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameDisableFogHeader" xml:space="preserve">
|
||||
<value>移除迷雾</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameDisableFogOff" xml:space="preserve">
|
||||
<value>保留</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameDisableFogOn" xml:space="preserve">
|
||||
<value>移除</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameDiscordActivityDescription" xml:space="preserve">
|
||||
<value>在我游戏时设置 Discord Activity 状态</value>
|
||||
</data>
|
||||
@@ -2525,8 +2537,14 @@
|
||||
<data name="ViewPageLaunchGameSwitchSchemeWarning" xml:space="preserve">
|
||||
<value>版本更新前需要提前转换至与启动器匹配的服务器</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameTargetFovDescription" xml:space="preserve">
|
||||
<value>调整相机视野,默认 45</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameTargetFovHeader" xml:space="preserve">
|
||||
<value>调整视野</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameUnlockFpsDescription" xml:space="preserve">
|
||||
<value>请在游戏内关闭「垂直同步」选项,需要高性能的显卡以支持更高的帧率</value>
|
||||
<value>请在游戏内关闭「垂直同步」选项,需要高性能的显卡以支持更高的帧率,将值设置为 -1 以表示无限制帧率</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameUnlockFpsHeader" xml:space="preserve">
|
||||
<value>解锁帧率限制</value>
|
||||
|
||||
@@ -32,7 +32,7 @@ internal abstract partial class DbStoreOptions : ObservableObject
|
||||
return input.ToStringOrEmpty();
|
||||
}
|
||||
|
||||
protected void InitializeOptions(string keyLike, Expression<Func<SettingEntry, bool>> entrySelector, Action<string, string?> entryAction)
|
||||
protected void InitializeOptions(Expression<Func<SettingEntry, bool>> entrySelector, Action<string, string?> entryAction)
|
||||
{
|
||||
using (IServiceScope scope = serviceProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -60,6 +60,63 @@ internal sealed class LaunchOptions : DbStoreOptions
|
||||
InitializeMonitors(Monitors);
|
||||
InitializeScreenFps(out primaryScreenFps);
|
||||
|
||||
// Batch initialization, boost up performance
|
||||
InitializeOptions(entry => entry.Key.StartsWith("Launch."), (key, value) =>
|
||||
{
|
||||
_ = key switch
|
||||
{
|
||||
SettingEntry.LaunchIsLaunchOptionsEnabled => InitializeBooleanValue(ref isEnabled, value),
|
||||
SettingEntry.LaunchIsFullScreen => InitializeBooleanValue(ref isFullScreen, value),
|
||||
SettingEntry.LaunchIsBorderless => InitializeBooleanValue(ref isBorderless, value),
|
||||
SettingEntry.LaunchIsExclusive => InitializeBooleanValue(ref isExclusive, value),
|
||||
SettingEntry.LaunchScreenWidth => InitializeInt32Value(ref screenWidth, value),
|
||||
SettingEntry.LaunchIsScreenWidthEnabled => InitializeBooleanValue(ref isScreenWidthEnabled, value),
|
||||
SettingEntry.LaunchScreenHeight => InitializeInt32Value(ref screenHeight, value),
|
||||
SettingEntry.LaunchIsScreenHeightEnabled => InitializeBooleanValue(ref isScreenHeightEnabled, value),
|
||||
SettingEntry.LaunchUnlockFps => InitializeBooleanValue(ref unlockFps, value),
|
||||
SettingEntry.LaunchTargetFps => InitializeInt32Value(ref targetFps, value),
|
||||
SettingEntry.LaunchTargetFov => InitializeFloatValue(ref targetFov, value),
|
||||
SettingEntry.LaunchDisableFog => InitializeBooleanValue(ref disableFog, value),
|
||||
SettingEntry.LaunchIsMonitorEnabled => InitializeBooleanValue(ref isMonitorEnabled, value),
|
||||
SettingEntry.LaunchIsUseCloudThirdPartyMobile => InitializeBooleanValue(ref isUseCloudThirdPartyMobile, value),
|
||||
SettingEntry.LaunchIsWindowsHDREnabled => InitializeBooleanValue(ref isWindowsHDREnabled, value),
|
||||
SettingEntry.LaunchUseStarwardPlayTimeStatistics => InitializeBooleanValue(ref useStarwardPlayTimeStatistics, value),
|
||||
SettingEntry.LaunchUseBetterGenshinImpactAutomation => InitializeBooleanValue(ref useBetterGenshinImpactAutomation, value),
|
||||
SettingEntry.LaunchSetDiscordActivityWhenPlaying => InitializeBooleanValue(ref setDiscordActivityWhenPlaying, value),
|
||||
_ => default,
|
||||
};
|
||||
});
|
||||
|
||||
static Core.Void InitializeBooleanValue(ref bool? storage, string? value)
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
storage = bool.Parse(value);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
static Core.Void InitializeInt32Value(ref int? storage, string? value)
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
storage = int.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
static Core.Void InitializeFloatValue(ref float? storage, string? value)
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
storage = float.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
static void InitializeMonitors(List<NameValue<int>> monitors)
|
||||
{
|
||||
try
|
||||
@@ -109,21 +166,22 @@ internal sealed class LaunchOptions : DbStoreOptions
|
||||
set => SetOption(ref gamePathEntries, SettingEntry.GamePathEntries, value, value => JsonSerializer.Serialize(value));
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => GetOption(ref isEnabled, SettingEntry.LaunchIsLaunchOptionsEnabled, false);
|
||||
set => SetOption(ref isEnabled, SettingEntry.LaunchIsLaunchOptionsEnabled, value);
|
||||
}
|
||||
|
||||
public bool IsAdvancedLaunchOptionsEnabled
|
||||
{
|
||||
get => GetOption(ref isAdvancedLaunchOptionsEnabled, SettingEntry.IsAdvancedLaunchOptionsEnabled);
|
||||
set => SetOption(ref isAdvancedLaunchOptionsEnabled, SettingEntry.IsAdvancedLaunchOptionsEnabled, value);
|
||||
}
|
||||
|
||||
#region Launch Prefixed Options
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => GetOption(ref isEnabled, SettingEntry.LaunchIsLaunchOptionsEnabled, true);
|
||||
set => SetOption(ref isEnabled, SettingEntry.LaunchIsLaunchOptionsEnabled, value);
|
||||
}
|
||||
|
||||
public bool IsFullScreen
|
||||
{
|
||||
get => GetOption(ref isFullScreen, SettingEntry.LaunchIsFullScreen);
|
||||
get => GetOption(ref isFullScreen, SettingEntry.LaunchIsFullScreen, false);
|
||||
set => SetOption(ref isFullScreen, SettingEntry.LaunchIsFullScreen, value);
|
||||
}
|
||||
|
||||
@@ -187,10 +245,7 @@ internal sealed class LaunchOptions : DbStoreOptions
|
||||
set => SetOption(ref disableFog, SettingEntry.LaunchDisableFog, value);
|
||||
}
|
||||
|
||||
public List<NameValue<int>> Monitors { get; } = [];
|
||||
|
||||
[AllowNull]
|
||||
public NameValue<int> Monitor
|
||||
public NameValue<int>? Monitor
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -229,6 +284,27 @@ internal sealed class LaunchOptions : DbStoreOptions
|
||||
set => SetOption(ref isWindowsHDREnabled, SettingEntry.LaunchIsWindowsHDREnabled, value);
|
||||
}
|
||||
|
||||
public bool UseStarwardPlayTimeStatistics
|
||||
{
|
||||
get => GetOption(ref useStarwardPlayTimeStatistics, SettingEntry.LaunchUseStarwardPlayTimeStatistics, false);
|
||||
set => SetOption(ref useStarwardPlayTimeStatistics, SettingEntry.LaunchUseStarwardPlayTimeStatistics, value);
|
||||
}
|
||||
|
||||
public bool UseBetterGenshinImpactAutomation
|
||||
{
|
||||
get => GetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, false);
|
||||
set => SetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, value);
|
||||
}
|
||||
|
||||
public bool SetDiscordActivityWhenPlaying
|
||||
{
|
||||
get => GetOption(ref setDiscordActivityWhenPlaying, SettingEntry.LaunchSetDiscordActivityWhenPlaying, true);
|
||||
set => SetOption(ref setDiscordActivityWhenPlaying, SettingEntry.LaunchSetDiscordActivityWhenPlaying, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public List<NameValue<int>> Monitors { get; } = [];
|
||||
|
||||
public List<AspectRatio> AspectRatios { get; } =
|
||||
[
|
||||
new(3840, 2160),
|
||||
@@ -249,22 +325,4 @@ internal sealed class LaunchOptions : DbStoreOptions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseStarwardPlayTimeStatistics
|
||||
{
|
||||
get => GetOption(ref useStarwardPlayTimeStatistics, SettingEntry.LaunchUseStarwardPlayTimeStatistics, false);
|
||||
set => SetOption(ref useStarwardPlayTimeStatistics, SettingEntry.LaunchUseStarwardPlayTimeStatistics, value);
|
||||
}
|
||||
|
||||
public bool UseBetterGenshinImpactAutomation
|
||||
{
|
||||
get => GetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, false);
|
||||
set => SetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, value);
|
||||
}
|
||||
|
||||
public bool SetDiscordActivityWhenPlaying
|
||||
{
|
||||
get => GetOption(ref setDiscordActivityWhenPlaying, SettingEntry.LaunchSetDiscordActivityWhenPlaying, true);
|
||||
set => SetOption(ref setDiscordActivityWhenPlaying, SettingEntry.LaunchSetDiscordActivityWhenPlaying, value);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ internal sealed class Int32ToVisibilityConverter : IValueConverter
|
||||
/// <inheritdoc/>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return value is not 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
return value is not null && value is not 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -357,7 +357,7 @@
|
||||
MinWidth="{ThemeResource SettingsCardContentControlMinWidth2}"
|
||||
Padding="10,8,0,0"
|
||||
Maximum="720"
|
||||
Minimum="60"
|
||||
Minimum="-1"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Value="{Binding LaunchOptions.TargetFps, Mode=TwoWay}"/>
|
||||
<ToggleSwitch
|
||||
@@ -367,23 +367,22 @@
|
||||
OnContent="{shuxm:ResourceString Name=ViewPageLaunchGameUnlockFpsOn}"/>
|
||||
</StackPanel>
|
||||
<cwc:SettingsExpander.Items>
|
||||
<cwc:SettingsCard Description="{shuxm:ResourceString Name=ViewPageLaunchGameUnlockFpsKindDescription}" Header="{shuxm:ResourceString Name=ViewPageLaunchGameUnlockFpsKindHeader}">
|
||||
<StackPanel VerticalAlignment="Center" Spacing="3">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Right"
|
||||
Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}"
|
||||
Opacity="0.8"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding LaunchOptions.UnlockerKind.Description, Mode=OneWay}"/>
|
||||
<shuxc:SizeRestrictedContentControl HorizontalAlignment="Right">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding LaunchOptions.UnlockerKinds, Mode=OneWay}"
|
||||
SelectedItem="{Binding LaunchOptions.UnlockerKind, Mode=TwoWay}"/>
|
||||
</shuxc:SizeRestrictedContentControl>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<cwc:SettingsCard Description="{shuxm:ResourceString Name=ViewPageLaunchGameTargetFovDescription}" Header="{shuxm:ResourceString Name=ViewPageLaunchGameTargetFovHeader}">
|
||||
<NumberBox
|
||||
MinWidth="{ThemeResource SettingsCardContentControlMinWidth2}"
|
||||
Padding="10,8,0,0"
|
||||
Maximum="55"
|
||||
Minimum="45"
|
||||
SmallChange="1"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Value="{Binding LaunchOptions.TargetFov, Mode=TwoWay}"/>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard Description="{shuxm:ResourceString Name=ViewPageLaunchGameDisableFogDescription}" Header="{shuxm:ResourceString Name=ViewPageLaunchGameDisableFogHeader}">
|
||||
<ToggleSwitch
|
||||
MinWidth="{ThemeResource SettingsCardContentControlMinWidth}"
|
||||
IsOn="{Binding LaunchOptions.DisableFog, Mode=TwoWay}"
|
||||
OffContent="{shuxm:ResourceString Name=ViewPageLaunchGameDisableFogOff}"
|
||||
OnContent="{shuxm:ResourceString Name=ViewPageLaunchGameDisableFogOn}"/>
|
||||
</cwc:SettingsCard>
|
||||
</cwc:SettingsExpander.Items>
|
||||
</cwc:SettingsExpander>
|
||||
|
||||
@@ -189,32 +189,17 @@ internal static partial class HutaoEndpoints
|
||||
|
||||
public static string StaticRaw(string category, string fileName)
|
||||
{
|
||||
return Kind switch
|
||||
{
|
||||
ApiKind.AlphaCN => $"{ApiAlphaSnapGenshin}/cn/static/raw/{category}/{fileName}",
|
||||
ApiKind.AlphaOS => $"{ApiAlphaSnapGenshin}/global/static/raw/{category}/{fileName}",
|
||||
_ => $"{ApiSnapGenshin}/static/raw/{category}/{fileName}",
|
||||
};
|
||||
return $"{ApiSnapGenshin}/static/raw/{category}/{fileName}";
|
||||
}
|
||||
|
||||
public static string StaticZip(string fileName)
|
||||
{
|
||||
return Kind switch
|
||||
{
|
||||
ApiKind.AlphaCN => $"{ApiAlphaSnapGenshin}/cn/static/zip/{fileName}.zip",
|
||||
ApiKind.AlphaOS => $"{ApiAlphaSnapGenshin}/global/static/zip/{fileName}.zip",
|
||||
_ => $"{ApiSnapGenshin}/static/zip/{fileName}.zip",
|
||||
};
|
||||
return $"{ApiSnapGenshin}/static/zip/{fileName}.zip";
|
||||
}
|
||||
|
||||
public static string StaticSize()
|
||||
{
|
||||
return Kind switch
|
||||
{
|
||||
ApiKind.AlphaCN => $"{ApiAlphaSnapGenshin}/cn/static/size",
|
||||
ApiKind.AlphaOS => $"{ApiAlphaSnapGenshin}/global/static/size",
|
||||
_ => $"{ApiSnapGenshin}/static/size",
|
||||
};
|
||||
return $"{ApiSnapGenshin}/static/size";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user