From 00eb27daa894f0de1a8e18ead84eeaae076d74d0 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 12 Sep 2021 22:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9F=BA=E5=BB=BA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E9=80=80=E5=87=BA=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E5=92=8C=E9=83=A8=E5=88=86=E5=87=BA=E9=94=99=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/IdentifyOperTask.cpp | 3 ++ src/MeoAssistance/InfrastAbstractTask.cpp | 35 ++++++++---- src/MeoAssistance/InfrastAbstractTask.h | 1 + src/MeoAssistance/InfrastDormTask.cpp | 60 +++++++++++++-------- src/MeoAssistance/InfrastOfficeTask.cpp | 22 +++++--- src/MeoAssistance/InfrastPowerTask.cpp | 26 ++++++--- src/MeoAssistance/InfrastProductionTask.cpp | 26 +++++---- src/MeoAssistance/WinMacro.cpp | 2 + 8 files changed, 117 insertions(+), 58 deletions(-) diff --git a/src/MeoAssistance/IdentifyOperTask.cpp b/src/MeoAssistance/IdentifyOperTask.cpp index 59d72a2bc5..9571233db6 100644 --- a/src/MeoAssistance/IdentifyOperTask.cpp +++ b/src/MeoAssistance/IdentifyOperTask.cpp @@ -91,6 +91,9 @@ std::optional> asst::IdentifyOp // 一边识别一边滑动,把所有干员名字抓出来 // 正向完整滑一遍,再反向完整滑一遍,提高识别率 while (true) { + if (need_exit()) { + return std::nullopt; + } const cv::Mat& image = m_controller_ptr->get_image(true); // 异步进行滑动操作 diff --git a/src/MeoAssistance/InfrastAbstractTask.cpp b/src/MeoAssistance/InfrastAbstractTask.cpp index be24585b70..10e4b54123 100644 --- a/src/MeoAssistance/InfrastAbstractTask.cpp +++ b/src/MeoAssistance/InfrastAbstractTask.cpp @@ -37,8 +37,10 @@ bool asst::InfrastAbstractTask::swipe_to_the_left() } m_swipe_duration = SwipeDurationDefault; m_swipe_extra_delay = SwipeExtraDelayDefault; - sleep(SwipeExtraDelayDefault); - return ret; + if (!ret) { + return false; + } + return sleep(SwipeExtraDelayDefault); } bool asst::InfrastAbstractTask::click_clear_button() @@ -70,17 +72,16 @@ bool asst::InfrastAbstractTask::swipe(bool reverse) DebugTraceFunction; //#ifndef LOG_TRACE - bool ret = true; + bool ret = false; if (!reverse) { - ret &= m_controller_ptr->swipe(m_swipe_begin, m_swipe_end, m_swipe_duration); + ret = m_controller_ptr->swipe(m_swipe_begin, m_swipe_end, m_swipe_duration); ++m_swipe_times; } else { - ret &= m_controller_ptr->swipe(m_swipe_end, m_swipe_begin, m_swipe_duration); + ret = m_controller_ptr->swipe(m_swipe_end, m_swipe_begin, m_swipe_duration); --m_swipe_times; } - ret &= sleep(m_swipe_extra_delay); - return ret; + return ret && sleep(m_swipe_extra_delay); //#else // return sleep(SwipeExtraDelay); //#endif @@ -88,6 +89,8 @@ bool asst::InfrastAbstractTask::swipe(bool reverse) bool asst::InfrastAbstractTask::swipe_left() { + DebugTraceFunction; + const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, @@ -103,6 +106,8 @@ bool asst::InfrastAbstractTask::swipe_left() bool asst::InfrastAbstractTask::swipe_right() { + DebugTraceFunction; + const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, @@ -116,6 +121,16 @@ bool asst::InfrastAbstractTask::swipe_right() return m_controller_ptr->swipe(right_rect, left_rect); } +bool asst::InfrastAbstractTask::append_task_to_back_to_infrast_home() +{ + const static json::value append_json = json::object{ + { "task", "InfrastBegin" }, + { "task_chain", m_task_chain } + }; + m_callback(AsstMsg::AppendProcessTask, append_json, m_callback_arg); + return true; +} + std::vector