mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-20 08:29:50 +08:00
多语言下拉框挪到其他设置下 (#1362)
This commit is contained in:
@@ -860,11 +860,77 @@
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="设定一些其他功能的配置,如失去焦点自动激活游戏等"
|
||||
Text="设定一些其他功能的配置,如语言Language、失去焦点自动恢复等"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</ui:CardExpander.Header>
|
||||
<StackPanel>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="游戏语言"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="Game Language"
|
||||
TextWrapping="Wrap" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding LanguageDict}"
|
||||
SelectedValuePath="Key"
|
||||
DisplayMemberPath="Value"
|
||||
SelectedItem="{Binding Config.OtherConfig.GameCultureInfoName, Converter={StaticResource CultureInfoNameToKVPConverter}, Mode=TwoWay}"
|
||||
>
|
||||
<b:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="SelectionChanged">
|
||||
<b:InvokeCommandAction Command="{Binding GameLangSelectionChangedCommand}"
|
||||
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"/>
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<!--<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="BGI界面语言"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="BGI UI Language"
|
||||
TextWrapping="Wrap" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding LanguageDict}"
|
||||
SelectedValuePath="Key"
|
||||
DisplayMemberPath="Value"
|
||||
SelectedItem="{Binding Config.AutoFishingConfig.UiCultureInfoName, Converter={StaticResource CultureInfoNameToKVPConverter}, Mode=TwoWay}" />
|
||||
</Grid>-->
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@@ -890,7 +956,6 @@
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.OtherConfig.RestoreFocusOnLostEnabled, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
<!-- 地图 -->
|
||||
|
||||
@@ -1576,72 +1576,6 @@
|
||||
DisplayMemberPath="Value"
|
||||
SelectedItem="{Binding Config.AutoFishingConfig.FishingTimePolicy, Converter={StaticResource EnumToKVPConverter}, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="游戏语言"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="Game Language"
|
||||
TextWrapping="Wrap" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding LanguageDict}"
|
||||
SelectedValuePath="Key"
|
||||
DisplayMemberPath="Value"
|
||||
SelectedItem="{Binding Config.OtherConfig.GameCultureInfoName, Converter={StaticResource CultureInfoNameToKVPConverter}, Mode=TwoWay}"
|
||||
>
|
||||
<b:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="SelectionChanged">
|
||||
<b:InvokeCommandAction Command="{Binding GameLangSelectionChangedCommand}"
|
||||
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"/>
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<!--<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="BGI界面语言"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="BGI UI Language"
|
||||
TextWrapping="Wrap" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding LanguageDict}"
|
||||
SelectedValuePath="Key"
|
||||
DisplayMemberPath="Value"
|
||||
SelectedItem="{Binding Config.AutoFishingConfig.UiCultureInfoName, Converter={StaticResource CultureInfoNameToKVPConverter}, Mode=TwoWay}" />
|
||||
</Grid>-->
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
@@ -12,11 +18,14 @@ using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.View.Converters;
|
||||
using BetterGenshinImpact.View.Pages;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Win32;
|
||||
using Wpf.Ui;
|
||||
|
||||
@@ -47,6 +56,18 @@ public partial class CommonSettingsPageViewModel : ViewModel
|
||||
public ObservableCollection<string> CountryList { get; } = new();
|
||||
public ObservableCollection<string> Areas { get; } = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private FrozenDictionary<string, string> _languageDict = new string[] { "zh-Hans", "zh-Hant", "en", "fr" }
|
||||
.ToFrozenDictionary(
|
||||
c => c,
|
||||
c =>
|
||||
{
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(c);
|
||||
var stringLocalizer = App.GetService<IStringLocalizer<CultureInfoNameToKVPConverter>>() ?? throw new NullReferenceException();
|
||||
return stringLocalizer["简体中文"].ToString();
|
||||
}
|
||||
);
|
||||
|
||||
public string SelectedCountry
|
||||
{
|
||||
get => _selectedCountry;
|
||||
@@ -232,4 +253,10 @@ public partial class CommonSettingsPageViewModel : ViewModel
|
||||
keyBindingsWindow.Owner = Application.Current.MainWindow;
|
||||
keyBindingsWindow.ShowDialog();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OnGameLangSelectionChanged(KeyValuePair<string, string> type)
|
||||
{
|
||||
await OcrFactory.ChangeCulture(type.Key);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -31,12 +30,7 @@ using Wpf.Ui.Violeta.Controls;
|
||||
using BetterGenshinImpact.ViewModel.Pages.View;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Vanara.Extensions;
|
||||
using System.Collections.Frozen;
|
||||
using System.Globalization;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using BetterGenshinImpact.View.Converters;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -134,18 +128,6 @@ public partial class TaskSettingsPageViewModel : ViewModel
|
||||
.GetCustomAttribute<DescriptionAttribute>()?
|
||||
.Description ?? e.ToString());
|
||||
|
||||
[ObservableProperty]
|
||||
private FrozenDictionary<string, string> _languageDict = new string[] { "zh-Hans", "zh-Hant", "en", "fr" }
|
||||
.ToFrozenDictionary(
|
||||
c => c,
|
||||
c =>
|
||||
{
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(c);
|
||||
var stringLocalizer = App.GetService<IStringLocalizer<CultureInfoNameToKVPConverter>>() ?? throw new NullReferenceException();
|
||||
return stringLocalizer["简体中文"].ToString();
|
||||
}
|
||||
);
|
||||
|
||||
private bool saveScreenshotOnKeyTick;
|
||||
public bool SaveScreenshotOnKeyTick
|
||||
{
|
||||
@@ -434,10 +416,4 @@ public partial class TaskSettingsPageViewModel : ViewModel
|
||||
{
|
||||
_autoFightViewModel.OnOpenLocalScriptRepo();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OnGameLangSelectionChanged(KeyValuePair<string, string> type)
|
||||
{
|
||||
await OcrFactory.ChangeCulture(type.Key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user