diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index f192219dd4..e4a1e3f675 100755 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -30,6 +30,7 @@ namespace MaaWpfGui.Constants public const string ConfigurationCron = "Cron"; public const string Localization = "GUI.Localization"; + public const string OperNameLanguage = "GUI.OperNameLanguage"; public const string UseTray = "GUI.UseTray"; public const string MinimizeToTray = "GUI.MinimizeToTray"; public const string HideCloseButton = "GUI.HideCloseButton"; diff --git a/src/MaaWpfGui/Helper/DataHelper.cs b/src/MaaWpfGui/Helper/DataHelper.cs index d35966fd66..a8b30d7b9b 100644 --- a/src/MaaWpfGui/Helper/DataHelper.cs +++ b/src/MaaWpfGui/Helper/DataHelper.cs @@ -100,7 +100,7 @@ namespace MaaWpfGui.Helper return null; } - language ??= Instances.SettingsViewModel.Language; + language ??= Instances.SettingsViewModel.OperNameLocalization; return language switch { diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index c3e59535c2..08eec0c7bb 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1010,7 +1010,8 @@ namespace MaaWpfGui.Main var missingOpers = details["details"]?["opers"]?.ToObject>>(); if (missingOpers is not null) { - var missingOpersStr = "[" + string.Join("]; [", missingOpers.Select(opers => string.Join(", ", opers))) + "]"; + var missingOpersStr = "[" + string.Join("]; [", missingOpers.Select(opers => + string.Join(", ", opers.Select(oper => DataHelper.GetLocalizedCharacterName(oper))))) + "]"; Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("MissingOperators") + missingOpersStr, UiLogColor.Error); } else @@ -1432,11 +1433,12 @@ namespace MaaWpfGui.Main } case "BattleFormation": - Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("BattleFormation") + "\n" + JsonConvert.SerializeObject(subTaskDetails!["formation"])); + Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("BattleFormation") + "\n[" + + string.Join(", ", subTaskDetails!["formation"]?.ToObject>().Select(oper => DataHelper.GetLocalizedCharacterName(oper))) + "]"); break; case "BattleFormationSelected": - Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("BattleFormationSelected") + subTaskDetails!["selected"]); + Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("BattleFormationSelected") + DataHelper.GetLocalizedCharacterName(subTaskDetails!["selected"]?.ToString())); break; case "CopilotAction": diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 07c8cbf44a..09af5c8687 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -408,6 +408,9 @@ Only supports Official(CN) and Bilibili server. Login account is not supported.< Auto I.S. Reclamation Algorithm Reclamation Algorithm 2 + Operator name display language + Follow MAA + Follow game client Light Dark Sync with OS @@ -590,6 +593,12 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Loop Times Start Video Link + Skill + Total {0} Operator(s) + Directive EC unit: + Other operators: + Tactical Equipment (horizontal): + Initial Strategy: Tips: \n\n diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index ef521ff966..d02291b974 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -407,6 +407,9 @@ 自動ローグ 生息演算「砂中の火」 生息演算「熱砂秘聞」 + オペレーター名の表示言語 + MAAをフォローする + ゲームクライアントをフォローする ライトモード ダークモード OSと同期する @@ -589,6 +592,12 @@ ループ回数 開始 映像へのハイパーリンク + スキル + 合計 {0} 名のオペレーター + 拡張式戦術ユニット: + その他のオペレーター: + 初期戦術装備(横): + 初期戦略: ヒント: \n\n diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 2291bfef1c..84d72eb2f5 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -407,6 +407,9 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요. 통합전략 생존연산·모래 속의 불 생존연산·사막 이야기 + 간부 이름 표시 언어 + MAA 따라가기 + 게임 클라이언트 따라가기 라이트 다크 시스템 연동 @@ -591,6 +594,12 @@ Only once가 체크되면 실행 후 Only once가 체크되기 전 상태로 작 반복 횟수 시작 영상 링크 + 스킬 + 총 {0}명의 오퍼레이터 + 에너지 기어: + 기타 오퍼레이터: + 전술 장비 (가로): + 초기 전략: 팁:\n\n diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index a6e554e24d..a795bdea63 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -408,6 +408,9 @@ 自动肉鸽 生息演算·沙中之火 生息演算·沙洲遗闻 + 干员名称显示语言 + 跟随MAA + 跟随游戏客户端 亮色 暗色 与系统同步 @@ -592,6 +595,12 @@ 右键清除未激活任务 开始 视频链接 + 技能 + 共 {0} 名干员 + 导能原件: + 编队工具人: + 开局装备(横向): + 开局策略: 小提示: \n\n diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 739c6f5755..2fb72d9de2 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -398,6 +398,9 @@ 自動肉鴿 生息演算·沙中之火 生息演算·沙洲遺聞 + 幹員名稱顯示語言 + 跟隨MAA + 跟隨遊戲客戶端 亮色 暗色 與系統同步 @@ -582,6 +585,12 @@ 循環次數 開始 影片連結 + 技能 + 共 {0} 名幹員 + 導能組件: + 其他幹員: + 開局裝備(橫向): + 開局策略: 小提示: \n\n diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index 7b134b6072..2037d91d9f 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -373,11 +373,15 @@ namespace MaaWpfGui.ViewModels.UI } AddLog(string.Empty, UiLogColor.Message, showTime: false); + AddLog("------------------------------------------------", UiLogColor.Message, showTime: false); + AddLog(string.Empty, UiLogColor.Message, showTime: false); + int count = 0; foreach (var oper in json["opers"] ?? new JArray()) { count++; - AddLog($"{oper["name"]}, {oper["skill"]} 技能", UiLogColor.Message, showTime: false); + var localizedName = DataHelper.GetLocalizedCharacterName((string?)oper["name"]); + AddLog($"{localizedName}, {LocalizationHelper.GetString("CopilotSkill")} {oper["skill"]}", UiLogColor.Message, showTime: false); } if (json.TryGetValue("groups", out var groupsValue)) @@ -386,13 +390,14 @@ namespace MaaWpfGui.ViewModels.UI { count++; string groupName = group["name"] + ": "; - var operInfos = group["opers"]!.Cast().Select(oper => $"{oper["name"]} {oper["skill"]}").ToList(); + var operInfos = group["opers"]!.Cast() + .Select(oper => $"{DataHelper.GetLocalizedCharacterName((string?)oper["name"])} {oper["skill"]}").ToList(); AddLog(groupName + string.Join(" / ", operInfos), UiLogColor.Message, showTime: false); } } - AddLog($"共 {count} 名干员", UiLogColor.Message, showTime: false); + AddLog(string.Format(LocalizationHelper.GetString("TotalOperatorsCount"), count), UiLogColor.Message, showTime: false); if (json.TryGetValue("type", out var typeValue)) { @@ -401,19 +406,28 @@ namespace MaaWpfGui.ViewModels.UI { _taskType = "SSSCopilot"; + if (json.TryGetValue("buff", out var buffValue)) + { + string buffLog = LocalizationHelper.GetString("DirectiveECTerm"); + AddLog(buffLog + DataHelper.GetLocalizedCharacterName((string?)buffValue), UiLogColor.Message, showTime: false); + } + if (json.TryGetValue("tool_men", out var toolMenValue)) { - AddLog("编队工具人:\n" + toolMenValue, UiLogColor.Message, showTime: false); + string toolMenLog = LocalizationHelper.GetString("OtherOperators"); + AddLog(toolMenLog + toolMenValue, UiLogColor.Message, showTime: false); } if (json.TryGetValue("equipment", out var equipmentValue) && equipmentValue is JArray equipmentJArray) { - AddLog("开局装备(横向):\n" + string.Join('\n', equipmentJArray.Select(i => (string?)i).Chunk(4).Select(i => string.Join(",", i))), UiLogColor.Message, showTime: false); + string equipmentLog = LocalizationHelper.GetString("InitialEquipmentHorizontal") + '\n'; + AddLog(equipmentLog + string.Join('\n', equipmentJArray.Select(i => (string?)i).Chunk(4).Select(i => string.Join(",", i))), UiLogColor.Message, showTime: false); } if (json.TryGetValue("strategy", out var strategyValue)) { - AddLog("开局策略:" + strategyValue, UiLogColor.Message, showTime: false); + string strategyLog = LocalizationHelper.GetString("InitialStrategy"); + AddLog(strategyLog + strategyValue, UiLogColor.Message, showTime: false); } } } diff --git a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs index 2a7452652e..97bbfeffcb 100644 --- a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs @@ -316,8 +316,8 @@ namespace MaaWpfGui.ViewModels.UI foreach (var oper in (JArray?)combs["opers"] ?? []) { int operLevel = (int)oper["level"]; - string operId = oper["id"]?.ToString(); - string operName = oper["name"]?.ToString(); + var operId = oper["id"]?.ToString(); + var operName = DataHelper.GetLocalizedCharacterName(oper["name"]?.ToString()); string potential = string.Empty; @@ -617,7 +617,16 @@ namespace MaaWpfGui.ViewModels.UI List> operHave = []; List> operNotHave = []; - string localizedName = ConfigurationHelper.GetValue(ConfigurationKeys.Localization, string.Empty) switch + string localizedName = ConfigurationHelper.GetValue(ConfigurationKeys.OperNameLanguage, string.Empty) == "OperNameLanguageClient" ? + ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty) switch + { + "Official" => "name", + "Bilibili" => "name", + "YoStarJP" => "name_jp", + "YoStarKR" => "name_kr", + "txwy" => "name_tw", + _ => "name_en", + } : ConfigurationHelper.GetValue(ConfigurationKeys.Localization, string.Empty) switch { "zh-cn" => "name", "ja-jp" => "name_jp", diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 4c77ff4b5a..574e47e44b 100755 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1970,7 +1970,7 @@ namespace MaaWpfGui.ViewModels.UI continue; } - var localizedName = DataHelper.GetLocalizedCharacterName(name, _language); + var localizedName = DataHelper.GetLocalizedCharacterName(name, OperNameLocalization); if (!string.IsNullOrEmpty(localizedName) && !(_clientType.Contains("YoStar") && DataHelper.GetLocalizedCharacterName(name, "en-us") == DataHelper.GetLocalizedCharacterName(name, "zh-cn"))) { roguelikeCoreCharList.Add(localizedName); @@ -4571,6 +4571,15 @@ namespace MaaWpfGui.ViewModels.UI /// public List LanguageList { get; set; } + /// + /// Gets the list of operator name language settings + /// + public List OperNameLanguageModeList { get; } = + [ + new() { Display = LocalizationHelper.GetString("OperNameLanguageMAA"), Value = "OperNameLanguageMAA" }, + new() { Display = LocalizationHelper.GetString("OperNameLanguageClient"), Value = "OperNameLanguageClient" } + ]; + /// /// Gets the list of dark mode. /// @@ -4845,7 +4854,7 @@ namespace MaaWpfGui.ViewModels.UI get => _language; set { - if (!SetAndNotify(ref _language, value)) + if (value == _language) { return; } @@ -4885,6 +4894,8 @@ namespace MaaWpfGui.ViewModels.UI Bootstrapper.ShutdownAndRestartWithoutArgs(); } + SetAndNotify(ref _language, value); + return; string FormatText(string text, string key) @@ -4904,6 +4915,79 @@ namespace MaaWpfGui.ViewModels.UI } } + private static readonly Dictionary _clientLanguageMapper = new() + { + { string.Empty, "zh-cn" }, + { "Official", "zh-cn" }, + { "Bilibili", "zh-cn" }, + { "YoStarEN", "en-us" }, + { "YoStarJP", "ja-jp" }, + { "YoStarKR", "ko-kr" }, + { "txwy", "zh-tw" }, + }; + + private string _operNameLanguage = ConfigurationHelper.GetValue(ConfigurationKeys.OperNameLanguage, "OperNameLanguageMAA"); + + public string OperNameLanguage + { + get => _operNameLanguage; + + set + { + if (value == _operNameLanguage) + { + return; + } + + switch (value) + { + case "OperNameLanguageClient": + ConfigurationHelper.SetValue(ConfigurationKeys.OperNameLanguage, value); + break; + case "OperNameLanguageMAA": + default: + ConfigurationHelper.SetValue(ConfigurationKeys.OperNameLanguage, "OperNameLanguageMAA"); + break; + } + + var mainWindow = Application.Current.MainWindow; + + if (mainWindow != null) + { + mainWindow.Show(); + mainWindow.WindowState = mainWindow.WindowState = WindowState.Normal; + mainWindow.Activate(); + } + + var result = MessageBoxHelper.Show( + LocalizationHelper.GetString("LanguageChangedTip"), + LocalizationHelper.GetString("Tip"), + MessageBoxButton.OKCancel, + MessageBoxImage.Question, + ok: LocalizationHelper.GetString("Ok"), + cancel: LocalizationHelper.GetString("ManualRestart")); + if (result == MessageBoxResult.OK) + { + Bootstrapper.ShutdownAndRestartWithoutArgs(); + } + + SetAndNotify(ref _operNameLanguage, value); + } + } + + public string OperNameLocalization + { + get + { + if (_operNameLanguage == "OperNameLanguageClient") + { + return _clientLanguageMapper[ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty)]; + } + + return _language; + } + } + #endregion #region HotKey diff --git a/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml index 99997ae69f..3807cf8091 100644 --- a/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml @@ -93,6 +93,17 @@ SelectedValue="{Binding Language}" SelectedValuePath="Value" Style="{StaticResource ComboBoxExtend}" /> +