apply suggestions

This commit is contained in:
qhy040404
2024-04-08 12:00:16 +08:00
parent dc7bc7e35d
commit 699ac60aaf
4 changed files with 27 additions and 15 deletions

View File

@@ -1334,6 +1334,9 @@
<data name="ViewDialogLaunchGameAccountTitle" xml:space="preserve">
<value>为账号命名</value>
</data>
<data name="ViewDialogLaunchGameConfigurationFixDialogHint" xml:space="preserve">
<value>请选择当前游戏路径对应的游戏服务器</value>
</data>
<data name="ViewDialogLaunchGameConfigurationFixDialogTitle" xml:space="preserve">
<value>正在修复配置文件</value>
</data>

View File

@@ -1,4 +1,4 @@
<ContentDialog
<ContentDialog
x:Class="Snap.Hutao.View.Dialog.LaunchGameConfigurationFixDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -14,12 +14,17 @@
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
<shccs:ComboBox2
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DisplayMemberPath="DisplayName"
EnableMemberPath="IsNotCompatOnly"
ItemsSource="{x:Bind KnownSchemes}"
SelectedItem="{x:Bind SelectedScheme, Mode=TwoWay}"
Style="{StaticResource DefaultComboBoxStyle}"/>
<StackPanel Orientation="Vertical">
<shccs:ComboBox2
HorizontalAlignment="Stretch"
DisplayMemberPath="DisplayName"
EnableMemberPath="IsNotCompatOnly"
ItemsSource="{x:Bind KnownSchemes}"
SelectedItem="{x:Bind SelectedScheme, Mode=TwoWay}"
Style="{StaticResource DefaultComboBoxStyle}"/>
<TextBlock
Margin="0,8,0,0"
HorizontalAlignment="Center"
Text="{shcm:ResourceString Name=ViewDialogLaunchGameConfigurationFixDialogHint}"/>
</StackPanel>
</ContentDialog>

View File

@@ -10,15 +10,19 @@ namespace Snap.Hutao.View.Dialog;
[DependencyProperty("SelectedScheme", typeof(LaunchScheme))]
internal sealed partial class LaunchGameConfigurationFixDialog : ContentDialog
{
public LaunchGameConfigurationFixDialog()
private readonly ITaskContext taskContext;
public LaunchGameConfigurationFixDialog(IServiceProvider serviceProvider)
{
InitializeComponent();
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
}
public async ValueTask<ValueResult<bool, LaunchScheme?>> GetLaunchSchemeAsync()
{
await taskContext.SwitchToMainThreadAsync();
ContentDialogResult result = await ShowAsync();
return new(result == ContentDialogResult.Primary, SelectedScheme);
}
}

View File

@@ -75,15 +75,15 @@ internal sealed partial class LaunchGameShared
if (isOk)
{
ArgumentNullException.ThrowIfNull(launchScheme);
string gameBiz = launchScheme.IsOversea ? "hk4e_global" : "hk4e_cn";
string content = $"""
[General]
channel={(int)launchScheme.Channel}
channel={launchScheme.Channel:D}
cps=mihoyo
game_version={version}
sub_channel={(int)launchScheme.SubChannel}
sub_channel={launchScheme.SubChannel:D}
sdk_version=
game_biz=hk4e_{(launchScheme.IsOversea ? "global" : "cn")}
game_biz={gameBiz}
""";
await File.WriteAllTextAsync(gameFileSystem.GameConfigFilePath, content).ConfigureAwait(false);