Skip to content

Commit

Permalink
chore: rename for internal impl
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 18, 2024
1 parent e55ae3b commit f8b5f29
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/en_us/1.1-QuickStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MyAction(CustomAction):
# Perform click action
context.controller.post_click(100, 10).wait()
# Override the next tasks to execute
context.override_next(task_name, ["TaskA", "TaskB"])
context.override_next(node_name, ["TaskA", "TaskB"])
```

### Write Your Own Code
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/1.1-快速开始.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MyAction(CustomAction):
# 进行点击
context.controller.post_click(100, 10).wait()
# 重写接下来要执行的任务
context.override_next(task_name, ["TaskA", "TaskB"])
context.override_next(node_name, ["TaskA", "TaskB"])
```

### 自行编写代码
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Resource/PipelineResMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool PipelineResMgr::check_next_list(const PipelineData::NextList& next_list, co
{
for (const auto& next : next_list) {
if (!data_map.contains(next)) {
LogError << "Invalid next task name" << VAR(next);
LogError << "Invalid next node name" << VAR(next);
return false;
}
}
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Component/CustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ MAA_TASK_NS_BEGIN

bool CustomAction::run(
Context& context,
std::string task_name,
std::string node_name,
MAA_RES_NS::CustomActionSession session,
const MAA_RES_NS::Action::CustomParam& param,
MaaRecoId reco_id,
const cv::Rect& rect)
{
LogFunc << VAR(context.task_id()) << VAR(task_name) << VAR_VOIDP(session.action) << VAR_VOIDP(session.trans_arg)
LogFunc << VAR(context.task_id()) << VAR(node_name) << VAR_VOIDP(session.action) << VAR_VOIDP(session.trans_arg)
<< VAR(param.custom_param) << VAR(reco_id) << VAR(rect);

if (!session.action) {
LogError << "Action is null" << VAR(task_name) << VAR(param.name);
LogError << "Action is null" << VAR(node_name) << VAR(param.name);
return false;
}

Expand All @@ -26,14 +26,14 @@ bool CustomAction::run(
bool ret = session.action(
&context,
context.task_id(),
task_name.c_str(),
node_name.c_str(),
param.name.c_str(),
custom_param_string.c_str(),
reco_id,
&crect,
session.trans_arg);

LogDebug << VAR(task_name) << VAR_VOIDP(session.action) << VAR(session.trans_arg) << VAR(ret);
LogDebug << VAR(node_name) << VAR_VOIDP(session.action) << VAR(session.trans_arg) << VAR(ret);

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Task/Component/CustomAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CustomAction
public:
static bool
run(Context& context,
std::string task_name,
std::string node_name,
MAA_RES_NS::CustomActionSession session,
const MAA_RES_NS::Action::CustomParam& param,
MaaRecoId reco_id,
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Component/Recognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ RecoResult Recognizer::nn_detect(const MAA_VISION_NS::NeuralNetworkDetectorParam
RecoResult Recognizer::custom_recognize(const MAA_VISION_NS::CustomRecognitionParam& param, const std::string& name)
{
using namespace MAA_VISION_NS;
std::ignore = name; // task name
std::ignore = name; // node name

if (!tasker_) {
LogError << "tasker_ is null";
Expand Down Expand Up @@ -366,7 +366,7 @@ cv::Rect Recognizer::get_roi(const MAA_VISION_NS::Target roi)
return cv::Rect { raw.x + roi.offset.x, raw.y + roi.offset.y, raw.width + roi.offset.width, raw.height + roi.offset.height };
}

void Recognizer::save_draws(const std::string& task_name, const RecoResult& result) const
void Recognizer::save_draws(const std::string& node_name, const RecoResult& result) const
{
const auto& option = GlobalOptionMgr::get_instance();

Expand All @@ -377,20 +377,20 @@ void Recognizer::save_draws(const std::string& task_name, const RecoResult& resu
auto dir = option.log_dir() / "vision";

for (const auto& draw : result.draws) {
std::string filename = std::format("{}_{}_{}.png", task_name, result.reco_id, format_now_for_filename());
std::string filename = std::format("{}_{}_{}.png", node_name, result.reco_id, format_now_for_filename());
auto filepath = dir / path(filename);
imwrite(filepath, draw);
LogDebug << "save draw to" << filepath;
}
}

void Recognizer::show_hit_draw(const cv::Rect& box, const std::string& task_name, MaaRecoId uid) const
void Recognizer::show_hit_draw(const cv::Rect& box, const std::string& node_name, MaaRecoId uid) const
{
if (!GlobalOptionMgr::get_instance().show_hit_draw()) {
return;
}

const std::string kWinName = std::format("Hit: {} {}", task_name, uid);
const std::string kWinName = std::format("Hit: {} {}", node_name, uid);

cv::Mat draw = image_.clone();

Expand Down
4 changes: 2 additions & 2 deletions source/MaaFramework/Task/Component/Recognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Recognizer
RecoResult custom_recognize(const MAA_VISION_NS::CustomRecognitionParam& param, const std::string& name);

cv::Rect get_roi(const MAA_VISION_NS::Target roi);
void save_draws(const std::string& task_name, const RecoResult& result) const;
void show_hit_draw(const cv::Rect& box, const std::string& task_name, MaaRecoId uid) const;
void save_draws(const std::string& node_name, const RecoResult& result) const;
void show_hit_draw(const cv::Rect& box, const std::string& node_name, MaaRecoId uid) const;

private:
bool debug_mode() const;
Expand Down
10 changes: 5 additions & 5 deletions source/MaaFramework/Task/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ Tasker* Context::tasker() const
return tasker_;
}

std::optional<Context::PipelineData> Context::get_pipeline_data(const std::string& task_name)
std::optional<Context::PipelineData> Context::get_pipeline_data(const std::string& node_name)
{
auto override_it = pipeline_override_.find(task_name);
auto override_it = pipeline_override_.find(node_name);
if (override_it != pipeline_override_.end()) {
LogDebug << "found in override" << VAR(task_name);
LogDebug << "found in override" << VAR(node_name);
return override_it->second;
}

Expand All @@ -194,12 +194,12 @@ std::optional<Context::PipelineData> Context::get_pipeline_data(const std::strin
}

auto& raw_data_map = resource->pipeline_res().get_pipeline_data_map();
auto raw_it = raw_data_map.find(task_name);
auto raw_it = raw_data_map.find(node_name);
if (raw_it != raw_data_map.end()) {
return raw_it->second;
}

LogWarn << "task not found" << VAR(task_name);
LogWarn << "task not found" << VAR(node_name);
return std::nullopt;
}

Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Task/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Context
virtual Tasker* tasker() const override;

public:
std::optional<PipelineData> get_pipeline_data(const std::string& task_name);
std::optional<PipelineData> get_pipeline_data(const std::string& node_name);

private:
bool check_pipeline() const;
Expand Down
2 changes: 1 addition & 1 deletion source/binding/NodeJS/release/maa-node/src/maa.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export declare function tasker_get_task_detail(
): [entry: string, node_ids: NodeId[], status: Status] | null
export declare function tasker_get_latest_node(
handle: TaskerHandle,
task_name: string
node_name: string
): NodeId | null

// config.cpp
Expand Down

0 comments on commit f8b5f29

Please sign in to comment.