mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix.修复一些滑动的bug
This commit is contained in:
@@ -901,7 +901,7 @@
|
||||
"specificRect": [
|
||||
1080,
|
||||
200,
|
||||
200,
|
||||
100,
|
||||
300
|
||||
],
|
||||
"preDelay": 1000,
|
||||
@@ -912,9 +912,9 @@
|
||||
"algorithm": "justReturn",
|
||||
"action": "clickRect",
|
||||
"specificRect": [
|
||||
600,
|
||||
200,
|
||||
700,
|
||||
200,
|
||||
100,
|
||||
300
|
||||
]
|
||||
},
|
||||
@@ -928,7 +928,7 @@
|
||||
300
|
||||
],
|
||||
"preDelay": 100,
|
||||
"rearDelay": 1000,
|
||||
"rearDelay": 2000,
|
||||
"maxTimes": 2,
|
||||
"Doc": "这里的preDelay作为滑动duration使用,rearDelay作为滑动额外延时使用,maxTimes作为重复次数使用"
|
||||
},
|
||||
|
||||
@@ -295,14 +295,20 @@ bool asst::Assistance::start_infrast_shift()
|
||||
|
||||
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
|
||||
|
||||
// 再次进宿舍,把刚从设施里换下来的人放进去
|
||||
m_tasks_deque.emplace_back(dorm_task_ptr);
|
||||
|
||||
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
|
||||
|
||||
auto power_task_ptr = std::make_shared<InfrastPowerTask>(task_callback, (void*)this);
|
||||
power_task_ptr->set_task_chain(InfrastTaskCahin);
|
||||
m_tasks_deque.emplace_back(power_task_ptr);
|
||||
|
||||
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
|
||||
|
||||
// 再次进宿舍,把刚从设施里换下来的人放进去
|
||||
m_tasks_deque.emplace_back(dorm_task_ptr);
|
||||
auto office_task_ptr = std::make_shared<InfrastOfficeTask>(task_callback, (void*)this);
|
||||
office_task_ptr->set_task_chain(InfrastTaskCahin);
|
||||
m_tasks_deque.emplace_back(office_task_ptr);
|
||||
|
||||
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ int asst::Controller::click_without_scale(const Rect& rect, bool block)
|
||||
return click_without_scale(rand_point_in_rect(rect), block);
|
||||
}
|
||||
|
||||
int asst::Controller::swipe(const Point& p1, const Point& p2, int duration, bool block, int extra_delay)
|
||||
int asst::Controller::swipe(const Point& p1, const Point& p2, int duration, bool block, int extra_delay, bool extra_swipe)
|
||||
{
|
||||
int x1 = p1.x * m_control_scale;
|
||||
int y1 = p1.y * m_control_scale;
|
||||
@@ -443,15 +443,15 @@ int asst::Controller::swipe(const Point& p1, const Point& p2, int duration, bool
|
||||
int y2 = p2.y * m_control_scale;
|
||||
//log.trace("Swipe, raw:", p1.x, p1.y, p2.x, p2.y, "corr:", x1, y1, x2, y2);
|
||||
|
||||
return swipe_without_scale(Point(x1, y1), Point(x2, y2), duration, block, extra_delay);
|
||||
return swipe_without_scale(Point(x1, y1), Point(x2, y2), duration, block, extra_delay, extra_swipe);
|
||||
}
|
||||
|
||||
int asst::Controller::swipe(const Rect& r1, const Rect& r2, int duration, bool block, int extra_delay)
|
||||
int asst::Controller::swipe(const Rect& r1, const Rect& r2, int duration, bool block, int extra_delay, bool extra_swipe)
|
||||
{
|
||||
return swipe(rand_point_in_rect(r1), rand_point_in_rect(r2), duration, block, extra_delay);
|
||||
return swipe(rand_point_in_rect(r1), rand_point_in_rect(r2), duration, block, extra_delay, extra_swipe);
|
||||
}
|
||||
|
||||
int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int duration, bool block, int extra_delay)
|
||||
int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int duration, bool block, int extra_delay, bool extra_swipe)
|
||||
{
|
||||
if (p1.x < 0 || p1.x >= m_emulator_info.adb.display_width
|
||||
|| p1.y < 0 || p1.y >= m_emulator_info.adb.display_height
|
||||
@@ -476,7 +476,7 @@ int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int
|
||||
int extra_swipe_duration = resource.cfg().get_options().adb_extra_swipe_duration;
|
||||
|
||||
// 额外的滑动:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来
|
||||
if (extra_swipe_duration >= 0) {
|
||||
if (extra_swipe && extra_swipe_duration >= 0) {
|
||||
std::string extra_cmd = utils::string_replace_all(m_emulator_info.adb.swipe, "[x1]", std::to_string(p2.x));
|
||||
extra_cmd = utils::string_replace_all(extra_cmd, "[y1]", std::to_string(p2.y));
|
||||
int end_x = 0, end_y = 0;
|
||||
@@ -508,9 +508,9 @@ int asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int
|
||||
return id;
|
||||
}
|
||||
|
||||
int asst::Controller::swipe_without_scale(const Rect& r1, const Rect& r2, int duration, bool block, int extra_delay)
|
||||
int asst::Controller::swipe_without_scale(const Rect& r1, const Rect& r2, int duration, bool block, int extra_delay, bool extra_swipe)
|
||||
{
|
||||
return swipe_without_scale(rand_point_in_rect(r1), rand_point_in_rect(r2), duration, block, extra_delay);
|
||||
return swipe_without_scale(rand_point_in_rect(r1), rand_point_in_rect(r2), duration, block, extra_delay, extra_swipe);
|
||||
}
|
||||
|
||||
cv::Mat asst::Controller::get_image(bool raw)
|
||||
|
||||
@@ -40,10 +40,10 @@ namespace asst {
|
||||
int click_without_scale(const Rect& rect, bool block = true);
|
||||
|
||||
constexpr static int SwipeExtraDelayDefault = 1000;
|
||||
int swipe(const Point& p1, const Point& p2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault);
|
||||
int swipe(const Rect& r1, const Rect& r2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault);
|
||||
int swipe_without_scale(const Point& p1, const Point& p2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault);
|
||||
int swipe_without_scale(const Rect& r1, const Rect& r2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault);
|
||||
int swipe(const Point& p1, const Point& p2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault, bool extra_swipe = true);
|
||||
int swipe(const Rect& r1, const Rect& r2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault, bool extra_swipe = true);
|
||||
int swipe_without_scale(const Point& p1, const Point& p2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault, bool extra_swipe = true);
|
||||
int swipe_without_scale(const Rect& r1, const Rect& r2, int duration = 0, bool block = true, int extra_delay = SwipeExtraDelayDefault, bool extra_swipe = true);
|
||||
|
||||
void wait(unsigned id) const noexcept;
|
||||
|
||||
|
||||
@@ -70,10 +70,10 @@ void asst::InfrastAbstractTask::async_swipe_of_operlist(bool reverse)
|
||||
static int duration = resource.task().task_ptr("InfrastOperListSwipeBegin")->pre_delay;
|
||||
|
||||
if (!reverse) {
|
||||
m_last_swipe_id = ctrler.swipe(begin_rect, end_rect, duration, false);
|
||||
m_last_swipe_id = ctrler.swipe(begin_rect, end_rect, duration, false, 0, true);
|
||||
}
|
||||
else {
|
||||
m_last_swipe_id = ctrler.swipe(end_rect, begin_rect, duration, false);
|
||||
m_last_swipe_id = ctrler.swipe(end_rect, begin_rect, duration, false, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ void asst::InfrastAbstractTask::swipe_to_the_left_of_operlist()
|
||||
static int loop_times = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->max_times;
|
||||
|
||||
for (int i = 0; i != loop_times; ++i) {
|
||||
ctrler.swipe(end_rect, begin_rect, duration, true);
|
||||
ctrler.swipe(end_rect, begin_rect, duration, true, 0, false);
|
||||
}
|
||||
sleep(extra_delay);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ void asst::InfrastAbstractTask::swipe_to_the_left_of_main_ui()
|
||||
static int duration = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->pre_delay;
|
||||
static int extra_delay = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->rear_delay;
|
||||
|
||||
ctrler.swipe(end_rect, begin_rect, duration, true);
|
||||
ctrler.swipe(end_rect, begin_rect, duration, true, extra_delay, false);
|
||||
}
|
||||
|
||||
void asst::InfrastAbstractTask::swipe_to_the_right_of_main_ui()
|
||||
@@ -143,5 +143,5 @@ void asst::InfrastAbstractTask::swipe_to_the_right_of_main_ui()
|
||||
static int duration = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->pre_delay;
|
||||
static int extra_delay = resource.task().task_ptr("InfrastOperListSwipeToTheLeftBegin")->rear_delay;
|
||||
|
||||
ctrler.swipe(begin_rect, end_rect, duration, true);
|
||||
ctrler.swipe(begin_rect, end_rect, duration, true, extra_delay, false);
|
||||
}
|
||||
Reference in New Issue
Block a user