This commit is contained in:
DismissedLight
2023-11-04 17:21:31 +08:00
parent 749ef0e138
commit e4e9dd91f1
3 changed files with 126 additions and 91 deletions

View File

@@ -1967,6 +1967,12 @@
<data name="ViewPageLaunchGameAdvanceHeader" xml:space="preserve">
<value>高级功能</value>
</data>
<data name="ViewPageLaunchGameAppearanceAspectRatioDescription" xml:space="preserve">
<value>快速切换到指定的分辨率</value>
</data>
<data name="ViewPageLaunchGameAppearanceAspectRatioHeader" xml:space="preserve">
<value>分辨率</value>
</data>
<data name="ViewPageLaunchGameAppearanceBorderlessDescription" xml:space="preserve">
<value>将窗口创建为弹出窗口,不带框架</value>
</data>

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using CommunityToolkit.WinUI.Controls;
using Microsoft.UI.Windowing;
using Snap.Hutao.Model;
using Snap.Hutao.Model.Entity;
@@ -35,6 +36,7 @@ internal sealed class LaunchOptions : DbStoreOptions
private int? targetFps;
private NameValue<int>? monitor;
private bool? isMonitorEnabled;
private AspectRatio? selectedAspectRatio;
/// <summary>
/// 构造一个新的启动游戏选项
@@ -162,6 +164,25 @@ internal sealed class LaunchOptions : DbStoreOptions
set => SetOption(ref isMonitorEnabled, SettingEntry.LaunchIsMonitorEnabled, value);
}
public List<AspectRatio> AspectRatios { get; } = new()
{
new(2560, 1440),
new(1920, 1080),
};
public AspectRatio? SelectedAspectRatio
{
get => selectedAspectRatio;
set
{
if (SetProperty(ref selectedAspectRatio, value) && value is AspectRatio aspectRatio)
{
ScreenWidth = (int)aspectRatio.Width;
ScreenHeight = (int)aspectRatio.Height;
}
}
}
private static void InitializeMonitors(List<NameValue<int>> monitors)
{
// This list can't use foreach

View File

@@ -34,6 +34,82 @@
DataContext="{Binding Mode=OneWay}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameResourceDiffHeader}"/>
</DataTemplate>
<DataTemplate x:Key="GameAccountListTemplate">
<Grid>
<StackPanel Margin="0,12">
<TextBlock Text="{Binding Name}"/>
<TextBlock
Opacity="0.8"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding AttachUid, TargetNullValue={shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountAttachUidNull}}"/>
</StackPanel>
<StackPanel
x:Name="ButtonPanel"
HorizontalAlignment="Right"
Orientation="Horizontal"
Visibility="Collapsed">
<Button
MinWidth="48"
Margin="4,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.AttachGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE723;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountAttachUidToolTip}"/>
<Button
MinWidth="48"
Margin="4,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.ModifyGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE8AC;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountRenameToolTip}"/>
<Button
MinWidth="48"
Margin="4,8,0,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.RemoveGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE74D;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountRemoveToolTip}"/>
</StackPanel>
<Grid.Resources>
<Storyboard x:Name="ButtonPanelVisibleStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="ButtonPanelCollapsedStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="PointerEntered">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelVisibleStoryboard}"/>
</mxic:EventTriggerBehavior>
<mxic:EventTriggerBehavior EventName="PointerExited">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelCollapsedStoryboard}"/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
</Grid>
</DataTemplate>
</Page.Resources>
<Grid>
<Grid
@@ -112,85 +188,10 @@
HeaderIcon="{shcm:FontIcon Glyph=&#xE748;}"
IsClickEnabled="True"/>
<Border Style="{StaticResource BorderCardStyle}">
<ListView ItemsSource="{Binding GameAccounts}" SelectedItem="{Binding SelectedGameAccount, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Margin="0,12">
<TextBlock Text="{Binding Name}"/>
<TextBlock
Opacity="0.8"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding AttachUid, TargetNullValue={shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountAttachUidNull}}"/>
</StackPanel>
<StackPanel
x:Name="ButtonPanel"
HorizontalAlignment="Right"
Orientation="Horizontal"
Visibility="Collapsed">
<Button
MinWidth="48"
Margin="4,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.AttachGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE723;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountAttachUidToolTip}"/>
<Button
MinWidth="48"
Margin="4,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.ModifyGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE8AC;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountRenameToolTip}"/>
<Button
MinWidth="48"
Margin="4,8,0,8"
VerticalAlignment="Stretch"
Command="{Binding DataContext.RemoveGameAccountCommand, Source={StaticResource BindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE74D;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageLaunchGameSwitchAccountRemoveToolTip}"/>
</StackPanel>
<Grid.Resources>
<Storyboard x:Name="ButtonPanelVisibleStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="ButtonPanelCollapsedStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="PointerEntered">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelVisibleStoryboard}"/>
</mxic:EventTriggerBehavior>
<mxic:EventTriggerBehavior EventName="PointerExited">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelCollapsedStoryboard}"/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView
ItemTemplate="{StaticResource GameAccountListTemplate}"
ItemsSource="{Binding GameAccounts}"
SelectedItem="{Binding SelectedGameAccount, Mode=TwoWay}"/>
</Border>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageLaunchGameProcessHeader}"/>
<cwc:SettingsExpander
@@ -198,25 +199,32 @@
Header="{shcm:ResourceString Name=ViewPageLaunchGameArgumentsHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE943;}"
IsExpanded="True">
<ToggleSwitch Width="156" IsOn="{Binding Options.IsEnabled, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsEnabled, Mode=TwoWay}"/>
<cwc:SettingsExpander.Items>
<cwc:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceExclusiveDescription}"
Header="-window-mode exclusive"
IsEnabled="{Binding Options.IsEnabled}">
<ToggleSwitch Width="156" IsOn="{Binding Options.IsExclusive, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsExclusive, Mode=TwoWay}"/>
</cwc:SettingsCard>
<cwc:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceFullscreenDescription}"
Header="-screen-fullscreen"
IsEnabled="{Binding Options.IsEnabled}">
<ToggleSwitch Width="156" IsOn="{Binding Options.IsFullScreen, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsFullScreen, Mode=TwoWay}"/>
</cwc:SettingsCard>
<cwc:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceBorderlessDescription}"
Header="-popupwindow"
IsEnabled="{Binding Options.IsEnabled}">
<ToggleSwitch Width="156" IsOn="{Binding Options.IsBorderless, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsBorderless, Mode=TwoWay}"/>
</cwc:SettingsCard>
<cwc:SettingsCard Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceAspectRatioDescription}" Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceAspectRatioHeader}">
<ComboBox
Width="156"
Margin="0,0,136,0"
ItemsSource="{Binding Options.AspectRatios}"
SelectedItem="{Binding Options.SelectedAspectRatio, Mode=TwoWay}"/>
</cwc:SettingsCard>
<cwc:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthDescription}"
@@ -225,10 +233,11 @@
<StackPanel Orientation="Horizontal" Spacing="16">
<NumberBox
Width="156"
Padding="10,6,0,0"
Padding="12,6,0,0"
VerticalAlignment="Center"
IsEnabled="{Binding Options.IsScreenWidthEnabled}"
Value="{Binding Options.ScreenWidth, Mode=TwoWay}"/>
<ToggleSwitch Width="156" IsOn="{Binding Options.IsScreenWidthEnabled, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsScreenWidthEnabled, Mode=TwoWay}"/>
</StackPanel>
</cwc:SettingsCard>
<cwc:SettingsCard
@@ -238,10 +247,11 @@
<StackPanel Orientation="Horizontal" Spacing="16">
<NumberBox
Width="156"
Padding="10,6,0,0"
Padding="12,6,0,0"
VerticalAlignment="Center"
IsEnabled="{Binding Options.IsScreenHeightEnabled}"
Value="{Binding Options.ScreenHeight, Mode=TwoWay}"/>
<ToggleSwitch Width="156" IsOn="{Binding Options.IsScreenHeightEnabled, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsScreenHeightEnabled, Mode=TwoWay}"/>
</StackPanel>
</cwc:SettingsCard>
<cwc:SettingsCard
@@ -251,11 +261,12 @@
<StackPanel Orientation="Horizontal" Spacing="16">
<ComboBox
Width="156"
VerticalAlignment="Center"
DisplayMemberPath="Name"
IsEnabled="{Binding Options.IsMonitorEnabled}"
ItemsSource="{Binding Options.Monitors}"
SelectedItem="{Binding Options.Monitor, Mode=TwoWay}"/>
<ToggleSwitch Width="156" IsOn="{Binding Options.IsMonitorEnabled, Mode=TwoWay}"/>
<ToggleSwitch Width="120" IsOn="{Binding Options.IsMonitorEnabled, Mode=TwoWay}"/>
</StackPanel>
</cwc:SettingsCard>
</cwc:SettingsExpander.Items>
@@ -282,9 +293,6 @@
OnContent="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsOn}"/>
</StackPanel>
</cwc:SettingsCard>
<StackPanel Spacing="{StaticResource SettingsCardSpacing}"/>
</StackPanel>
</Grid>
</ScrollViewer>