From 21e6b33f2409974a59d44879077a6f3760f88e96 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sat, 3 Dec 2022 21:02:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E2=80=9C=E6=9A=82?= =?UTF-8?q?=E5=81=9C=E4=B8=8B=E5=B9=B2=E5=91=98=E2=80=9D=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=85=B3=E9=97=AD=E3=80=82=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E9=83=A8=E7=BD=B2=E9=83=A8=E7=BD=B2=E5=B9=B2=E5=91=98?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 8 ++++---- src/MaaCore/Assistant.cpp | 13 ++++++++++--- src/MaaCore/Common/AsstTypes.h | 5 +++-- src/MaaCore/Controller.cpp | 7 ++++++- src/MaaCore/Controller.h | 3 +++ src/MaaWpfGui/Main/AsstProxy.cs | 3 ++- src/MaaWpfGui/Main/SettingsViewModel.cs | 18 ++++++++++++++++-- src/MaaWpfGui/Res/Localizations/en-us.xaml | 1 + src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 1 + .../RoguelikeSettingsUserControl.xaml | 19 ++++++++++++++++++- 10 files changed, 64 insertions(+), 14 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index ca7ed544ff..c78f109638 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -6362,17 +6362,17 @@ }, "BattleUseOper": { "algorithm": "JustReturn", - "preDelay": 200, - "postDelay": 300, + "preDelay": 100, + "postDelay": 200, "Doc": "pre 是从点击干员,到干员信息弹出来等待的时间;post 是干员上场,到设置朝向之间等待的时间" }, "BattleSwipeOper": { "algorithm": "JustReturn", - "preDelay": 500, + "preDelay": 400, "postDelay": 150, "Doc": "pre 是将干员滑动到场上的 duration 系数;post 是设置干员朝向滑动的 duration", "specialParams": [ - 300, + 400, 2, 0 ], diff --git a/src/MaaCore/Assistant.cpp b/src/MaaCore/Assistant.cpp index e3d1e1f3a7..0e6d355841 100644 --- a/src/MaaCore/Assistant.cpp +++ b/src/MaaCore/Assistant.cpp @@ -94,12 +94,19 @@ bool asst::Assistant::set_instance_option(InstanceOptionKey key, const std::stri m_ctrler->set_minitouch_enabled(true, true); return true; } - else { - Log.error("unknown value", value); - return false; + break; + case InstanceOptionKey::DeploymentWithPause: + if (constexpr std::string_view Enable = "1"; value == Enable) { + m_ctrler->set_swipe_with_pause(true); + return true; + } + else if (constexpr std::string_view Disable = "0"; value == Disable) { + m_ctrler->set_swipe_with_pause(false); + return true; } break; } + Log.error("Unknown key or value", value); return false; } diff --git a/src/MaaCore/Common/AsstTypes.h b/src/MaaCore/Common/AsstTypes.h index 7fb192c019..9fb9fb7af3 100644 --- a/src/MaaCore/Common/AsstTypes.h +++ b/src/MaaCore/Common/AsstTypes.h @@ -38,8 +38,9 @@ namespace asst enum class InstanceOptionKey { Invalid = 0, - /* Deprecated */ // MinitouchEnabled = 1, - TouchMode = 2, + /* Deprecated */ // MinitouchEnabled = 1, + TouchMode = 2, // 触控模式设置, "minitouch" | "maatouch" | "adb" + DeploymentWithPause = 3, // 自动战斗、肉鸽、保全 是否使用 暂停下干员, "0" | "1" }; struct Point diff --git a/src/MaaCore/Controller.cpp b/src/MaaCore/Controller.cpp index 8bc416af11..7641c0d41b 100644 --- a/src/MaaCore/Controller.cpp +++ b/src/MaaCore/Controller.cpp @@ -1252,7 +1252,7 @@ bool asst::Controller::press_esc() bool asst::Controller::support_swipe_with_pause() const noexcept { - return m_minitouch_enabled && m_minitouch_available && !m_adb.swipe.empty(); + return m_minitouch_enabled && m_minitouch_available && m_swipe_with_pause_enabled && !m_adb.press_esc.empty(); } bool asst::Controller::connect(const std::string& adb_path, const std::string& address, const std::string& config) @@ -1648,6 +1648,11 @@ void asst::Controller::set_minitouch_enabled(bool enable, bool maa_touch) noexce m_use_maa_touch = maa_touch; } +void asst::Controller::set_swipe_with_pause(bool enable) noexcept +{ + m_swipe_with_pause_enabled = enable; +} + const std::string& asst::Controller::get_uuid() const { return m_uuid; diff --git a/src/MaaCore/Controller.h b/src/MaaCore/Controller.h index ee61ceb48b..69c7d10cbb 100644 --- a/src/MaaCore/Controller.h +++ b/src/MaaCore/Controller.h @@ -37,6 +37,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, bool maa_touch = false) noexcept; + void set_swipe_with_pause(bool enable) noexcept; const std::string& get_uuid() const; cv::Mat get_image(bool raw = false); @@ -160,6 +161,8 @@ namespace asst } screencap_method = ScreencapMethod::UnknownYet; } m_adb; + bool m_swipe_with_pause_enabled = false; + bool m_minitouch_enabled = true; // 开关 bool m_use_maa_touch = false; bool m_minitouch_available = false; // 状态 diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 9c1566371a..51cbd67215 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -267,7 +267,7 @@ namespace MaaWpfGui mainModel.SetInited(); mainModel.Idle = true; var settingsModel = _container.Get(); - settingsModel.UpdateTouchMode(); + settingsModel.UpdateInstanceSettings(); Execute.OnUIThread(async () => { var task = Task.Run(() => @@ -1638,6 +1638,7 @@ namespace MaaWpfGui { /* Deprecated */ // MinitouchEnabled = 1, TouchMode = 2, + DeploymentWithPause = 3, } } diff --git a/src/MaaWpfGui/Main/SettingsViewModel.cs b/src/MaaWpfGui/Main/SettingsViewModel.cs index 0ee565ba29..d108c1dae8 100644 --- a/src/MaaWpfGui/Main/SettingsViewModel.cs +++ b/src/MaaWpfGui/Main/SettingsViewModel.cs @@ -1017,6 +1017,19 @@ namespace MaaWpfGui } } + private bool _deploymentWithPause = bool.Parse(ViewStatusStorage.Get("Roguelike.DeploymentWithPause", false.ToString())); + + public bool DeploymentWithPause + { + get => _deploymentWithPause; + set + { + SetAndNotify(ref _deploymentWithPause, value); + ViewStatusStorage.Set("Roguelike.DeploymentWithPause", value.ToString()); + UpdateInstanceSettings(); + } + } + /* 访问好友设置 */ private bool _creditFightTaskEnabled = Convert.ToBoolean(ViewStatusStorage.Get("Visit.CreditFightTaskEnabled", bool.FalseString)); @@ -1874,14 +1887,15 @@ namespace MaaWpfGui { SetAndNotify(ref _touchMode, value); ViewStatusStorage.Set("Connect.TouchMode", value); - UpdateTouchMode(); + UpdateInstanceSettings(); } } - public void UpdateTouchMode() + public void UpdateInstanceSettings() { var asstProxy = _container.Get(); asstProxy.AsstSetInstanceOption(InstanceOptionKey.TouchMode, TouchMode); + asstProxy.AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, DeploymentWithPause ? "1" : "0"); } private static readonly string GoogleAdbDownloadUrl = "https://dl.google.com/android/repository/platform-tools-latest-windows.zip"; diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 76acc05f78..7fa076ba2e 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -73,6 +73,7 @@ Starting Roles Starting Oper (single, CN name only) Only supports the CN name of a single oper, default if not filled. + Deployemnt with Pause (Works for IS, Copilot and 保全派驻) Default Mind over matter (to be updated) diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index d9f4799927..4204b25e65 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -73,6 +73,7 @@ 开局职业组 开局干员 (单个) 仅支持单个干员中文名,不填写则默认选择 + 暂停下干员(同时影响肉鸽、自动战斗、保全) 默认分队 心胜于物分队 diff --git a/src/MaaWpfGui/Views/UserControl/RoguelikeSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/RoguelikeSettingsUserControl.xaml index 794c9ced9d..cec1c95ca4 100644 --- a/src/MaaWpfGui/Views/UserControl/RoguelikeSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/RoguelikeSettingsUserControl.xaml @@ -15,6 +15,7 @@ + @@ -78,6 +80,7 @@ IsChecked="{Binding RoguelikeInvestmentEnabled}" /> @@ -110,6 +113,7 @@ Orientation="Horizontal"> @@ -128,6 +132,7 @@ Orientation="Horizontal"> @@ -142,11 +147,12 @@ + + + \ No newline at end of file