diff --git a/resource/config.json b/resource/config.json index 29b02796fc..eb8eb3f198 100644 --- a/resource/config.json +++ b/resource/config.json @@ -268,30 +268,6 @@ "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", "callMinitouch": "[Adb] -s [AdbSerial] shell \"/data/local/tmp/[minitouchWorkingFile]\" -i" - }, - "MaaTouch": { - "devices": "[Adb] devices", - "addressRegex": "(.+)\tdevice", - "connect": "[Adb] connect [AdbSerial]", - "uuid": "[Adb] -s [AdbSerial] shell settings get secure android_id", - "click": "[Adb] -s [AdbSerial] shell input tap [x] [y]", - "swipe": "[Adb] -s [AdbSerial] shell input swipe [x1] [y1] [x2] [y2] [duration]", - "pressEsc": "[Adb] -s [AdbSerial] shell input keyevent 111", - "display": "[Adb] -s [AdbSerial] shell dumpsys window displays | grep -o -E cur=+[^\\ ]+ | grep -o -E [0-9]+", - "displayFormat": "%d%d", - "screencapRawByNC": "[Adb] -s [AdbSerial] exec-out \"screencap | nc -w 3 [NcAddress] [NcPort]\"", - "ncAddress": "[Adb] -s [AdbSerial] shell \" cat /proc/net/arp | grep : \"", - "ncPort": 6723, - "screencapRawWithGzip": "[Adb] -s [AdbSerial] exec-out \"screencap | gzip -1\"", - "screencapEncode": "[Adb] -s [AdbSerial] exec-out screencap -p", - "release": "[Adb] kill-server", - "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", - "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell echo maatouch", - "orientation": "[Adb] -s [AdbSerial] shell echo 0", - "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", - "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", - "callMinitouch": "[Adb] -s [AdbSerial] shell \"export CLASSPATH=/data/local/tmp/[minitouchWorkingFile]; app_process /data/local/tmp com.shxyke.MaaTouch.App\"" } } } diff --git a/src/MaaCore/Assistant.cpp b/src/MaaCore/Assistant.cpp index 54d8d42895..b3343385a3 100644 --- a/src/MaaCore/Assistant.cpp +++ b/src/MaaCore/Assistant.cpp @@ -81,13 +81,17 @@ bool asst::Assistant::set_instance_option(InstanceOptionKey key, const std::stri { Log.info(__FUNCTION__, "| key", static_cast(key), "value", value); switch (key) { - case InstanceOptionKey::MinitouchEnabled: - if (constexpr std::string_view Disable = "0"; value == Disable) { + case InstanceOptionKey::TouchMode: + if (constexpr std::string_view Adb = "adb"; value == Adb) { m_ctrler->set_minitouch_enabled(false); return true; } - else if (constexpr std::string_view Enable = "1"; value == Enable) { - m_ctrler->set_minitouch_enabled(true); + else if (constexpr std::string_view Minitouch = "minitouch"; value == Minitouch) { + m_ctrler->set_minitouch_enabled(true, false); + return true; + } + else if (constexpr std::string_view MaaTouch = "maatouch"; value == MaaTouch) { + m_ctrler->set_minitouch_enabled(true, true); return true; } else { diff --git a/src/MaaCore/Common/AsstTypes.h b/src/MaaCore/Common/AsstTypes.h index 58236f5731..7fb192c019 100644 --- a/src/MaaCore/Common/AsstTypes.h +++ b/src/MaaCore/Common/AsstTypes.h @@ -38,7 +38,8 @@ namespace asst enum class InstanceOptionKey { Invalid = 0, - MinitouchEnabled = 1, + /* Deprecated */ // MinitouchEnabled = 1, + TouchMode = 2, }; struct Point diff --git a/src/MaaCore/Controller.cpp b/src/MaaCore/Controller.cpp index cdec680c69..fcbaa57911 100644 --- a/src/MaaCore/Controller.cpp +++ b/src/MaaCore/Controller.cpp @@ -1520,10 +1520,11 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a return false; } - do { + while (m_minitouch_enabled) { m_minitouch_avaiable = false; - std::string abilist = call_command(cmd_replace(adb_cfg.abilist)).value_or("maatouch"); + std::string abilist = + m_use_maa_touch ? "maatouch" : call_command(cmd_replace(adb_cfg.abilist)).value_or("maatouch"); std::string_view optimal_abi; for (const auto& abi : Config.get_options().minitouch_programs_order) { if (abilist.find(abi) != std::string::npos) { @@ -1550,7 +1551,8 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a m_adb.call_minitouch = minitouch_cmd_rep(adb_cfg.call_minitouch); if (!call_and_hup_minitouch(m_adb.call_minitouch)) break; - std::string orientation_str = call_command(cmd_replace(adb_cfg.orientation)).value_or("0"); + std::string orientation_str = + m_use_maa_touch ? "0" : call_command(cmd_replace(adb_cfg.orientation)).value_or("0"); if (!orientation_str.empty()) { char first = orientation_str.front(); if (first == '0' || first == '1' || first == '2' || first == '3') { @@ -1559,7 +1561,17 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a } m_minitouch_avaiable = true; - } while (false); + break; + }; + + if (m_minitouch_enabled && !m_minitouch_avaiable) { + json::value info = get_info_json() | json::object { + { "what", "TouchModeNotAvaiable" }, + { "why", "" }, + }; + callback(AsstMsg::ConnectionInfo, info); + return false; + } // try to find the fastest way if (!screencap()) { @@ -1628,6 +1640,12 @@ bool asst::Controller::inited() const noexcept return m_inited; } +void asst::Controller::set_minitouch_enabled(bool enable, bool maa_touch) noexcept +{ + m_minitouch_enabled = enable; + m_use_maa_touch = maa_touch; +} + const std::string& asst::Controller::get_uuid() const { return m_uuid; diff --git a/src/MaaCore/Controller.h b/src/MaaCore/Controller.h index 6ee8a86ace..07743f772a 100644 --- a/src/MaaCore/Controller.h +++ b/src/MaaCore/Controller.h @@ -36,7 +36,7 @@ namespace asst bool connect(const std::string& adb_path, const std::string& address, const std::string& config); bool inited() const noexcept; - void set_minitouch_enabled(bool enable) noexcept { m_minitouch_enabled = enable; } + void set_minitouch_enabled(bool enable, bool maa_touch = false) noexcept; const std::string& get_uuid() const; cv::Mat get_image(bool raw = false); @@ -159,7 +159,8 @@ namespace asst } screencap_method = ScreencapMethod::UnknownYet; } m_adb; - bool m_minitouch_enabled = true; // 开关 + bool m_minitouch_enabled = true; // 开关 + bool m_use_maa_touch = false; bool m_minitouch_avaiable = false; // 状态 #ifdef _WIN32 diff --git a/src/MaaWpfGui/MaaWpfGui.csproj b/src/MaaWpfGui/MaaWpfGui.csproj index 518393e6ac..face25fa5e 100644 --- a/src/MaaWpfGui/MaaWpfGui.csproj +++ b/src/MaaWpfGui/MaaWpfGui.csproj @@ -131,6 +131,9 @@ + + GameClientUserControl.xaml + GUISettingsUserControl.xaml @@ -213,6 +216,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index cd998c3e43..9c1566371a 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -428,6 +428,10 @@ namespace MaaWpfGui case "ScreencapFailed": mainModel.AddLog(Localization.GetString("ScreencapFailed"), UILogColor.Error); break; + + case "TouchModeNotAvaiable": + mainModel.AddLog(Localization.GetString("TouchModeNotAvaiable"), UILogColor.Error); + break; } } @@ -1632,7 +1636,8 @@ namespace MaaWpfGui public enum InstanceOptionKey { - MinitouchEnabled = 1, + /* Deprecated */ // MinitouchEnabled = 1, + TouchMode = 2, } } diff --git a/src/MaaWpfGui/Main/CopilotViewModel.cs b/src/MaaWpfGui/Main/CopilotViewModel.cs index 30f92053ef..cd475589ca 100644 --- a/src/MaaWpfGui/Main/CopilotViewModel.cs +++ b/src/MaaWpfGui/Main/CopilotViewModel.cs @@ -425,7 +425,7 @@ namespace MaaWpfGui { AddLog(Localization.GetString("Running")); var settingsModel = _container.Get(); - if (!settingsModel.AdbReplaced && !settingsModel.UseAdbTouchMode) + if (!settingsModel.AdbReplaced && !settingsModel.IsAdbTouchMode()) { AddLog(Localization.GetString("AdbReplacementTips"), UILogColor.Info); } diff --git a/src/MaaWpfGui/Main/SettingsViewModel.cs b/src/MaaWpfGui/Main/SettingsViewModel.cs index 4dc85afa67..80b909f866 100644 --- a/src/MaaWpfGui/Main/SettingsViewModel.cs +++ b/src/MaaWpfGui/Main/SettingsViewModel.cs @@ -71,6 +71,7 @@ namespace MaaWpfGui _maaHotKeyManager = _container.Get(); DisplayName = Localization.GetString("Settings"); + _listTitle.Add(Localization.GetString("GameSettings")); _listTitle.Add(Localization.GetString("BaseSettings")); _listTitle.Add(Localization.GetString("RoguelikeSettings")); _listTitle.Add(Localization.GetString("RecruitingSettings")); @@ -176,10 +177,16 @@ namespace MaaWpfGui new CombData { Display = Localization.GetString("Nox"), Value = "Nox" }, new CombData { Display = Localization.GetString("XYAZ"), Value = "XYAZ" }, new CombData { Display = Localization.GetString("WSA"), Value = "WSA" }, - new CombData { Display = Localization.GetString("MaaTouch"), Value = "MaaTouch" }, new CombData { Display = Localization.GetString("Compatible"), Value = "Compatible" }, }; + TouchModeList = new List + { + new CombData { Display = Localization.GetString("MiniTouchMode"), Value = "minitouch" }, + new CombData { Display = Localization.GetString("MaaTouchMode"), Value = "maatouch" }, + new CombData { Display = Localization.GetString("AdbTouchMode"), Value = "adb" }, + }; + _dormThresholdLabel = Localization.GetString("DormThreshold") + ": " + _dormThreshold + "%"; RoguelikeModeList = new List @@ -513,6 +520,8 @@ namespace MaaWpfGui /// public List ConnectConfigList { get; set; } + public List TouchModeList { get; set; } + /// /// Gets or sets the list of inverse clear modes. /// @@ -1855,15 +1864,20 @@ namespace MaaWpfGui } } - private bool _useAdbTouchMode = Convert.ToBoolean(ViewStatusStorage.Get("Connect.UseAdbTouchMode", false.ToString())); - - public bool UseAdbTouchMode + public bool IsAdbTouchMode() { - get => _useAdbTouchMode; + return TouchMode == "adb"; + } + + private string _touchMode = ViewStatusStorage.Get("Connect.TouchMode", "minitouch"); + + public string TouchMode + { + get => _touchMode; set { - SetAndNotify(ref _useAdbTouchMode, value); - ViewStatusStorage.Set("Connect.UseAdbTouchMode", value.ToString()); + SetAndNotify(ref _touchMode, value); + ViewStatusStorage.Set("Connect.TouchMode", value); UpdateTouchMode(); } } @@ -1871,7 +1885,7 @@ namespace MaaWpfGui public void UpdateTouchMode() { var asstProxy = _container.Get(); - asstProxy.AsstSetInstanceOption(InstanceOptionKey.MinitouchEnabled, UseAdbTouchMode ? "0" : "1"); + asstProxy.AsstSetInstanceOption(InstanceOptionKey.TouchMode, TouchMode); } private static readonly string GoogleAdbDownloadUrl = "https://dl.google.com/android/repository/platform-tools-latest-windows.zip"; diff --git a/src/MaaWpfGui/Main/TaskQueueViewModel.cs b/src/MaaWpfGui/Main/TaskQueueViewModel.cs index e4f9a60943..8b11091b59 100644 --- a/src/MaaWpfGui/Main/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/Main/TaskQueueViewModel.cs @@ -663,7 +663,7 @@ namespace MaaWpfGui { AddLog(Localization.GetString("Running")); var settingsModel = _container.Get(); - if (!settingsModel.AdbReplaced && !settingsModel.UseAdbTouchMode) + if (!settingsModel.AdbReplaced && !settingsModel.IsAdbTouchMode()) { AddLog(Localization.GetString("AdbReplacementTips"), UILogColor.Info); } diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 6f5e5174b5..76acc05f78 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -6,6 +6,7 @@ xmlns:uri="clr-namespace:System;assembly=System.Runtime"> Settings + Client Base I.S. Recruit @@ -167,13 +168,16 @@ Auto start with PC Auto Run task after launched - Client version + Client Type Startup Emulator after launched Delay time Emulator exec path Select Forced Replace ADB File - Compatibility Touch Mode (without minitouch) + Touch Mode + Minitouch (Default) + MaaTouch (Experimental) + Adb Input (Compatibility) Addiction Command arguments I.S. Theme @@ -212,7 +216,7 @@ Auto detect connection The checkbox will be automatically unchecked after each detect is completed, and can be checked again if you need to re-detect - Always detect connection automatically + Always detect ADB path (rel/abs) Connection address It will be filled in automatically when you use it for the first time. If you encounter any problems, you can try to manually modify it @@ -389,6 +393,7 @@ Reconnect succeeded. Continue the task Reconnect failed. The connection is down! Screencap failed. If it happens repeatedly, try restarting or changing the emulator. + Touch mode is not avaiable, please enter Settings - Connection Settings to change other touch modes Identify error Task error: Combat error diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index e066192f8c..ca55f89155 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -136,7 +136,7 @@ スタートアップ アプリの起動時に自動的に実行 - クライアントバージョン + クライアントバージョン 起動時にエミュレータ自動起動 エミュレータを待つ時間(秒) エミュレータパス @@ -180,7 +180,7 @@ 接続自動認識 このチェックボックスは、検出が完了するたびに自動的にチェックが外れますが、再検出が必要な場合は再度チェックを入れることができます - 常時自動接続検知 + 常時検知 adbパス(相対/絶対) 接続先アドレス 問題があれば手動で修正してください。 @@ -188,7 +188,6 @@ adb再接続失敗時にエミュレータを自動で再起動 再接続に20回失敗した後、エミュレータを再起動してみてください,バックグラウンドのタイムドタスクを使用し、終了時にエミュレータを終了させるタスクを設定する場合は、必ずチェックを入れること ADBの強制置き換え - 互換性 タッチモード(ミニタッチなし) @@ -280,7 +279,7 @@ タスクが選択されていません 動作中…… 動作停止中…… - もし全てでスタックする場合は、設定 - 接続設定 - ADBの強制置き換え、もしくは 互換性 タッチモード をチェックしてください。 + もし全てでスタックする場合は、設定 - 接続設定 - ADBの強制置き換え、もしくは 互換性 タッチモード をチェックしてください。 動作停止 不明なエラーが発生しました @@ -471,4 +470,4 @@ つ、次は飲みすぎないようにしないと…… Hello World! - + \ No newline at end of file diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index bd37e5cbe5..eefc9b69bb 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -167,13 +167,12 @@ 시스템 시작 시 실행 실행 후 작업 시작 - 클라이언트 버전 + 클라이언트 버전 실행 후 에뮬레이터를 실행 에뮬레이터 실행 대기 (초) 에뮬레이터 경로 선택 ADB 강제 교체 - 터치 호환 모드 (minitouch 없이) 추가 변수 통합전략 테마 @@ -212,7 +211,7 @@ 연결 자동 감지 이 체크박스는 감지가 끝나면 자동으로 체크가 해제됩니다. 다시 감지하려면 다시 체크해주세요. - 항상 연결 자동 감지 + 항상 감지 adb 경로 (상대/절대) 연결 주소 문제가 있으면 수동으로 수정하십시오 diff --git a/src/MaaWpfGui/Res/Localizations/pallas.xaml b/src/MaaWpfGui/Res/Localizations/pallas.xaml index b9c62dc883..0d62f006f4 100644 --- a/src/MaaWpfGui/Res/Localizations/pallas.xaml +++ b/src/MaaWpfGui/Res/Localizations/pallas.xaml @@ -134,7 +134,7 @@ 🍺🍸🍻🍸🍻🍷💃 🍻🍸🍸🍺🍷🍺🍻🍷 - 🍺🍷🍸🍸🍷🍻 + 🍺🍷🍸🍸🍷🍻 💃💃🍻🍸🍺🍸🍺🍸🕺🍺🍸 🍻💃🕺🍻🍷🍷🍷🍷🍸🕺🍺🍷🍸 🍻🍸🍸🍷🍻🕺 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 944d9a64bb..d9f4799927 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -6,6 +6,7 @@ xmlns:uri="clr-namespace:System;assembly=System.Runtime"> 设置 + 游戏设置 基建设置 肉鸽设置 自动公招 @@ -167,13 +168,16 @@ 开机自动启动 启动后直接运行 - 客户端版本 + 客户端类型 启动后自动开启模拟器 等待模拟器启动时间(秒) 模拟器路径 选择 强制替换 ADB - 兼容性的触控模式(不使用 minitouch) + 触控模式 + Minitouch(默认) + MaaTouch(实验功能) + Adb Input(兼容模式) 附加命令 肉鸽主题 @@ -212,7 +216,7 @@ 自动检测连接 每次检测完成后会自动取消勾选,若需要重新检测可再次勾选,若反复连接失败可勾选始终自动检测连接 - 始终自动检测连接 + 始终检测 adb 路径 (相对/绝对) 连接地址 若遇到问题可尝试手动修改 @@ -388,6 +392,7 @@ 模拟器断开,正在尝试重连 重连成功,继续任务 重连失败,连接断开! + 触控模式不可用。请进入 设置 - 连接设置 切换其他触控模式 截图失败,如反复出现请尝试重启或更换模拟器! 识别错误 任务出错: diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 99bd0820e4..0f30c640b7 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -134,7 +134,7 @@ 開機自動啟動 啟動後直接運行 - 用戶端版本 + 用戶端類型 啟動後自動開啟模擬器 等待模擬器啟動時間(秒) 模擬器路徑 diff --git a/src/MaaWpfGui/Views/DepotView.xaml b/src/MaaWpfGui/Views/DepotView.xaml index d431889c91..62af4d16b5 100644 --- a/src/MaaWpfGui/Views/DepotView.xaml +++ b/src/MaaWpfGui/Views/DepotView.xaml @@ -22,20 +22,20 @@ + TextWrapping="Wrap" /> + TextWrapping="Wrap" /> + - - + + - - + + - - + + - - + + - - + + diff --git a/src/MaaWpfGui/Views/RecruitView.xaml b/src/MaaWpfGui/Views/RecruitView.xaml index 56afdc6d9b..d561d7aa40 100644 --- a/src/MaaWpfGui/Views/RecruitView.xaml +++ b/src/MaaWpfGui/Views/RecruitView.xaml @@ -22,20 +22,20 @@ + TextWrapping="Wrap" /> + TextWrapping="Wrap" /> - @@ -60,7 +60,7 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[1]}" /> - @@ -75,7 +75,7 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[2]}" /> - @@ -90,7 +90,7 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[3]}" /> - @@ -105,7 +105,7 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[4]}" /> - @@ -120,7 +120,7 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[5]}" /> - @@ -135,7 +135,10 @@ Foreground="Gray" Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[6]}" /> - + - + - + + + + + Text="{Binding ListTitle[11]}" /> + Text="{Binding ListTitle[12]}" /> diff --git a/src/MaaWpfGui/Views/TaskQueueView.xaml b/src/MaaWpfGui/Views/TaskQueueView.xaml index 04fb3e6a63..049e35ab6d 100644 --- a/src/MaaWpfGui/Views/TaskQueueView.xaml +++ b/src/MaaWpfGui/Views/TaskQueueView.xaml @@ -160,7 +160,6 @@ --> - @@ -199,20 +198,20 @@ + TextWrapping="Wrap" /> + TextWrapping="Wrap" /> diff --git a/src/MaaWpfGui/Views/UserControl/AutoRecruitSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/AutoRecruitSettingsUserControl.xaml index f73783c13e..f5277f5b92 100644 --- a/src/MaaWpfGui/Views/UserControl/AutoRecruitSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/AutoRecruitSettingsUserControl.xaml @@ -19,9 +19,7 @@ - + - + @@ -25,29 +25,25 @@ - + IsChecked="{Binding AutoDetectConnection}" + ToolTip="{DynamicResource AutoDetectConnectionTip}" /> + IsChecked="{Binding AlwaysAutoDetectConnection}" + Visibility="{c:Binding AutoDetectConnection}" />