mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
完成从任意界面到制造站的ProcessTask
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -425,3 +425,5 @@ FodyWeavers.xsd
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
screen.png
|
||||
|
||||
@@ -290,8 +290,13 @@ bool asst::Assistance::start_infrast()
|
||||
*/
|
||||
constexpr static const char* InfrastTaskCahin = "Infrast";
|
||||
|
||||
// 1. 从任意界面进入基建,使用ProcessTask
|
||||
// 2. 一键收获贸易站、制造站、干员信赖,使用ProcessTask
|
||||
append_match_task(InfrastTaskCahin, { "InfrastBegin" });
|
||||
|
||||
// TODO,这里需要根据用户设置,是先制造站还是先贸易站,或者是别的设施
|
||||
// 从进入制造站,到进入干员选择界面清空选择
|
||||
append_match_task(InfrastTaskCahin, { "Manufacturing" });
|
||||
append_match_task(InfrastTaskCahin, { "Manufacturing", "ManufacturingMini" });
|
||||
|
||||
// 识别并选择最优解干员组合
|
||||
auto task_ptr = std::make_shared<InfrastStationTask>(task_callback, (void*)this);
|
||||
|
||||
@@ -86,7 +86,7 @@ std::pair<std::vector<cv::KeyPoint>, cv::Mat> asst::Identify::surf_detect(const
|
||||
|
||||
constexpr int min_hessian = 400;
|
||||
// SURF特征点检测
|
||||
static cv::Ptr<SIFT> detector = SIFT::create(min_hessian);
|
||||
static cv::Ptr<SURF> detector = SURF::create(min_hessian);
|
||||
std::vector<KeyPoint> keypoints;
|
||||
cv::Mat mat_vector;
|
||||
// 找到特征点并计算特征描述子(向量)
|
||||
|
||||
@@ -34,7 +34,7 @@ bool asst::InfrastStationTask::run()
|
||||
}
|
||||
auto&& [width, height] = m_view_ptr->getAdbDisplaySize();
|
||||
m_swipe_begin = Rect(width * 0.9, height * 0.5, 0, 0);
|
||||
m_swipe_end = Rect(width * 0.4, height * 0.5, 0, 0);
|
||||
m_swipe_end = Rect(width * 0.5, height * 0.5, 0, 0);
|
||||
|
||||
auto detect_ret = swipe_and_detect();
|
||||
if (!detect_ret) {
|
||||
|
||||
@@ -140,7 +140,7 @@ std::shared_ptr<TaskInfo> ProcessTask::match_image(Rect* matched_rect)
|
||||
// 逐个匹配当前可能的任务
|
||||
for (const std::string& task_name : m_cur_tasks_name) {
|
||||
std::shared_ptr<TaskInfo> task_info_ptr = Configer::get_instance().m_all_tasks_info[task_name];
|
||||
if (task_info_ptr == nullptr) {
|
||||
if (task_info_ptr == nullptr) { // 说明配置文件里没这个任务
|
||||
m_callback(AsstMsg::PtrIsNull, json::value(), m_callback_arg);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
using namespace asst;
|
||||
|
||||
bool WinMacro::m_is_adb_connect = false;
|
||||
|
||||
WinMacro::WinMacro(const EmulatorInfo& info, HandleType type)
|
||||
: m_emulator_info(info),
|
||||
m_handle_type(type),
|
||||
@@ -99,14 +101,17 @@ bool WinMacro::findHandle()
|
||||
adb_dir = adb_dir.substr(0, pos);
|
||||
adb_dir = '"' + StringReplaceAll(m_emulator_info.adb.path, "[EmulatorPath]", adb_dir) + '"';
|
||||
|
||||
if (m_handle_type == HandleType::Control)
|
||||
{
|
||||
if (!m_is_adb_connect) {
|
||||
std::string connect_cmd = StringReplaceAll(m_emulator_info.adb.connect, "[Adb]", adb_dir);
|
||||
if (!callCmd(connect_cmd)) {
|
||||
DebugTraceError("Connect Adb Error", connect_cmd);
|
||||
return false;
|
||||
}
|
||||
m_is_adb_connect = true;
|
||||
}
|
||||
|
||||
if (m_handle_type == HandleType::Control)
|
||||
{
|
||||
m_click_cmd = StringReplaceAll(m_emulator_info.adb.click, "[Adb]", adb_dir);
|
||||
m_swipe_cmd = StringReplaceAll(m_emulator_info.adb.swipe, "[Adb]", adb_dir);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace asst {
|
||||
const HandleType m_handle_type;
|
||||
HWND m_handle = NULL;
|
||||
bool m_is_adb = false;
|
||||
static bool m_is_adb_connect;
|
||||
std::string m_click_cmd; // adb点击命令,不是adb的句柄用不到这个
|
||||
std::string m_swipe_cmd; // adb滑动命令,不是adb的句柄用不到这个
|
||||
std::string m_screencap_cmd; // adb截图命令,不是adb的句柄用不到这个
|
||||
|
||||
@@ -297,6 +297,7 @@
|
||||
"template": "Return.png",
|
||||
"templThreshold": 0.85,
|
||||
"histThreshold": 0.85,
|
||||
"rearDelay": 1000,
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
"Friends",
|
||||
@@ -359,6 +360,7 @@
|
||||
]
|
||||
},
|
||||
"ReturnToMall": {
|
||||
"rearDelay": 1000,
|
||||
"template": "Return.png",
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
@@ -446,8 +448,57 @@
|
||||
"Stop"
|
||||
]
|
||||
},
|
||||
"InfrastBegin": {
|
||||
"algorithm": "justreturn",
|
||||
"type": "doNothing",
|
||||
"next": [
|
||||
"EnterInfrast",
|
||||
"InfrastNotification",
|
||||
"ReturnToInfrast"
|
||||
]
|
||||
},
|
||||
"ReturnToInfrast": {
|
||||
"template": "Return.png",
|
||||
"templThreshold": 0.85,
|
||||
"histThreshold": 0.85,
|
||||
"rearDelay": 1000,
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
"EnterInfrast",
|
||||
"ReturnToInfrast"
|
||||
]
|
||||
},
|
||||
"EnterInfrast": {
|
||||
"template": "EnterInfrast.png",
|
||||
"templThreshold": 0.85,
|
||||
"histThreshold": 0.85,
|
||||
"rareDelay": 3000,
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
"InfrastEnteredFlag"
|
||||
]
|
||||
},
|
||||
"InfrastEnteredFlag": {
|
||||
"template": "InfrastEnteredFlag.png",
|
||||
"type": "doNothing",
|
||||
"next": [
|
||||
"InfrastNotification",
|
||||
"Stop"
|
||||
]
|
||||
},
|
||||
"Manufacturing": {
|
||||
"template": "Manufacturing.png",
|
||||
"templThreshold": 0.8,
|
||||
"cache": false,
|
||||
"type": "clickSelf",
|
||||
"rearDelay": 1000,
|
||||
"next": [
|
||||
"ManufacturingLeftBottom"
|
||||
]
|
||||
},
|
||||
"ManufacturingMini": {
|
||||
"template": "ManufacturingMini.png",
|
||||
"templThreshold": 0.8,
|
||||
"cache": false,
|
||||
"type": "clickSelf",
|
||||
"rearDelay": 1000,
|
||||
@@ -483,6 +534,38 @@
|
||||
"next": [
|
||||
"Stop"
|
||||
]
|
||||
},
|
||||
"InfrastNotification": {
|
||||
"template": "InfrastNotification.png",
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
"InfrastReward",
|
||||
"InfrastExitReward"
|
||||
]
|
||||
},
|
||||
"InfrastReward": {
|
||||
"algorithm": "OcrDetect",
|
||||
"text": [ "可收获", "订单交付" ],
|
||||
"rearDelay": 1000,
|
||||
"type": "clickSelf",
|
||||
"next": [
|
||||
"InfrastReward",
|
||||
"InfrastExitReward"
|
||||
]
|
||||
},
|
||||
"InfrastExitReward": {
|
||||
"Doc": "干员疲劳、线索收集 是不能一键收获的,所以要先退出一键收获的界面,这里点击的是控制中枢左侧那一片空白的区域",
|
||||
"algorithm": "justreturn",
|
||||
"type": "clickRect",
|
||||
"specificArea": [
|
||||
250,
|
||||
100,
|
||||
380,
|
||||
140
|
||||
],
|
||||
"next": [
|
||||
"Stop"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 MiB |
BIN
resource/template/EnterInfrast.png
Normal file
BIN
resource/template/EnterInfrast.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
BIN
resource/template/InfrastEnteredFlag.png
Normal file
BIN
resource/template/InfrastEnteredFlag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
BIN
resource/template/InfrastNotification.png
Normal file
BIN
resource/template/InfrastNotification.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
BIN
resource/template/ManufacturingMini.png
Normal file
BIN
resource/template/ManufacturingMini.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user