mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
refine ui
This commit is contained in:
@@ -12,6 +12,11 @@ internal static partial class SpecialNameHandler
|
||||
// "#(?!.*(?:F#|M#|NON_BREAK_SPACE|REALNAME\[ID\(1\)(\|HOSTONLY\(true\)|)\]|\{LAYOUT_MOBILE#.+?\}\{LAYOUT_PC#.+?\}\{LAYOUT_PS#.+?\})).*
|
||||
public static string Handle(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
if (input.AsSpan()[0] is not '#')
|
||||
{
|
||||
return input;
|
||||
|
||||
@@ -2543,6 +2543,12 @@
|
||||
<data name="ViewPageSettingResetStaticResourceHeader" xml:space="preserve">
|
||||
<value>重置图片资源</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingsAdvancedOptionsLaunchUnlockFpsDescription" xml:space="preserve">
|
||||
<value>在启动游戏页面的进程部分加入解锁帧率限制选项</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingsAdvancedOptionsLaunchUnlockFpsHeader" xml:space="preserve">
|
||||
<value>启动游戏-解锁帧率限制</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingSetDataFolderDescription" xml:space="preserve">
|
||||
<value>更改目录后需要手动移动目录内的数据,否则会重新创建用户数据</value>
|
||||
</data>
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shvg="using:Snap.Hutao.ViewModel.Game"
|
||||
MinHeight="180"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
d:DataContext="{d:DesignInstance shvg:LaunchGameViewModelSlim}"
|
||||
Background="Transparent"
|
||||
Command="{Binding LaunchCommand}"
|
||||
@@ -22,12 +24,6 @@
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
<Grid CornerRadius="{ThemeResource ControlCornerRadius}">
|
||||
<Image
|
||||
Margin="0,40,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0.4"
|
||||
Source="ms-appx:///Resource/HutaoIconSourceTransparentBackgroundGradient1.png"
|
||||
Stretch="Uniform"/>
|
||||
<Grid Margin="12" ColumnSpacing="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using CommunityToolkit.WinUI.Animations;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Snap.Hutao.Control.Theme;
|
||||
using Snap.Hutao.Service.BackgroundImage;
|
||||
using Snap.Hutao.Service.Navigation;
|
||||
using Snap.Hutao.View.Page;
|
||||
@@ -17,6 +20,8 @@ internal sealed partial class MainView : UserControl
|
||||
{
|
||||
private readonly INavigationService navigationService;
|
||||
private readonly IBackgroundImageService backgroundImageService;
|
||||
private TaskCompletionSource acutalThemeChangedTaskCompletionSource = new();
|
||||
private CancellationTokenSource periodicTimerCancellationTokenSource = new();
|
||||
|
||||
/// <summary>
|
||||
/// 构造一个新的主视图
|
||||
@@ -25,6 +30,8 @@ internal sealed partial class MainView : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ActualThemeChanged += OnActualThemeChanged;
|
||||
|
||||
IServiceProvider serviceProvider = Ioc.Default;
|
||||
|
||||
backgroundImageService = serviceProvider.GetRequiredService<IBackgroundImageService>();
|
||||
@@ -52,20 +59,38 @@ internal sealed partial class MainView : UserControl
|
||||
|
||||
await AnimationBuilder
|
||||
.Create()
|
||||
.Opacity(to: 0D, duration: TimeSpan.FromMilliseconds(300), easingType: EasingType.Sine)
|
||||
.Opacity(to: 0D, duration: TimeSpan.FromMilliseconds(1000), easingType: EasingType.Sine, easingMode: EasingMode.EaseIn)
|
||||
.StartAsync(BackdroundImagePresenter)
|
||||
.ConfigureAwait(true);
|
||||
|
||||
BackdroundImagePresenter.Source = backgroundImage.ImageSource;
|
||||
double targetOpacity = (1 - backgroundImage.Luminance) * 0.8;
|
||||
double targetOpacity = ThemeHelper.IsDarkMode(ActualTheme) ? 1 - backgroundImage.Luminance : backgroundImage.Luminance;
|
||||
|
||||
await AnimationBuilder
|
||||
.Create()
|
||||
.Opacity(to: targetOpacity, duration: TimeSpan.FromMilliseconds(300), easingType: EasingType.Sine)
|
||||
.Opacity(to: targetOpacity, duration: TimeSpan.FromMilliseconds(1000), easingType: EasingType.Sine, easingMode: EasingMode.EaseOut)
|
||||
.StartAsync(BackdroundImagePresenter)
|
||||
.ConfigureAwait(true);
|
||||
}
|
||||
} while (await timer.WaitForNextTickAsync().ConfigureAwait(false));
|
||||
|
||||
try
|
||||
{
|
||||
await Task.WhenAny(timer.WaitForNextTickAsync(periodicTimerCancellationTokenSource.Token).AsTask(), acutalThemeChangedTaskCompletionSource.Task).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
acutalThemeChangedTaskCompletionSource = new();
|
||||
periodicTimerCancellationTokenSource = new();
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnActualThemeChanged(FrameworkElement frameworkElement, object args)
|
||||
{
|
||||
acutalThemeChangedTaskCompletionSource.TrySetResult();
|
||||
periodicTimerCancellationTokenSource.Cancel();
|
||||
}
|
||||
}
|
||||
@@ -119,10 +119,7 @@
|
||||
cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
||||
<Border Padding="16" Style="{ThemeResource AcrylicBorderCardStyle}">
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}" Visibility="Visible">
|
||||
<Grid
|
||||
MaxHeight="176"
|
||||
BorderThickness="0"
|
||||
Style="{ThemeResource GridCardStyle}">
|
||||
<Grid MaxHeight="176" Style="{ThemeResource GridCardStyle}">
|
||||
<Grid Padding="48,28,48,28" ColumnSpacing="48">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
@@ -476,7 +473,8 @@
|
||||
<cwc:SettingsExpander
|
||||
Description="{Binding DataFolderView.Size}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingDataFolderHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsExpanded="True">
|
||||
<cwc:SettingsExpander.Content>
|
||||
<Button
|
||||
Command="{Binding DataFolderView.OpenFolderCommand}"
|
||||
@@ -484,6 +482,11 @@
|
||||
Style="{ThemeResource SettingButtonStyle}"/>
|
||||
</cwc:SettingsExpander.Content>
|
||||
<cwc:SettingsExpander.Items>
|
||||
<cwc:SettingsCard
|
||||
Command="{Binding OpenBackgroundImageFolderCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingOpenBackgroundImageFolderDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingOpenBackgroundImageFolderHeader}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
ActionIcon="{shcm:FontIcon Glyph=}"
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingStorageSetAction}"
|
||||
@@ -502,7 +505,8 @@
|
||||
<cwc:SettingsExpander
|
||||
Description="{Binding CacheFolderView.Size}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingCacheFolderHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsExpanded="True">
|
||||
<cwc:SettingsExpander.Content>
|
||||
<Button
|
||||
Command="{Binding CacheFolderView.OpenFolderCommand}"
|
||||
@@ -510,11 +514,6 @@
|
||||
Style="{ThemeResource SettingButtonStyle}"/>
|
||||
</cwc:SettingsExpander.Content>
|
||||
<cwc:SettingsExpander.Items>
|
||||
<cwc:SettingsCard
|
||||
Command="{Binding OpenBackgroundImageFolderCommand}"
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingOpenBackgroundImageFolderDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingOpenBackgroundImageFolderHeader}"
|
||||
IsClickEnabled="True"/>
|
||||
<cwc:SettingsCard
|
||||
ActionIcon="{shcm:FontIcon Glyph=}"
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingResetAction}"
|
||||
@@ -541,11 +540,13 @@
|
||||
HeaderIcon="{cw:FontIcon Glyph=}">
|
||||
<ToggleSwitch Width="120" IsOn="{Binding IsAllocConsoleDebugModeEnabled, Mode=TwoWay}"/>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard
|
||||
<cwc:SettingsExpander
|
||||
shch:SettingsExpanderHelper.IsItemsEnabled="{Binding RuntimeOptions.IsElevated}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||
IsEnabled="{Binding RuntimeOptions.IsElevated}">
|
||||
<cwc:SettingsCard.Description>
|
||||
IsEnabled="{Binding RuntimeOptions.IsElevated}"
|
||||
IsExpanded="True">
|
||||
<cwc:SettingsExpander.Description>
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
|
||||
@@ -553,12 +554,15 @@
|
||||
Visibility="{Binding LaunchOptions.IsAdvancedLaunchOptionsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"/>
|
||||
<TextBlock Text="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledDescription}" Visibility="{Binding LaunchOptions.IsAdvancedLaunchOptionsEnabled, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
||||
</StackPanel>
|
||||
</cwc:SettingsCard.Description>
|
||||
</cwc:SettingsExpander.Description>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<shvc:Elevation Visibility="{Binding RuntimeOptions.IsElevated, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
||||
<ToggleSwitch Width="120" IsOn="{Binding IsAdvancedLaunchOptionsEnabled, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsExpander.Items>
|
||||
<cwc:SettingsCard Description="{shcm:ResourceString Name=ViewPageSettingsAdvancedOptionsLaunchUnlockFpsDescription}" Header="{shcm:ResourceString Name=ViewPageSettingsAdvancedOptionsLaunchUnlockFpsHeader}"/>
|
||||
</cwc:SettingsExpander.Items>
|
||||
</cwc:SettingsExpander>
|
||||
<cwc:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingDangerousAction}"
|
||||
Command="{Binding DeleteUsersCommand}"
|
||||
|
||||
Reference in New Issue
Block a user