From 7373fecdd0702221954c2190a40b80c5015ad991 Mon Sep 17 00:00:00 2001 From: imba-tjd <109224573@qq.com> Date: Mon, 28 Jun 2021 16:45:35 +0800 Subject: [PATCH] =?UTF-8?q?TextHook=EF=BC=9A=E4=BB=A5U16=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E5=86=99=E5=85=A5CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 1 + .../GuidePages/Hook/ChooseGamePage.xaml.cs | 2 +- MisakaTranslator-WPF/IAppSettings.cs | 6 ++ MisakaTranslator-WPF/MainWindow.xaml.cs | 2 +- .../DictionaryPages/MecabDictPage.xaml.cs | 1 - .../SettingsPages/HookSettingsPage.xaml | 32 +++++-- .../SettingsPages/HookSettingsPage.xaml.cs | 85 +++++++++++++++++++ MisakaTranslator-WPF/lang/en-US.xaml | 2 +- MisakaTranslator-WPF/lang/zh-CN.xaml | 2 +- TextHookLibrary/NativeMethods.txt | 2 + TextHookLibrary/TextHookHandle.cs | 61 ++++++++----- 11 files changed, 163 insertions(+), 33 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0d8c6927..7159642e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,6 +7,7 @@ AnyCPU 11.0 2.12.2.0 + true diff --git a/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml.cs b/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml.cs index f6d11db3..880dd5eb 100644 --- a/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml.cs +++ b/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.xaml.cs @@ -54,7 +54,7 @@ private void ConfirmButton_Click(object sender, RoutedEventArgs e) Common.textHooker = new TextHookHandle(SameNameGameProcessList); } - if(!Common.textHooker.Init(!(bool)x64GameCheckBox.IsChecked)) + if (!Common.textHooker.Init((bool)x64GameCheckBox.IsChecked ? Common.appSettings.Textractor_Path64 : Common.appSettings.Textractor_Path32)) { HandyControl.Controls.MessageBox.Show(Application.Current.Resources["MainWindow_TextractorError_Hint"].ToString()); return; diff --git a/MisakaTranslator-WPF/IAppSettings.cs b/MisakaTranslator-WPF/IAppSettings.cs index 54320919..c0a58748 100644 --- a/MisakaTranslator-WPF/IAppSettings.cs +++ b/MisakaTranslator-WPF/IAppSettings.cs @@ -455,6 +455,12 @@ string ForegroundHex [Option(Alias = "Mecab.dicPath", DefaultValue = "")] string Mecab_dicPath { get; set; } + + [Option(Alias = "Textractor.Path32", DefaultValue = "")] + string Textractor_Path32 { get; set; } + + [Option(Alias = "Textractor.Path64", DefaultValue = "")] + string Textractor_Path64 { get; set; } } public interface IRepeatRepairSettings diff --git a/MisakaTranslator-WPF/MainWindow.xaml.cs b/MisakaTranslator-WPF/MainWindow.xaml.cs index 6afb0dda..33bfd787 100644 --- a/MisakaTranslator-WPF/MainWindow.xaml.cs +++ b/MisakaTranslator-WPF/MainWindow.xaml.cs @@ -250,7 +250,7 @@ private async Task StartTranslateByGid(int gid) { Common.textHooker = pidList.Count == 1 ? new TextHookHandle(pidList[0].Id) : new TextHookHandle(pidList); - if(!Common.textHooker.Init(!gameInfoList[gid].Isx64)) + if (!Common.textHooker.Init(gameInfoList[gid].Isx64 ? Common.appSettings.Textractor_Path64 : Common.appSettings.Textractor_Path32)) { HandyControl.Controls.MessageBox.Show(Application.Current.Resources["MainWindow_TextractorError_Hint"].ToString()); return; diff --git a/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml.cs b/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml.cs index bfd49d05..0bd73bd6 100644 --- a/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml.cs +++ b/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml.cs @@ -17,7 +17,6 @@ public MecabDictPage() private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) { - FolderBrowserDialog dialog = new(); if (dialog.ShowDialog() == DialogResult.OK) { diff --git a/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml b/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml index 3d625cab..21427165 100644 --- a/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml +++ b/MisakaTranslator-WPF/SettingsPages/HookSettingsPage.xaml @@ -13,12 +13,32 @@ - - - - - -