diff --git a/include/MaaFramework/Task/MaaCustomRecognizer.h b/include/MaaFramework/Task/MaaCustomRecognizer.h index 4e7dfe44e..65d6c4ab4 100644 --- a/include/MaaFramework/Task/MaaCustomRecognizer.h +++ b/include/MaaFramework/Task/MaaCustomRecognizer.h @@ -13,7 +13,7 @@ extern "C" MaaBool (*analyze)(MaaSyncContextHandle sync_context, const MaaImageBufferHandle image, MaaStringView task_name, MaaStringView custom_recognition_param, MaaTransparentArg recognizer_arg, /*out*/ MaaRectHandle out_box, - /*out*/ MaaStringBufferHandle detail_buff); + /*out*/ MaaStringBufferHandle out_detail); }; #ifdef __cplusplus diff --git a/include/MaaFramework/Task/MaaSyncContext.h b/include/MaaFramework/Task/MaaSyncContext.h index 0916f3dc1..60c36fcef 100644 --- a/include/MaaFramework/Task/MaaSyncContext.h +++ b/include/MaaFramework/Task/MaaSyncContext.h @@ -10,13 +10,13 @@ extern "C" /* SyncContext */ - MaaBool MAA_FRAMEWORK_API MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task, + MaaBool MAA_FRAMEWORK_API MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView param); MaaBool MAA_FRAMEWORK_API MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image, - MaaStringView task, MaaStringView task_param, + MaaStringView task_name, MaaStringView task_param, /* out */ MaaRectHandle out_box, - /* out */ MaaStringBufferHandle detail_buff); - MaaBool MAA_FRAMEWORK_API MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task, + /* out */ MaaStringBufferHandle out_detail); + MaaBool MAA_FRAMEWORK_API MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView task_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail); MaaBool MAA_FRAMEWORK_API MaaSyncContextClick(MaaSyncContextHandle sync_context, int32_t x, int32_t y); @@ -32,7 +32,7 @@ extern "C" MaaBool MAA_FRAMEWORK_API MaaSyncContextScreencap(MaaSyncContextHandle sync_context, /* out */ MaaImageBufferHandle buffer); - MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task, + MaaBool MAA_FRAMEWORK_API MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task_name, /* out */ MaaStringBufferHandle buffer); #ifdef __cplusplus diff --git a/sample/cpp/main.cpp b/sample/cpp/main.cpp index 434d67ac6..aa04c55ad 100644 --- a/sample/cpp/main.cpp +++ b/sample/cpp/main.cpp @@ -71,7 +71,7 @@ int main([[maybe_unused]] int argc, char** argv) MaaBool my_analyze(MaaSyncContextHandle sync_context, const MaaImageBufferHandle image, MaaStringView task_name, MaaStringView custom_recognition_param, MaaTransparentArg arg, /*out*/ MaaRectHandle out_box, - /*out*/ MaaStringBufferHandle detail_buff) + /*out*/ MaaStringBufferHandle out_detail) { /* Get image */ @@ -101,7 +101,7 @@ MaaBool my_analyze(MaaSyncContextHandle sync_context, const MaaImageBufferHandle out_box->height = my_box[3]; // Step 2: output anything you want - MaaSetString(detail_buff, + MaaSetString(out_detail, "Balabala, this string will be used by MaaCustomActionAPI and MaaSyncContextGetTaskResult. " "And for compatibility, I recommend you use json."); diff --git a/source/MaaFramework/API/MaaSyncContext.cpp b/source/MaaFramework/API/MaaSyncContext.cpp index 095a61292..63f9b8446 100644 --- a/source/MaaFramework/API/MaaSyncContext.cpp +++ b/source/MaaFramework/API/MaaSyncContext.cpp @@ -4,23 +4,23 @@ #include "Buffer/StringBuffer.hpp" #include "Utils/Logger.h" -MaaBool MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringView param) +MaaBool MaaSyncContextRunTask(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView param) { - LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(param); + LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(param); if (!sync_context) { LogError << "handle is null"; return false; } - return sync_context->run_task(task, param); + return sync_context->run_task(task_name, param); } -MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image, MaaStringView task, - MaaStringView task_param, MaaRectHandle out_box, MaaStringBufferHandle detail_buff) +MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageBufferHandle image, MaaStringView task_name, + MaaStringView task_param, MaaRectHandle out_box, MaaStringBufferHandle out_detail) { - LogFunc << VAR_VOIDP(sync_context) << VAR(image) << VAR(task) << VAR(task_param) << VAR(out_box) - << VAR(detail_buff); + LogFunc << VAR_VOIDP(sync_context) << VAR(image) << VAR(task_name) << VAR(task_param) << VAR(out_box) + << VAR(out_detail); if (!sync_context || !image) { LogError << "handle is null"; @@ -30,7 +30,7 @@ MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageB cv::Rect cvbox {}; std::string detail; - bool ret = sync_context->run_recognizer(image->get(), task, task_param, cvbox, detail); + bool ret = sync_context->run_recognizer(image->get(), task_name, task_param, cvbox, detail); if (out_box) { out_box->x = cvbox.x; @@ -38,17 +38,17 @@ MaaBool MaaSyncContextRunRecognizer(MaaSyncContextHandle sync_context, MaaImageB out_box->width = cvbox.width; out_box->height = cvbox.height; } - if (detail_buff) { - detail_buff->set(std::move(detail)); + if (out_detail) { + out_detail->set(std::move(detail)); } return ret; } -MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringView task_param, +MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView task_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail) { - LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(task_param) << VAR(cur_box) << VAR(cur_rec_detail); + LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(task_param) << VAR(cur_box) << VAR(cur_rec_detail); if (!sync_context) { LogError << "handle is null"; @@ -63,7 +63,7 @@ MaaBool MaaSyncContextRunAction(MaaSyncContextHandle sync_context, MaaStringView cvbox.height = cur_box->height; } - bool ret = sync_context->run_action(task, task_param, cvbox, cur_rec_detail); + bool ret = sync_context->run_action(task_name, task_param, cvbox, cur_rec_detail); return ret; } @@ -161,16 +161,16 @@ MaaBool MaaSyncContextScreencap(MaaSyncContextHandle sync_context, MaaImageBuffe return true; } -MaaBool MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task, MaaStringBufferHandle buffer) +MaaBool MaaSyncContextGetTaskResult(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringBufferHandle buffer) { - LogFunc << VAR_VOIDP(sync_context) << VAR(task) << VAR(buffer); + LogFunc << VAR_VOIDP(sync_context) << VAR(task_name) << VAR(buffer); if (!sync_context || !buffer) { LogError << "handle is null"; return false; } - auto res = sync_context->task_result(task); + auto res = sync_context->task_result(task_name); if (res.empty()) { LogError << "res is empty"; return false;